arendst / Tasmota

Alternative firmware for ESP8266 and ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at
https://tasmota.github.io/docs
GNU General Public License v3.0
22.26k stars 4.82k forks source link

[TasmotaClient] teleperiod message is cutted off #18427

Closed Gifford47 closed 1 year ago

Gifford47 commented 1 year ago

PROBLEM DESCRIPTION

i have a esp32 and a 3v3 arduino pro mini attached to it. on the arduino side i read all gpios and want to send the states via teleperiod function to mqtt. the string from arduino is with 152 chars a bit long. after sending the string from arduino to the esp, the message is cutted off and only 100 chars left. i tried to expand the read and write buffers but nothing changed. so i assume there`s a limit on tasmota side.

The code on the arduino (tasmotaclient) side is:

void user_FUNC_JSON(void)
{
  char myjson[240];
  // analog pins as int: A0=14,A1=15,A2=16,A3=17,A4=18,A5=19,A6=20,A7=21
  //send analog pins first
  sprintf(myjson,"{\"1\":%u,\"2\":%u,\"3\":%u,\"4\":%u,\"5\":%u,\"6\":%u,\"7\":%u,\"8\":%u,"
  "\"9\":%d,\"10\":%d,\"11\":%d,\"12\":%d,\"13\":%d,\"14\":%d,\"15\":%d,\"16\":%d,\"17\":%d,\"18\":%d,\"19\":%d,\"20\":%d}", \
  analogRead(A0), analogRead(A1), analogRead(A2), analogRead(A3), analogRead(A4), analogRead(A5), analogRead(A6), analogRead(A7),\
  digitalRead(2), digitalRead(3), digitalRead(4), digitalRead(5), digitalRead(6), digitalRead(7), digitalRead(8), \
  digitalRead(9), digitalRead(10), digitalRead(11), digitalRead(12), digitalRead(13));
  client.sendJSON(myjson);
}

the Log on the esp side is:

11:42:19.624 CMD: teleperiod
11:42:19.628 MQT: stat/tasmota_AAAAAA/RESULT = {"TelePeriod":600}
11:42:20.078 MQT: tele/tasmota_AAAAAA/STATE = {"Time":"2023-04-16T11:42:20","Uptime":"0T00:01:15","UptimeSec":75,"Heap":175,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"Berry":{"HeapUsed":3,"Objects":43},"POWER":"OFF"}
11:42:20.123 MQT: tele/tasmota_AAAAAA/SENSOR = {"Time":"2023-04-16T11:42:20","TasmotaClient":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"1}

REQUESTED INFORMATION

Make sure your have performed every step and checked the applicable boxes before submitting your issue. Thank you!

- [X] If using rules, provide the output of this command: `Backlog Rule1; Rule2; Rule3`:
```lua
No Rules used
- [X] Set `weblog` to 4 and then, when you experience your issue, provide the output of the Console log:
```lua
11:46:45.299 CMD: teleperiod
11:46:45.301 SRC: WebConsole from 192.168.1.165
11:46:45.304 CMD: Grp 0, Cmd 'TELEPERIOD', Idx 1, Len 0, Pld -99, Data ''
11:46:45.308 MQT: stat/tasmota_AAAAAA/RESULT = {"TelePeriod":600}
11:46:46.051 BRY: GC from 4083 to 3798 bytes, objects freed 1/43 (in 1 ms) - slots from 48/122 to 45/122
11:46:46.056 MQT: tele/tasmota_AAAAAA/STATE = {"Time":"2023-04-16T11:46:46","Uptime":"0T00:05:41","UptimeSec":341,"Heap":175,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"Berry":{"HeapUsed":3,"Objects":43},"POWER":"OFF"}
11:46:46.102 MQT: tele/tasmota_AAAAAA/SENSOR = {"Time":"2023-04-16T11:46:46","TasmotaClient":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"1}

TO REPRODUCE

EXPECTED BEHAVIOUR

The whole teleperiod message is send to tasmota and further to mqtt broker.

SCREENSHOTS

If applicable, add screenshots to help explain your problem.

ADDITIONAL CONTEXT

Add any other context about the problem here.

(Please, remember to close the issue when the problem has been addressed)

barbudor commented 1 year ago

Yes It's here : https://github.com/arendst/Tasmota/blob/d95d56f3e476a2e3fdb79f3c52d67937fba4b4f4/tasmota/tasmota_xdrv_driver/xdrv_31_tasmota_client.ino#L440-L450

However increasing a buffer in the stack would not be a good idea...

arendst commented 1 year ago

Let me do some heap research and provide a fix as 100 is indeed a bit small.

arendst commented 1 year ago

Fixed in latest dev release. Increased to 250 characaters. Larger would need a partial rewrite of TasmotaClient to handle indexes over 8-bit.

Gifford47 commented 1 year ago

Wow, that's a fast answer and solution 😀 thanks for your support @arendst @barbudor !!

Jason2866 commented 1 year ago

Closing since fixed