mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-22 18:26:30 +00:00
Berry mqtt.publish
now distinguishes between string
and bytes
(#19196)
This commit is contained in:
parent
0a664b3613
commit
9f16f09f29
@ -13,6 +13,7 @@ All notable changes to this project will be documented in this file.
|
||||
### Changed
|
||||
- Initial ``DisplayMode`` from 1 to 0 and ``DisplayDimmmer`` from 10% to 50% (#19138)
|
||||
- ESP32 Framework (Core) from v2.0.10 to v2.0.11
|
||||
- Berry `mqtt.publish` now distinguishes between `string` and `bytes`
|
||||
|
||||
### Fixed
|
||||
- Initial battery level percentage (#19160)
|
||||
|
@ -33,8 +33,10 @@ extern "C" {
|
||||
bool retain = false;
|
||||
int32_t payload_start = 0;
|
||||
int32_t len = -1; // send all of it
|
||||
bool is_binary = be_isbytes(vm, 3); // is this a binary payload (or false = string)
|
||||
if (top >= 4) { retain = be_tobool(vm, 4); }
|
||||
if (top >= 5) {
|
||||
if (!is_binary) { be_raise(vm, "argument_error", "start and len are not allowed with string payloads"); }
|
||||
payload_start = be_toint(vm, 5);
|
||||
if (payload_start < 0) payload_start = 0;
|
||||
}
|
||||
@ -60,7 +62,7 @@ extern "C" {
|
||||
|
||||
be_pop(vm, be_top(vm)); // clear stack to avoid any indirect warning message in subsequent calls to Berry
|
||||
|
||||
MqttPublishPayload(topic, payload, len, retain);
|
||||
MqttPublishPayload(topic, payload, is_binary ? len : 0 /*if string don't send length*/, retain);
|
||||
|
||||
be_return_nil(vm); // Return
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user