correct end char termination

This commit is contained in:
1technophile committed 2017-12-31 11:26:39 +01:00
1 parent 4077a954ca
commit 87364e2897
1 file changed
+15 -16
+15 -16
View File
@@ -51,7 +51,7 @@
#include <PubSubClient.h> #include <PubSubClient.h>
// array to store previous received RFs, IRs codes and their timestamps // array to store previous received RFs, IRs codes and their timestamps
#ifdef ESP8266 #if defined(ESP8266) || defined(ESP32)
#define array_size 12 #define array_size 12
unsigned long ReceivedSignal[array_size][2] ={{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}}; unsigned long ReceivedSignal[array_size][2] ={{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
#else #else
@@ -63,10 +63,12 @@ unsigned long ReceivedSignal[array_size][2] ={{0,0},{0,0},{0,0},{0,0}};
//adding this to bypass the problem of the arduino builder issue 50 //adding this to bypass the problem of the arduino builder issue 50
void callback(char*topic, byte* payload,unsigned int length); void callback(char*topic, byte* payload,unsigned int length);
#ifdef ESP8266 #ifdef ESP32
#include <WiFi.h>
#include <ArduinoOTA.h>
WiFiClient eClient;
#elif defined(ESP8266)
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h> #include <ArduinoOTA.h>
WiFiClient eClient; WiFiClient eClient;
#else #else
@@ -135,9 +137,9 @@ void callback(char* topic, byte* payload, unsigned int length) {
void setup() void setup()
{ {
#ifdef ESP8266 #if defined(ESP8266) || defined(ESP32)
//Launch serial for debugging purposes //Launch serial for debugging purposes
#ifdef ZgatewaySRFB #if defined(ZgatewaySRFB) || defined(ESP32)
Serial.begin(SERIAL_BAUD); // in the case of sonoff RF Bridge the link to the RF emitter/receiver is made by serial and need TX/RX Serial.begin(SERIAL_BAUD); // in the case of sonoff RF Bridge the link to the RF emitter/receiver is made by serial and need TX/RX
#else #else
Serial.begin(SERIAL_BAUD, SERIAL_8N1, SERIAL_TX_ONLY); Serial.begin(SERIAL_BAUD, SERIAL_8N1, SERIAL_TX_ONLY);
@@ -189,9 +191,6 @@ void setup()
#ifdef ZsensorBH1750 #ifdef ZsensorBH1750
setupZsensorBH1750(); setupZsensorBH1750();
#endif #endif
#ifdef ZsensorTSL2561
setupZsensorTSL2561();
#endif
#ifdef ZgatewayIR #ifdef ZgatewayIR
setupIR(); setupIR();
#endif #endif
@@ -215,7 +214,7 @@ void setup()
#endif #endif
} }
#ifdef ESP8266 #if defined(ESP8266) || defined(ESP32)
void setup_wifi() { void setup_wifi() {
delay(10); delay(10);
WiFi.mode(WIFI_STA); WiFi.mode(WIFI_STA);
@@ -268,7 +267,7 @@ void loop()
// MQTT loop // MQTT loop
client.loop(); client.loop();
#ifdef ESP8266 #if defined(ESP8266) || defined(ESP32)
ArduinoOTA.handle(); ArduinoOTA.handle();
#endif #endif
@@ -278,9 +277,6 @@ void loop()
#ifdef ZsensorBH1750 #ifdef ZsensorBH1750
MeasureLightIntensity(); //Addon to measure Light Intensity with a BH1750 MeasureLightIntensity(); //Addon to measure Light Intensity with a BH1750
#endif #endif
#ifdef ZsensorTSL2561
MeasureLightIntensityTSL2561(); // Addon to measure Light Intensity with a TSL2561
#endif
#ifdef ZsensorDHT #ifdef ZsensorDHT
MeasureTempAndHum(); //Addon to measure the temperature with a DHT MeasureTempAndHum(); //Addon to measure the temperature with a DHT
#endif #endif
@@ -312,8 +308,10 @@ void loop()
delay(100); delay(100);
#endif #endif
#ifdef ZgatewayBT #ifdef ZgatewayBT
if(BTtoMQTT()) #ifndef ESP32
trc(F("BTtoMQTT OK")); if(BTtoMQTT())
trc(F("BTtoMQTT OK"));
#endif
#endif #endif
#ifdef ZgatewayRFM69 #ifdef ZgatewayRFM69
if(RFM69toMQTT()) if(RFM69toMQTT())
@@ -411,6 +409,7 @@ void extract_char(char * token_char, char * subset, int start ,int l, boolean re
if (reverse) revert_hex_data(tmp_subset, subset, l+1); if (reverse) revert_hex_data(tmp_subset, subset, l+1);
else strncpy( subset, tmp_subset , l+1); else strncpy( subset, tmp_subset , l+1);
} }
subset[l] = '\0';
} }
void revert_hex_data(char * in, char * out, int l){ void revert_hex_data(char * in, char * out, int l){