Merge pull request #1231 from MichaelDvP/dev2

fix mqtt `on_message`
This commit is contained in:
Proddy
2023-07-24 08:03:39 +01:00
committed by GitHub
3 changed files with 11 additions and 14 deletions

View File

@@ -27,7 +27,7 @@
"@preact/compat": "^17.1.2", "@preact/compat": "^17.1.2",
"@table-library/react-table-library": "4.1.4", "@table-library/react-table-library": "4.1.4",
"@types/lodash-es": "^4.17.8", "@types/lodash-es": "^4.17.8",
"@types/node": "^20.4.2", "@types/node": "^20.4.4",
"@types/react": "^18.2.15", "@types/react": "^18.2.15",
"@types/react-dom": "^18.2.7", "@types/react-dom": "^18.2.7",
"@types/react-router-dom": "^5.3.3", "@types/react-router-dom": "^5.3.3",

View File

@@ -1730,10 +1730,10 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@types/node@npm:^20.4.2": "@types/node@npm:^20.4.4":
version: 20.4.2 version: 20.4.4
resolution: "@types/node@npm:20.4.2" resolution: "@types/node@npm:20.4.4"
checksum: ca506e089737d54effabda5d6534fdf9fdbe22adbcc4864a170feea390389f38cbae6abcf89c2b1ce5c3e4ffc450b35341509a7619f850babf43106009f01b2d checksum: 93748f53c7f34acde229436717408a0b8f88540647a4bacb863ee46a1545d53a056fa9b486721067b5a7bf0d5123fb1c13519e977b34aef1ddef9857a1c1e5fc
languageName: node languageName: node
linkType: hard linkType: hard
@@ -1971,7 +1971,7 @@ __metadata:
"@preact/preset-vite": ^2.5.0 "@preact/preset-vite": ^2.5.0
"@table-library/react-table-library": 4.1.4 "@table-library/react-table-library": 4.1.4
"@types/lodash-es": ^4.17.8 "@types/lodash-es": ^4.17.8
"@types/node": ^20.4.2 "@types/node": ^20.4.4
"@types/react": ^18.2.15 "@types/react": ^18.2.15
"@types/react-dom": ^18.2.7 "@types/react-dom": ^18.2.7
"@types/react-router-dom": ^5.3.3 "@types/react-router-dom": ^5.3.3

View File

@@ -211,18 +211,15 @@ void Mqtt::incoming(const char * topic, const char * payload) {
// received an MQTT message that we subscribed too // received an MQTT message that we subscribed too
// topic is the full path // topic is the full path
// payload is json or a single string and converted to a json with key 'value' // payload is json or a single string and converted to a json with key 'value'
void Mqtt::on_message(const char * topic, const char * message, size_t len) const { void Mqtt::on_message(const char * topic, const char * payload, size_t len) const {
// This causes a compile error "error: variable-sized object may not be initialized" // the payload is not terminated correctly, so make a copy
// so commenting out and assuming with the new mqtt lib it's always null terminated
/*
// sometimes the payload is not terminated correctly, so make a copy
// convert payload to a null-terminated char string // convert payload to a null-terminated char string
char message[len + 2] = {'\0'}; char message[len + 1];
if (payload != nullptr) { if (payload != nullptr) {
strlcpy(message, payload, len + 1); strlcpy(message, payload, len + 1);
} else {
message[0] = '\0';
} }
*/
#if defined(EMSESP_DEBUG) #if defined(EMSESP_DEBUG)
if (len) { if (len) {