From d63f1bb5bf8a5bbc2b74555f15df82dda2324830 Mon Sep 17 00:00:00 2001 From: Mit4el Date: Sat, 21 Sep 2024 12:09:11 +0300 Subject: [PATCH] add IRremote --- include/utils/StringUtils.h | 2 +- myProfile.json | 106 ++++++------ platformio.ini | 93 ++++++++--- src/modules/exec/IRremote/IRremote.cpp | 215 +++++++++++++++++++++++++ src/modules/exec/IRremote/modinfo.json | 94 +++++++++++ src/modules/exec/Telegram/Telegram.cpp | 14 +- src/utils/I2CUtils.cpp | 4 +- src/utils/StringUtils.cpp | 2 +- 8 files changed, 448 insertions(+), 82 deletions(-) create mode 100644 src/modules/exec/IRremote/IRremote.cpp create mode 100644 src/modules/exec/IRremote/modinfo.json diff --git a/include/utils/StringUtils.h b/include/utils/StringUtils.h index ea403cfb..9fac0aa5 100644 --- a/include/utils/StringUtils.h +++ b/include/utils/StringUtils.h @@ -40,7 +40,7 @@ boolean isDigitDotCommaStr(const String& str); String prettyBytes(size_t size); -String uint64ToString(uint64_t input, uint8_t base = 10); +String uint64ToStringIoTM(uint64_t input, uint8_t base = 10); void cleanString(String& str); diff --git a/myProfile.json b/myProfile.json index fcd49a01..0e6bc051 100644 --- a/myProfile.json +++ b/myProfile.json @@ -135,15 +135,15 @@ }, { "path": "src/modules/virtual/Cron", - "active": false + "active": true }, { "path": "src/modules/virtual/DiscoveryHA", - "active": true + "active": false }, { "path": "src/modules/virtual/DiscoveryHomeD", - "active": true + "active": false }, { "path": "src/modules/virtual/GoogleSheet", @@ -155,19 +155,19 @@ }, { "path": "src/modules/virtual/LogingDaily", - "active": false + "active": true }, { "path": "src/modules/virtual/Math", - "active": false + "active": true }, { "path": "src/modules/virtual/owmWeather", - "active": false + "active": true }, { "path": "src/modules/virtual/Ping", - "active": false + "active": true }, { "path": "src/modules/virtual/Timer", @@ -193,11 +193,11 @@ }, { "path": "src/modules/sensors/A02Distance", - "active": false + "active": true }, { "path": "src/modules/sensors/Acs712", - "active": false + "active": true }, { "path": "src/modules/sensors/Ads1115", @@ -205,11 +205,11 @@ }, { "path": "src/modules/sensors/AhtXX", - "active": false + "active": true }, { "path": "src/modules/sensors/AnalogAdc", - "active": false + "active": true }, { "path": "src/modules/sensors/BH_1750", @@ -217,7 +217,7 @@ }, { "path": "src/modules/sensors/BL0937", - "active": false + "active": true }, { "path": "src/modules/sensors/Ble", @@ -233,19 +233,19 @@ }, { "path": "src/modules/sensors/Bme280", - "active": false + "active": true }, { "path": "src/modules/sensors/Bmp280", - "active": false + "active": true }, { "path": "src/modules/sensors/Dht1122", - "active": false + "active": true }, { "path": "src/modules/sensors/Ds18b20", - "active": false + "active": true }, { "path": "src/modules/sensors/DS2401", @@ -289,7 +289,7 @@ }, { "path": "src/modules/sensors/Impulse", - "active": false + "active": true }, { "path": "src/modules/sensors/Ina219", @@ -317,7 +317,7 @@ }, { "path": "src/modules/sensors/MQgas", - "active": false + "active": true }, { "path": "src/modules/sensors/Ntc", @@ -329,7 +329,7 @@ }, { "path": "src/modules/sensors/Pzem004t_v2", - "active": false + "active": true }, { "path": "src/modules/sensors/RCswitch", @@ -337,11 +337,11 @@ }, { "path": "src/modules/sensors/RTC", - "active": false + "active": true }, { "path": "src/modules/sensors/S8", - "active": false + "active": true }, { "path": "src/modules/sensors/Scd40", @@ -357,25 +357,25 @@ }, { "path": "src/modules/sensors/Sht20", - "active": false + "active": true }, { "path": "src/modules/sensors/Sht30", - "active": false + "active": true }, { "path": "src/modules/sensors/Sonar", - "active": false + "active": true }, { "path": "src/modules/sensors/UART", - "active": false + "active": true } ], "executive_devices": [ { "path": "src/modules/exec/AnalogBtn", - "active": false + "active": true }, { "path": "src/modules/exec/BrokerMQTT", @@ -383,24 +383,24 @@ }, { "path": "src/modules/exec/ButtonIn", - "active": false - }, - { - "path": "src/modules/exec/ButtonOut", - "active": false - }, - { - "path": "src/modules/exec/Buzzer", - "active": false - }, - { - "path": "src/modules/exec/EctoControlAdapter", "active": true }, { - "path": "src/modules/exec/Enconder", + "path": "src/modules/exec/ButtonOut", + "active": true + }, + { + "path": "src/modules/exec/Buzzer", + "active": true + }, + { + "path": "src/modules/exec/EctoControlAdapter", "active": false }, + { + "path": "src/modules/exec/Enconder", + "active": true + }, { "path": "src/modules/exec/EspCam", "active": false @@ -415,6 +415,10 @@ }, { "path": "src/modules/exec/IoTServo", + "active": true + }, + { + "path": "src/modules/exec/IRremote", "active": false }, { @@ -423,15 +427,15 @@ }, { "path": "src/modules/exec/Mcp23017", - "active": false + "active": true }, { "path": "src/modules/exec/Mp3", - "active": false + "active": true }, { "path": "src/modules/exec/Multitouch", - "active": false + "active": true }, { "path": "src/modules/exec/MySensors", @@ -439,15 +443,15 @@ }, { "path": "src/modules/exec/Pcf8574", - "active": false + "active": true }, { "path": "src/modules/exec/Pwm32", - "active": false + "active": true }, { "path": "src/modules/exec/Pwm8266", - "active": false + "active": true }, { "path": "src/modules/exec/SDcard", @@ -471,11 +475,11 @@ }, { "path": "src/modules/exec/TelegramLT", - "active": false + "active": true }, { "path": "src/modules/exec/Telegram_v2", - "active": true + "active": false }, { "path": "src/modules/exec/Thermostat", @@ -489,11 +493,11 @@ "screens": [ { "path": "src/modules/display/DwinI", - "active": false + "active": true }, { "path": "src/modules/display/Lcd2004", - "active": false + "active": true }, { "path": "src/modules/display/Nextion", @@ -509,11 +513,11 @@ }, { "path": "src/modules/display/Oled64", - "active": false + "active": true }, { "path": "src/modules/display/Smi2_m", - "active": false + "active": true }, { "path": "src/modules/display/TM16XX", diff --git a/platformio.ini b/platformio.ini index e697c59f..6e651962 100644 --- a/platformio.ini +++ b/platformio.ini @@ -21,7 +21,7 @@ lib_deps = ${common_env_data.lib_deps_external} ${env:esp8266_1mb_ota_fromitems.lib_deps} ESPAsyncUDP -build_flags = ${common.build_flags} +build_flags = ${common.build_flags} -Desp8266_1mb_ota="esp8266_1mb_ota" framework = arduino board = nodemcuv2 @@ -43,7 +43,7 @@ lib_deps = ${common_env_data.lib_deps_external} ${env:esp8266_1mb_fromitems.lib_deps} ESPAsyncUDP -build_flags = ${common.build_flags} +build_flags = ${common.build_flags} -Desp8266_1mb="esp8266_1mb" framework = arduino board = nodemcuv2 @@ -65,7 +65,7 @@ lib_deps = ${common_env_data.lib_deps_external} ${env:esp8285_1mb_ota_fromitems.lib_deps} ESPAsyncUDP -build_flags = ${common.build_flags} +build_flags = ${common.build_flags} -Desp8266_1mb_ota="esp8266_1mb_ota" framework = arduino board = esp8285 @@ -87,7 +87,7 @@ lib_deps = ${common_env_data.lib_deps_external} ${env:esp8266_2mb_fromitems.lib_deps} ESPAsyncUDP -build_flags = ${common.build_flags} +build_flags = ${common.build_flags} -Desp8266_2mb="esp8266_2mb" framework = arduino board = d1_wroom_02 @@ -109,7 +109,7 @@ lib_deps = ${common_env_data.lib_deps_external} ${env:esp8266_2mb_ota_fromitems.lib_deps} ESPAsyncUDP -build_flags = ${common.build_flags} +build_flags = ${common.build_flags} -Desp8266_2mb_ota="esp8266_2mb_ota" framework = arduino board = d1_wroom_02 @@ -131,7 +131,7 @@ lib_deps = ${common_env_data.lib_deps_external} ${env:esp8285_1mb_fromitems.lib_deps} ESPAsyncUDP -build_flags = ${common.build_flags} +build_flags = ${common.build_flags} -Desp8266_1mb="esp8266_1mb" framework = arduino board = esp8285 @@ -153,7 +153,7 @@ lib_deps = ${common_env_data.lib_deps_external} ${env:esp8266_4mb_fromitems.lib_deps} ESPAsyncUDP -build_flags = ${common.build_flags} +build_flags = ${common.build_flags} -Desp8266_4mb="esp8266_4mb" framework = arduino board = nodemcuv2 @@ -176,7 +176,7 @@ lib_deps = ${common_env_data.lib_deps_external} ${env:esp8266_16mb_fromitems.lib_deps} ESPAsyncUDP -build_flags = ${common.build_flags} +build_flags = ${common.build_flags} -Desp8266_16mb="esp8266_16mb" framework = arduino board = nodemcuv2 @@ -198,7 +198,7 @@ extra_scripts = pre:tools/patch32_ws.py lib_deps = ${common_env_data.lib_deps_external} ${env:esp32_4mb_fromitems.lib_deps} -build_flags = ${common.build_flags} +build_flags = ${common.build_flags} -Desp32_4mb="esp32_4mb" -Wl,--wrap=esp_panic_handler framework = arduino @@ -221,7 +221,7 @@ extra_scripts = pre:tools/patch32_ws.py lib_deps = ${common_env_data.lib_deps_external} ${env:esp32_4mb3f_fromitems.lib_deps} -build_flags = ${common.build_flags} +build_flags = ${common.build_flags} -Desp32_4mb="esp32_4mb" -Wl,--wrap=esp_panic_handler framework = arduino @@ -245,7 +245,7 @@ extra_scripts = pre:tools/patch32_ws.py lib_deps = ${common_env_data.lib_deps_external} ${env:esp32cam_4mb_fromitems.lib_deps} -build_flags = ${common.build_flags} +build_flags = ${common.build_flags} -Desp32cam_4mb="esp32cam_4mb" -DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue @@ -270,7 +270,7 @@ extra_scripts = pre:tools/patch32_ws.py lib_deps = ${common_env_data.lib_deps_external} ${env:esp32s2_4mb_fromitems.lib_deps} -build_flags = ${common.build_flags} +build_flags = ${common.build_flags} -Desp32s2_4mb="esp32s2_4mb" -DARDUINO_USB_CDC_ON_BOOT=1 -DARDUINO_USB_MODE=0 @@ -295,7 +295,7 @@ extra_scripts = pre:tools/patch32_ws.py lib_deps = ${common_env_data.lib_deps_external} ${env:esp32c3m_4mb_fromitems.lib_deps} -build_flags = ${common.build_flags} +build_flags = ${common.build_flags} -Desp32c3m_4mb="esp32c3m_4mb" -Wl,--wrap=esp_panic_handler framework = arduino @@ -319,7 +319,7 @@ extra_scripts = pre:tools/patch32_ws.py lib_deps = ${common_env_data.lib_deps_external} ${env:esp32s3_16mb_fromitems.lib_deps} -build_flags = ${common.build_flags} +build_flags = ${common.build_flags} -Desp32s3_16mb="esp32s3_16mb" -Wl,--wrap=esp_panic_handler framework = arduino @@ -345,7 +345,7 @@ extra_scripts = pre:tools/patch32_ws.py lib_deps = ${common_env_data.lib_deps_external} ${env:esp32_16mb_fromitems.lib_deps} -build_flags = ${common.build_flags} +build_flags = ${common.build_flags} -Desp32_16mb="esp32_16mb" -Wl,--wrap=esp_panic_handler framework = arduino @@ -722,16 +722,69 @@ build_src_filter = [env:esp32_4mb3f_fromitems] lib_deps = - gyverlibs/FastBot + https://github.com/enjoyneering/AHTxx.git + adafruit/Adafruit BME280 Library + adafruit/Adafruit BMP280 Library + beegee-tokyo/DHT sensor library for ESPx + https://github.com/milesburton/Arduino-Temperature-Control-Library + robtillaart/SHT2x@^0.1.1 + WEMOS SHT3x@1.0.0 + plerup/EspSoftwareSerial + gyverlibs/EncButton @ ^2.0 + https://github.com/RoboticsBrno/ServoESP32#v1.0.3 + adafruit/Adafruit MCP23017 Arduino Library@^2.1.0 + adafruit/Adafruit BusIO @ ^1.13.2 + dfrobot/DFRobotDFPlayerMini @ ^1.0.5 + adafruit/Adafruit BusIO @ ^1.13.2 + plerup/EspSoftwareSerial + https://github.com/robotclass/RobotClass_LiquidCrystal_I2C + marcoschwartz/LiquidCrystal_I2C@^1.1.4 + https://github.com/stblassitude/Adafruit_SSD1306_Wemos_OLED + https://github.com/adafruit/Adafruit-GFX-Library build_src_filter = - + - + + + + + + + + + + + + + + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [env:esp32cam_4mb_fromitems] lib_deps = diff --git a/src/modules/exec/IRremote/IRremote.cpp b/src/modules/exec/IRremote/IRremote.cpp new file mode 100644 index 00000000..a3487b4d --- /dev/null +++ b/src/modules/exec/IRremote/IRremote.cpp @@ -0,0 +1,215 @@ +#include "Global.h" +#include "classes/IoTItem.h" + +#include +#include +#include +#include + +IRac* ac; + +const uint16_t kIrLed = 4; // The ESP GPIO pin to use that controls the IR LED. + +class IRremote : public IoTItem { + private: + + String _set_id; // заданная температура + + //float pv_last = 0; // предыдущая температура + + //float sp, pv, pv2; + //String interim; + int enable = 1; + float _tmp; + + int _prot; // протокол + int _pinTx; // Выход модуля передатчика + + public: + IRremote(String parameters): IoTItem(parameters) { + jsonRead(parameters, "pinTx", _pinTx); //передатчик + jsonRead(parameters, "prot", _prot); // используемый протокол + jsonRead(parameters, "set_id", _set_id); // id установленной температуры + + + + + if (_pinTx >= 0) { + IoTgpio.pinMode(_pinTx, OUTPUT); + IoTgpio.digitalWrite(_pinTx, false); } + + // Set up what we want to send. + // See state_t, opmode_t, fanspeed_t, swingv_t, & swingh_t in IRsend.h for + // all the various options. + + ac = new IRac(kIrLed); + ac->next.protocol = (decode_type_t)_prot; + ac->next.model = 1; // Некоторые кондиционеры имеют разные модели. Попробуйте только первое. + ac->next.mode = stdAc::opmode_t::kCool; // Сначала запустите в прохладном режиме. + ac->next.celsius = true; // Используйте градусы Цельсия в качестве единиц измерения температуры. Ложь = Фаренгейт + ac->next.degrees = 20; // 20 degrees. + ac->next.fanspeed = stdAc::fanspeed_t::kMedium; // Запустите вентилятор на средней скорости. + ac->next.swingv = stdAc::swingv_t::kOff; // Не поворачивайте вентилятор вверх или вниз. + ac->next.swingh = stdAc::swingh_t::kOff; // Не поворачивайте вентилятор влево или вправо. + ac->next.light = false; // Выключите все светодиоды/световые приборы/дисплеи, которые сможем. + ac->next.beep = false; // Если есть возможность, выключите все звуковые сигналы кондиционера. + ac->next.econo = false; // Turn off any economy modes if we can. + ac->next.filter = false; // Turn off any Ion/Mold/Health filters if we can. + ac->next.turbo = false; // Don't use any turbo/powerful/etc modes. + ac->next.quiet = false; // Don't use any quiet/silent/etc modes. + ac->next.sleep = -1; // Don't set any sleep time or modes. + ac->next.clean = false; // Turn off any Cleaning options if we can. + ac->next.clock = -1; // Don't set any current time if we can avoid it. + ac->next.power = false; // Initially start with the unit off. + + Serial.println("Try to turn on & off every supported A/C type ..."); +} + + + void doByInterval() { + + + + // pv_last = pv; + } + + IoTValue execute(String command, std::vector ¶m) { + + if (command == "on") { + + ac->next.power = true; // Типа команда включить + ac->sendAc(); // Send the message. + + SerialPrint("i", F("IRremote"), "Ballu AC on "); + } + + if (command == "off") { + + ac->next.power = false; + ac->sendAc(); // Send the message. + + SerialPrint("i", F("IRremote"), "Ballu AC off "); + } + + if (command == "cool") { + + ac->next.mode = stdAc::opmode_t::kCool; + ac->sendAc(); // Send the message. + + SerialPrint("i", F("IRremote"), "Ballu AC cool "); + } + + if (command == "heat") { + + ac->next.mode = stdAc::opmode_t::kHeat; + ac->sendAc(); // Send the message. + + SerialPrint("i", F("IRremote"), "Ballu AC heat "); + } + + if (command == "dry") { + + ac->next.mode = stdAc::opmode_t::kDry; + ac->sendAc(); // Send the message. + + SerialPrint("i", F("IRremote"), "Ballu AC dry "); + } + if (command == "auto") { + + ac->next.fanspeed = stdAc::fanspeed_t::kAuto; + ac->sendAc(); // Send the message. + + SerialPrint("i", F("IRremote"), "Ballu AC speed1 "); + } + if (command == "speedmin") { + + ac->next.fanspeed = stdAc::fanspeed_t::kMin; + ac->sendAc(); // Send the message. + + SerialPrint("i", F("IRremote"), "Ballu AC speed min "); + } + if (command == "speedlow") { + + ac->next.fanspeed = stdAc::fanspeed_t::kLow; + ac->sendAc(); // Send the message. + + SerialPrint("i", F("IRremote"), "Ballu AC speed low "); + } + if (command == "speedmed") { + + ac->next.fanspeed = stdAc::fanspeed_t::kMedium; // Надо выбрать под конкретный кондиционер из 6-ти вариантов + ac->sendAc(); // Send the message. + + SerialPrint("i", F("IRremote"), "Ballu AC speed medium "); + } + if (command == "speedhigh") { + + ac->next.fanspeed = stdAc::fanspeed_t::kHigh; // Надо выбрать под конкретный кондиционер из 6-ти вариантов + ac->sendAc(); // Send the message. + + SerialPrint("i", F("IRremote"), "Ballu AC speed high"); + } + if (command == "speedmax") { + + ac->next.fanspeed = stdAc::fanspeed_t::kMax; // Надо выбрать под конкретный кондиционер из 6-ти вариантов + ac->sendAc(); // Send the message. + + SerialPrint("i", F("IRremote"), "Ballu AC speed max"); + } + + if (command == "speedmh") { + + ac->next.fanspeed = stdAc::fanspeed_t::kMediumHigh; // Надо выбрать под конкретный кондиционер из 6-ти вариантов + ac->sendAc(); // Send the message. + + SerialPrint("i", F("IRremote"), "Ballu AC speed mh"); + } + + //setTemp acc.setTemp(val) + + if (command == "setTemp") { + + // заданная температура + IoTItem *tmp = findIoTItem(_set_id); + if (tmp) + { + //interim = tmp->getValue(); + _tmp = ::atof(tmp->getValue().c_str()); + ac->next.degrees = _tmp; // set Temp 17 C - 30 C. + ac->sendAc(); // Send the message. + SerialPrint("i", F("IRremote"), "Ballu AC set temp -> " + String(_tmp) ); + } + else + { + // если не заполнены настройки кондиционера + setValue("ошибка настройки кондиционера"); + } + + //ac->next.degrees = _tmp; // set Temp 17 C - 30 C. + //ac->sendAc(); // Send the message. + + + } + //ac->next.swingv = stdAc::swingv_t::kOff; + + if (command == "swing") { + + ac->next.swingv = stdAc::swingv_t::kMiddle;; // Надо выбрать под конкретный кондиционер из 6-ти вариантов + ac->sendAc(); // Send the message. + + SerialPrint("i", F("IRremote"), "Ballu AC swing middle"); + } + + return {}; // команда поддерживает возвращаемое значения. Т.е. по итогу выполнения команды или общения с внешней системой, можно вернуть значение в сценарий для дальнейшей обработки + } + + ~IRremote() {}; +}; + +void* getAPI_IRremote(String subtype, String param) { + if (subtype == F("IRremote")) { + return new IRremote(param); + } else { + return nullptr; + } +} diff --git a/src/modules/exec/IRremote/modinfo.json b/src/modules/exec/IRremote/modinfo.json new file mode 100644 index 00000000..ce6869d7 --- /dev/null +++ b/src/modules/exec/IRremote/modinfo.json @@ -0,0 +1,94 @@ +{ + "menuSection": "executive_devices", + + "configItem": [{ + + "global": 0, + "name": "Управление кондиционером", + "type": "Reading", + "subtype": "IRremote", + "id": "ir", + "pinTx": 4, + "set_id": "", + "int": 1, + "prot": 15 + }], + + "about": { + "authorName": "Serghei Crasnicov", + "authorContact": "https://t.me/Serghei63", + "authorGit": "https://github.com/Serghei63", + "specialThanks": "Mikhail Bubnov https://t.me/Mit4bmw , Олег Астахов https://t.me/Threedreality , Valentin Khandriga @Valiuhaaa", + "moduleName": "IRremote", + "moduleVersion": "2.0", + "usedRam": { + "esp32_4mb": 15, + "esp8266_4mb": 15 + }, + "title": "Эмулятор IR пульта", + "moduleDesc": "Позволяет управлять кондиционером и другой техникой по IR каналу", + "propInfo": { + "pinTx": "GPIO номер, к которому подключен инфракрасный приемник.", + "prot": " Цифровой код протокола . UNKNOWN = -1, UNUSED = 0, COOLIX - 15, SAMSUNG_AC - 46 ....", + "set_id": "id установленной температуры" + }, + "funcInfo": [ + { + "name": "on", + "descr": "Включить конциционер", + "params": [] + }, + { + "name": "off", + "descr": "Выключить конциционер", + "params": [] + }, + { + "name": "cool", + "descr": "Режим охлаждения", + "params": [] + }, + { + "name": "heat", + "descr": "Режим нагрева", + "params": [] + }, + { + "name": "dry", + "descr": "Режим осушения", + "params": [] + }, + { + "name": "speed1", + "descr": "Медленная скорость вентилятора", + "params": [] + }, + { + "name": "speed2", + "descr": "Средняя скорость вентилятора", + "params": [] + }, + { + "name": "speed3", + "descr": "Максимальная скорость вентилятора", + "params": [] + }, + { + "name": "setTemp", + "descr": "Установленная температура", + "params": [] + } + ] + }, + + "defActive": false, + + "usedLibs": { + "esp32*": [ + "https://github.com/crankyoldgit/IRremoteESP8266" + ], + "esp82*": [ + "https://github.com/crankyoldgit/IRremoteESP8266" + ] + } +} \ No newline at end of file diff --git a/src/modules/exec/Telegram/Telegram.cpp b/src/modules/exec/Telegram/Telegram.cpp index da7186af..3dfc3a9a 100644 --- a/src/modules/exec/Telegram/Telegram.cpp +++ b/src/modules/exec/Telegram/Telegram.cpp @@ -19,21 +19,21 @@ class Telegram : public IoTItem { msg = deleteBeforeDelimiter(msg, "_"); generateOrder(selectToMarker(msg, "_"), selectToMarkerLast(msg, "_")); _myBot.sendMessage(_chatID, "order done"); - SerialPrint("<-", F("Telegram"), "chat ID: " + uint64ToString(_chatID) + ", msg: " + String(msg)); + SerialPrint("<-", F("Telegram"), "chat ID: " + uint64ToStringIoTM(_chatID) + ", msg: " + String(msg)); } else if (msg.indexOf("get") != -1) { msg = deleteBeforeDelimiter(msg, "_"); IoTItem* item = findIoTItem(msg); if (item) { _myBot.sendMessage(_chatID, item->getValue()); - SerialPrint("<-", F("Telegram"), "chat ID: " + uint64ToString(_chatID) + ", msg: " + String(msg)); + SerialPrint("<-", F("Telegram"), "chat ID: " + uint64ToStringIoTM(_chatID) + ", msg: " + String(msg)); } } else if (msg.indexOf("all") != -1) { String list = returnListOfParams(); _myBot.sendMessage(_chatID, list); - SerialPrint("<-", F("Telegram"), "chat ID: " + uint64ToString(_chatID) + "\n" + list); + SerialPrint("<-", F("Telegram"), "chat ID: " + uint64ToStringIoTM(_chatID) + "\n" + list); } else if (msg.indexOf("help") != -1) { _myBot.sendMessage(_chatID, "ID: " + chipId); - _myBot.sendMessage(_chatID, "chatID: " + uint64ToString(_chatID)); + _myBot.sendMessage(_chatID, "chatID: " + uint64ToStringIoTM(_chatID)); _myBot.sendMessage(_chatID, F("Wrong order, use /all to get all values, /get_id to get value, or /set_id_value to set value")); } else { setValue(msg); @@ -70,7 +70,7 @@ class Telegram : public IoTItem { if (_receiveMsg) { TBMessage msg; if (_myBot.getNewMessage(msg)) { - SerialPrint("->", F("Telegram"), "chat ID: " + uint64ToString(msg.sender.id) + ", msg: " + msg.text); + SerialPrint("->", F("Telegram"), "chat ID: " + uint64ToStringIoTM(msg.sender.id) + ", msg: " + msg.text); if (_autos) { _chatID = msg.sender.id; } @@ -100,12 +100,12 @@ class Telegram : public IoTItem { void sendTelegramMsg(bool often, String msg) { if (often) { _myBot.sendMessage(_chatID, msg); - SerialPrint("<-", F("Telegram"), "chat ID: " + uint64ToString(_chatID) + ", msg: " + msg); + SerialPrint("<-", F("Telegram"), "chat ID: " + uint64ToStringIoTM(_chatID) + ", msg: " + msg); } else { if (_prevMsg != msg) { _prevMsg = msg; _myBot.sendMessage(_chatID, msg); - SerialPrint("<-", F("Telegram"), "chat ID: " + uint64ToString(_chatID) + ", msg: " + msg); + SerialPrint("<-", F("Telegram"), "chat ID: " + uint64ToStringIoTM(_chatID) + ", msg: " + msg); } } } diff --git a/src/utils/I2CUtils.cpp b/src/utils/I2CUtils.cpp index 077578f2..3d26fff4 100644 --- a/src/utils/I2CUtils.cpp +++ b/src/utils/I2CUtils.cpp @@ -14,14 +14,14 @@ void scanI2C() { if (error == 0){ message += "I2C device found at address 0x"; - message += uint64ToString(address, 16); + message += uint64ToStringIoTM(address, 16); message += " !"; nDevices++; } else if (error==4) { message += "Unknow error at address 0x"; - message += uint64ToString(address, 16); + message += uint64ToStringIoTM(address, 16); } } if (nDevices == 0) diff --git a/src/utils/StringUtils.cpp b/src/utils/StringUtils.cpp index f33db48c..bfb0ec1d 100644 --- a/src/utils/StringUtils.cpp +++ b/src/utils/StringUtils.cpp @@ -183,7 +183,7 @@ String prettyBytes(size_t size) { return String(size / 1024.0 / 1024.0 / 1024.0) + "GB"; } -String uint64ToString(uint64_t input, uint8_t base) { +String uint64ToStringIoTM(uint64_t input, uint8_t base) { String result = ""; do {