Git Product home page Git Product logo

j-rios / utlgbotlib Goto Github PK

View Code? Open in Web Editor NEW
20.0 4.0 9.0 2.78 MB

Universal Telegram Bot library for Arduino, ESP-IDF and Native (Windows and Linux) devices, that let you create Telegram Bots. You can use it with ESP8266 and ESP32 microcontrollers.

License: GNU General Public License v3.0

C 84.35% C++ 1.70% Python 2.38% Shell 8.39% Makefile 1.48% CMake 0.50% Tcl 0.01% Perl 1.14% SmPL 0.01% GDB 0.05%
esp32 esp32-arduino esp32-idf telegram telegram-bot-api arduino arduino-library esp32-library utlgbotlib esp-idf

utlgbotlib's Introduction

uTLGBotLib

Universal Telegram Bot library for Arduino, ESP-IDF and Native (Windows and Linux) devices, that let you create Telegram Bots. You can use it with ESP8266 and ESP32 microcontrollers.

Micro Telegram Bot Library is a lightweight C++ library implementation that uses Telegram Bot API to create Bots. The library goal is to be compatible with multiples devices, from embedded microcontrollers, to Servers and PCs (Windows and Linux). Inside microcontrollers world, uTLGBotLib focus on Espressif ESP32 (support for ESP-IDF and Arduino frameworks) and ESP8266 (support for Arduino) microcontrollers, but new devices could be supported.

Notes

  • Due library target embedded devices such microcontrollers, it MUST be take a lot of care in memory usage, from library size to safety use.

  • To avoid ram memory fragmentation and stack-heap collisions, the library doesn't use dynamic memory in non Native (Windows/Linux) platforms (ESP8266 and ESP32).

  • The library uses multihttpsclient to implement all low level HTTP request specific for each device/system.

  • The library uses jsmn library to parse JSON text in the safest (memory) way possible, because it just get a string and return the indexes where each json element ("token") start and end.

  • Sub-library multihttpsclient uses mbedtls library to handle HTTPS requests in Native (Windows and Linux) systems.

  • uTLGBotLib is a generic library, for that reason, to add support of a new device/system, you just need to specify the expected print() macros in utlgbotlib.cpp and create specific files in multihttpsclient library to implement the HTTP requests for this device/system.

  • You can set debug levels from 0 to 2:

Bot.set_debug(0); // No debug msgs
Bot.set_debug(1); // Bot debug msgs
Bot.set_debug(2); // Bot+HTTPS debug msgs
  • Global define "UTLGBOT_NO_DEBUG" to disable build debug prints and save some flash and sram memory usage.

  • Global define "UTLGBOT_MEMORY_LEVEL" with values 0 to 5, to set library build memory usage level. It allows to reduce library flash and sram memory needs by reducing HTTPS response buffer length and maximum telegram text messages length buffer.

-DUTLGBOT_MEMORY_LEVEL=0 // Max TLG msgs:  128 chars
-DUTLGBOT_MEMORY_LEVEL=1 // Max TLG msgs:  256 chars
-DUTLGBOT_MEMORY_LEVEL=2 // Max TLG msgs:  512 chars
-DUTLGBOT_MEMORY_LEVEL=3 // Max TLG msgs: 1024 chars
-DUTLGBOT_MEMORY_LEVEL=4 // Max TLG msgs: 2048 chars
-DUTLGBOT_MEMORY_LEVEL=5 // Max TLG msgs: 4097 chars (telegram max msg length)
  • Defines must be passed to compiler by flag (-DUTLGBOT_NO_DEBUG -DUTLGBOT_MEMORY_LEVEL=2). Note that define in source code won't work as expected due utlgbot.cpp is compiled independent of main.cpp and that cause different definitions of memory levels from each file compiled.

utlgbotlib's People

Contributors

j-rios avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

utlgbotlib's Issues

How to display utf-8 character? like chinese

I use the example "show_received_messages" , I send message with telegram
English word display is normal, but when I type in Chinese "你好" it show "\u4f60\u597d"
How to display utf-8 character?

Received message.
From chat ID: 1048xxxxx
From chat type: private
From chat alias: terxxxxx
From chat name: Terxxxxx
From chat title:
From chat where not all members are admins.
From user ID: 1048xxxxx
From user alias: @terxxxxx
From user name: Terxxxxx
From user with language code: zh-hans
From user that is not a Bot.
Message ID: 630
Message sent date (UNIX epoch time): 1590229558l
Text: \u4f60\u597d

and I test serial print utf-8 code, it can print Chinese word

        Serial.println("");
        Serial.println("WiFi connected");
        Serial.print("IP address: ");
        Serial.println(WiFi.localIP());
        char mesg[50] = "\u65e5\u5b89\u4f60\u597d"; //日安你好
        Serial.println(mesg);
        wifi_connected = true;

WiFi connected
IP address: 192.168.0.144
日安你好

Platformio fail to build mbedtls in ESP-IDF and Arduino

Hello,

thanks for this library, i would like to use for a little project in my home. I have a problem with the build process...i get many "undeclaration" errors like this:

lib\multihttpsclient\mbedtls\library\aes.c:1844:20: error: 'MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED' undeclared (first use in this function)

and many others...but the header files are included correctly, i didn't touch the sources yet; i just commented in platformio.ini the unused sections (native and arduino, i'm working on ESP32 platform).

thanks for help!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.