From 97750611f88216e30a1963fec02c11aa092d64a7 Mon Sep 17 00:00:00 2001 From: xopr Date: Sun, 12 Mar 2023 21:52:24 +0100 Subject: [PATCH] Fix for #1458: crash on ASCII and HEX data (#1526) --- main/ZgatewayLORA.ino | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main/ZgatewayLORA.ino b/main/ZgatewayLORA.ino index 82b40dd..a1a8f88 100644 --- a/main/ZgatewayLORA.ino +++ b/main/ZgatewayLORA.ino @@ -73,6 +73,10 @@ Try and determine device given the JSON type uint8_t _determineDevice(JsonObject& LORAdata) { const char* protocol_name = LORAdata["type"]; + // No type provided + if (!protocol_name) + return UNKNOWN_DEVICE; + if (strcmp(protocol_name, "WiPhone") == 0) return WIPHONE; @@ -240,7 +244,7 @@ void MQTTtoLORA(char* topicOri, JsonObject& LORAdata) { // json object decoding // We have hex data: create convert to binary byte raw[strlen(hex) / 2]; _hexToRaw(hex, raw, sizeof(raw)); - LoRa.print((char*)raw); + LoRa.write((uint8_t*)raw, sizeof(raw)); } else { // ascii payload LoRa.print(message);