diff --git a/.travis.yml b/.travis.yml
index e945e8a3..fc2a483c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -10,9 +10,9 @@ before_install:
- "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16"
- sleep 3
- export DISPLAY=:1.0
- - wget http://downloads.arduino.cc/arduino-1.8.5-linux64.tar.xz
- - tar xf arduino-1.8.5-linux64.tar.xz
- - sudo mv arduino-1.8.5 /usr/local/share/arduino
+ - wget http://downloads.arduino.cc/arduino-1.8.6-linux64.tar.xz
+ - tar xf arduino-1.8.6-linux64.tar.xz
+ - sudo mv arduino-1.8.6 /usr/local/share/arduino
- sudo ln -s /usr/local/share/arduino/arduino /usr/local/bin/arduino
install:
- ln -s $PWD /usr/local/share/arduino/OpenMQTTGateway
@@ -31,7 +31,6 @@ install:
- arduino --pref "boardsmanager.additional.urls=http://arduino.esp8266.com/stable/package_esp8266com_index.json" --save-prefs
- arduino --install-boards esp8266:esp8266
- arduino --board $BD --save-prefs
- - arduino --pref "compiler.warning_level=all" --save-prefs
script:
- arduino --verify --board $BD $PWD/OpenMQTTGateway.ino
notifications:
diff --git a/OpenMQTTGateway.ino b/OpenMQTTGateway.ino
index e4de2b5c..3d7bdd8f 100644
--- a/OpenMQTTGateway.ino
+++ b/OpenMQTTGateway.ino
@@ -57,6 +57,18 @@
along with this program. If not, see .
*/
#include "User_config.h"
+
+// array to store previous received RFs, IRs codes and their timestamps
+#if defined(ESP8266) || defined(ESP32) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__)
+ #define MQTT_MAX_PACKET_SIZE 1024
+ #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}};
+#else // boards with smaller memory
+ #define MQTT_MAX_PACKET_SIZE 256
+ #define array_size 4
+ unsigned long ReceivedSignal[array_size][2] ={{0,0},{0,0},{0,0},{0,0}};
+#endif
+
#include
#include
@@ -112,16 +124,7 @@
#ifdef ZsensorGPIOKeyCode
#include "config_GPIOKeyCode.h"
#endif
-// array to store previous received RFs, IRs codes and their timestamps
-#if defined(ESP8266) || defined(ESP32) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__)
- #define MQTT_MAX_PACKET_SIZE 1024
- #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}};
-#else // boards with smaller memory
- #define MQTT_MAX_PACKET_SIZE 256
- #define array_size 4
- unsigned long ReceivedSignal[array_size][2] ={{0,0},{0,0},{0,0},{0,0}};
-#endif
+
/*------------------------------------------------------------------------*/
//adding this to bypass the problem of the arduino builder issue 50
@@ -129,9 +132,12 @@ void callback(char*topic, byte* payload,unsigned int length);
boolean connectedOnce = false; //indicate if we have been connected once to MQTT
+int failure_number = 0; // number of failure connecting to MQTT
+
#ifdef ESP32
#include
#include
+ #include
WiFiClient eClient;
#ifdef MDNS_SD
#include
@@ -179,7 +185,6 @@ void saveConfigCallback () {
boolean reconnect() {
- int failure_number = 0;
// Loop until we're reconnected
while (!client.connected()) {
trc(F("MQTT connection...")); //F function enable to decrease sram usage
@@ -187,9 +192,9 @@ boolean reconnect() {
trc(F("Connected to broker"));
failure_number = 0;
// Once connected, publish an announcement...
- client.publish(will_Topic,Gateway_AnnouncementMsg,will_Retain);
+ pub(will_Topic,Gateway_AnnouncementMsg,will_Retain);
// publish version
- client.publish(version_Topic,OMG_VERSION,will_Retain);
+ pub(version_Topic,OMG_VERSION,will_Retain);
//Subscribing to topic
if (client.subscribe(subjectMQTTtoX)) {
#ifdef ZgatewayRF
@@ -205,6 +210,8 @@ boolean reconnect() {
}
} else {
failure_number ++; // we count the failure
+ trc(F("failure_number"));
+ trc(failure_number);
trc(F("failed, rc="));
trc(client.state());
trc(F("try again in 5s"));
@@ -252,6 +259,7 @@ void setup()
Serial.end();
Serial.begin(SERIAL_BAUD, SERIAL_8N1, SERIAL_TX_ONLY);// enable on ESP8266 to free some pin
#endif
+
#if defined(ESP8266) && !defined(ESPWifiManualSetup)
setup_wifimanager();
#else // ESP32 case we don't use Wifi manager yet
@@ -308,6 +316,7 @@ void setup()
delay(500);
digitalWrite(led_receive, HIGH);
digitalWrite(led_send, HIGH);
+
#endif
#if defined(MDNS_SD) && defined(ESP8266)
@@ -386,7 +395,8 @@ void setup()
#endif
#ifdef ZsensorGPIOKeyCode
setupGPIOKeyCode();
- #endif
+ #endif
+
trc(F("MQTT_MAX_PACKET_SIZE"));
trc(MQTT_MAX_PACKET_SIZE);
trc(F("Setup OpenMQTTGateway end"));
@@ -414,7 +424,6 @@ void setup_wifi() {
failureAttempt++; //DIRTY FIX ESP32
if (failureAttempt > 30) setup_wifi(); //DIRTY FIX ESP32
}
-
trc(F("WiFi ok with manual config credentials"));
}
@@ -533,8 +542,8 @@ void setup_wifimanager(){
}
}
-
#else // Arduino case
+
void setup_ethernet() {
if (gateway[0] != 0 || Dns[0]!=0)
{
@@ -584,7 +593,6 @@ void setup_ethernet() {
void loop()
{
-
unsigned long now = millis();
//MQTT client connexion management
if (!client.connected()) { // not connected
@@ -642,27 +650,16 @@ void loop()
MeasureADC(); //Addon to measure the analog value of analog pin
#endif
#ifdef ZgatewayRF
- if(RFtoMQTT()){
- trc(F("RFtoMQTT OK"));
- //GREEN ON
- digitalWrite(led_receive, LOW);
- timer_led_receive = millis();
- }
+ RFtoMQTT();
#endif
#ifdef ZgatewayRF315
- if(RF315toMQTT()){
- trc(F("RF315toMQTT OK"));
- //GREEN ON
- digitalWrite(led_receive, LOW);
- timer_led_receive = millis();
- }
+ RF315toMQTT();
#endif
#ifdef ZgatewayRF2
- if(RF2toMQTT()){
- trc(F("RF2toMQTT OK"));
- digitalWrite(led_receive, LOW);
- timer_led_receive = millis();
- }
+ RF2toMQTT();
+ #endif
+ #ifdef ZgatewayPilight
+ PilighttoMQTT();
#endif
#ifdef ZgatewayPilight
if(PilighttoMQTT()){
@@ -672,16 +669,10 @@ void loop()
}
#endif
#ifdef ZgatewaySRFB
- if(SRFBtoMQTT())
- trc(F("SRFBtoMQTT OK"));
+ SRFBtoMQTT();
#endif
#ifdef ZgatewayIR
- if(IRtoMQTT()) {
- trc(F("IRtoMQTT OK"));
- digitalWrite(led_receive, LOW);
- timer_led_receive = millis();
- delay(100);
- }
+ IRtoMQTT();
#endif
#ifdef ZgatewayBT
#ifndef multiCore
@@ -709,7 +700,7 @@ void stateMeasures(){
unsigned long now = millis();
if (now > (timer_sys_measures + TimeBetweenReadingSYS)) {//retriving value of memory ram every TimeBetweenReadingSYS
timer_sys_measures = millis();
- StaticJsonBuffer<200> jsonBuffer;
+ StaticJsonBuffer jsonBuffer;
JsonObject& SYSdata = jsonBuffer.createObject();
trc("Uptime (s)");
unsigned long uptime = millis()/1000;
@@ -737,46 +728,52 @@ void stateMeasures(){
modules = modules + ZgatewayRF315;
#endif
#ifdef ZsensorBME280
- modules = modules + ZsensorBME280;
+ modules = modules + ZsensorBME280;
#endif
#ifdef ZsensorBH1750
- modules = modules + ZsensorBH1750;
+ modules = modules + ZsensorBH1750;
#endif
#ifdef ZsensorTSL2561
- modules = modules + ZsensorTSL2561;
+ modules = modules + ZsensorTSL2561;
#endif
#ifdef ZactuatorONOFF
- modules = modules + ZactuatorONOFF;
+ modules = modules + ZactuatorONOFF;
#endif
#ifdef Zgateway2G
- modules = modules + Zgateway2G;
+ modules = modules + Zgateway2G;
#endif
#ifdef ZgatewayIR
- modules = modules + ZgatewayIR;
+ modules = modules + ZgatewayIR;
#endif
#ifdef ZgatewayRF2
- modules = modules + ZgatewayRF2;
+ modules = modules + ZgatewayRF2;
+ #endif
+ #ifdef ZgatewayPilight
+ modules = modules + ZgatewayPilight;
#endif
#ifdef ZgatewayPilight
modules = modules + ZgatewayPilight;
#endif
#ifdef ZgatewaySRFB
- modules = modules + ZgatewaySRFB;
+ modules = modules + ZgatewaySRFB;
#endif
#ifdef ZgatewayBT
- modules = modules + ZgatewayBT;
+ modules = modules + ZgatewayBT;
#endif
#ifdef ZgatewayRFM69
- modules = modules + ZgatewayRFM69;
+ modules = modules + ZgatewayRFM69;
#endif
#ifdef ZsensorINA226
- modules = modules + ZsensorINA226;
+ modules = modules + ZsensorINA226;
#endif
#ifdef ZsensorHCSR501
- modules = modules + ZsensorHCSR501;
+ modules = modules + ZsensorHCSR501;
#endif
#ifdef ZsensorGPIOInput
- modules = modules + ZsensorGPIOInput;
+ modules = modules + ZsensorGPIOInput;
+ #endif
+ #ifdef ZsensorGPIOKeyCode
+ modules = modules + ZsensorGPIOKeyCode;
#endif
#ifdef ZsensorGPIOKeyCode
modules = modules + ZsensorGPIOKeyCode;
@@ -785,7 +782,7 @@ void stateMeasures(){
trc(modules);
char JSONmessageBuffer[100];
SYSdata.printTo(JSONmessageBuffer, sizeof(JSONmessageBuffer));
- client.publish(subjectSYStoMQTT,JSONmessageBuffer);
+ pub(subjectSYStoMQTT,JSONmessageBuffer);
}
}
#endif
@@ -837,43 +834,78 @@ return false;
}
void receivingMQTT(char * topicOri, char * datacallback) {
+ if (strstr(topicOri, subjectMultiGTWKey) != NULL) // storing received value so as to avoid publishing this value if it has been already sent by this or another OpenMQTTGateway
+ {
+ trc(F("Storing signal"));
+ unsigned long data = strtoul(datacallback, NULL, 10); // we will not be able to pass values > 4294967295
+ storeValue(data);
+ trc(F("Data stored"));
+ }
+ //YELLOW ON
+ digitalWrite(led_send, LOW);
- if (strstr(topicOri, subjectMultiGTWKey) != NULL) // storing received value so as to avoid publishing this value if it has been already sent by this or another OpenMQTTGateway
- {
- trc(F("Storing signal"));
- unsigned long data = strtoul(datacallback, NULL, 10); // we will not be able to pass values > 4294967295
- storeValue(data);
- trc(F("Data stored"));
- }
-//YELLOW ON
-digitalWrite(led_send, LOW);
-#ifdef ZgatewayRF
- MQTTtoRF(topicOri, datacallback);
-#endif
-#ifdef ZgatewayRF315
- MQTTtoRF315(topicOri, datacallback);
-#endif
-#ifdef ZgatewayRF2
- MQTTtoRF2(topicOri, datacallback);
-#endif
-#ifdef ZgatewayPilight
- MQTTtoPilight(topicOri, datacallback);
-#endif
-#ifdef Zgateway2G
- MQTTto2G(topicOri, datacallback);
-#endif
-#ifdef ZgatewaySRFB
- MQTTtoSRFB(topicOri, datacallback);
-#endif
-#ifdef ZgatewayIR
- MQTTtoIR(topicOri, datacallback);
-#endif
-#ifdef ZgatewayRFM69
- MQTTtoRFM69(topicOri, datacallback);
-#endif
-#ifdef ZactuatorONOFF
- MQTTtoONOFF(topicOri, datacallback);
-#endif
+ trc(F("Creating Json buffer"));
+ StaticJsonBuffer jsonBuffer;
+ JsonObject& jsondata = jsonBuffer.parseObject(datacallback);
+
+ if (jsondata.success()) { // json object ok -> json decoding
+ #ifdef ZgatewayPilight // ZgatewayPilight is only defined with json publishing
+ MQTTtoPilight(topicOri, jsondata);
+ #endif
+ #ifdef jsonPublishing
+ #ifdef ZgatewayRF
+ MQTTtoRF(topicOri, jsondata);
+ #endif
+ #ifdef ZgatewayRF315
+ MQTTtoRF315(topicOri, jsondata);
+ #endif
+ #ifdef ZgatewayRF2
+ MQTTtoRF2(topicOri, jsondata);
+ #endif
+ #ifdef Zgateway2G
+ MQTTto2G(topicOri, jsondata);
+ #endif
+ #ifdef ZgatewaySRFB
+ MQTTtoSRFB(topicOri, jsondata);
+ #endif
+ #ifdef ZgatewayIR
+ MQTTtoIR(topicOri, jsondata);
+ #endif
+ #ifdef ZgatewayRFM69
+ MQTTtoRFM69(topicOri, jsondata);
+ #endif
+ #ifdef ZactuatorONOFF
+ MQTTtoONOFF(topicOri, jsondata);
+ #endif
+ #endif
+ } else { // not a json object --> simple decoding
+ #ifdef simplePublishing
+ #ifdef ZgatewayRF
+ MQTTtoRF(topicOri, datacallback);
+ #endif
+ #ifdef ZgatewayRF315
+ MQTTtoRF315(topicOri, datacallback);
+ #endif
+ #ifdef ZgatewayRF2
+ MQTTtoRF2(topicOri, datacallback);
+ #endif
+ #ifdef Zgateway2G
+ MQTTto2G(topicOri, datacallback);
+ #endif
+ #ifdef ZgatewaySRFB
+ MQTTtoSRFB(topicOri, datacallback);
+ #endif
+ #ifdef ZgatewayIR
+ MQTTtoIR(topicOri, datacallback);
+ #endif
+ #ifdef ZgatewayRFM69
+ MQTTtoRFM69(topicOri, datacallback);
+ #endif
+ #ifdef ZactuatorONOFF
+ MQTTtoONOFF(topicOri, datacallback);
+ #endif
+ #endif
+ }
//YELLOW OFF
digitalWrite(led_send, HIGH);
}
@@ -962,3 +994,112 @@ void trc(float msg){
Serial.println(msg);
#endif
}
+
+void pub(char * topic, char * payload, boolean retainFlag){
+ client.publish(topic, payload, retainFlag);
+}
+
+void pub(char * topicori, JsonObject& data){
+
+ String topic = topicori;
+ #ifdef valueAsASubject
+ unsigned long value = data["value"];
+ if (value != 0){
+ topic = topic + "/"+ String(value);
+ }
+ #endif
+
+ #ifdef jsonPublishing
+ char JSONmessageBuffer[JSON_MSG_BUFFER];
+ trc(F("Pub json into:"));
+ trc(topic);
+ data.printTo(JSONmessageBuffer, sizeof(JSONmessageBuffer));
+ trc(JSONmessageBuffer);
+ pub(topic, JSONmessageBuffer);
+ #endif
+
+ #ifdef simplePublishing
+ trc(F("Pub data per topic"));
+ // Loop through all the key-value pairs in obj
+ for (JsonPair& p : data) {
+ #if defined(ESP8266)
+ yield();
+ #endif
+ if (p.value.is() || p.value.is()) {
+ trc(p.key);
+ trc(p.value.as());
+ if (strcmp(p.key, "value") == 0){ // if data is a value we don't integrate the name into the topic
+ pub(topic,p.value.as());
+ }else{ // if data is not a value we integrate the name into the topic
+ pub(topic + "/" + String(p.key),p.value.as());
+ }
+ } else if (p.value.is()) {
+ trc(p.key);
+ trc(p.value.as());
+ pub(topic + "/" + String(p.key),p.value.as());
+ } else if (p.value.is()) {
+ trc(p.key);
+ trc(p.value.as());
+ pub(topic + "/" + String(p.key),p.value.as());
+ }
+ }
+ #endif
+}
+
+void pub(char * topic, char * payload){
+ client.publish(topic, payload);
+}
+
+void pub(char * topic, String payload){
+ client.publish(topic,(char *)payload.c_str());
+}
+
+void pub(String topic, String payload){
+ client.publish((char *)topic.c_str(),(char *)payload.c_str());
+}
+
+void pub(String topic, char * payload){
+ client.publish((char *)topic.c_str(),payload);
+}
+
+void pub(String topic, int payload){
+ char val[12];
+ sprintf(val, "%d", payload);
+ client.publish((char *)topic.c_str(),val);
+}
+
+void pub(String topic, float payload){
+ char val[12];
+ dtostrf(payload,3,1,val);
+ client.publish((char *)topic.c_str(),val);
+}
+
+void pub(char * topic, float payload){
+ char val[12];
+ dtostrf(payload,3,1,val);
+ client.publish(topic,val);
+}
+
+void pub(char * topic, int payload){
+ char val[6];
+ sprintf(val, "%d", payload);
+ client.publish(topic,val);
+}
+
+void pub(char * topic, unsigned int payload){
+ char val[6];
+ sprintf(val, "%u", payload);
+ client.publish(topic,val);
+}
+
+void pub(char * topic, unsigned long payload){
+ char val[11];
+ sprintf(val, "%lu", payload);
+ client.publish(topic,val);
+}
+
+void pub(String topic, unsigned long payload){
+ char val[11];
+ sprintf(val, "%lu", payload);
+ client.publish((char *)topic.c_str(),val);
+}
diff --git a/User_config.h b/User_config.h
index 4fb8d408..64f8f82b 100644
--- a/User_config.h
+++ b/User_config.h
@@ -5,11 +5,8 @@
Send and receiving command by MQTT
This program enables to:
- - receive MQTT data from a topic and send RF 433Mhz signal corresponding to the received MQTT data
- - publish MQTT data to a different topic related to received 433Mhz signal
- - receive MQTT data from a topic and send IR signal corresponding to the received MQTT data
- - publish MQTT data to a different topic related to received IR signal
- - publish MQTT data to a different topic related to BLE devices rssi signal
+ - receive MQTT data from a topic and send signals corresponding to the received MQTT data
+ - publish MQTT data to a different topic related to received signals
Copyright: (c)Florian ROBERT
@@ -29,7 +26,39 @@
along with this program. If not, see .
*/
/*-------------------VERSION----------------------*/
-#define OMG_VERSION "0.8"
+#define OMG_VERSION "0.9beta"
+
+/*-------------CONFIGURE WIFIMANAGER-------------*/
+/*
+ * The following parameters are set during the WifiManager setup process:
+ * - wifi_ssid
+ * - wifi_password
+ * - mqtt_user
+ * - mqtt_pass
+ * - mqtt_server
+ * - mqtt_port
+ *
+ * To completely disable WifiManager, define ESPWifiManualSetup.
+ * If you do so, please don't forget to set these variables before compiling
+ *
+ * Otherwise you can provide these credentials on the web interface after connecting
+ * to the access point with your password (SSID: WifiManager_ssid, password: WifiManager_password)
+ */
+
+/*-------------DEFINE YOUR NETWORK PARAMETERS BELOW----------------*/
+#if defined(ESP8266) // for nodemcu, weemos and esp8266
+ //#define ESPWifiManualSetup true //uncomment you don't want to use wifimanager for your credential settings on ESP
+#endif
+
+#if defined(ESP32) || defined(ESPWifiManualSetup) // for nodemcu, weemos and esp8266
+ #define wifi_ssid "wifi ssid"
+ #define wifi_password "wifi password"
+#else // for arduino + W5100
+ const byte mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0x54, 0x95 }; //W5100 ethernet shield mac adress
+#endif
+
+#define WifiManager_password "your_password" //this is going to be the WPA2-PSK password for the initial setup access point
+#define WifiManager_ssid "OpenMQTTGateway" //this is the network name of the initial setup access point
/*-------------CONFIGURE WIFIMANAGER-------------*/
/*
@@ -61,6 +90,48 @@ char mqtt_server[40] = "192.168.1.17";
char mqtt_port[6] = "1883";
#define Gateway_Name "OpenMQTTGateway"
+
+//uncomment the line below to integrate msg value into the subject when receiving
+//#define valueAsASubject true
+
+/*-------------DEFINE THE MODULES YOU WANT BELOW----------------*/
+//Addons and module management, comment the Z line
+
+#define ZgatewayRF "RF" //ESP8266, Arduino, ESP32
+//#define ZgatewayRF315 "RF315" //ESP8266, Arduino, ESP32
+#define ZgatewayIR "IR" //ESP8266, Arduino, Sonoff RF Bridge
+//#define ZgatewayPilight "Pilight" //ESP8266, Arduino, ESP32
+#define ZgatewayBT "BT" //ESP8266, Arduino, ESP32
+//#define ZgatewayRF2 "RF2" //ESP8266, Arduino, ESP32
+//#define ZgatewaySRFB "SRFB" // Sonoff RF Bridge
+//#define Zgateway2G "2G" //ESP8266, Arduino, ESP32
+//#define ZactuatorONOFF "ONOFF" //ESP8266, Arduino, ESP32, Sonoff RF Bridge
+//#define ZsensorINA226 "INA226" //ESP8266, Arduino, ESP32
+//#define ZsensorHCSR501 "HCSR501" //ESP8266, Arduino, ESP32, Sonoff RF Bridge
+//#define ZsensorADC "ADC" //ESP8266, Arduino, ESP32
+//#define ZsensorBH1750 "BH1750" //ESP8266, Arduino, ESP32
+//#define ZsensorTSL2561 "TSL2561" //ESP8266, Arduino, ESP32
+//#define ZsensorBME280 "BME280" //ESP8266, Arduino, ESP32
+//#define ZsensorDHT "DHT" //ESP8266, Arduino, ESP32, Sonoff RF Bridge
+//#define ZgatewayRFM69 "RFM69" //ESP8266, Arduino, ESP32
+//#define ZsensorGPIOKeyCode "GPIOKeyCode" //ESP8266, Arduino, ESP32
+//#define ZsensorGPIOInput "GPIOInput" //ESP8266, Arduino, ESP32
+
+/*-------------DEFINE YOUR ADVANCED NETWORK PARAMETERS BELOW----------------*/
+//#define MDNS_SD //uncomment if you want to use mdns for discovering automatically your ip server, please note that MDNS with ESP32 can cause the BLE to not work
+//#define cleanFS true //uncomment if you want to clean the ESP memory and reenter your credentials
+#define maxMQTTretry 4 //maximum MQTT connection attempts before going to wifi setup
+
+//set minimum quality of signal so it ignores AP's under that quality
+#define MinimumWifiSignalQuality 8
+
+// these values are only used if no dhcp configuration is available
+const byte ip[] = { 192, 168, 1, 99 }; //ip adress
+const byte gateway[] = { 0, 0, 0, 0 }; //ip adress, if first value is different from 0 advanced config network will be used and you should fill gateway & dns
+const byte Dns[] = { 0, 0, 0, 0 }; //ip adress, if first value is different from 0 advanced config network will be used and you should fill gateway & dns
+const byte subnet[] = { 255, 255, 255, 0 }; //ip adress
+
+/*-------------DEFINE YOUR MQTT ADVANCED PARAMETERS BELOW----------------*/
#define Base_Topic "home/"
#define version_Topic Base_Topic Gateway_Name "/version"
#define will_Topic Base_Topic Gateway_Name "/LWT"
@@ -69,27 +140,13 @@ char mqtt_port[6] = "1883";
#define will_Message "Offline"
#define Gateway_AnnouncementMsg "Online"
-/*-------------DEFINE YOUR NETWORK PARAMETERS BELOW----------------*/
-//#define MDNS_SD //uncomment if you want to use mdns for discovering automatically your ip server, please note that MDNS with ESP32 can cause the BLE to not work
-//#define cleanFS true //uncomment if you want to clean the ESP memory and reenter your credentials
-#define maxMQTTretry 4 //maximum MQTT connection attempts before going to wifi setup
+#define jsonPublishing true //comment if you don't want to use Json publishing (one topic for all the parameters)
+//example home/OpenMQTTGateway_ESP32_DEVKIT/BTtoMQTT/4XXXXXXXXXX4 {"rssi":-63,"servicedata":"fe0000000000000000000000000000000000000000"}
-//set minimum quality of signal so it ignores AP's under that quality
-#define MinimumWifiSignalQuality 8
-
-// Update these with values suitable for your network.
-#if defined(ESP32) || defined(ESPWifiManualSetup) // for nodemcu, weemos and esp8266
- #define wifi_ssid "wifi ssid"
- #define wifi_password "wifi password"
-#else // for arduino + W5100
- const byte mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0x54, 0x95 }; //W5100 ethernet shield mac adress
-#endif
-
-// these values are only used if no dhcp configuration is available
-const byte ip[] = { 192, 168, 1, 99 }; //ip address
-const byte gateway[] = { 0, 0, 0, 0 }; //ip address, if first value is different from 0 advanced config network will be used and you should fill gateway & dns
-const byte Dns[] = { 0, 0, 0, 0 }; //ip address, if first value is different from 0 advanced config network will be used and you should fill gateway & dns
-const byte subnet[] = { 255, 255, 255, 0 }; //ip address
+#define simplePublishing true //comment if you don't want to use simple publishing (one topic for one parameter)
+//example
+// home/OpenMQTTGateway_ESP32_DEVKIT/BTtoMQTT/4XXXXXXXXXX4/rssi -63.0
+// home/OpenMQTTGateway_ESP32_DEVKIT/BTtoMQTT/4XXXXXXXXXX4/servicedata fe0000000000000000000000000000000000000000
/*-------------DEFINE YOUR OTA PARAMETERS BELOW----------------*/
#define ota_hostname Gateway_Name
@@ -104,27 +161,6 @@ const byte subnet[] = { 255, 255, 255, 0 }; //ip address
// VCC ------------D|-----------/\/\/\/\ ----------------- Arduino PIN
// LED Resistor 270-510R
-/*-------------DEFINE THE MODULES YOU WANT BELOW----------------*/
-//Addons and module management, comment the Z line
-
-#define ZgatewayRF "RF" //ESP8266, Arduino, ESP32
-//#define ZgatewayRF315 "RF315" //ESP8266, Arduino, ESP32
-#define ZgatewayIR "IR" //ESP8266, Arduino, Sonoff RF Bridge
-#define ZgatewayBT "BT" //ESP8266, Arduino, ESP32
-//#define ZgatewayRF2 "RF2" //ESP8266, Arduino, ESP32
-//#define ZgatewayPilight "Pilight" //ESP8266
-//#define ZgatewaySRFB "SRFB" // Sonoff RF Bridge
-//#define Zgateway2G "2G" //ESP8266, Arduino, ESP32
-//#define ZactuatorONOFF "ONOFF" //ESP8266, Arduino, ESP32, Sonoff RF Bridge
-//#define ZsensorINA226 "INA226" //ESP8266, Arduino, ESP32
-//#define ZsensorHCSR501 "HCSR501" //ESP8266, Arduino, ESP32, Sonoff RF Bridge
-//#define ZsensorADC "ADC" //ESP8266, Arduino, ESP32
-//#define ZsensorBH1750 "BH1750" //ESP8266, Arduino, ESP32
-//#define ZsensorTSL2561 "TSL2561" //ESP8266, Arduino, ESP32
-//#define ZsensorBME280 "BME280" //ESP8266, Arduino, ESP32
-//#define ZsensorDHT "DHT" //ESP8266, Arduino, ESP32, Sonoff RF Bridge
-//#define ZgatewayRFM69 "RFM69" //ESP8266, Arduino, ESP32
-
/*----------------------------OTHER PARAMETERS-----------------------------*/
/*-------------------CHANGING THEM IS NOT COMPULSORY-----------------------*/
/*----------------------------USER PARAMETERS-----------------------------*/
@@ -146,6 +182,8 @@ const byte subnet[] = { 255, 255, 255, 0 }; //ip address
#define multiCore //comment to don't use multicore function of ESP32 for BLE
#endif
+#define JSON_MSG_BUFFER 256 // Json message max buffer size, don't put 1024 or higher it is causing unexpected behaviour on ESP8266
+
#define TimeBetweenReadingSYS 120000 // time between system readings (like memory)
#define subjectSYStoMQTT Base_Topic Gateway_Name "/SYStoMQTT"
diff --git a/ZactuatorONOFF.ino b/ZactuatorONOFF.ino
index 58e4138f..39029034 100644
--- a/ZactuatorONOFF.ino
+++ b/ZactuatorONOFF.ino
@@ -38,22 +38,41 @@ void setupONOFF(){
trc(F("ZactuatorONOFF setup done "));
}
-void MQTTtoONOFF(char * topicOri, char * datacallback){
-
- bool boolSWITCHTYPE;
- boolSWITCHTYPE = to_bool(datacallback);
- String topic = topicOri;
-
- if ((topic == subjectMQTTtoONOFF)){
- trc(F("MQTTtoONOFF"));
- trc(boolSWITCHTYPE);
- digitalWrite(ACTUATOR_ONOFF_PIN, boolSWITCHTYPE);
- boolean result = client.publish(subjectGTWONOFFtoMQTT, datacallback);// we acknowledge the sending by publishing the value to an acknowledgement topic
- if (result){
- trc(F("MQTTtoONOFF ack pub."));
- trc(datacallback);
+#ifdef simplePublishing
+ void MQTTtoONOFF(char * topicOri, char * datacallback){
+
+ bool boolSWITCHTYPE;
+ boolSWITCHTYPE = to_bool(datacallback);
+ String topic = topicOri;
+
+ if (topic == subjectMQTTtoONOFF){
+ trc(F("MQTTtoONOFF data analysis"));
+ trc(boolSWITCHTYPE);
+ digitalWrite(ACTUATOR_ONOFF_PIN, boolSWITCHTYPE);
+ // we acknowledge the sending by publishing the value to an acknowledgement topic
+ pub(subjectGTWONOFFtoMQTT, datacallback);
}
}
-}
#endif
+#ifdef jsonPublishing
+ void MQTTtoONOFF(char * topicOri, JsonObject& ONOFFdata){
+
+ String topic = topicOri;
+
+ if (topic == subjectMQTTtoONOFF){
+ trc(F("MQTTtoONOFF json data analysis"));
+ int boolSWITCHTYPE = ONOFFdata["switchType"] | 99;
+ if (boolSWITCHTYPE != 99) {
+ trc(F("MQTTtoONOFF boolSWITCHTYPE ok"));
+ trc(boolSWITCHTYPE);
+ digitalWrite(ACTUATOR_ONOFF_PIN, boolSWITCHTYPE);
+ // we acknowledge the sending by publishing the value to an acknowledgement topic
+ pub(subjectGTWONOFFtoMQTT, ONOFFdata);
+ }else{
+ trc(F("MQTTtoONOFF Fail reading from json"));
+ }
+ }
+ }
+#endif
+#endif
diff --git a/Zgateway2G.ino b/Zgateway2G.ino
index 38b737aa..bc5cb867 100644
--- a/Zgateway2G.ino
+++ b/Zgateway2G.ino
@@ -81,53 +81,81 @@ void signalStrengthAnalysis(){
boolean _2GtoMQTT(){
// Get the memory locations of unread SMS messages.
unreadSMSNum = A6l.getUnreadSMSLocs(unreadSMSLocs, 512);
+ trc(F("Creating SMS buffer"));
+ StaticJsonBuffer jsonBuffer;
+ JsonObject& SMSdata = jsonBuffer.createObject();
for (int i = 0; i < unreadSMSNum; i++) {
trc("New message at index: ");
trc(unreadSMSNum);
sms = A6l.readSMS(unreadSMSLocs[i]);
- trc(sms.number);
- trc(sms.date);
- trc(sms.message);
+ SMSdata.set("message", (char *)sms.message.c_str());
+ SMSdata.set("date", (char *)sms.date.c_str());
+ SMSdata.set("phone", (char *)sms.number.c_str());
A6l.deleteSMS(unreadSMSLocs[i]); // we delete the SMS received
- trc(F("data 2GtoMQTT"));
- client.publish(subject2GtoMQTTphone,(char *)sms.number.c_str());
- client.publish(subject2GtoMQTTdate,(char *)sms.date.c_str());
- client.publish(subject2GtoMQTTmessage,(char *)sms.message.c_str());
+ trc(F("Adv data 2GtoMQTT"));
+ pub(subject2GtoMQTT,SMSdata);
return true;
}
return false;
}
-
-void MQTTto2G(char * topicOri, char * datacallback) {
-
- String data = datacallback; // we will not be able to pass values > 4294967295
-
- // 2G DATA ANALYSIS
- //We look into the subject to see if a special RF protocol is defined
- String topic = topicOri;
- String phone_number = "";
- int pos0 = topic.lastIndexOf(_2GPhoneKey);
- if (pos0 != -1) {
- pos0 = pos0 + strlen(_2GPhoneKey);
- phone_number = topic.substring(pos0);
- trc(F("Phone number to send SMS:"));
- trc(phone_number);
- }
- if((strstr(topicOri, subjectMQTTto2G) != NULL) && (pos0 != -1)){
- trc(F("MQTTto2G"));
- trc(data);
- if (A6l.sendSMS(phone_number,data) == A6_OK ) {
- trc("SMS OK");
- }else{
- trc("SMS KO");
- }
- // Acknowledgement to the GTW2G topic
- boolean result = client.publish(subjectGTW2GtoMQTT, datacallback);// we acknowledge the sending by publishing the value to an acknowledgement topic, for the moment even if it is a signal repetition we acknowledge also
- if (result){
- trc(F("MQTTto2G ack pub."));
- trc(data);
- }
- }
+#ifdef simplePublishing
+ void MQTTto2G(char * topicOri, char * datacallback) {
-}
+ String data = datacallback;
+ String topic = topicOri;
+
+ if (topic == subjectMQTTto2G) {
+ trc(F("MQTTto2G data analysis"));
+ // 2G DATA ANALYSIS
+ String phone_number = "";
+ int pos0 = topic.lastIndexOf(_2GPhoneKey);
+ if (pos0 != -1) {
+ pos0 = pos0 + strlen(_2GPhoneKey);
+ phone_number = topic.substring(pos0);
+ trc(F("MQTTto2G phone ok"));
+ trc(phone_number);
+ trc(F("MQTTto2G sms"));
+ trc(data);
+ if (A6l.sendSMS(phone_number,data) == A6_OK ) {
+ trc("SMS OK");
+ // Acknowledgement to the GTW2G topic
+ pub(subjectGTW2GtoMQTT, datacallback);// we acknowledge the sending by publishing the value to an acknowledgement topic, for the moment even if it is a signal repetition we acknowledge also
+ }else{
+ trc("SMS KO");
+ // Acknowledgement to the GTW2G topic
+ pub(subjectGTW2GtoMQTT, "SMS KO");// we acknowledge the sending by publishing the value to an acknowledgement topic, for the moment even if it is a signal repetition we acknowledge also
+ }
+ }else{
+ trc(F("MQTTto2G Fail reading phone number"));
+ }
+ }
+ }
+#endif
+
+#ifdef jsonPublishing
+ void MQTTto2G(char * topicOri, JsonObject& SMSdata) {
+
+ String topic = topicOri;
+ if (topic == subjectMQTTto2G) {
+ const char * sms = SMSdata["message"];
+ const char * phone = SMSdata["phone"];
+ trc(F("MQTTto2G json data analysis"));
+ if (sms && phone) {
+ trc(F("MQTTto2G sms & phone ok"));
+ trc(sms);
+ if (A6l.sendSMS(String(phone),String(sms)) == A6_OK ) {
+ trc("SMS OK");
+ // Acknowledgement to the GTW2G topic
+ pub(subjectGTW2GtoMQTT, SMSdata);// we acknowledge the sending by publishing the value to an acknowledgement topic, for the moment even if it is a signal repetition we acknowledge also
+ }else{
+ trc("SMS KO");
+ pub(subjectGTW2GtoMQTT, "SMS KO");// we acknowledge the sending by publishing the value to an acknowledgement topic, for the moment even if it is a signal repetition we acknowledge also
+ }
+ }else{
+ trc(F("MQTTto2G Fail reading from json"));
+ }
+ }
+
+ }
+#endif
#endif
diff --git a/ZgatewayBT.ino b/ZgatewayBT.ino
index 6ecb04e5..bff4860f 100644
--- a/ZgatewayBT.ino
+++ b/ZgatewayBT.ino
@@ -50,40 +50,34 @@ Thanks to wolass https://github.com/wolass for suggesting me HM 10 and dinosd ht
class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
void onResult(BLEAdvertisedDevice advertisedDevice) {
+ trc(F("Creating BLE buffer"));
+ StaticJsonBuffer jsonBuffer;
+ JsonObject& BLEdata = jsonBuffer.createObject();
String mac_adress = advertisedDevice.getAddress().toString().c_str();
+ BLEdata.set("id", mac_adress);
mac_adress.replace(":","");
mac_adress.toUpperCase();
String mactopic = subjectBTtoMQTT + mac_adress;
if (advertisedDevice.haveName()){
- trc(F("Get Name "));
- String nameBLE = advertisedDevice.getName().c_str();
- trc(nameBLE);
- client.publish((char *)(mactopic + "/name").c_str(),(char *)nameBLE.c_str());
+ BLEdata.set("name", (char *)advertisedDevice.getName().c_str());
}
if (advertisedDevice.haveManufacturerData()){
- trc(F("Get ManufacturerData "));
- String ManufacturerData = advertisedDevice.getManufacturerData().c_str();
- trc(ManufacturerData);
- client.publish((char *)(mactopic + "/ManufacturerData").c_str(),(char *)ManufacturerData.c_str());
+ BLEdata.set("manufacturerdata", (char *)advertisedDevice.getManufacturerData().c_str());
}
if (advertisedDevice.haveRSSI()){
- trc(F("Get RSSI "));
- String rssi = String(advertisedDevice.getRSSI());
- String rssitopic = mactopic + subjectBTtoMQTTrssi;
- trc(rssitopic + " " + rssi);
- client.publish((char *)rssitopic.c_str(),(char *)rssi.c_str());
+ BLEdata.set("rssi", (int) advertisedDevice.getRSSI());
+ #ifdef subjectHomePresence
+ haRoomPresence(BLEdata);// this device has an rssi in consequence we can use it for home assistant room presence component
+ #endif
}
if (advertisedDevice.haveTXPower()){
- trc(F("Get TXPower "));
- int8_t TXPower = advertisedDevice.getTXPower();
- trc(TXPower);
- char cTXPower[5];
- sprintf(cTXPower, "%d", TXPower);
- client.publish((char *)(mactopic + "/tx").c_str(),cTXPower);
+ BLEdata.set("txpower", (int8_t) advertisedDevice.getTXPower());
}
if (advertisedDevice.haveServiceData()){
+
char mac[mac_adress.length()+1];
mac_adress.toCharArray(mac,mac_adress.length()+1);
+
trc(F("Get service data "));
std::string serviceData = advertisedDevice.getServiceData();
int serviceDataLength = serviceData.length();
@@ -100,28 +94,25 @@ Thanks to wolass https://github.com/wolass for suggesting me HM 10 and dinosd ht
char service_data[returnedString.length()+1];
returnedString.toCharArray(service_data,returnedString.length()+1);
service_data[returnedString.length()] = '\0';
- trc(F("service_data"));
- trc(service_data);
- String mactopic(mac);
- mactopic = subjectBTtoMQTT + mactopic + subjectBTtoMQTTservicedata;
- client.publish((char *)mactopic.c_str(),service_data);
+ BLEdata.set("servicedata", service_data);
- trc(F("Get service data UUID"));
- BLEUUID serviceDataUUID = advertisedDevice.getServiceDataUUID();
- trc(serviceDataUUID.toString().c_str());
-
- if (strstr(serviceDataUUID.toString().c_str(),"fe95") != NULL){
+ BLEdata.set("servicedatauuid", (char *)advertisedDevice.getServiceDataUUID().toString().c_str());
+
+ char topic[] = subjectBTtoMQTT;
+ strcat(topic, mac);
+ pub(topic,BLEdata);
+
+ if (strstr(BLEdata["servicedatauuid"].as(),"fe95") != NULL){
trc("Processing BLE device data");
int pos = -1;
pos = strpos(service_data,"209800");
- if (strstr(service_data,"209800") != NULL) {
+ if (pos != -1){
trc("mi flora data reading");
-
boolean result = process_data(pos - 24,service_data,mac);
}
pos = -1;
pos = strpos(service_data,"20aa01");
- if (strstr(service_data,"20aa01") != NULL){
+ if (pos != -1){
trc("mi jia data reading");
boolean result = process_data(pos - 26,service_data,mac);
}
@@ -160,7 +151,7 @@ Thanks to wolass https://github.com/wolass for suggesting me HM 10 and dinosd ht
"coreTask", /* Name of the task */
10000, /* Stack size in words */
NULL, /* Task input parameter */
- 1, /* Priority of the task */
+ 0, /* Priority of the task */
NULL, /* Task handle. */
taskCore); /* Core where the task should run */
trc(F("ZgatewayBT multicore ESP32 setup done "));
@@ -269,36 +260,45 @@ boolean BTtoMQTT() {
if((strlen(d[0].extract)) == 12) // if a mac adress is detected we publish it
{
- strupp(d[0].extract);
- String mactopic;
- trc(d[0].extract);
- trc(d[0].extract);
- mactopic = subjectBTtoMQTT + String(d[0].extract) + subjectBTtoMQTTrssi;
- int rssi = (int)strtol(d[2].extract, NULL, 16) - 256;
- char val[12];
- sprintf(val, "%d", rssi);
- client.publish((char *)mactopic.c_str(),val);
- trc(F("service_data"));
- String Service_data(d[5].extract);
- Service_data = Service_data.substring(14);
- trc(Service_data);
- mactopic = subjectBTtoMQTT + String(d[0].extract) + subjectBTtoMQTTservicedata;
- client.publish((char *)mactopic.c_str(),(char *)(Service_data).c_str());
- if (strcmp(d[4].extract, "fe95") == 0) {
- int pos = -1;
- pos = strpos(d[5].extract,"209800");
- if (pos != -1) {
- trc("mi flora data reading");
- boolean result = process_data(pos - 38,(char *)Service_data.c_str(),d[0].extract);
- }
- pos = -1;
- pos = strpos(d[5].extract,"20aa01");
- if (pos != -1){
- trc("mi jia data reading");
- boolean result = process_data(pos - 40,(char *)Service_data.c_str(),d[0].extract);
- }
- return true;
+ trc(F("Creating BLE buffer"));
+ StaticJsonBuffer jsonBuffer;
+ JsonObject& BLEdata = jsonBuffer.createObject();
+ #ifdef subjectHomePresence
+ String HomePresenceId;
+ for (int i = 0; i++; i<13){
+ String HomePresenceId = HomePresenceId + String(d[0].extract[i]);
+ if(i % 2 == 0) HomePresenceId += ":";
}
+ trc(F("HomePresenceId"));
+ trc(HomePresenceId);
+ BLEdata.set("id", HomePresenceId);
+ #endif
+ strupp(d[0].extract);
+ String topic = subjectBTtoMQTT + String(d[0].extract);
+ int rssi = (int)strtol(d[2].extract, NULL, 16) - 256;
+ BLEdata.set("rssi", (int)rssi);
+ #ifdef subjectHomePresence
+ haRoomPresence(BLEdata);// this device has an rssi in consequence we can use it for home assistant room presence component
+ #endif
+ String Service_data(d[5].extract);
+ Service_data = Service_data.substring(14);
+ BLEdata.set("servicedata", (char *)Service_data.c_str());
+ pub((char *)topic.c_str(),BLEdata);
+ if (strcmp(d[4].extract, "fe95") == 0) {
+ int pos = -1;
+ pos = strpos(d[5].extract,"209800");
+ if (pos != -1) {
+ trc("mi flora data reading");
+ boolean result = process_data(pos - 38,(char *)Service_data.c_str(),d[0].extract);
+ }
+ pos = -1;
+ pos = strpos(d[5].extract,"20aa01");
+ if (pos != -1){
+ trc("mi jia data reading");
+ boolean result = process_data(pos - 40,(char *)Service_data.c_str(),d[0].extract);
+ }
+ return true;
+ }
}
}
}
@@ -341,10 +341,8 @@ boolean BTtoMQTT() {
String onedevice = discResult.substring(0,78);
onedevice.replace(STRING_MSG,"");
String mac = onedevice.substring(53,65);
- String rssi = onedevice.substring(66,70);
- String mactopic = subjectBTtoMQTT + mac + subjectBTtoMQTTrssi;
trc(mactopic + " " + rssi);
- client.publish((char *)mactopic.c_str(),(char *)rssi.c_str());
+ pub(subjectBTtoMQTT + mac + subjectBTtoMQTTrssi,onedevice.substring(66,70));
discResult = discResult.substring(78);
}
return true;
@@ -369,6 +367,11 @@ boolean BTtoMQTT() {
#endif
boolean process_data(int offset, char * rest_data, char * mac_adress){
+ trc(F("Creating BLE buffer"));
+ StaticJsonBuffer jsonBuffer;
+ JsonObject& BLEdata = jsonBuffer.createObject();
+ trc("rest_data");
+ trc(rest_data);
int data_length = 0;
switch (rest_data[51 + offset]) {
case '1' :
@@ -376,6 +379,7 @@ boolean process_data(int offset, char * rest_data, char * mac_adress){
case '3' :
case '4' :
data_length = ((rest_data[51 + offset] - '0') * 2)+1;
+ trc("data_length");
trc(data_length);
break;
default:
@@ -398,41 +402,38 @@ boolean process_data(int offset, char * rest_data, char * mac_adress){
// second value
char val2[12];
- String mactopic2(mac_adress);
- mactopic2 = subjectBTtoMQTT + mactopic2;
- bool hasTopic2 = false;
-
-
+ trc("rest_data");
+ trc(rest_data);
// Mi flora provides tem(perature), (earth) moi(sture), fer(tility) and lux (illuminance)
// Mi Jia provides tem(perature), batt(erry) and hum(idity)
// following the value of digit 47 we determine the type of data we get from the sensor
switch (rest_data[47 + offset]) {
case '9' :
- mactopic = mactopic + subjectBTtoMQTTfer;
dtostrf(value,0,0,val);
+ BLEdata.set("fer", val);
break;
case '4' :
- mactopic = mactopic + subjectBTtoMQTTtem;
if (value > 65000) value = value - 65535;
dtostrf(value/10,3,1,val); // temp has to be divided by 10
+ BLEdata.set("tem", val);
break;
case '6' :
- mactopic = mactopic + subjectBTtoMQTThum;
if (value > 65000) value = value - 65535;
dtostrf(value/10,3,1,val); // hum has to be divided by 10
+ BLEdata.set("hum", val);
break;
case '7' :
- mactopic = mactopic + subjectBTtoMQTTlux;
dtostrf(value,0,0,val);
+ BLEdata.set("lux", val);
break;
case '8' :
- mactopic = mactopic + subjectBTtoMQTTmoi;
dtostrf(value,0,0,val);
+ BLEdata.set("moi", val);
break;
case 'a' : // batteryLevel
- mactopic = mactopic + subjectBTtoMQTTbatt;
dtostrf(value,0,0,val);
+ BLEdata.set("batt", val);
break;
case 'd' : // temp+hum
@@ -443,28 +444,31 @@ boolean process_data(int offset, char * rest_data, char * mac_adress){
value = strtol(tempAr, NULL, 16);
if (value > 65000) value = value - 65535;
dtostrf(value/10,3,1,val); // hum has to be divided by 10
- trc(val);
+ BLEdata.set("hum", val);
// temperature
memcpy(tempAr, &data[4], 4);
tempAr[4] = '\0';
value = strtol(tempAr, NULL, 16);
if (value > 65000) value = value - 65535;
dtostrf(value/10,3,1,val2); // hum has to be divided by 10
- trc(val2);
- mactopic = mactopic + subjectBTtoMQTThum;
- mactopic2 = mactopic2 + subjectBTtoMQTTtem;
- hasTopic2 = true;
+ BLEdata.set("tem", val2);
break;
default:
trc("can't read values");
return false;
}
- client.publish((char *)mactopic.c_str(),val);
- if (hasTopic2){
- client.publish((char *)mactopic2.c_str(),val2);
- }
- trc(val);
+ pub((char *)mactopic.c_str(),BLEdata);
return true;
- }
+}
+
+void haRoomPresence(JsonObject& HomePresence){
+ trc("BLE DISTANCE :");
+ double BLErssi = HomePresence["rssi"];
+ double ratio = BLErssi/-59;
+ double distance = (0.89)* pow(ratio,7.7095) + 0.11;
+ HomePresence["distance"] = distance;
+ trc(distance);
+ pub(subjectHomePresence,HomePresence);
+}
#endif
diff --git a/ZgatewayIR.ino b/ZgatewayIR.ino
index 6fd063a8..16014321 100644
--- a/ZgatewayIR.ino
+++ b/ZgatewayIR.ino
@@ -89,22 +89,28 @@ trc(IR_RECEIVER_PIN);
trc(F("ZgatewayIR setup done "));
}
-boolean IRtoMQTT(){
+void IRtoMQTT(){
decode_results results;
if (irrecv.decode(&results)){
+ trc(F("Creating IR buffer"));
+ StaticJsonBuffer jsonBuffer;
+ JsonObject& IRdata = jsonBuffer.createObject();
+
trc(F("Rcv. IR"));
#ifdef ESP32
String taskMessage = "Task running on core ";
taskMessage = taskMessage + xPortGetCoreID();
trc(taskMessage);
#endif
- unsigned long MQTTvalue = 0;
- String MQTTprotocol;
- String MQTTbits;
- MQTTvalue = results.value;
- MQTTprotocol = String(results.decode_type);
- MQTTbits = String(results.bits);
+ IRdata.set("value", (unsigned long)(results.value));
+ IRdata.set("protocol", (int)(results.decode_type));
+ IRdata.set("bits",(int)(results.bits));
+
+ trc(F("LED MNG"));
+ digitalWrite(led_receive, LOW);
+ timer_led_receive = millis();
+
String rawCode = "";
// Dump data
for (uint16_t i = 1; i < results.rawlen; i++) {
@@ -117,6 +123,7 @@ boolean IRtoMQTT(){
if ( i < results.rawlen-1 ) rawCode = rawCode + ","; // ',' not needed on last one
}
trc(rawCode);
+ IRdata.set("raw", rawCode);
// if needed we directly resend the raw code
if (RawDirectForward){
#ifdef ESP8266
@@ -129,353 +136,662 @@ boolean IRtoMQTT(){
#endif
rawsend[i] = results.rawbuf[i];
}
- irsend.sendRaw(rawsend, results.rawlen, RawFrequency);
+ irsend.sendRaw(rawsend, results.rawlen, RawFrequency);
trc(F("raw signal redirected"));
}
irrecv.resume(); // Receive the next value
-
- if (pubIRunknownPrtcl == false && MQTTprotocol == "-1"){ // don't publish unknown IR protocol
+ unsigned long MQTTvalue = IRdata.get("value");
+ if (pubIRunknownPrtcl == false && IRdata.get("protocol") == -1){ // don't publish unknown IR protocol
trc(F("--no pub. unknown protocol--"));
} else if (!isAduplicate(MQTTvalue) && MQTTvalue!=0) {// conditions to avoid duplications of RF -->MQTT
- trc(F("Adv data IRtoMQTT"));
- client.publish(subjectIRtoMQTTprotocol,(char *)MQTTprotocol.c_str());
- client.publish(subjectIRtoMQTTbits,(char *)MQTTbits.c_str());
- client.publish(subjectIRtoMQTTRaw,(char *)rawCode.c_str());
- trc(F("Sending IRtoMQTT"));
- String value = String(MQTTvalue);
- trc(value);
- boolean result = client.publish(subjectIRtoMQTT,(char *)value.c_str());
+ trc(F("Adv data IRtoMQTT"));
+ pub(subjectIRtoMQTT,IRdata);
if (repeatIRwMQTT){
trc(F("Pub. IR for repeat"));
- client.publish(subjectMQTTtoIR,(char *)value.c_str());
+ pub(subjectMQTTtoIR,MQTTvalue);
}
- return result;
}
- }
- return false;
+ }
}
-void MQTTtoIR(char * topicOri, char * datacallback) {
-
- // IR DATA ANALYSIS
- //send received MQTT value by IR signal
- boolean signalSent = false;
- uint64_t data = 0;
- String strcallback = String(datacallback);
- trc(datacallback);
- int s = strcallback.length();
- //number of "," value count
- int count = 0;
- for(int i = 0; i < s; i++)
- {
- if (datacallback[i] == ',') {
- count++;
- }
- }
- if(count == 0){
- data = strtoul(datacallback, NULL, 10); // standard sending with unsigned long, we will not be able to pass values > 4294967295
- }
- #ifdef IR_GC
- else if(strstr(topicOri, "IR_GC") != NULL){ // sending GC data from https://irdb.globalcache.com
- trc("IR_GC");
- //buffer allocation from char datacallback
- uint16_t GC[count+1];
- String value = "";
- int j = 0;
- for(int i = 0; i < s; i++)
- {
- if (datacallback[i] != ',') {
- value = value + String(datacallback[i]);
- }
- if ((datacallback[i] == ',') || (i == s - 1))
- {
- GC[j]= value.toInt();
- value = "";
- j++;
- }
- }
- irsend.sendGC(GC, j);
- signalSent = true;
- }
- #endif
- #ifdef IR_Raw
- else if(strstr(topicOri, "IR_Raw") != NULL){ // sending Raw data
- trc("IR_Raw");
- //buffer allocation from char datacallback
- #ifdef ESP8266
- uint16_t Raw[count+1];
- #else
- unsigned int Raw[count+1];
- #endif
- String value = "";
- int j = 0;
- for(int i = 0; i < s; i++)
- {
- if (datacallback[i] != ',') {
- value = value + String(datacallback[i]);
- }
- if ((datacallback[i] == ',') || (i == s - 1))
- {
- Raw[j]= value.toInt();
- value = "";
- j++;
- }
- }
- irsend.sendRaw(Raw, j, RawFrequency);
- signalSent = true;
- }
- #endif
+#ifdef simplePublishing
+ void MQTTtoIR(char * topicOri, char * datacallback) {
- //We look into the subject to see if a special Bits number is defined
- String topic = topicOri;
- unsigned int valueBITS = 0;
- int pos = topic.lastIndexOf(IRbitsKey);
- if (pos != -1){
- pos = pos + +strlen(IRbitsKey);
- valueBITS = (topic.substring(pos,pos + 2)).toInt();
- trc(F("Bits nb:"));
- trc(valueBITS);
- }
- //We look into the subject to see if a special repeat number is defined
- uint16_t valueRPT = 0;
- int pos2 = topic.lastIndexOf(IRRptKey);
- if (pos2 != -1) {
- pos2 = pos2 + strlen(IRRptKey);
- valueRPT = (topic.substring(pos2,pos2 + 1)).toInt();
- trc(F("IR repeat:"));
- trc(valueRPT);
- }
+ // IR DATA ANALYSIS
+ //send received MQTT value by IR signal
+ boolean signalSent = false;
+ uint64_t data = 0;
+ String strcallback = String(datacallback);
+ trc(datacallback);
+ unsigned int s = strcallback.length();
+ //number of "," value count
+ int count = 0;
+ for(int i = 0; i < s; i++)
+ {
+ if (datacallback[i] == ',') {
+ count++;
+ }
+ }
+ if(count == 0){
+ data = strtoul(datacallback, NULL, 10); // standard sending with unsigned long, we will not be able to pass values > 4294967295
+ }
+ #ifdef IR_GC
+ else if(strstr(topicOri, "IR_GC") != NULL){ // sending GC data from https://irdb.globalcache.com
+ trc("IR_GC");
+ //buffer allocation from char datacallback
+ uint16_t GC[count+1];
+ String value = "";
+ int j = 0;
+ for(int i = 0; i < s; i++)
+ {
+ if (datacallback[i] != ',') {
+ value = value + String(datacallback[i]);
+ }
+ if ((datacallback[i] == ',') || (i == s - 1))
+ {
+ GC[j]= value.toInt();
+ value = "";
+ j++;
+ }
+ }
+ irsend.sendGC(GC, j);
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_Raw
+ else if(strstr(topicOri, "IR_Raw") != NULL){ // sending Raw data
+ trc("IR_Raw");
+ //buffer allocation from char datacallback
+ #ifdef ESP8266
+ uint16_t Raw[count+1];
+ #else
+ unsigned int Raw[count+1];
+ #endif
+ String value = "";
+ int j = 0;
+ for(int i = 0; i < s; i++)
+ {
+ if (datacallback[i] != ',') {
+ value = value + String(datacallback[i]);
+ }
+ if ((datacallback[i] == ',') || (i == s - 1))
+ {
+ Raw[j]= value.toInt();
+ value = "";
+ j++;
+ }
+ }
+ irsend.sendRaw(Raw, j, RawFrequency);
+ signalSent = true;
+ }
+ #endif
+
+ //We look into the subject to see if a special Bits number is defined
+ String topic = topicOri;
+ unsigned int valueBITS = 0;
+ int pos = topic.lastIndexOf(IRbitsKey);
+ if (pos != -1){
+ pos = pos + +strlen(IRbitsKey);
+ valueBITS = (topic.substring(pos,pos + 2)).toInt();
+ trc(F("Bits nb:"));
+ trc(valueBITS);
+ }
+ //We look into the subject to see if a special repeat number is defined
+ uint16_t valueRPT = 0;
+ int pos2 = topic.lastIndexOf(IRRptKey);
+ if (pos2 != -1) {
+ pos2 = pos2 + strlen(IRRptKey);
+ valueRPT = (topic.substring(pos2,pos2 + 1)).toInt();
+ trc(F("IR repeat:"));
+ trc(valueRPT);
+ }
+
+ #ifdef ESP8266 // send coolix not available for arduino IRRemote library
+ #ifdef IR_COOLIX
+ if (strstr(topicOri, "IR_COOLIX") != NULL){
+ if (valueBITS == 0) valueBITS = COOLIX_BITS;
+ irsend.sendCOOLIX(data, valueBITS, valueRPT);
+ signalSent = true;
+ }
+ #endif
+ #endif
+ if (strstr(topicOri, "IR_NEC") != NULL || strstr(topicOri, subjectMQTTtoIR) != NULL ){
+ if (valueBITS == 0) valueBITS = NEC_BITS;
+ #ifdef ESP8266
+ irsend.sendNEC(data, valueBITS, valueRPT);
+ #else
+ for (int i=0; i <= valueRPT; i++) irsend.sendNEC(data, valueBITS);
+ #endif
+ signalSent = true;
+ }
+ #ifdef IR_Whynter
+ if (strstr(topicOri, "IR_Whynter") != NULL){
+ if (valueBITS == 0) valueBITS = WHYNTER_BITS;
+ #ifdef ESP8266
+ irsend.sendWhynter(data, valueBITS, valueRPT);
+ #else
+ for (int i=0; i <= valueRPT; i++) irsend.sendWhynter(data, valueBITS);
+ #endif
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_LG
+ if (strstr(topicOri, "IR_LG") != NULL){
+ if (valueBITS == 0) valueBITS = LG_BITS;
+ #ifdef ESP8266
+ irsend.sendLG(data, valueBITS, valueRPT);
+ #else
+ for (int i=0; i <= valueRPT; i++) irsend.sendLG(data, valueBITS);
+ #endif
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_Sony
+ if (strstr(topicOri, "IR_Sony") != NULL){
+ if (valueBITS == 0) valueBITS = SONY_12_BITS;
+ if (valueRPT == 0) valueRPT = repeatIRwNumber;
+ #ifdef ESP8266
+ irsend.sendSony(data, valueBITS, valueRPT);
+ #else
+ for (int i=0; i <= valueRPT; i++) irsend.sendSony(data, valueBITS);
+ #endif
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_DISH
+ if (strstr(topicOri, "IR_DISH") != NULL){
+ if (valueBITS == 0) valueBITS = DISH_BITS;
+ #ifdef ESP8266
+ irsend.sendDISH(data, valueBITS, valueRPT);
+ #else
+ for (int i=0; i <= valueRPT; i++) irsend.sendDISH(data, valueBITS);
+ #endif
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_RC5
+ if (strstr(topicOri, "IR_RC5") != NULL){
+ if (valueBITS == 0) valueBITS = RC5_BITS;
+ #ifdef ESP8266
+ irsend.sendRC5(data, valueBITS, valueRPT);
+ #else
+ for (int i=0; i <= valueRPT; i++) irsend.sendRC5(data, valueBITS);
+ #endif
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_RC6
+ if (strstr(topicOri, "IR_RC6") != NULL){
+ if (valueBITS == 0) valueBITS = RC6_MODE0_BITS;
+ #ifdef ESP8266
+ irsend.sendRC6(data, valueBITS, valueRPT);
+ #else
+ for (int i=0; i <= valueRPT; i++) irsend.sendRC6(data, valueBITS);
+ #endif
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_Sharp
+ if (strstr(topicOri, "IR_Sharp") != NULL){
+ if (valueBITS == 0) valueBITS = SHARP_BITS;
+ #ifdef ESP8266
+ irsend.sendSharpRaw(data, valueBITS, valueRPT);
+ #else
+ for (int i=0; i <= valueRPT; i++) irsend.sendSharpRaw(data, valueBITS);
+ #endif
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_SAMSUNG
+ if (strstr(topicOri, "IR_SAMSUNG") != NULL){
+ if (valueBITS == 0) valueBITS = SAMSUNG_BITS;
+ #ifdef ESP8266
+ irsend.sendSAMSUNG(data, valueBITS, valueRPT);
+ #else
+ for (int i=0; i <= valueRPT; i++) irsend.sendSAMSUNG(data, valueBITS);
+ #endif
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_JVC
+ if (strstr(topicOri, "IR_JVC") != NULL){
+ if (valueBITS == 0) valueBITS = JVC_BITS;
+ if (valueRPT == 0) valueRPT = repeatIRwNumber;
+ #ifdef ESP8266
+ irsend.sendJVC(data, valueBITS, valueRPT);
+ #else
+ for (int i=0; i <= valueRPT; i++) irsend.sendJVC(data, valueBITS);
+ #endif
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_PANASONIC
+ if (strstr(topicOri, "IR_PANASONIC") != NULL){
+ if (valueRPT == 0) valueRPT = repeatIRwNumber;
+ #ifdef ESP8266
+ if (valueBITS == 0) valueBITS = PANASONIC_BITS;
+ irsend.sendPanasonic(PanasonicAddress, data, valueBITS, valueRPT);
+ #else
+ for (int i=0; i <= valueRPT; i++) irsend.sendPanasonic(PanasonicAddress, data);
+ #endif
+ signalSent = true;
+ }
+ #endif
- #ifdef ESP8266 // send coolix not available for arduino IRRemote library
- #ifdef IR_COOLIX
- if (strstr(topicOri, "IR_COOLIX") != NULL){
- if (valueBITS == 0) valueBITS = COOLIX_BITS;
- irsend.sendCOOLIX(data, valueBITS, valueRPT);
+ #ifdef ESP8266 // sendings not available on arduino
+ #ifdef IR_RCMM
+ if (strstr(topicOri, "IR_RCMM") != NULL){
+ if (valueBITS == 0) valueBITS = RCMM_BITS;
+ irsend.sendRCMM(data, valueBITS, valueRPT);
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_DENON
+ if (strstr(topicOri, "IR_DENON") != NULL){
+ if (valueBITS == 0) valueBITS = DENON_BITS;
+ irsend.sendDenon(data, valueBITS, valueRPT);
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_GICABLE
+ if (strstr(topicOri, "IR_GICABLE") != NULL){
+ if (valueBITS == 0) valueBITS = GICABLE_BITS;
+ if (valueRPT == 0) valueRPT = std::max(valueRPT, (uint16_t) GICABLE_MIN_REPEAT);
+ irsend.sendGICable(data, valueBITS, valueRPT);
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_SHERWOOD
+ if (strstr(topicOri, "IR_SHERWOOD") != NULL){
+ if (valueBITS == 0) valueBITS = SHERWOOD_BITS;
+ if (valueRPT == 0) valueRPT = std::max(valueRPT, (uint16_t) SHERWOOD_MIN_REPEAT);
+ irsend.sendSherwood(data, valueBITS, valueRPT);
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_MITSUBISHI
+ if (strstr(topicOri, "IR_MITSUBISHI") != NULL){
+ if (valueBITS == 0) valueBITS = MITSUBISHI_BITS;
+ if (valueRPT == 0) valueRPT = std::max(valueRPT, (uint16_t) MITSUBISHI_MIN_REPEAT);
+ irsend.sendMitsubishi(data, valueBITS, valueRPT);
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_NIKAI
+ if (strstr(topicOri, "IR_NIKAI") != NULL){
+ if (valueBITS == 0) valueBITS = NIKAI_BITS;
+ irsend.sendNikai(data, valueBITS, valueRPT);
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_MIDEA
+ if (strstr(topicOri, "IR_MIDEA") != NULL){
+ if (valueBITS == 0) valueBITS = MIDEA_BITS;
+ irsend.sendMidea(data, valueBITS, valueRPT);
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_MAGIQUEST
+ if (strstr(topicOri, "IR_MAGIQUEST") != NULL){
+ if (valueBITS == 0) valueBITS = MAGIQUEST_BITS;
+ irsend.sendMagiQuest(data, valueBITS, valueRPT);
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_LASERTAG
+ if (strstr(topicOri, "IR_LASERTAG") != NULL){
+ if (valueBITS == 0) valueBITS = LASERTAG_BITS;
+ irsend.sendLasertag(data, valueBITS, valueRPT);
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_CARRIER_AC
+ if (strstr(topicOri, "IR_CARRIER_AC") != NULL){
+ if (valueBITS == 0) valueBITS = CARRIER_AC_BITS;
+ irsend.sendCarrierAC(data, valueBITS, valueRPT);
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_MITSUBISHI2
+ if (strstr(topicOri, "IR_MITSUBISHI2") != NULL){
+ if (valueBITS == 0) valueBITS = MITSUBISHI_BITS;
+ if (valueRPT == 0) valueRPT = std::max(valueRPT, (uint16_t) MITSUBISHI_MIN_REPEAT);
+ irsend.sendMitsubishi2(data, valueBITS, valueRPT);
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_AIWA_RC_T501
+ if (strstr(topicOri, "IR_MITSUBISHI") != NULL){
+ if (valueBITS == 0) valueBITS = AIWA_RC_T501_BITS;
+ if (valueRPT == 0) valueRPT = std::max(valueRPT, (uint16_t) AIWA_RC_T501_MIN_REPEAT);
+ irsend.sendAiwaRCT501(data, valueBITS, valueRPT);
signalSent = true;
}
#endif
#endif
- if (strstr(topicOri, "IR_NEC") != NULL || strstr(topicOri, subjectMQTTtoIR) != NULL ){
- if (valueBITS == 0) valueBITS = NEC_BITS;
- #ifdef ESP8266
- irsend.sendNEC(data, valueBITS, valueRPT);
- #else
- for (int i=0; i <= valueRPT; i++) irsend.sendNEC(data, valueBITS);
- #endif
- signalSent = true;
+
+ if (signalSent){ // we acknowledge the sending by publishing the value to an acknowledgement topic, for the moment even if it is a signal repetition we acknowledge also
+ pub(subjectGTWIRtoMQTT, datacallback);
+ }
+ irrecv.enableIRIn(); // ReStart the IR receiver (if not restarted it is not able to receive data)
}
- #ifdef IR_Whynter
- if (strstr(topicOri, "IR_Whynter") != NULL){
- if (valueBITS == 0) valueBITS = WHYNTER_BITS;
- #ifdef ESP8266
- irsend.sendWhynter(data, valueBITS, valueRPT);
- #else
- for (int i=0; i <= valueRPT; i++) irsend.sendWhynter(data, valueBITS);
- #endif
- signalSent = true;
- }
- #endif
- #ifdef IR_LG
- if (strstr(topicOri, "IR_LG") != NULL){
- if (valueBITS == 0) valueBITS = LG_BITS;
- #ifdef ESP8266
- irsend.sendLG(data, valueBITS, valueRPT);
- #else
- for (int i=0; i <= valueRPT; i++) irsend.sendLG(data, valueBITS);
- #endif
- signalSent = true;
- }
- #endif
- #ifdef IR_Sony
- if (strstr(topicOri, "IR_Sony") != NULL){
- if (valueBITS == 0) valueBITS = SONY_12_BITS;
- if (valueRPT == 0) valueRPT = 2;
- #ifdef ESP8266
- irsend.sendSony(data, valueBITS, valueRPT);
- #else
- for (int i=0; i <= valueRPT; i++) irsend.sendSony(data, valueBITS);
- #endif
- signalSent = true;
- }
- #endif
- #ifdef IR_DISH
- if (strstr(topicOri, "IR_DISH") != NULL){
- if (valueBITS == 0) valueBITS = DISH_BITS;
- #ifdef ESP8266
- irsend.sendDISH(data, valueBITS, valueRPT);
- #else
- for (int i=0; i <= valueRPT; i++) irsend.sendDISH(data, valueBITS);
- #endif
- signalSent = true;
- }
- #endif
- #ifdef IR_RC5
- if (strstr(topicOri, "IR_RC5") != NULL){
- if (valueBITS == 0) valueBITS = RC5_BITS;
- #ifdef ESP8266
- irsend.sendRC5(data, valueBITS, valueRPT);
- #else
- for (int i=0; i <= valueRPT; i++) irsend.sendRC5(data, valueBITS);
- #endif
- signalSent = true;
- }
- #endif
- #ifdef IR_RC6
- if (strstr(topicOri, "IR_RC6") != NULL){
- if (valueBITS == 0) valueBITS = RC6_MODE0_BITS;
- #ifdef ESP8266
- irsend.sendRC6(data, valueBITS, valueRPT);
- #else
- for (int i=0; i <= valueRPT; i++) irsend.sendRC6(data, valueBITS);
- #endif
- signalSent = true;
- }
- #endif
- #ifdef IR_Sharp
- if (strstr(topicOri, "IR_Sharp") != NULL){
- if (valueBITS == 0) valueBITS = SHARP_BITS;
- #ifdef ESP8266
- irsend.sendSharpRaw(data, valueBITS, valueRPT);
- #else
- for (int i=0; i <= valueRPT; i++) irsend.sendSharpRaw(data, valueBITS);
- #endif
- signalSent = true;
- }
- #endif
- #ifdef IR_SAMSUNG
- if (strstr(topicOri, "IR_SAMSUNG") != NULL){
- if (valueBITS == 0) valueBITS = SAMSUNG_BITS;
- #ifdef ESP8266
- irsend.sendSAMSUNG(data, valueBITS, valueRPT);
- #else
- for (int i=0; i <= valueRPT; i++) irsend.sendSAMSUNG(data, valueBITS);
- #endif
- signalSent = true;
- }
- #endif
- #ifdef IR_JVC
- if (strstr(topicOri, "IR_JVC") != NULL){
- if (valueBITS == 0) valueBITS = JVC_BITS;
- if (valueRPT == 0) valueRPT = 2;
- #ifdef ESP8266
- irsend.sendJVC(data, valueBITS, valueRPT);
- #else
- for (int i=0; i <= valueRPT; i++) irsend.sendJVC(data, valueBITS);
- #endif
- signalSent = true;
- }
- #endif
- #ifdef IR_PANASONIC
- if (strstr(topicOri, "IR_PANASONIC") != NULL){
- if (valueRPT == 0) valueRPT = 2;
- #ifdef ESP8266
- if (valueBITS == 0) valueBITS = PANASONIC_BITS;
- irsend.sendPanasonic(PanasonicAddress, data, valueBITS, valueRPT);
- #else
- for (int i=0; i <= valueRPT; i++) irsend.sendPanasonic(PanasonicAddress, data);
- #endif
- signalSent = true;
- }
- #endif
-
-#ifdef ESP8266 // sendings not available on arduino
- #ifdef IR_RCMM
- if (strstr(topicOri, "IR_RCMM") != NULL){
- if (valueBITS == 0) valueBITS = RCMM_BITS;
- irsend.sendRCMM(data, valueBITS, valueRPT);
- signalSent = true;
- }
- #endif
- #ifdef IR_DENON
- if (strstr(topicOri, "IR_DENON") != NULL){
- if (valueBITS == 0) valueBITS = DENON_BITS;
- irsend.sendDenon(data, valueBITS, valueRPT);
- signalSent = true;
- }
- #endif
- #ifdef IR_GICABLE
- if (strstr(topicOri, "IR_GICABLE") != NULL){
- if (valueBITS == 0) valueBITS = GICABLE_BITS;
- if (valueRPT == 0) valueRPT = std::max(valueRPT, (uint16_t) GICABLE_MIN_REPEAT);
- irsend.sendGICable(data, valueBITS, valueRPT);
- signalSent = true;
- }
- #endif
- #ifdef IR_SHERWOOD
- if (strstr(topicOri, "IR_SHERWOOD") != NULL){
- if (valueBITS == 0) valueBITS = SHERWOOD_BITS;
- if (valueRPT == 0) valueRPT = std::max(valueRPT, (uint16_t) SHERWOOD_MIN_REPEAT);
- irsend.sendSherwood(data, valueBITS, valueRPT);
- signalSent = true;
- }
- #endif
- #ifdef IR_MITSUBISHI
- if (strstr(topicOri, "IR_MITSUBISHI") != NULL){
- if (valueBITS == 0) valueBITS = MITSUBISHI_BITS;
- if (valueRPT == 0) valueRPT = std::max(valueRPT, (uint16_t) MITSUBISHI_MIN_REPEAT);
- irsend.sendMitsubishi(data, valueBITS, valueRPT);
- signalSent = true;
- }
- #endif
- #ifdef IR_NIKAI
- if (strstr(topicOri, "IR_NIKAI") != NULL){
- if (valueBITS == 0) valueBITS = NIKAI_BITS;
- irsend.sendNikai(data, valueBITS, valueRPT);
- signalSent = true;
- }
- #endif
- #ifdef IR_MIDEA
- if (strstr(topicOri, "IR_MIDEA") != NULL){
- if (valueBITS == 0) valueBITS = MIDEA_BITS;
- irsend.sendMidea(data, valueBITS, valueRPT);
- signalSent = true;
- }
- #endif
- #ifdef IR_MAGIQUEST
- if (strstr(topicOri, "IR_MAGIQUEST") != NULL){
- if (valueBITS == 0) valueBITS = MAGIQUEST_BITS;
- irsend.sendMagiQuest(data, valueBITS, valueRPT);
- signalSent = true;
- }
- #endif
- #ifdef IR_LASERTAG
- if (strstr(topicOri, "IR_LASERTAG") != NULL){
- if (valueBITS == 0) valueBITS = LASERTAG_BITS;
- irsend.sendLasertag(data, valueBITS, valueRPT);
- signalSent = true;
- }
- #endif
- #ifdef IR_CARRIER_AC
- if (strstr(topicOri, "IR_CARRIER_AC") != NULL){
- if (valueBITS == 0) valueBITS = CARRIER_AC_BITS;
- irsend.sendCarrierAC(data, valueBITS, valueRPT);
- signalSent = true;
- }
- #endif
- #ifdef IR_MITSUBISHI2
- if (strstr(topicOri, "IR_MITSUBISHI2") != NULL){
- if (valueBITS == 0) valueBITS = MITSUBISHI_BITS;
- if (valueRPT == 0) valueRPT = std::max(valueRPT, (uint16_t) MITSUBISHI_MIN_REPEAT);
- irsend.sendMitsubishi2(data, valueBITS, valueRPT);
- signalSent = true;
- }
- #endif
- #ifdef IR_AIWA_RC_T501
- if (strstr(topicOri, "IR_MITSUBISHI") != NULL){
- if (valueBITS == 0) valueBITS = AIWA_RC_T501_BITS;
- if (valueRPT == 0) valueRPT = std::max(valueRPT, (uint16_t) AIWA_RC_T501_MIN_REPEAT);
- irsend.sendAiwaRCT501(data, valueBITS, valueRPT);
- signalSent = true;
- }
- #endif
#endif
- if (signalSent){ // we acknowledge the sending by publishing the value to an acknowledgement topic, for the moment even if it is a signal repetition we acknowledge also
- boolean result = client.publish(subjectGTWIRtoMQTT, datacallback);
- if (result){
- trc(F("MQTTtoIR ack pub."));
- };
+#ifdef jsonPublishing
+ void MQTTtoIR(char * topicOri, JsonObject& IRdata) {
+
+ String topic = topicOri;
+
+ if (topic == subjectMQTTtoIR) {
+ trc(F("MQTTtoIR json data analysis"));
+ unsigned long data = IRdata["value"];
+ const char * raw = IRdata["raw"];
+ if (data != 0||raw) {
+ trc(F("MQTTtoIR data || raw ok"));
+ boolean signalSent = false;
+ trc(data);
+ const char * protocol_name = IRdata["protocol_name"];
+ if(raw){
+ unsigned int s = strlen(raw);
+ //number of "," value count
+ int count = 0;
+ for(int i = 0; i < s; i++)
+ {
+ if (raw[i] == ',') {
+ count++;
+ }
+ }
+ #ifdef IR_GC
+ if(strstr(protocol_name, "IR_GC") != NULL){ // sending GC data from https://irdb.globalcache.com
+ trc("IR_GC");
+ //buffer allocation from char datacallback
+ uint16_t GC[count+1];
+ String value = "";
+ int j = 0;
+ for(int i = 0; i < s; i++)
+ {
+ if (raw[i] != ',') {
+ value = value + String(raw[i]);
+ }
+ if ((raw[i] == ',') || (i == s - 1))
+ {
+ GC[j]= value.toInt();
+ value = "";
+ j++;
+ }
+ }
+ irsend.sendGC(GC, j);
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_Raw
+ if(strstr(protocol_name, "IR_Raw") != NULL){ // sending Raw data
+ trc("IR_Raw");
+ //buffer allocation from char datacallback
+ #ifdef ESP8266
+ uint16_t Raw[count+1];
+ #else
+ unsigned int Raw[count+1];
+ #endif
+ String value = "";
+ int j = 0;
+ for(int i = 0; i < s; i++)
+ {
+ if (raw[i] != ',') {
+ value = value + String(raw[i]);
+ }
+ if ((raw[i] == ',') || (i == s - 1))
+ {
+ Raw[j]= value.toInt();
+ value = "";
+ j++;
+ }
+ }
+ irsend.sendRaw(Raw, j, RawFrequency);
+ signalSent = true;
+ }
+ #endif
+ }else if(protocol_name){
+ unsigned int valueBITS = IRdata["bits"];
+ trc(F("Bits nb:"));
+ trc(valueBITS);
+
+ uint16_t valueRPT = IRdata["repeat"]|repeatIRwNumber;
+ trc(F("IR repeat:"));
+ trc(valueRPT);
+
+ #ifdef ESP8266 // send coolix not available for arduino IRRemote library
+ #ifdef IR_COOLIX
+ if (strstr(protocol_name, "IR_COOLIX") != NULL){
+ if (valueBITS == 0) valueBITS = COOLIX_BITS;
+ irsend.sendCOOLIX(data, valueBITS, valueRPT);
+ signalSent = true;
+ }
+ #endif
+ #endif
+ if (strstr(protocol_name, "IR_NEC") != NULL || !protocol_name ){
+ if (valueBITS == 0) valueBITS = NEC_BITS;
+ #ifdef ESP8266
+ irsend.sendNEC(data, valueBITS, valueRPT);
+ #else
+ for (int i=0; i <= valueRPT; i++) irsend.sendNEC(data, valueBITS);
+ #endif
+ signalSent = true;
+ }
+ #ifdef IR_Whynter
+ if (strstr(protocol_name, "IR_Whynter") != NULL){
+ if (valueBITS == 0) valueBITS = WHYNTER_BITS;
+ #ifdef ESP8266
+ irsend.sendWhynter(data, valueBITS, valueRPT);
+ #else
+ for (int i=0; i <= valueRPT; i++) irsend.sendWhynter(data, valueBITS);
+ #endif
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_LG
+ if (strstr(protocol_name, "IR_LG") != NULL){
+ if (valueBITS == 0) valueBITS = LG_BITS;
+ #ifdef ESP8266
+ irsend.sendLG(data, valueBITS, valueRPT);
+ #else
+ for (int i=0; i <= valueRPT; i++) irsend.sendLG(data, valueBITS);
+ #endif
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_Sony
+ if (strstr(protocol_name, "IR_Sony") != NULL){
+ if (valueBITS == 0) valueBITS = SONY_12_BITS;
+ #ifdef ESP8266
+ irsend.sendSony(data, valueBITS, valueRPT);
+ #else
+ for (int i=0; i <= valueRPT; i++) irsend.sendSony(data, valueBITS);
+ #endif
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_DISH
+ if (strstr(protocol_name, "IR_DISH") != NULL){
+ if (valueBITS == 0) valueBITS = DISH_BITS;
+ #ifdef ESP8266
+ irsend.sendDISH(data, valueBITS, valueRPT);
+ #else
+ for (int i=0; i <= valueRPT; i++) irsend.sendDISH(data, valueBITS);
+ #endif
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_RC5
+ if (strstr(protocol_name, "IR_RC5") != NULL){
+ if (valueBITS == 0) valueBITS = RC5_BITS;
+ #ifdef ESP8266
+ irsend.sendRC5(data, valueBITS, valueRPT);
+ #else
+ for (int i=0; i <= valueRPT; i++) irsend.sendRC5(data, valueBITS);
+ #endif
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_RC6
+ if (strstr(protocol_name, "IR_RC6") != NULL){
+ if (valueBITS == 0) valueBITS = RC6_MODE0_BITS;
+ #ifdef ESP8266
+ irsend.sendRC6(data, valueBITS, valueRPT);
+ #else
+ for (int i=0; i <= valueRPT; i++) irsend.sendRC6(data, valueBITS);
+ #endif
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_Sharp
+ if (strstr(protocol_name, "IR_Sharp") != NULL){
+ if (valueBITS == 0) valueBITS = SHARP_BITS;
+ #ifdef ESP8266
+ irsend.sendSharpRaw(data, valueBITS, valueRPT);
+ #else
+ for (int i=0; i <= valueRPT; i++) irsend.sendSharpRaw(data, valueBITS);
+ #endif
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_SAMSUNG
+ if (strstr(protocol_name, "IR_SAMSUNG") != NULL){
+ if (valueBITS == 0) valueBITS = SAMSUNG_BITS;
+ #ifdef ESP8266
+ irsend.sendSAMSUNG(data, valueBITS, valueRPT);
+ #else
+ for (int i=0; i <= valueRPT; i++) irsend.sendSAMSUNG(data, valueBITS);
+ #endif
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_JVC
+ if (strstr(protocol_name, "IR_JVC") != NULL){
+ if (valueBITS == 0) valueBITS = JVC_BITS;
+ #ifdef ESP8266
+ irsend.sendJVC(data, valueBITS, valueRPT);
+ #else
+ for (int i=0; i <= valueRPT; i++) irsend.sendJVC(data, valueBITS);
+ #endif
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_PANASONIC
+ if (strstr(protocol_name, "IR_PANASONIC") != NULL){
+ #ifdef ESP8266
+ if (valueBITS == 0) valueBITS = PANASONIC_BITS;
+ irsend.sendPanasonic(PanasonicAddress, data, valueBITS, valueRPT);
+ #else
+ for (int i=0; i <= valueRPT; i++) irsend.sendPanasonic(PanasonicAddress, data);
+ #endif
+ signalSent = true;
+ }
+ #endif
+
+ #ifdef ESP8266 // sendings not available on arduino
+ #ifdef IR_RCMM
+ if (strstr(protocol_name, "IR_RCMM") != NULL){
+ if (valueBITS == 0) valueBITS = RCMM_BITS;
+ irsend.sendRCMM(data, valueBITS, valueRPT);
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_DENON
+ if (strstr(protocol_name, "IR_DENON") != NULL){
+ if (valueBITS == 0) valueBITS = DENON_BITS;
+ irsend.sendDenon(data, valueBITS, valueRPT);
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_GICABLE
+ if (strstr(protocol_name, "IR_GICABLE") != NULL){
+ if (valueBITS == 0) valueBITS = GICABLE_BITS;
+ if (valueRPT == repeatIRwNumber) valueRPT = std::max(valueRPT, (uint16_t) GICABLE_MIN_REPEAT);
+ irsend.sendGICable(data, valueBITS, valueRPT);
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_SHERWOOD
+ if (strstr(protocol_name, "IR_SHERWOOD") != NULL){
+ if (valueBITS == 0) valueBITS = SHERWOOD_BITS;
+ if (valueRPT == repeatIRwNumber) valueRPT = std::max(valueRPT, (uint16_t) SHERWOOD_MIN_REPEAT);
+ irsend.sendSherwood(data, valueBITS, valueRPT);
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_MITSUBISHI
+ if (strstr(protocol_name, "IR_MITSUBISHI") != NULL){
+ if (valueBITS == 0) valueBITS = MITSUBISHI_BITS;
+ if (valueRPT == repeatIRwNumber) valueRPT = std::max(valueRPT, (uint16_t) MITSUBISHI_MIN_REPEAT);
+ irsend.sendMitsubishi(data, valueBITS, valueRPT);
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_NIKAI
+ if (strstr(protocol_name, "IR_NIKAI") != NULL){
+ if (valueBITS == 0) valueBITS = NIKAI_BITS;
+ irsend.sendNikai(data, valueBITS, valueRPT);
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_MIDEA
+ if (strstr(protocol_name, "IR_MIDEA") != NULL){
+ if (valueBITS == 0) valueBITS = MIDEA_BITS;
+ irsend.sendMidea(data, valueBITS, valueRPT);
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_MAGIQUEST
+ if (strstr(protocol_name, "IR_MAGIQUEST") != NULL){
+ if (valueBITS == 0) valueBITS = MAGIQUEST_BITS;
+ irsend.sendMagiQuest(data, valueBITS, valueRPT);
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_LASERTAG
+ if (strstr(protocol_name, "IR_LASERTAG") != NULL){
+ if (valueBITS == 0) valueBITS = LASERTAG_BITS;
+ irsend.sendLasertag(data, valueBITS, valueRPT);
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_CARRIER_AC
+ if (strstr(protocol_name, "IR_CARRIER_AC") != NULL){
+ if (valueBITS == 0) valueBITS = CARRIER_AC_BITS;
+ irsend.sendCarrierAC(data, valueBITS, valueRPT);
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_MITSUBISHI2
+ if (strstr(protocol_name, "IR_MITSUBISHI2") != NULL){
+ if (valueBITS == 0) valueBITS = MITSUBISHI_BITS;
+ if (valueRPT == repeatIRwNumber) valueRPT = std::max(valueRPT, (uint16_t) MITSUBISHI_MIN_REPEAT);
+ irsend.sendMitsubishi2(data, valueBITS, valueRPT);
+ signalSent = true;
+ }
+ #endif
+ #ifdef IR_AIWA_RC_T501
+ if (strstr(protocol_name, "IR_MITSUBISHI") != NULL){
+ if (valueBITS == 0) valueBITS = AIWA_RC_T501_BITS;
+ if (valueRPT == repeatIRwNumber) valueRPT = std::max(valueRPT, (uint16_t) AIWA_RC_T501_MIN_REPEAT);
+ irsend.sendAiwaRCT501(data, valueBITS, valueRPT);
+ signalSent = true;
+ }
+ #endif
+ #endif
+
+ if (signalSent){ // we acknowledge the sending by publishing the value to an acknowledgement topic, for the moment even if it is a signal repetition we acknowledge also
+ pub(subjectGTWIRtoMQTT, IRdata);
+ }
+ irrecv.enableIRIn(); // ReStart the IR receiver (if not restarted it is not able to receive data)
+ }else{
+ trc(F("MQTTtoIR Fail reading protocol name from json"));
+ }
+ }else{
+ trc(F("MQTTtoIR Fail reading from json"));
+ }
+ }
}
- irrecv.enableIRIn(); // ReStart the IR receiver (if not restarted it is not able to receive data)
-}
+#endif
#endif
diff --git a/ZgatewayPilight.ino b/ZgatewayPilight.ino
index 3e62daff..bf4e1b35 100644
--- a/ZgatewayPilight.ino
+++ b/ZgatewayPilight.ino
@@ -17,23 +17,18 @@
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- OpenMQTTGateway is distributed in the hope that it will be useful,
+ OpenMQTTGateway is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
+ You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
-
-#ifdef ZgatewayPilight
-
-#include
-
-ESPiLight rf(RF_EMITTER_PIN); // use -1 to disable transmitter
-
+ #ifdef ZgatewayPilight
+ #include
+ ESPiLight rf(RF_EMITTER_PIN); // use -1 to disable transmitter
void setupPilight(){
- #ifndef ZgatewayRF && ZgatewayRF2 //receiving with Pilight is not compatible with ZgatewayRF or RF2 as far as I can tell
+ #ifndef ZgatewayRF && ZgatewayRF2 && ZgatewayRF315 //receiving with Pilight is not compatible with ZgatewayRF or RF2 or RF315 as far as I can tell
rf.setCallback(pilightCallback);
rf.initReceiver(RF_RECEIVER_PIN);
trc(F("RF_EMITTER_PIN "));
@@ -41,94 +36,64 @@ void setupPilight(){
trc(F("RF_RECEIVER_PIN "));
trc(String(RF_RECEIVER_PIN));
trc(F("ZgatewayPilight setup done "));
- #endif
+ #else
+ trc(F("ZgatewayPilight setup cannot be done, comment first ZgatewayRF && ZgatewayRF2 && ZgatewayRF315"));
+ #endif
}
-boolean PilighttoMQTT(){
+void PilighttoMQTT(){
rf.loop();
}
void pilightCallback(const String &protocol, const String &message, int status,
size_t repeats, const String &deviceID) {
-
- if (status == VALID) {
-
+ if (status == VALID) {
+ trc(F("Creating RF PiLight buffer"));
+ StaticJsonBuffer jsonBuffer;
+ JsonObject& RFPiLightdata = jsonBuffer.createObject();
trc(F("Rcv. Pilight"));
- String MQTTprotocol;
- String MQTTdeviceID;
- String MQTTmessage;
-
- MQTTprotocol = String(protocol);
- MQTTdeviceID = String(deviceID);
- MQTTmessage = String(message);
- String MQTTPilightstring;
- MQTTPilightstring = subjectPilighttoMQTT+String("/")+MQTTprotocol+String("/")+MQTTdeviceID;
- trc(F("Adv data PilighttoMQTT"));
- client.publish((char *)MQTTPilightstring.c_str(),(char *)MQTTmessage.c_str());
-
- }
+ RFPiLightdata.set("message", (char *)message.c_str());
+ RFPiLightdata.set("protocol",(char *)protocol.c_str());
+ RFPiLightdata.set("length", (char *)deviceID.c_str());
+ RFPiLightdata.set("repeats", (int)repeats);
+ RFPiLightdata.set("status", (int)status);
+ pub(subjectPilighttoMQTT,RFPiLightdata);
+ }
}
-void MQTTtoPilight(char * topicOri, char * datacallback) {
-
- String topic = topicOri;
-
- int pos = topic.lastIndexOf(subjectMQTTtoPilight);
- if (pos == -1){
- return;
- }
-
- trc(F("Adv data PilighttoMQTT"));
-
- char *last = strrchr(topicOri, '/');
- String protocol = "";
-
- if (last+1 != NULL) {
- protocol = last+1;
- }
-
- int result = 0;
-
- if (protocol == PilightRAW){
- trc(F("RAW:"));
- trc(String(datacallback));
-
- uint16_t rawpulses[MAXPULSESTREAMLENGTH];
- int rawlen =
- rf.stringToPulseTrain(datacallback, rawpulses, MAXPULSESTREAMLENGTH);
- if (rawlen > 0) {
- rf.sendPulseTrain(rawpulses, rawlen);
- result = rawlen;
- } else {
+void MQTTtoPilight(char * topicOri, JsonObject& Pilightdata) {
+String topic = topicOri;
+int result = 0;
+
+if (topic == subjectMQTTtoPilight) {
+ trc(F("MQTTtoPilight json data analysis"));
+ const char * message = Pilightdata["message"];
+ const char * protocol = Pilightdata["protocol"];
+ if (message && protocol) {
+ trc(F("MQTTtoPilight msg & protocol ok"));
+ result = rf.send(protocol, message);
+ }else{
+ trc(F("MQTTtoPilight fail reading from json"));
+ }
+ int msgLength = 0;
+ uint16_t codes[MAXPULSESTREAMLENGTH];
+ msgLength = rf.stringToPulseTrain(
+ message,
+ codes, MAXPULSESTREAMLENGTH);
+ if (msgLength > 0) {
+ trc(F("MQTTtoPilight raw ok"));
+ rf.sendPulseTrain(codes, msgLength);
+ result = msgLength;
+ }else{
+ trc(F("MQTTtoPilight raw KO"));
result = -9999;
}
- } else {
- trc(F("PROTO:"));
- trc(protocol);
- result = rf.send(protocol, datacallback);
- }
-
- String MQTTmessage;
- String MQTTprotocol = String(protocol);
- String MQTTPilightstring = subjectPilighttoMQTT+String("/")+MQTTprotocol+String("/");
-
- if (result > 0) {
+
+ String MQTTmessage;
+ if (result > 0) {
trc(F("Adv data MQTTtoPilight push state via PilighttoMQTT"));
-
- MQTTmessage = String(datacallback);
-
- char *deviceID = "0";
-
- DynamicJsonBuffer jb;
- JsonObject& rjson = jb.parseObject(MQTTmessage);
- if (rjson.success()) {
- strcpy(deviceID, rjson["id"]);
- }
-
- MQTTmessage = String(datacallback);
- MQTTPilightstring += String(deviceID);
-
- } else {
+ pub(subjectGTWPilighttoMQTT, Pilightdata);
+ } else {
switch (result) {
case ESPiLight::ERROR_UNAVAILABLE_PROTOCOL:
MQTTmessage = "protocol is not avaiable";
@@ -148,13 +113,8 @@ void MQTTtoPilight(char * topicOri, char * datacallback) {
}
trc(F("ESPiLight Error: "));
trc(String(MQTTmessage));
- MQTTPilightstring += String("error");
-
- }
-
- client.publish((char *)MQTTPilightstring.c_str(),(char *)MQTTmessage.c_str());
-
+ pub(subjectGTWPilighttoMQTT, MQTTmessage);
+ }
+ }
}
-
-#endif
-
+ #endif
diff --git a/ZgatewayRF.ino b/ZgatewayRF.ino
index 37be2c5c..71679d0a 100644
--- a/ZgatewayRF.ino
+++ b/ZgatewayRF.ino
@@ -44,43 +44,41 @@ void setupRF(){
trc(F("ZgatewayRF setup done "));
}
-boolean RFtoMQTT(){
+void RFtoMQTT(){
if (mySwitch.available()){
+ trc(F("Creating RF buffer"));
+ StaticJsonBuffer jsonBuffer;
+ JsonObject& RFdata = jsonBuffer.createObject();
trc(F("Rcv. RF"));
#ifdef ESP32
String taskMessage = "RF Task running on core ";
taskMessage = taskMessage + xPortGetCoreID();
trc(taskMessage);
#endif
- unsigned long MQTTvalue = 0;
- String MQTTprotocol;
- String MQTTbits;
- String MQTTlength;
- MQTTvalue = mySwitch.getReceivedValue();
- MQTTprotocol = String(mySwitch.getReceivedProtocol());
- MQTTbits = String(mySwitch.getReceivedBitlength());
- MQTTlength = String(mySwitch.getReceivedDelay());
+ RFdata.set("value", (unsigned long)mySwitch.getReceivedValue());
+ RFdata.set("protocol",(int)mySwitch.getReceivedProtocol());
+ RFdata.set("length", (int)mySwitch.getReceivedBitlength());
+ RFdata.set("delay", (int)mySwitch.getReceivedDelay());
mySwitch.resetAvailable();
+
+ trc(F("LED MNG"));
+ digitalWrite(led_receive, LOW);
+ timer_led_receive = millis();
+
+ unsigned long MQTTvalue = RFdata.get("value");
if (!isAduplicate(MQTTvalue) && MQTTvalue!=0) {// conditions to avoid duplications of RF -->MQTT
- trc(F("Adv data RFtoMQTT"));
- client.publish(subjectRFtoMQTTprotocol,(char *)MQTTprotocol.c_str());
- client.publish(subjectRFtoMQTTbits,(char *)MQTTbits.c_str());
- client.publish(subjectRFtoMQTTlength,(char *)MQTTlength.c_str());
- trc(F("Sending RFtoMQTT"));
- String value = String(MQTTvalue);
- trc(value);
- boolean result = client.publish(subjectRFtoMQTT,(char *)value.c_str());
+ trc(F("Adv data RFtoMQTT"));
+ pub(subjectRFtoMQTT,RFdata);
if (repeatRFwMQTT){
trc(F("Publish RF for repeat"));
- client.publish(subjectMQTTtoRF,(char *)value.c_str());
+ pub(subjectMQTTtoRF,RFdata);
}
- return result;
}
}
- return false;
}
+#ifdef simplePublishing
void MQTTtoRF(char * topicOri, char * datacallback) {
unsigned long data = strtoul(datacallback, NULL, 10); // we will not be able to pass values > 4294967295
@@ -119,9 +117,7 @@ void MQTTtoRF(char * topicOri, char * datacallback) {
mySwitch.setProtocol(1,350);
mySwitch.send(data, 24);
// Acknowledgement to the GTWRF topic
- boolean result = client.publish(subjectGTWRFtoMQTT, datacallback);
- if (result)trc(F("Ack pub."));
-
+ pub(subjectGTWRFtoMQTT, datacallback);
} else if ((valuePRT != 0) || (valuePLSL != 0)|| (valueBITS != 0)){
trc(F("MQTTtoRF usr par."));
if (valuePRT == 0) valuePRT = 1;
@@ -133,12 +129,47 @@ void MQTTtoRF(char * topicOri, char * datacallback) {
mySwitch.setProtocol(valuePRT,valuePLSL);
mySwitch.send(data, valueBITS);
// Acknowledgement to the GTWRF topic
- boolean result = client.publish(subjectGTWRFtoMQTT, datacallback);// we acknowledge the sending by publishing the value to an acknowledgement topic, for the moment even if it is a signal repetition we acknowledge also
- if (result){
- trc(F("MQTTtoRF ack pub."));
- trc(data);
- }
- }
-
+ pub(subjectGTWRFtoMQTT, datacallback);// we acknowledge the sending by publishing the value to an acknowledgement topic, for the moment even if it is a signal repetition we acknowledge also
+ }
}
#endif
+
+#ifdef jsonPublishing
+ void MQTTtoRF(char * topicOri, JsonObject& RFdata) { // json object decoding
+
+ String topic = topicOri;
+
+ if (topic == subjectMQTTtoRF) {
+ trc(F("MQTTtoRF json data analysis"));
+ unsigned long data = RFdata["value"];
+ if (data != 0) {
+ trc(F("MQTTtoRF data ok"));
+ int valuePRT = RFdata["protocol"];
+ int valuePLSL = RFdata["delay"];
+ int valueBITS = RFdata["length"];
+ if ((valuePRT == 0) && (valuePLSL == 0) && (valueBITS == 0)){
+ trc(F("MQTTtoRF dflt"));
+ mySwitch.setProtocol(1,350);
+ mySwitch.send(data, 24);
+ // Acknowledgement to the GTWRF topic
+ pub(subjectGTWRFtoMQTT, RFdata);
+ } else if ((valuePRT != 0) || (valuePLSL != 0)|| (valueBITS != 0)){
+ trc(F("MQTTtoRF usr par."));
+ if (valuePRT == 0) valuePRT = 1;
+ if (valuePLSL == 0) valuePLSL = 350;
+ if (valueBITS == 0) valueBITS = 24;
+ trc(valuePRT);
+ trc(valuePLSL);
+ trc(valueBITS);
+ mySwitch.setProtocol(valuePRT,valuePLSL);
+ mySwitch.send(data, valueBITS);
+ // Acknowledgement to the GTWRF topic
+ pub(subjectGTWRFtoMQTT, RFdata);// we acknowledge the sending by publishing the value to an acknowledgement topic, for the moment even if it is a signal repetition we acknowledge also
+ }
+ }else{
+ trc(F("MQTTtoRF Fail reading from json"));
+ }
+ }
+ }
+#endif
+#endif
diff --git a/ZgatewayRF2.ino b/ZgatewayRF2.ino
index cf1aba09..52206568 100644
--- a/ZgatewayRF2.ino
+++ b/ZgatewayRF2.ino
@@ -62,31 +62,29 @@ void setupRF2(){
digitalWrite(RF_EMITTER_PIN, LOW);
}
-boolean RF2toMQTT(){
+void RF2toMQTT(){
if(rf2rd.hasNewData){
+ trc(F("Creating RF2 buffer"));
+ StaticJsonBuffer jsonBuffer;
+ JsonObject& RF2data = jsonBuffer.createObject();
+
+ rf2rd.hasNewData = false;
- rf2rd.hasNewData=false;
trc(F("Rcv. RF2"));
- String MQTTAddress;
- String MQTTperiod;
- String MQTTunit;
- String MQTTgroupBit;
- String MQTTswitchType;
-
- MQTTAddress = String(rf2rd.address);
- MQTTperiod = String(rf2rd.period);
- MQTTunit = String(rf2rd.unit);
- MQTTgroupBit = String(rf2rd.groupBit);
- MQTTswitchType = String(rf2rd.switchType);
- String MQTTRF2string;
- MQTTRF2string = subjectRF2toMQTT+String("/")+RF2codeKey+MQTTAddress+String("/")+RF2unitKey+MQTTunit+String("/")+RF2groupKey+MQTTgroupBit+String("/")+RF2periodKey+MQTTperiod;
- trc(F("Adv data RF2toMQTT"));
- client.publish((char *)MQTTRF2string.c_str(),(char *)MQTTswitchType.c_str());
- return true;
+ RF2data.set("unit", (int)rf2rd.unit);
+ RF2data.set("groupBit", (int)rf2rd.groupBit);
+ RF2data.set("period", (int)rf2rd.period);
+ RF2data.set("address", (unsigned long)rf2rd.address);
+ RF2data.set("switchType", (int)rf2rd.switchType);
+ trc(F("LED MNG"));
+ digitalWrite(led_receive, LOW);
+ timer_led_receive = millis();
+
+ trc(F("Adv data RF2toMQTT"));
+ pub(subjectRF2toMQTT,RF2data);
}
- return false;
}
void rf2Callback(unsigned int period, unsigned long address, unsigned long groupBit, unsigned long unit, unsigned long switchType) {
@@ -100,116 +98,177 @@ void rf2Callback(unsigned int period, unsigned long address, unsigned long group
}
-void MQTTtoRF2(char * topicOri, char * datacallback) {
-
- // RF DATA ANALYSIS
- //We look into the subject to see if a special RF protocol is defined
- String topic = topicOri;
- bool boolSWITCHTYPE;
- boolSWITCHTYPE = to_bool(datacallback);
- bool isDimCommand = false;
+#ifdef simplePublishing
+ void MQTTtoRF2(char * topicOri, char * datacallback) {
- long valueCODE = 0;
- int valueUNIT = -1;
- int valuePERIOD = 0;
- int valueGROUP = 0;
- int valueDIM = -1;
-
- int pos = topic.lastIndexOf(RF2codeKey);
- if (pos != -1){
- pos = pos + +strlen(RF2codeKey);
- valueCODE = (topic.substring(pos,pos + 8)).toInt();
- trc(F("RF2 code:"));
- trc(valueCODE);
- }
- int pos2 = topic.lastIndexOf(RF2periodKey);
- if (pos2 != -1) {
- pos2 = pos2 + strlen(RF2periodKey);
- valuePERIOD = (topic.substring(pos2,pos2 + 3)).toInt();
- trc(F("RF2 Period:"));
- trc(valuePERIOD);
- }
- int pos3 = topic.lastIndexOf(RF2unitKey);
- if (pos3 != -1){
- pos3 = pos3 + strlen(RF2unitKey);
- valueUNIT = (topic.substring(pos3, topic.indexOf("/", pos3))).toInt();
- trc(F("Unit:"));
- trc(valueUNIT);
- }
- int pos4 = topic.lastIndexOf(RF2groupKey);
- if (pos4 != -1) {
- pos4 = pos4 + strlen(RF2groupKey);
- valueGROUP = (topic.substring(pos4,pos4 + 1)).toInt();
- trc(F("RF2 Group:"));
- trc(valueGROUP);
- }
- int pos5 = topic.lastIndexOf(RF2dimKey);
- if (pos5 != -1) {
- isDimCommand = true;
- valueDIM = atoi(datacallback);
- trc(F("RF2 Dim:"));
- trc(valueDIM);
- }
-
- if ((topic == subjectMQTTtoRF2) || (valueCODE != 0) || (valueUNIT != -1)|| (valuePERIOD != 0)){
- trc(F("MQTTtoRF2"));
- if (valueCODE == 0) valueCODE = 8233378;
- if (valueUNIT == -1) valueUNIT = 0;
- if (valuePERIOD == 0) valuePERIOD = 272;
- trc(valueCODE);
- trc(valueUNIT);
- trc(valuePERIOD);
- trc(valueGROUP);
- trc(boolSWITCHTYPE);
- trc(valueDIM);
- NewRemoteReceiver::disable();
- trc(F("Creating transmitter"));
- NewRemoteTransmitter transmitter(valueCODE, RF_EMITTER_PIN, valuePERIOD);
- trc(F("Sending data"));
- if (valueGROUP) {
- if (isDimCommand) {
- transmitter.sendGroupDim(valueDIM);
+ // RF DATA ANALYSIS
+ //We look into the subject to see if a special RF protocol is defined
+ String topic = topicOri;
+ bool boolSWITCHTYPE;
+ boolSWITCHTYPE = to_bool(datacallback);
+ bool isDimCommand = false;
+
+ long valueCODE = 0;
+ int valueUNIT = -1;
+ int valuePERIOD = 0;
+ int valueGROUP = 0;
+ int valueDIM = -1;
+
+ int pos = topic.lastIndexOf(RF2codeKey);
+ if (pos != -1){
+ pos = pos + +strlen(RF2codeKey);
+ valueCODE = (topic.substring(pos,pos + 8)).toInt();
+ trc(F("RF2 code:"));
+ trc(valueCODE);
+ }
+ int pos2 = topic.lastIndexOf(RF2periodKey);
+ if (pos2 != -1) {
+ pos2 = pos2 + strlen(RF2periodKey);
+ valuePERIOD = (topic.substring(pos2,pos2 + 3)).toInt();
+ trc(F("RF2 Period:"));
+ trc(valuePERIOD);
+ }
+ int pos3 = topic.lastIndexOf(RF2unitKey);
+ if (pos3 != -1){
+ pos3 = pos3 + strlen(RF2unitKey);
+ valueUNIT = (topic.substring(pos3, topic.indexOf("/", pos3))).toInt();
+ trc(F("Unit:"));
+ trc(valueUNIT);
+ }
+ int pos4 = topic.lastIndexOf(RF2groupKey);
+ if (pos4 != -1) {
+ pos4 = pos4 + strlen(RF2groupKey);
+ valueGROUP = (topic.substring(pos4,pos4 + 1)).toInt();
+ trc(F("RF2 Group:"));
+ trc(valueGROUP);
+ }
+ int pos5 = topic.lastIndexOf(RF2dimKey);
+ if (pos5 != -1) {
+ isDimCommand = true;
+ valueDIM = atoi(datacallback);
+ trc(F("RF2 Dim:"));
+ trc(valueDIM);
+ }
+
+ if ((topic == subjectMQTTtoRF2) || (valueCODE != 0) || (valueUNIT != -1)|| (valuePERIOD != 0)){
+ trc(F("MQTTtoRF2"));
+ if (valueCODE == 0) valueCODE = 8233378;
+ if (valueUNIT == -1) valueUNIT = 0;
+ if (valuePERIOD == 0) valuePERIOD = 272;
+ trc(valueCODE);
+ trc(valueUNIT);
+ trc(valuePERIOD);
+ trc(valueGROUP);
+ trc(boolSWITCHTYPE);
+ trc(valueDIM);
+ NewRemoteReceiver::disable();
+ trc(F("Creating transmitter"));
+ NewRemoteTransmitter transmitter(valueCODE, RF_EMITTER_PIN, valuePERIOD);
+ trc(F("Sending data"));
+ if (valueGROUP) {
+ if (isDimCommand) {
+ transmitter.sendGroupDim(valueDIM);
+ }
+ else {
+ transmitter.sendGroup(boolSWITCHTYPE);
+ }
}
else {
- transmitter.sendGroup(boolSWITCHTYPE);
+ if (isDimCommand) {
+ transmitter.sendDim(valueUNIT, valueDIM);
+ }
+ else {
+ transmitter.sendUnit(valueUNIT, boolSWITCHTYPE);
+ }
}
- }
- else {
+ trc(F("Data sent"));
+ NewRemoteReceiver::enable();
+
+ // Publish state change back to MQTT
+ String MQTTAddress;
+ String MQTTperiod;
+ String MQTTunit;
+ String MQTTgroupBit;
+ String MQTTswitchType;
+ String MQTTdimLevel;
+
+ MQTTAddress = String(valueCODE);
+ MQTTperiod = String(valuePERIOD);
+ MQTTunit = String(valueUNIT);
+ MQTTgroupBit = String(rf2rd.groupBit);
+ MQTTswitchType = String(boolSWITCHTYPE);
+ MQTTdimLevel = String(valueDIM);
+ String MQTTRF2string;
+ trc(F("Adv data MQTTtoRF2 push state via RF2toMQTT"));
if (isDimCommand) {
- transmitter.sendDim(valueUNIT, valueDIM);
+ MQTTRF2string = subjectRF2toMQTT+String("/")+RF2codeKey+MQTTAddress+String("/")+RF2unitKey+MQTTunit+String("/")+RF2groupKey+MQTTgroupBit+String("/")+RF2dimKey+String("/")+RF2periodKey+MQTTperiod;
+ pub(MQTTRF2string,MQTTdimLevel);
}
- else {
- transmitter.sendUnit(valueUNIT, boolSWITCHTYPE);
+ else {
+ MQTTRF2string = subjectRF2toMQTT+String("/")+RF2codeKey+MQTTAddress+String("/")+RF2unitKey+MQTTunit+String("/")+RF2groupKey+MQTTgroupBit+String("/")+RF2periodKey+MQTTperiod;
+ pub(MQTTRF2string,MQTTswitchType);
}
}
- trc(F("Data sent"));
- NewRemoteReceiver::enable();
-
- // Publish state change back to MQTT
- String MQTTAddress;
- String MQTTperiod;
- String MQTTunit;
- String MQTTgroupBit;
- String MQTTswitchType;
- String MQTTdimLevel;
-
- MQTTAddress = String(valueCODE);
- MQTTperiod = String(valuePERIOD);
- MQTTunit = String(valueUNIT);
- MQTTgroupBit = String(rf2rd.groupBit);
- MQTTswitchType = String(boolSWITCHTYPE);
- MQTTdimLevel = String(valueDIM);
- String MQTTRF2string;
- trc(F("Adv data MQTTtoRF2 push state via RF2toMQTT"));
- if (isDimCommand) {
- MQTTRF2string = subjectRF2toMQTT+String("/")+RF2codeKey+MQTTAddress+String("/")+RF2unitKey+MQTTunit+String("/")+RF2groupKey+MQTTgroupBit+String("/")+RF2dimKey+String("/")+RF2periodKey+MQTTperiod;
- client.publish((char *)MQTTRF2string.c_str(),(char *)MQTTdimLevel.c_str());
- }
- else {
- MQTTRF2string = subjectRF2toMQTT+String("/")+RF2codeKey+MQTTAddress+String("/")+RF2unitKey+MQTTunit+String("/")+RF2groupKey+MQTTgroupBit+String("/")+RF2periodKey+MQTTperiod;
- client.publish((char *)MQTTRF2string.c_str(),(char *)MQTTswitchType.c_str());
- }
}
-}
-
+#endif
+
+#ifdef jsonPublishing
+ void MQTTtoRF2(char * topicOri, JsonObject& RF2data) { // json object decoding
+
+ String topic = topicOri;
+
+ if (topic == subjectMQTTtoRF2) {
+ trc(F("MQTTtoRF2 json data analysis"));
+ int boolSWITCHTYPE = RF2data["switchType"] | 99;
+ if (boolSWITCHTYPE != 99) {
+ trc(F("MQTTtoRF2 switch type ok"));
+ bool isDimCommand = false;
+ unsigned long valueCODE = RF2data["adress"];
+ int valueUNIT = RF2data["unit"] | -1;
+ int valuePERIOD = RF2data["period"];
+ int valueGROUP = RF2data["groupBit"];
+ int valueDIM = RF2data["dim"] | -1;
+ if ((valueCODE != 0) || (valueUNIT != -1)|| (valuePERIOD != 0)){
+ trc(F("MQTTtoRF2"));
+ if (valueCODE == 0) valueCODE = 8233378;
+ if (valueUNIT == -1) valueUNIT = 0;
+ if (valuePERIOD == 0) valuePERIOD = 272;
+ trc(valueCODE);
+ trc(valueUNIT);
+ trc(valuePERIOD);
+ trc(valueGROUP);
+ trc(boolSWITCHTYPE);
+ trc(valueDIM);
+ NewRemoteReceiver::disable();
+ trc(F("Creating transmitter"));
+ NewRemoteTransmitter transmitter(valueCODE, RF_EMITTER_PIN, valuePERIOD);
+ trc(F("Sending data"));
+ if (valueGROUP) {
+ if (isDimCommand) {
+ transmitter.sendGroupDim(valueDIM);
+ }
+ else {
+ transmitter.sendGroup(boolSWITCHTYPE);
+ }
+ }
+ else {
+ if (isDimCommand) {
+ transmitter.sendDim(valueUNIT, valueDIM);
+ }
+ else {
+ transmitter.sendUnit(valueUNIT, boolSWITCHTYPE);
+ }
+ }
+ trc(F("Data sent"));
+ NewRemoteReceiver::enable();
+
+ // Publish state change back to MQTT
+ pub(subjectGTWRF2toMQTT,RF2data);
+ }
+ }else{
+ trc(F("MQTTto2G Fail reading from json"));
+ }
+ }
+ }
+#endif
#endif
diff --git a/ZgatewayRF315.ino b/ZgatewayRF315.ino
index 9c917bc5..645e7cbb 100644
--- a/ZgatewayRF315.ino
+++ b/ZgatewayRF315.ino
@@ -45,100 +45,128 @@ void setupRF315(){
}
boolean RF315toMQTT(){
-
if (mySwitch315.available()){
+ trc(F("Creating RF315 buffer"));
+ StaticJsonBuffer jsonBuffer;
+ JsonObject& RF315data = jsonBuffer.createObject();
trc(F("Rcv. RF315"));
#ifdef ESP32
String taskMessage = "RF Task running on core ";
taskMessage = taskMessage + xPortGetCoreID();
trc(taskMessage);
#endif
- unsigned long MQTTvalue = 0;
- String MQTTprotocol;
- String MQTTbits;
- String MQTTlength;
- MQTTvalue = mySwitch315.getReceivedValue();
- MQTTprotocol = String(mySwitch315.getReceivedProtocol());
- MQTTbits = String(mySwitch315.getReceivedBitlength());
- MQTTlength = String(mySwitch315.getReceivedDelay());
+ RF315data.set("value", (unsigned long)mySwitch315.getReceivedValue());
+ RF315data.set("protocol",(int)mySwitch315.getReceivedProtocol());
+ RF315data.set("length", (int)mySwitch315.getReceivedBitlength());
+ RF315data.set("delay", (int)mySwitch315.getReceivedDelay());
mySwitch315.resetAvailable();
+
+ trc(F("LED MNG"));
+ digitalWrite(led_receive, LOW);
+ timer_led_receive = millis();
+
+ unsigned long MQTTvalue = RF315data.get("value");
if (!isAduplicate(MQTTvalue) && MQTTvalue!=0) {// conditions to avoid duplications of RF -->MQTT
- trc(F("Adv data RF315toMQTT"));
- client.publish(subjectRF315toMQTTprotocol,(char *)MQTTprotocol.c_str());
- client.publish(subjectRF315toMQTTbits,(char *)MQTTbits.c_str());
- client.publish(subjectRF315toMQTTlength,(char *)MQTTlength.c_str());
- trc(F("Sending RF315toMQTT"));
- String value = String(MQTTvalue);
- trc(value);
- boolean result = client.publish(subjectRF315toMQTT,(char *)value.c_str());
+ trc(F("Adv data RF315toMQTT"));
+ pub(subjectRF315toMQTT,RF315data);
if (repeatRF315wMQTT){
trc(F("Publish RF315 for repeat"));
- client.publish(subjectMQTTtoRF315,(char *)value.c_str());
+ pub(subjectMQTTtoRF315,RF315data);
}
- return result;
- }
- }
- return false;
-}
-
-void MQTTtoRF315(char * topicOri, char * datacallback) {
-
- unsigned long data = strtoul(datacallback, NULL, 10); // we will not be able to pass values > 4294967295
-
- // RF315 DATA ANALYSIS
- //We look into the subject to see if a special RF protocol is defined
- String topic = topicOri;
- int valuePRT = 0;
- int valuePLSL = 0;
- int valueBITS = 0;
- int pos = topic.lastIndexOf(RF315protocolKey);
- if (pos != -1){
- pos = pos + +strlen(RF315protocolKey);
- valuePRT = (topic.substring(pos,pos + 1)).toInt();
- trc(F("RF315 Protocol:"));
- trc(valuePRT);
- }
- //We look into the subject to see if a special RF pulselength is defined
- int pos2 = topic.lastIndexOf(RF315pulselengthKey);
- if (pos2 != -1) {
- pos2 = pos2 + strlen(RF315pulselengthKey);
- valuePLSL = (topic.substring(pos2,pos2 + 3)).toInt();
- trc(F("RF315 Pulse Lgth:"));
- trc(valuePLSL);
- }
- int pos3 = topic.lastIndexOf(RF315bitsKey);
- if (pos3 != -1){
- pos3 = pos3 + strlen(RF315bitsKey);
- valueBITS = (topic.substring(pos3,pos3 + 2)).toInt();
- trc(F("Bits nb:"));
- trc(valueBITS);
- }
-
- if ((topic == subjectMQTTtoRF315) && (valuePRT == 0) && (valuePLSL == 0) && (valueBITS == 0)){
- trc(F("MQTTtoRF315 dflt"));
- mySwitch315.setProtocol(1,350);
- mySwitch315.send(data, 24);
- // Acknowledgement to the GTWRF topic
- boolean result = client.publish(subjectGTWRF315toMQTT, datacallback);
- if (result)trc(F("Ack pub."));
-
- } else if ((valuePRT != 0) || (valuePLSL != 0)|| (valueBITS != 0)){
- trc(F("MQTTtoRF315 usr par."));
- if (valuePRT == 0) valuePRT = 1;
- if (valuePLSL == 0) valuePLSL = 350;
- if (valueBITS == 0) valueBITS = 24;
- trc(valuePRT);
- trc(valuePLSL);
- trc(valueBITS);
- mySwitch315.setProtocol(valuePRT,valuePLSL);
- mySwitch315.send(data, valueBITS);
- // Acknowledgement to the GTWRF topic
- boolean result = client.publish(subjectGTWRF315toMQTT, datacallback);// we acknowledge the sending by publishing the value to an acknowledgement topic, for the moment even if it is a signal repetition we acknowledge also
- if (result){
- trc(F("MQTTtoRF315 ack pub."));
- trc(data);
}
}
-
}
+
+#ifdef simplePublishing
+ void MQTTtoRF315(char * topicOri, char * datacallback) {
+
+ unsigned long data = strtoul(datacallback, NULL, 10); // we will not be able to pass values > 4294967295
+
+ // RF315 DATA ANALYSIS
+ //We look into the subject to see if a special RF protocol is defined
+ String topic = topicOri;
+ int valuePRT = 0;
+ int valuePLSL = 0;
+ int valueBITS = 0;
+ int pos = topic.lastIndexOf(RF315protocolKey);
+ if (pos != -1){
+ pos = pos + +strlen(RF315protocolKey);
+ valuePRT = (topic.substring(pos,pos + 1)).toInt();
+ trc(F("RF315 Protocol:"));
+ trc(valuePRT);
+ }
+ //We look into the subject to see if a special RF pulselength is defined
+ int pos2 = topic.lastIndexOf(RF315pulselengthKey);
+ if (pos2 != -1) {
+ pos2 = pos2 + strlen(RF315pulselengthKey);
+ valuePLSL = (topic.substring(pos2,pos2 + 3)).toInt();
+ trc(F("RF315 Pulse Lgth:"));
+ trc(valuePLSL);
+ }
+ int pos3 = topic.lastIndexOf(RF315bitsKey);
+ if (pos3 != -1){
+ pos3 = pos3 + strlen(RF315bitsKey);
+ valueBITS = (topic.substring(pos3,pos3 + 2)).toInt();
+ trc(F("Bits nb:"));
+ trc(valueBITS);
+ }
+
+ if ((topic == subjectMQTTtoRF315) && (valuePRT == 0) && (valuePLSL == 0) && (valueBITS == 0)){
+ trc(F("MQTTtoRF315 dflt"));
+ mySwitch315.setProtocol(1,350);
+ mySwitch315.send(data, 24);
+ // Acknowledgement to the GTWRF topic
+ pub(subjectGTWRF315toMQTT, datacallback);
+ } else if ((valuePRT != 0) || (valuePLSL != 0)|| (valueBITS != 0)){
+ trc(F("MQTTtoRF315 usr par."));
+ if (valuePRT == 0) valuePRT = 1;
+ if (valuePLSL == 0) valuePLSL = 350;
+ if (valueBITS == 0) valueBITS = 24;
+ trc(valuePRT);
+ trc(valuePLSL);
+ trc(valueBITS);
+ mySwitch315.setProtocol(valuePRT,valuePLSL);
+ mySwitch315.send(data, valueBITS);
+ // Acknowledgement to the GTWRF topic
+ pub(subjectGTWRF315toMQTT, datacallback);// we acknowledge the sending by publishing the value to an acknowledgement topic, for the moment even if it is a signal repetition we acknowledge also
+ }
+ }
+#endif
+
+#ifdef jsonPublishing
+ void MQTTtoRF315(char * topicOri, JsonObject& RF315data) { // json object decoding
+
+ String topic = topicOri;
+
+ if (topic == subjectMQTTtoRF315) {
+ trc(F("MQTTtoRF315 json data analysis"));
+ unsigned long data = RF315data["value"];
+ if (data != 0) {
+ trc(F("MQTTtoRF315 data ok"));
+ int valuePRT = RF315data["protocol"];
+ int valuePLSL = RF315data["delay"];
+ int valueBITS = RF315data["length"];
+ if ((valuePRT == 0) && (valuePLSL == 0) && (valueBITS == 0)){
+ trc(F("MQTTtoRF315 dflt"));
+ mySwitch315.setProtocol(1,350);
+ mySwitch315.send(data, 24);
+ // Acknowledgement to the GTWRF topic
+ pub(subjectGTWRF315toMQTT, RF315data);
+ } else if ((valuePRT != 0) || (valuePLSL != 0)|| (valueBITS != 0)){
+ trc(F("MQTTtoRF315 usr par."));
+ if (valuePRT == 0) valuePRT = 1;
+ if (valuePLSL == 0) valuePLSL = 350;
+ if (valueBITS == 0) valueBITS = 24;
+ trc(valuePRT);
+ trc(valuePLSL);
+ trc(valueBITS);
+ mySwitch315.setProtocol(valuePRT,valuePLSL);
+ mySwitch315.send(data, valueBITS);
+ // Acknowledgement to the GTWRF topic
+ pub(subjectGTWRF315toMQTT, RF315data);// we acknowledge the sending by publishing the value to an acknowledgement topic, for the moment even if it is a signal repetition we acknowledge also
+ }
+ }
+ }
+ }
+#endif
#endif
diff --git a/ZgatewayRFM69.ino b/ZgatewayRFM69.ino
index 80272e29..0b31d0ca 100644
--- a/ZgatewayRFM69.ino
+++ b/ZgatewayRFM69.ino
@@ -138,23 +138,13 @@ void setupRFM69(void) {
}
}
-#ifdef subjectRFM69toMQTTrssi
-void publishRSSI(int16_t rssi) {
- // Send the value of the rssi to MQTT
- char buff[sizeof(subjectRFM69toMQTTrssi)+4];
- sprintf(buff, "%s/%d", subjectRFM69toMQTTrssi, radio.SENDERID);
- char buff_rssi[5];
- sprintf(buff_rssi, "%d", radio.RSSI);
- boolean result = client.publish(buff, buff_rssi);
-}
-#else
-#define publishRSSI(input)
-#endif
-
boolean RFM69toMQTT(void) {
//check if something was received (could be an interrupt from the radio)
if (radio.receiveDone())
{
+ trc(F("Creating RFM69 buffer"));
+ StaticJsonBuffer jsonBuffer;
+ JsonObject& RFM69data = jsonBuffer.createObject();
uint8_t data[RF69_MAX_DATA_LEN+1]; // For the null character
uint8_t SENDERID = radio.SENDERID;
uint8_t DATALEN = radio.DATALEN;
@@ -177,9 +167,10 @@ boolean RFM69toMQTT(void) {
char buff[sizeof(subjectRFM69toMQTT)+4];
sprintf(buff, "%s/%d", subjectRFM69toMQTT, SENDERID);
- client.publish(buff,(char *)data);
-
- publishRSSI(RSSI);
+ RFM69data.set("data", (char *)data);
+ RFM69data.set("rssi", (int)radio.RSSI);
+ RFM69data.set("senderid", (int)radio.SENDERID);
+ pub(buff,RFM69data);
return true;
@@ -188,63 +179,95 @@ boolean RFM69toMQTT(void) {
}
}
-boolean MQTTtoRFM69(char * topicOri, char * datacallback) {
- int loops;
- uint32_t startMillis;
- static uint32_t deltaMillis = 0;
-
- bool good_topic = true;
- for (int i=0; i> 8) & 0xFF) ;
- hex_valueMiniPLSL[1] = (int)(valueMiniPLSL & 0xFF) ;
-
- byte hex_valueMaxiPLSL[2];
- hex_valueMaxiPLSL[0] = (int)((valueMaxiPLSL >> 8) & 0xFF) ;
- hex_valueMaxiPLSL[1] = (int)(valueMaxiPLSL & 0xFF) ;
-
- byte hex_valueSYNC[2];
- hex_valueSYNC[0] = (int)((valueSYNC >> 8) & 0xFF) ;
- hex_valueSYNC[1] = (int)(valueSYNC & 0xFF) ;
-
- unsigned long data = strtoul(datacallback, NULL, 10); // we will not be able to pass values > 4294967295
- byte hex_data[3];
- hex_data[0] = (unsigned long)((data >> 16) & 0xFF) ;
- hex_data[1] = (unsigned long)((data >> 8) & 0xFF) ;
- hex_data[2] = (unsigned long)(data & 0xFF) ;
-
- byte message_b[RF_MESSAGE_SIZE];
-
- memcpy(message_b, hex_valueSYNC, 2);
- memcpy(message_b + 2, hex_valueMiniPLSL, 2);
- memcpy(message_b + 4, hex_valueMaxiPLSL, 2);
- memcpy(message_b + 6, hex_data, 3);
-
- _rfbSend(message_b, valueRPT);
- // Acknowledgement to the GTWRF topic
- boolean result = client.publish(subjectGTWSRFBtoMQTT, datacallback);// we acknowledge the sending by publishing the value to an acknowledgement topic, for the moment even if it is a signal repetition we acknowledge also
- if (result) trc(F("MQTTtoSRFB ack pub."));
- }
- if (topic == subjectMQTTtoSRFBRaw){
-
- int pos = topic.lastIndexOf(SRFBRptKey);
- if (pos != -1){
- pos = pos + +strlen(SRFBRptKey);
- valueRPT = (topic.substring(pos,pos + 1)).toInt();
- trc(F("SRFB Repeat:"));
- trc(valueRPT);
- }
- if (valueRPT == 0) valueRPT = 1;
-
- byte message_b[RF_MESSAGE_SIZE];
- _rfbToArray(datacallback,message_b);
- _rfbSend(message_b, valueRPT);
- // Acknowledgement to the GTWRF topic
- boolean result = client.publish(subjectGTWSRFBtoMQTT, datacallback);// we acknowledge the sending by publishing the value to an acknowledgement topic, for the moment even if it is a signal repetition we acknowledge also
- if (result) trc(F("MQTTtoSRFBRaw ack pub."));
- }
-}
-
void _rfbSend(byte * message) {
Serial.println();
Serial.write(RF_CODE_START);
@@ -201,24 +101,37 @@ void _rfbDecode() {
if (action == RF_CODE_RFIN) {
_rfbToChar(&_uartbuf[1], buffer);
- client.publish(subjectSRFBtoMQTTRaw,buffer);
+
+ trc(F("Creating SRFB buffer"));
+ StaticJsonBuffer jsonBuffer;
+ JsonObject& SRFBdata = jsonBuffer.createObject();
+ SRFBdata.set("raw", (char *)buffer);
char val[8]= {0};
- extract_char(buffer, val, 12 ,8, false,true);
- client.publish(subjectSRFBtoMQTT,val);
+ extract_char(buffer, val, 12 ,8, false,true);
+ SRFBdata.set("value", (char *)val);
char val_Tsyn[4]= {0};
- extract_char(buffer, val_Tsyn, 0 ,4, false, true);
- client.publish(subjectSRFBtoMQTTTsyn,val_Tsyn);
-
+ extract_char(buffer, val_Tsyn , 0 ,4, false, true);
+ SRFBdata.set("delay", (char *)val_Tsyn);
+
char val_Thigh[4]= {0};
- extract_char(buffer, val_Thigh, 4 ,4, false, true);
- client.publish(subjectSRFBtoMQTTThigh,val_Thigh);
+ extract_char(buffer, val_Thigh , 4 ,4, false, true);
+ SRFBdata.set("val_Thigh", (char *)val_Thigh);
char val_Tlow[4]= {0};
- extract_char(buffer, val_Tlow, 8 ,4, false, true);
- client.publish(subjectSRFBtoMQTTTlow,val_Tlow);
+ extract_char(buffer,val_Tlow , 8 ,4, false, true);
+ SRFBdata.set("val_Tlow", (char *)val_Tlow);
+ unsigned long MQTTvalue = SRFBdata.get("value");
+ if (!isAduplicate(MQTTvalue) && MQTTvalue!=0) {// conditions to avoid duplications of RF -->MQTT
+ trc(F("Adv data SRFBtoMQTT"));
+ pub(subjectSRFBtoMQTT,SRFBdata);
+ if (repeatSRFBwMQTT){
+ trc(F("Publish SRFB for repeat"));
+ pub(subjectMQTTtoSRFB,SRFBdata);
+ }
+ }
_rfbAck();
}
}
@@ -256,4 +169,165 @@ bool _rfbToChar(byte * in, char * out) {
return true;
}
+#ifdef simplePublishing
+ void MQTTtoSRFB(char * topicOri, char * datacallback) {
+
+ // RF DATA ANALYSIS
+ String topic = topicOri;
+ int valueRPT = 0;
+
+ if (topic == subjectMQTTtoSRFB){
+
+ int valueMiniPLSL = 0;
+ int valueMaxiPLSL = 0;
+ int valueSYNC = 0;
+
+ int pos = topic.lastIndexOf(SRFBRptKey);
+ if (pos != -1){
+ pos = pos + +strlen(SRFBRptKey);
+ valueRPT = (topic.substring(pos,pos + 1)).toInt();
+ trc(F("SRFB Repeat:"));
+ trc(valueRPT);
+ }
+
+ int pos2 = topic.lastIndexOf(SRFBminipulselengthKey);
+ if (pos2 != -1) {
+ pos2 = pos2 + strlen(SRFBminipulselengthKey);
+ valueMiniPLSL = (topic.substring(pos2,pos2 + 3)).toInt();
+ trc(F("RF Mini Pulse Lgth:"));
+ trc(valueMiniPLSL);
+ }
+
+ int pos3 = topic.lastIndexOf(SRFBmaxipulselengthKey);
+ if (pos3 != -1){
+ pos3 = pos3 + strlen(SRFBmaxipulselengthKey);
+ valueMaxiPLSL = (topic.substring(pos3,pos3 + 2)).toInt();
+ trc(F("RF Maxi Pulse Lgth:"));
+ trc(valueMaxiPLSL);
+ }
+
+ int pos4 = topic.lastIndexOf(SRFBsyncKey);
+ if (pos4 != -1){
+ pos4 = pos4 + strlen(SRFBsyncKey);
+ valueSYNC = (topic.substring(pos4,pos4 + 2)).toInt();
+ trc(F("RF sync:"));
+ trc(valueSYNC);
+ }
+
+ trc(F("MQTTtoSRFB prts"));
+ if (valueRPT == 0) valueRPT = 1;
+ if (valueMiniPLSL == 0) valueMiniPLSL = 320;
+ if (valueMaxiPLSL == 0) valueMaxiPLSL = 900;
+ if (valueSYNC == 0) valueSYNC = 9500;
+
+ byte hex_valueMiniPLSL[2];
+ hex_valueMiniPLSL[0] = (int)((valueMiniPLSL >> 8) & 0xFF) ;
+ hex_valueMiniPLSL[1] = (int)(valueMiniPLSL & 0xFF) ;
+
+ byte hex_valueMaxiPLSL[2];
+ hex_valueMaxiPLSL[0] = (int)((valueMaxiPLSL >> 8) & 0xFF) ;
+ hex_valueMaxiPLSL[1] = (int)(valueMaxiPLSL & 0xFF) ;
+
+ byte hex_valueSYNC[2];
+ hex_valueSYNC[0] = (int)((valueSYNC >> 8) & 0xFF) ;
+ hex_valueSYNC[1] = (int)(valueSYNC & 0xFF) ;
+
+ unsigned long data = strtoul(datacallback, NULL, 10); // we will not be able to pass values > 4294967295
+ byte hex_data[3];
+ hex_data[0] = (unsigned long)((data >> 16) & 0xFF) ;
+ hex_data[1] = (unsigned long)((data >> 8) & 0xFF) ;
+ hex_data[2] = (unsigned long)(data & 0xFF) ;
+
+ byte message_b[RF_MESSAGE_SIZE];
+
+ memcpy(message_b, hex_valueSYNC, 2);
+ memcpy(message_b + 2, hex_valueMiniPLSL, 2);
+ memcpy(message_b + 4, hex_valueMaxiPLSL, 2);
+ memcpy(message_b + 6, hex_data, 3);
+
+ _rfbSend(message_b, valueRPT);
+ // Acknowledgement to the GTWRF topic
+ pub(subjectGTWSRFBtoMQTT, datacallback);// we acknowledge the sending by publishing the value to an acknowledgement topic, for the moment even if it is a signal repetition we acknowledge also
+ }
+ if (topic == subjectMQTTtoSRFBRaw){
+
+ int pos = topic.lastIndexOf(SRFBRptKey);
+ if (pos != -1){
+ pos = pos + +strlen(SRFBRptKey);
+ valueRPT = (topic.substring(pos,pos + 1)).toInt();
+ trc(F("SRFB Repeat:"));
+ trc(valueRPT);
+ }
+ if (valueRPT == 0) valueRPT = 1;
+
+ byte message_b[RF_MESSAGE_SIZE];
+ _rfbToArray(datacallback,message_b);
+ _rfbSend(message_b, valueRPT);
+ // Acknowledgement to the GTWRF topic
+ pub(subjectGTWSRFBtoMQTT, datacallback);// we acknowledge the sending by publishing the value to an acknowledgement topic, for the moment even if it is a signal repetition we acknowledge also
+ }
+ }
+#endif
+#ifdef jsonPublishing
+ void MQTTtoSRFB(char * topicOri, JsonObject& SRFBdata) {
+
+ // RF DATA ANALYSIS
+ String topic = topicOri;
+ const char * raw = SRFBdata["raw"];
+ int valueRPT = SRFBdata["repeat"]|1;
+ if (topic == subjectMQTTtoSRFB){
+ trc(F("MQTTtoSRFB json data analysis"));
+ if (raw){ // send raw in priority when defined in the json
+ trc(F("MQTTtoSRFB raw ok"));
+ byte message_b[RF_MESSAGE_SIZE];
+ _rfbToArray(raw,message_b);
+ _rfbSend(message_b, valueRPT);
+ }else{
+ unsigned long data = SRFBdata["value"];
+ if (data != 0) {
+ trc(F("MQTTtoSRFB data ok"));
+ int valueMiniPLSL = SRFBdata["val_Tlow"];
+ int valueMaxiPLSL =SRFBdata["val_Thigh"];
+ int valueSYNC = SRFBdata["delay"];
+
+ if (valueRPT == 0) valueRPT = 1;
+ if (valueMiniPLSL == 0) valueMiniPLSL = 320;
+ if (valueMaxiPLSL == 0) valueMaxiPLSL = 900;
+ if (valueSYNC == 0) valueSYNC = 9500;
+
+ byte hex_valueMiniPLSL[2];
+ hex_valueMiniPLSL[0] = (int)((valueMiniPLSL >> 8) & 0xFF) ;
+ hex_valueMiniPLSL[1] = (int)(valueMiniPLSL & 0xFF) ;
+
+ byte hex_valueMaxiPLSL[2];
+ hex_valueMaxiPLSL[0] = (int)((valueMaxiPLSL >> 8) & 0xFF) ;
+ hex_valueMaxiPLSL[1] = (int)(valueMaxiPLSL & 0xFF) ;
+
+ byte hex_valueSYNC[2];
+ hex_valueSYNC[0] = (int)((valueSYNC >> 8) & 0xFF) ;
+ hex_valueSYNC[1] = (int)(valueSYNC & 0xFF) ;
+
+ byte hex_data[3];
+ hex_data[0] = (unsigned long)((data >> 16) & 0xFF) ;
+ hex_data[1] = (unsigned long)((data >> 8) & 0xFF) ;
+ hex_data[2] = (unsigned long)(data & 0xFF) ;
+
+ byte message_b[RF_MESSAGE_SIZE];
+
+ memcpy(message_b, hex_valueSYNC, 2);
+ memcpy(message_b + 2, hex_valueMiniPLSL, 2);
+ memcpy(message_b + 4, hex_valueMaxiPLSL, 2);
+ memcpy(message_b + 6, hex_data, 3);
+
+ trc(F("MQTTtoSRFB send"));
+ _rfbSend(message_b, valueRPT);
+ // Acknowledgement to the GTWRF topic
+ pub(subjectGTWSRFBtoMQTT, SRFBdata);// we acknowledge the sending by publishing the value to an acknowledgement topic, for the moment even if it is a signal repetition we acknowledge also
+ }else{
+ trc(F("MQTTtoSRFB error decoding value"));
+ }
+ }
+ }
+ }
+#endif
#endif
diff --git a/ZsensorADC.ino b/ZsensorADC.ino
index dd127dbc..6ec80586 100644
--- a/ZsensorADC.ino
+++ b/ZsensorADC.ino
@@ -47,13 +47,14 @@ void MeasureADC(){
trc(F("Failed to read from ADC !"));
}else{
if(val >= persistedadc + ThresholdReadingADC || val <= persistedadc - ThresholdReadingADC){
- trc(F("Sending analog value to MQTT"));
- trc(val);
- client.publish(ADC,String(val).c_str());
+ trc(F("Creating ADC buffer"));
+ StaticJsonBuffer jsonBuffer;
+ JsonObject& ADCdata = jsonBuffer.createObject();
+ ADCdata.set("adc", (int)val);
+ pub(ADC,ADCdata);
persistedadc = val;
}
}
}
}
#endif
-
diff --git a/ZsensorBH1750.ino b/ZsensorBH1750.ino
index 2531b32a..522c25a1 100644
--- a/ZsensorBH1750.ino
+++ b/ZsensorBH1750.ino
@@ -54,6 +54,10 @@ void setupZsensorBH1750()
void MeasureLightIntensity()
{
if (millis() > (timebh1750 + TimeBetweenReadingBH1750)) {//retriving value of Lux, FtCd and Wattsm2 from BH1750
+ trc(F("Creating BH1750 buffer"));
+ StaticJsonBuffer jsonBuffer;
+ JsonObject& BH1750data = jsonBuffer.createObject();
+
timebh1750 = millis();
unsigned int i=0;
static float persistedll;
@@ -94,31 +98,25 @@ void MeasureLightIntensity()
// Generate Lux
if(Lux != persistedll || bh1750_always){
- trc(F("Sending Lux to MQTT"));
- trc(Lux);
- client.publish(LUX,String(Lux).c_str());
+ BH1750data.set("lux", (unsigned int)Lux);
}else{
trc(F("Same lux don't send it"));
}
// Generate FtCd
if(FtCd != persistedlf || bh1750_always){
- trc(F("Sending FtCd to MQTT"));
- trc(FtCd);
- client.publish(FTCD,String(FtCd).c_str());
+ BH1750data.set("ftCd", (unsigned int)FtCd);
}else{
trc(F("Same ftcd don't send it"));
}
// Generate Watts/m2
if(Wattsm2 != persistedlw || bh1750_always){
- trc(F("Sending Wattsm2 to MQTT"));
- trc(Wattsm2);
- client.publish(WATTSM2,String(Wattsm2).c_str());
+ BH1750data.set("wattsm2", (unsigned int)Wattsm2);
}else{
trc(F("Same wattsm2 don't send it"));
- }
-
+ }
+ if(BH1750data.size()>0) pub(subjectBH1750toMQTT,BH1750data);
}
persistedll = Lux;
persistedlf = FtCd;
diff --git a/ZsensorBME280.ino b/ZsensorBME280.ino
index 47f2e235..dc836be8 100644
--- a/ZsensorBME280.ino
+++ b/ZsensorBME280.ino
@@ -108,6 +108,7 @@ void MeasureTempHumAndPressure()
{
if (millis() > (timebme280 + TimeBetweenReadingbme280)) {
+
timebme280 = millis();
static float persisted_bme_tempc;
static float persisted_bme_tempf;
@@ -127,38 +128,33 @@ void MeasureTempHumAndPressure()
if (isnan(BmeTempC) || isnan(BmeTempF) || isnan(BmeHum) || isnan(BmePa) || isnan(BmeAltiM) || isnan(BmeAltiFt)) {
trc(F("Failed to read from Weather Sensor BME280!"));
}else{
+ trc(F("Creating BME280 buffer"));
+ StaticJsonBuffer jsonBuffer;
+ JsonObject& BME280data = jsonBuffer.createObject();
// Generate Temperature in degrees C
if(BmeTempC != persisted_bme_tempc || bme280_always){
- trc(F("Sending Degrees C to MQTT"));
- trc(BmeTempC);
- client.publish(TEMPBMEC, String(BmeTempC).c_str());
+ BME280data.set("tempc", (float)BmeTempC);
}else{
trc(F("Same Degrees C don't send it"));
}
// Generate Temperature in degrees F
if(BmeTempF != persisted_bme_tempf || bme280_always){
- trc(F("Sending Degrees F to MQTT"));
- trc(BmeTempF);
- client.publish(TEMPBMEF,String(BmeTempF).c_str());
+ BME280data.set("tempf", (float)BmeTempF);
}else{
trc(F("Same Degrees F don't send it"));
}
// Generate Humidity in percent
if(BmeHum != persisted_bme_hum || bme280_always){
- trc(F("Sending Humidity to MQTT"));
- trc(BmeHum);
- client.publish(HUMBME, String(BmeHum).c_str());
+ BME280data.set("hum", (float)BmeHum);
}else{
trc(F("Same Humidity don't send it"));
}
// Generate Pressure in Pa
if(BmePa != persisted_bme_pa || bme280_always){
- trc(F("Sending Pressure to MQTT"));
- trc(BmePa);
- client.publish(PRESSBME, String(BmePa).c_str());
+ BME280data.set("pa", (float)BmePa);
}else{
trc(F("Same Pressure don't send it"));
}
@@ -166,21 +162,18 @@ void MeasureTempHumAndPressure()
// Generate Altitude in Meter
if(BmeAltiM != persisted_bme_altim || bme280_always){
trc(F("Sending Altitude Meter to MQTT"));
- trc(BmeAltiM);
- client.publish(ALTIBMEM, String(BmeAltiM).c_str());
+ BME280data.set("altim", (float)BmeAltiM);
}else{
trc(F("Same Altitude Meter don't send it"));
}
// Generate Altitude in Feet
if(BmeAltiFt != persisted_bme_altift || bme280_always){
- trc(F("Sending Altitude Feet to MQTT"));
- trc(BmeAltiFt);
- client.publish(ALTIBMEFT, String(BmeAltiFt).c_str());
+ BME280data.set("altift", (float)BmeAltiFt);
}else{
trc(F("Same Altitude Feet don't send it"));
}
-
+ if(BME280data.size()>0) pub(BME,BME280data);
}
persisted_bme_tempc = BmeTempC;
persisted_bme_tempf = BmeTempF;
diff --git a/ZsensorDHT.ino b/ZsensorDHT.ino
index 55d7d3ed..ac1f11b4 100644
--- a/ZsensorDHT.ino
+++ b/ZsensorDHT.ino
@@ -48,20 +48,20 @@ void MeasureTempAndHum(){
if (isnan(h) || isnan(t)) {
trc(F("Failed to read from DHT sensor!"));
}else{
+ trc(F("Creating DHT buffer"));
+ StaticJsonBuffer jsonBuffer;
+ JsonObject& DHTdata = jsonBuffer.createObject();
if(h != persistedh || dht_always){
- trc(F("Sending Hum to MQTT"));
- trc(h);
- client.publish(HUM1,String(h).c_str());
+ DHTdata.set("hum", (float)h);
}else{
trc(F("Same hum don't send it"));
}
if(t != persistedt || dht_always){
- trc(F("Sending Temp to MQTT"));
- trc(t);
- client.publish(TEMP1, String(t).c_str());
+ DHTdata.set("temp", (float)t);
}else{
trc(F("Same temp don't send it"));
}
+ if(DHTdata.size()>0) pub(DHTTOPIC,DHTdata);
}
persistedh = h;
persistedt = t;
diff --git a/ZsensorGPIOInput.ino b/ZsensorGPIOInput.ino
index 563fb2a3..db03a0ff 100644
--- a/ZsensorGPIOInput.ino
+++ b/ZsensorGPIOInput.ino
@@ -1,79 +1,83 @@
-/*
- OpenMQTTGateway Addon - ESP8266 or Arduino program for home automation
- Act as a wifi or ethernet gateway between your 433mhz/infrared IR signal and a MQTT broker
- Send and receiving command by MQTT
-
- GPIO Input derived from HC SR-501 reading Addon and https://www.arduino.cc/en/Tutorial/Debounce
-
- This reads a high (open) or low (closed) through a circuit (switch, float sensor, etc.) connected to ground.
-
- Copyright: (c)Florian ROBERT
-
- Contributors:
- - 1technophile
- - QuagmireMan
-
- This file is part of OpenMQTTGateway.
-
- OpenMQTTGateway is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- OpenMQTTGateway is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
-*/
-#ifdef ZsensorGPIOInput
-
-unsigned long lastDebounceTime = 0;
-int InputState = 3; // Set to 3 so that it reads on startup
-int lastInputState = 3;
-
-
-void setupGPIOInput() {
- pinMode(GPIOInput_PIN, INPUT_PULLUP); // declare GPIOInput pin as input_pullup to prevent floating. Pin will be high when not connected to ground
-}
-
-void MeasureGPIOInput(){
- int reading = digitalRead(GPIOInput_PIN);
-
- // check to see if you just pressed the button
- // (i.e. the input went from LOW to HIGH), and you've waited long enough
- // since the last press to ignore any noise:
-
- // If the switch changed, due to noise or pressing:
- if (reading != lastInputState) {
- // reset the debouncing timer
- lastDebounceTime = millis();
-
- }
-
- if ((millis() - lastDebounceTime) > GPIOInputDebounceDelay) {
- // whatever the reading is at, it's been there for longer than the debounce
- // delay, so take it as the actual current state:
- #if defined(ESP8266) || defined(ESP32)
- yield();
- #endif
- // if the Input state has changed:
- if (reading != InputState) {
- InputState = reading;
-
- if (InputState == HIGH) {
- trc(F("GPIO HIGH"));
- client.publish(subjectGPIOInputtoMQTT,"HIGH");
- }
- if (InputState == LOW) {
- trc(F("GPIO LOW"));
- client.publish(subjectGPIOInputtoMQTT,"LOW");
- }
- }
- }
-
- // save the reading. Next time through the loop, it'll be the lastInputState:
- lastInputState = reading;
-
-}
+/*
+ OpenMQTTGateway Addon - ESP8266 or Arduino program for home automation
+ Act as a wifi or ethernet gateway between your 433mhz/infrared IR signal and a MQTT broker
+ Send and receiving command by MQTT
+
+ GPIO Input derived from HC SR-501 reading Addon and https://www.arduino.cc/en/Tutorial/Debounce
+
+ This reads a high (open) or low (closed) through a circuit (switch, float sensor, etc.) connected to ground.
+
+ Copyright: (c)Florian ROBERT
+
+ Contributors:
+ - 1technophile
+ - QuagmireMan
+
+ This file is part of OpenMQTTGateway.
+
+ OpenMQTTGateway is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+ OpenMQTTGateway is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+*/
+#ifdef ZsensorGPIOInput
+
+unsigned long lastDebounceTime = 0;
+int InputState = 3; // Set to 3 so that it reads on startup
+int lastInputState = 3;
+
+
+void setupGPIOInput() {
+ pinMode(GPIOInput_PIN, INPUT_PULLUP); // declare GPIOInput pin as input_pullup to prevent floating. Pin will be high when not connected to ground
+}
+
+void MeasureGPIOInput(){
+ int reading = digitalRead(GPIOInput_PIN);
+
+ // check to see if you just pressed the button
+ // (i.e. the input went from LOW to HIGH), and you've waited long enough
+ // since the last press to ignore any noise:
+
+ // If the switch changed, due to noise or pressing:
+ if (reading != lastInputState) {
+ // reset the debouncing timer
+ lastDebounceTime = millis();
+
+ }
+
+ if ((millis() - lastDebounceTime) > GPIOInputDebounceDelay) {
+ // whatever the reading is at, it's been there for longer than the debounce
+ // delay, so take it as the actual current state:
+ #if defined(ESP8266) || defined(ESP32)
+ yield();
+ #endif
+ // if the Input state has changed:
+ if (reading != InputState) {
+ InputState = reading;
+ trc(F("Creating GPIOInput buffer"));
+ StaticJsonBuffer jsonBuffer;
+ JsonObject& GPIOdata = jsonBuffer.createObject();
+ if (InputState == HIGH) {
+ trc(F("GPIO HIGH"));
+ pub(subjectGPIOInputtoMQTT,"HIGH");
+ GPIOdata.set("gpio", "HIGH");
+ }
+ if (InputState == LOW) {
+ trc(F("GPIO LOW"));
+ GPIOdata.set("gpio","LOW");
+ }
+ if(GPIOdata.size()>0) pub(subjectGPIOInputtoMQTT,GPIOdata);
+ }
+ }
+
+ // save the reading. Next time through the loop, it'll be the lastInputState:
+ lastInputState = reading;
+
+}
#endif
diff --git a/ZsensorGPIOKeyCode.ino b/ZsensorGPIOKeyCode.ino
index 43aa13e0..f8d78d6c 100644
--- a/ZsensorGPIOKeyCode.ino
+++ b/ZsensorGPIOKeyCode.ino
@@ -25,11 +25,10 @@
*/
#ifdef ZsensorGPIOKeyCode
+int InputStateGPIOKeyCode = 0x0f; // Set to 3 so that it reads on startup
+int lastInputStateGPIOKeyCode = 0x0f;
+int lastLatchStateGPIOKeyCode = 0;
unsigned long lastDebounceTime = 0;
-int InputState = 0x0f; // Set to 3 so that it reads on startup
-int lastInputState = 0x0f;
-int lastLatchState = 0;
-
void setupGPIOKeyCode() {
pinMode(GPIOKeyCode_LATCH_PIN, INPUT_PULLUP); //
@@ -54,8 +53,7 @@ void MeasureGPIOKeyCode(){
yield();
#endif
// if the Input state has changed:
- if (latch > 0 && lastLatchState != latch) {
-
+ if (latch > 0 && lastLatchStateGPIOKeyCode != latch) {
int reading = digitalRead(GPIOKeyCode_D0_PIN)
| (digitalRead(GPIOKeyCode_D1_PIN) << 1)
| (digitalRead(GPIOKeyCode_D2_PIN) << 2);
@@ -63,23 +61,23 @@ void MeasureGPIOKeyCode(){
char hex[3];
- InputState = reading;
- sprintf(hex, "%02x", InputState);
+ InputStateGPIOKeyCode = reading;
+ sprintf(hex, "%02x", InputStateGPIOKeyCode);
hex[2] = 0;
Serial.printf("GPIOKeyCode %s\n", hex);
client.publish(subjectGPIOKeyCodetoMQTT,hex);
- lastLatchState = latch;
+ lastLatchStateGPIOKeyCode = latch;
}
- if (latch != lastLatchState) {
- lastLatchState = latch;
+ if (latch != lastLatchStateGPIOKeyCode) {
+ lastLatchStateGPIOKeyCode = latch;
Serial.printf("GPIOKeyCode latch %d\n", latch);
if (latch == 0)
client.publish(subjectGPIOKeyCodeStatetoMQTT, "done");
}
// save the reading. Next time through the loop, it'll be the lastInputState:
- lastInputState = InputState;
+ lastInputStateGPIOKeyCode = InputStateGPIOKeyCode;
}
}
#endif
diff --git a/ZsensorHCSR501.ino b/ZsensorHCSR501.ino
index 5b16d452..1d92ab4b 100644
--- a/ZsensorHCSR501.ino
+++ b/ZsensorHCSR501.ino
@@ -34,6 +34,9 @@ void setupHCSR501() {
void MeasureHCSR501(){
if (millis() > TimeBeforeStartHCSR501) {//let time to init the PIR sensor
+ trc(F("Creating HCSR501 buffer"));
+ StaticJsonBuffer jsonBuffer;
+ JsonObject& HCSR501data = jsonBuffer.createObject();
static int pirState = LOW;
int PresenceValue = digitalRead(HCSR501_PIN);
#if defined(ESP8266) || defined(ESP32)
@@ -41,19 +44,19 @@ void MeasureHCSR501(){
#endif
if (PresenceValue == HIGH) {
if (pirState == LOW) {
- // turned on
- client.publish(subjectHCSR501toMQTT,"true");
- trc(F("HC SR501 Motion detected"));
+ //turned on
+ HCSR501data.set("hcsr501", "true");
pirState = HIGH;
}
} else {
if (pirState == HIGH){
- // turned off
- client.publish(subjectHCSR501toMQTT,"false");
- trc(F("HC SR501 Motion ended"));
- pirState = LOW;
+ // turned off
+ HCSR501data.set("hcsr501", "false");
+ trc(F("HC SR501 Motion ended"));
+ pirState = LOW;
}
}
+ if(HCSR501data.size()>0) pub(subjectHCSR501toMQTT,HCSR501data);
}
}
#endif
diff --git a/ZsensorINA226.ino b/ZsensorINA226.ino
index f13684ac..10380346 100644
--- a/ZsensorINA226.ino
+++ b/ZsensorINA226.ino
@@ -51,6 +51,9 @@ void setupINA226() {
void MeasureINA226(){
if (millis() > (timeINA226 + TimeBetweenReadingINA226)) {//retriving value of temperature and humidity of the box from DHT every xUL
timeINA226 = millis();
+ trc(F("Creating INA226 buffer"));
+ StaticJsonBuffer jsonBuffer;
+ JsonObject& INA226data = jsonBuffer.createObject();
// Topic on which we will send data
trc(F("Retrieving electrical data"));
// Bus Spannung, read-only, 16Bit, 0...40.96V max., LSB 1.25mV
@@ -78,11 +81,10 @@ void MeasureINA226(){
dtostrf(volt,6,3,volt_c);
dtostrf(current,6,3,current_c);
dtostrf(power,6,3,power_c);
-
- client.publish(subjectVolttoMQTT,volt_c);
- client.publish(subjectCurrenttoMQTT,current_c);
- client.publish(subjectPowertoMQTT,power_c);
-
+ INA226data.set("Volt", (char *)volt_c);
+ INA226data.set("Current", (char *)current_c);
+ INA226data.set("Power", (char *)power_c);
+ pub(subjectINA226toMQTT,INA226data);
}
}
diff --git a/ZsensorTSL2561.ino b/ZsensorTSL2561.ino
index 219ee1c1..b0030359 100644
--- a/ZsensorTSL2561.ino
+++ b/ZsensorTSL2561.ino
@@ -90,6 +90,10 @@ void MeasureLightIntensityTSL2561()
if (millis() > (timetsl2561 + TimeBetweenReadingtsl2561)) {
static uint32_t persisted_lux;
timetsl2561 = millis();
+
+ trc(F("Creating TSL2561 buffer"));
+ StaticJsonBuffer jsonBuffer;
+ JsonObject& TSL2561data = jsonBuffer.createObject();
sensors_event_t event;
tsl.getEvent(&event);
@@ -98,11 +102,12 @@ void MeasureLightIntensityTSL2561()
{
if (persisted_lux != event.light || tsl2561_always ) {
persisted_lux = event.light;
-
- trc("Sending Light Intensity in Lux to MQTT " + String(event.light) + " lux");
- client.publish(LUX, String(event.light).c_str());
- client.publish(FTCD, String((event.light)/10.764).c_str());
- client.publish(WATTSM2, String((event.light)/683.0).c_str());
+
+ TSL2561data.set("lux", (float)event.light);
+ TSL2561data.set("ftcd", (float)(event.light)/10.764);
+ TSL2561data.set("wattsm2", (float)(event.light)/683.0);
+
+ pub(subjectTSL12561toMQTT,TSL2561data);
} else {
trc("Same lux value, do not send");
}
@@ -112,4 +117,3 @@ void MeasureLightIntensityTSL2561()
}
}
#endif
-
diff --git a/config_2G.h b/config_2G.h
index 1a41632b..a829659d 100644
--- a/config_2G.h
+++ b/config_2G.h
@@ -29,9 +29,6 @@
#define subjectMQTTto2G Base_Topic Gateway_Name "/commands/MQTTto2G"
#define subject2GtoMQTT Base_Topic Gateway_Name "/2GtoMQTT"
#define subjectGTW2GtoMQTT Base_Topic Gateway_Name "/2GtoMQTT"
-#define subject2GtoMQTTphone Base_Topic Gateway_Name "/2GtoMQTT/phone"
-#define subject2GtoMQTTdate Base_Topic Gateway_Name "/2GtoMQTT/date"
-#define subject2GtoMQTTmessage Base_Topic Gateway_Name "/2GtoMQTT/message"
#define _2GPhoneKey "PHO_" // phone number define the phone number to send the SMS MQTT->2G
#define _2G_MODULE_BAUDRATE 9600
@@ -39,7 +36,16 @@
#define _2G_MAX_SIGNAL 1000
/*-------------------PIN DEFINITIONS----------------------*/
-#define _2G_TX_PIN D6 //D6 to A6 RX,
-#define _2G_RX_PIN D7 //D7 to A6 TX
-#define _2G_PWR_PIN D5 // connect a MOSFET to power on and off your A6/7 module
-
+#ifdef ESP8266
+ #define _2G_TX_PIN D6 //D6 to A6 RX,
+ #define _2G_RX_PIN D7 //D7 to A6 TX
+ #define _2G_PWR_PIN D5 // connect a MOSFET to power on and off your A6/7 module
+#elif defined(ESP32)
+ #define _2G_TX_PIN 16 //D16 to A6 RX,
+ #define _2G_RX_PIN 17 //D17 to A6 TX
+ #define _2G_PWR_PIN 5 // connect a MOSFET to power on and off your A6/7 module
+#else
+ #define _2G_TX_PIN 6 //D6 to A6 RX,
+ #define _2G_RX_PIN 7 //D7 to A6 TX
+ #define _2G_PWR_PIN 5 // connect a MOSFET to power on and off your A6/7 module
+#endif
diff --git a/config_BH1750.h b/config_BH1750.h
index 316e68d1..f2adb731 100644
--- a/config_BH1750.h
+++ b/config_BH1750.h
@@ -41,10 +41,7 @@
/*----------------------------USER PARAMETERS-----------------------------*/
/*-------------DEFINE YOUR MQTT PARAMETERS BELOW----------------*/
-#define LUX Base_Topic Gateway_Name "/LIGHTtoMQTT/lux"
-#define FTCD Base_Topic Gateway_Name "/LIGHTtoMQTT/ftcd"
-#define WATTSM2 Base_Topic Gateway_Name "/LIGHTtoMQTT/wattsm2"
-
+#define subjectBH1750toMQTT Base_Topic Gateway_Name "/BH1750toMQTT"
//Time used to wait for an interval before resending measured values
unsigned long timebh1750 = 0;
int BH1750_i2c_addr = 0x23; // Light Sensor I2C Address
diff --git a/config_BME280.h b/config_BME280.h
index a0a045c7..b114e9ab 100644
--- a/config_BME280.h
+++ b/config_BME280.h
@@ -41,14 +41,7 @@
/*----------------------------USER PARAMETERS-----------------------------*/
/*-------------DEFINE YOUR MQTT PARAMETERS BELOW----------------*/
-#define TEMPBMEC Base_Topic Gateway_Name "/CLIMAtoMQTT/bme/tempc"
-#define TEMPBMEF Base_Topic Gateway_Name "/CLIMAtoMQTT/bme/tempf"
-#define HUMBME Base_Topic Gateway_Name "/CLIMAtoMQTT/bme/hum"
-#define PRESSBME Base_Topic Gateway_Name "/CLIMAtoMQTT/bme/pa"
-#define ALTIBMEM Base_Topic Gateway_Name "/CLIMAtoMQTT/bme/altim"
-#define ALTIBMEFT Base_Topic Gateway_Name "/CLIMAtoMQTT/bme/altift"
+#define BME Base_Topic Gateway_Name "/CLIMAtoMQTT/bme"
//Time used to wait for an interval before resending measured values
unsigned long timebme280 = 0;
-
-
diff --git a/config_BT.h b/config_BT.h
index 716782aa..a4aee293 100644
--- a/config_BT.h
+++ b/config_BT.h
@@ -25,15 +25,6 @@
*/
/*----------------------BT topics & parameters-------------------------*/
#define subjectBTtoMQTT Base_Topic Gateway_Name "/BTtoMQTT/"
-//#define subjectBTtoMQTTrssi "/rssi" // will be the default parameter on the next release, for the moment rssi is published on mac topic
-#define subjectBTtoMQTTrssi ""
-#define subjectBTtoMQTTtem "/tem"
-#define subjectBTtoMQTThum "/hum"
-#define subjectBTtoMQTTmoi "/moi"
-#define subjectBTtoMQTTfer "/fer"
-#define subjectBTtoMQTTlux "/lux"
-#define subjectBTtoMQTTbatt "/batt"
-#define subjectBTtoMQTTservicedata "/servicedata"
#define TimeBtw_Read 55555 //define the time between 2 scans
#define Scan_duration 10 //define the time for a scan
#define HM-10
@@ -42,11 +33,9 @@
#define delimiter "4f4b2b444953413a"
#define delimiter_length 16
-/*-------------------HOME ASSISTANT ROOM PRESENCE !!! ESP32 only !!!!----------------------*/
-#define roomPresence //Uncomment to enable
-#ifdef roomPresence
- #define subjectHomePresence "/homePresence/salon" // will send Home Assistant room presence message to this topic (first part is same for all rooms, second is room name)
-#endif
+/*-------------------HOME ASSISTANT ROOM PRESENCE ----------------------*/
+// if not commented Home presence integration with HOME ASSISTANT is activated
+#define subjectHomePresence Base_Topic "/salon" // will send Home Assistant room presence message to this topic (first part is same for all rooms, second is room name)
struct decompose
diff --git a/config_DHT.h b/config_DHT.h
index c18aea70..7719482c 100644
--- a/config_DHT.h
+++ b/config_DHT.h
@@ -26,8 +26,7 @@
/*----------------------------USER PARAMETERS-----------------------------*/
/*-------------DEFINE YOUR MQTT PARAMETERS BELOW----------------*/
-#define HUM1 Base_Topic Gateway_Name "/DHTtoMQTT/dht1/hum"
-#define TEMP1 Base_Topic Gateway_Name "/DHTtoMQTT/dht1/temp"
+#define DHTTOPIC Base_Topic Gateway_Name "/DHTtoMQTT/dht1"
#define dht_always true // if false when the current value for temp or hum is the same as previous one don't send it by MQTT
#define TimeBetweenReadingDHT 30000 // time between 2 DHT readings
/*-------------DHT SENSOR TYPE-------------*/
diff --git a/config_HCSR501.h b/config_HCSR501.h
index b0c076b6..0d4d7262 100644
--- a/config_HCSR501.h
+++ b/config_HCSR501.h
@@ -27,11 +27,14 @@
/*----------------------------USER PARAMETERS-----------------------------*/
/*-------------DEFINE YOUR MQTT PARAMETERS BELOW----------------*/
#define subjectHCSR501toMQTT Base_Topic Gateway_Name "/HCSR501toMQTT"
+
#define TimeBeforeStartHCSR501 60000 //define the time necessary for HC SR501 init
/*-------------------PIN DEFINITIONS----------------------*/
-#if defined(ESP8266) || defined(ESP32)
+#if defined(ESP8266)
#define HCSR501_PIN D5
+#elif defined(ESP32)
+ #define HCSR501_PIN 5
#else
#define HCSR501_PIN 7
#endif
diff --git a/config_INA226.h b/config_INA226.h
index b5e4ac2f..e0eae989 100644
--- a/config_INA226.h
+++ b/config_INA226.h
@@ -26,9 +26,5 @@
/*----------------------------USER PARAMETERS-----------------------------*/
/*-------------DEFINE YOUR MQTT PARAMETERS BELOW----------------*/
-#define subjectVolttoMQTT Base_Topic Gateway_Name "/INA226toMQTT/Volt"
-#define subjectCurrenttoMQTT Base_Topic Gateway_Name "/INA226toMQTT/Current"
-#define subjectPowertoMQTT Base_Topic Gateway_Name "/INA226toMQTT/Power"
+#define subjectINA226toMQTT Base_Topic Gateway_Name "/INA226toMQTT"
#define TimeBetweenReadingINA226 30000 // time between 2 INA226 readings
-
-
diff --git a/config_IR.h b/config_IR.h
index 2b838e83..7470a589 100644
--- a/config_IR.h
+++ b/config_IR.h
@@ -29,14 +29,13 @@
#define subjectGTWIRtoMQTT Base_Topic Gateway_Name "/IRtoMQTT"
#define subjectIRtoMQTT Base_Topic Gateway_Name "/IRtoMQTT"
#define subjectMQTTtoIR Base_Topic Gateway_Name "/commands/MQTTtoIR"
-#define subjectIRtoMQTTprotocol Base_Topic Gateway_Name "/IRtoMQTT/protocol"
-#define subjectIRtoMQTTbits Base_Topic Gateway_Name "/IRtoMQTT/bits"
-#define subjectIRtoMQTTRaw Base_Topic Gateway_Name "/IRtoMQTT/raw"
+
// subject monitored to listen traffic processed by other gateways to store data and avoid ntuple
#define subjectMultiGTWIR "+/+/IRtoMQTT"
#define IRbitsKey "IRBITS_" // bits will be defined if a subject contains IRbitsKey followed by a value of 2 digits
#define IRRptKey "RPT_" // repeats will be defined if a subject contains IRRptKey followed by a value of 1 digit
#define repeatIRwMQTT false // do we repeat a received signal by using mqtt
+#define repeatIRwNumber 3 // default repeat of the signal
#define RawDirectForward false // direct repeat of IR signal with raw data
#define RawFrequency 38 // raw frequency sending
//#define DumpMode true // uncomment so as to see big dumps of IR codes
diff --git a/config_RF.h b/config_RF.h
index 6c4a2d30..3ef92da9 100644
--- a/config_RF.h
+++ b/config_RF.h
@@ -29,12 +29,10 @@
#define subjectMQTTtoRF Base_Topic Gateway_Name "/commands/MQTTto433"
#define subjectRFtoMQTT Base_Topic Gateway_Name "/433toMQTT"
#define subjectGTWRFtoMQTT Base_Topic Gateway_Name "/433toMQTT"
-#define subjectRFtoMQTTprotocol Base_Topic Gateway_Name "/433toMQTT/protocol"
-#define subjectRFtoMQTTbits Base_Topic Gateway_Name "/433toMQTT/bits"
-#define subjectRFtoMQTTlength Base_Topic Gateway_Name "/433toMQTT/length"
#define RFprotocolKey "433_" // protocol will be defined if a subject contains RFprotocolKey followed by a value of 1 digit
#define RFbitsKey "RFBITS_" // bits will be defined if a subject contains RFbitsKey followed by a value of 2 digits
-#define repeatRFwMQTT false // do we repeat a received signal by using mqtt
+#define repeatRFwMQTT false // do we repeat a received signal by using mqtt with RF gateway
+#define repeatSRFBwMQTT false // do we repeat a received signal by using mqtt with Sonoff RF Bridge
/*
RF supported protocols
433_1
@@ -54,6 +52,7 @@ RF supported protocols
//433Mhz newremoteswitch MQTT Subjects and keys
#define subjectMQTTtoRF2 Base_Topic Gateway_Name "/commands/MQTTtoRF2"
#define subjectRF2toMQTT Base_Topic Gateway_Name "/RF2toMQTT"
+#define subjectGTWRF2toMQTT Base_Topic Gateway_Name "/433toMQTT"
#define RF2codeKey "CODE_" // code will be defined if a subject contains RF2codeKey followed by a value of 7 digits
#define RF2periodKey "PERIOD_" // period will be defined if a subject contains RF2periodKey followed by a value of 3 digits
#define RF2unitKey "UNIT_" // number of your unit value will be defined if a subject contains RF2unitKey followed by a value of 1-2 digits
@@ -64,12 +63,13 @@ RF supported protocols
//433Mhz Pilight MQTT Subjects and keys
#define subjectMQTTtoPilight Base_Topic Gateway_Name "/commands/MQTTtoPilight"
#define subjectPilighttoMQTT Base_Topic Gateway_Name "/PilighttoMQTT"
+#define subjectGTWPilighttoMQTT Base_Topic Gateway_Name "/PilighttoMQTT"
#define PilightRAW "RAW"
/*-------------------PIN DEFINITIONS----------------------*/
#ifdef ESP8266
#define RF_RECEIVER_PIN 0 // D3 on nodemcu
- #define RF_EMITTER_PIN 3 // RX on nodemcu
+ #define RF_EMITTER_PIN 4 // RX on nodemcu if it doesn't work with 3, try with 4 (D2)
#elif defined(ESP32)
#define RF_RECEIVER_PIN 13 // D13 on DOIT ESP32
#define RF_EMITTER_PIN 12 // D12 on DOIT ESP32
diff --git a/config_RF315.h b/config_RF315.h
index 3d48b0ec..316a9868 100644
--- a/config_RF315.h
+++ b/config_RF315.h
@@ -29,9 +29,6 @@
#define subjectMQTTtoRF315 Base_Topic Gateway_Name "/commands/MQTTto315"
#define subjectRF315toMQTT Base_Topic Gateway_Name "/315toMQTT"
#define subjectGTWRF315toMQTT Base_Topic Gateway_Name "/315toMQTT"
-#define subjectRF315toMQTTprotocol Base_Topic Gateway_Name "/315toMQTT/protocol"
-#define subjectRF315toMQTTbits Base_Topic Gateway_Name "/315toMQTT/bits"
-#define subjectRF315toMQTTlength Base_Topic Gateway_Name "/315toMQTT/length"
#define RF315protocolKey "315_" // protocol will be defined if a subject contains RFprotocolKey followed by a value of 1 digit
#define RF315bitsKey "RFBITS_" // bits will be defined if a subject contains RFbitsKey followed by a value of 2 digits
#define repeatRF315wMQTT false // do we repeat a received signal by using mqtt
@@ -63,4 +60,3 @@ RF supported protocols
#define RF315_RECEIVER_PIN 1 //1 = D3 on arduino
#define RF315_EMITTER_PIN 4 //4 = D4 on arduino
#endif
-
diff --git a/config_RFM69.h b/config_RFM69.h
index c19520f1..2adeb3b4 100644
--- a/config_RFM69.h
+++ b/config_RFM69.h
@@ -28,10 +28,7 @@
// Topic where the message from RFM69 will be published by the gateway,
// appended with the nodeID of the sender
#define subjectRFM69toMQTT Base_Topic Gateway_Name "/RFM69toMQTT"
-// Upon reception of a packed, the RSSI of that packet will be publish to this topic,
-// appended with the nodeID of the sender
-#define subjectRFM69toMQTTrssi Base_Topic Gateway_Name "/RFM69toMQTT/rssi" // Comment this if you don't want the RSSI to be published.
-#define subjectRFM69toMQTTsender Base_Topic Gateway_Name "/RFM69toMQTT/sender"
+
// Topic subscribed by the gateway. Messages received will be sent to RFM69
#define subjectMQTTtoRFM69 Base_Topic Gateway_Name "/commands/MQTTtoRFM69"
#define RFM69receiverKey "RCV_" // receiver id will be defined if a subject contains RFM69receiverKey followed by a value of 3 digits
@@ -55,11 +52,16 @@ const char PROGMEM RFM69AP_NAME[] = "RFM69-AP";
#define POWER_LEVEL 31
/*-------------------PIN DEFINITIONS----------------------*/
-#if defined(ESP8266) || defined(ESP32)
+#if defined(ESP8266)
#define RFM69_CS D1
#define RFM69_IRQ D8 // GPIO15/D8
#define RFM69_IRQN digitalPinToInterrupt(RFM69_IRQ)
#define RFM69_RST D4 // GPIO02/D4
+#elif defined(ESP32)
+ #define RFM69_CS 1
+ #define RFM69_IRQ 8 // GPIO15/D8
+ #define RFM69_IRQN digitalPinToInterrupt(RFM69_IRQ)
+ #define RFM69_RST 4 // GPIO02/D4
#else
//RFM69 not tested with arduino
#define RFM69_CS 10
diff --git a/config_SRFB.h b/config_SRFB.h
index e20f427f..227762b8 100644
--- a/config_SRFB.h
+++ b/config_SRFB.h
@@ -29,12 +29,8 @@
//433Mhz MQTT Subjects and keys
#define subjectMQTTtoSRFB Base_Topic Gateway_Name "/commands/MQTTtoSRFB"
#define subjectMQTTtoSRFBRaw Base_Topic Gateway_Name "/commands/MQTTtoSRFB/Raw"
-#define subjectSRFBtoMQTTTsyn Base_Topic Gateway_Name "/SRFBtoMQTT/Tsyn"
-#define subjectSRFBtoMQTTTlow Base_Topic Gateway_Name "/SRFBtoMQTT/Tlow"
-#define subjectSRFBtoMQTTThigh Base_Topic Gateway_Name "/SRFBtoMQTT/Thigh"
#define subjectSRFBtoMQTT Base_Topic Gateway_Name "/SRFBtoMQTT"
#define subjectGTWSRFBtoMQTT Base_Topic Gateway_Name "/SRFBtoMQTT"
-#define subjectSRFBtoMQTTRaw Base_Topic Gateway_Name "/SRFBtoMQTT/Raw"
#define SRFBRptKey "RPT_"
#define SRFBmaxipulselengthKey "Thigh_"
#define SRFBminipulselengthKey "Tlow_"
@@ -57,6 +53,3 @@
#define RF_CODE_RFIN 0xA4
#define RF_CODE_RFOUT 0xA5
#define RF_CODE_STOP 0x55
-
-
-
diff --git a/config_TSL2561.h b/config_TSL2561.h
index 44a7aa60..557dc170 100644
--- a/config_TSL2561.h
+++ b/config_TSL2561.h
@@ -40,9 +40,7 @@
#define TimeBetweenReadingtsl2561 30000
/*----------------------------USER PARAMETERS-----------------------------*/
/*-------------DEFINE YOUR MQTT PARAMETERS BELOW----------------*/
-#define LUX Base_Topic Gateway_Name "/LIGHTtoMQTT/lux"
-#define FTCD Base_Topic Gateway_Name "/LIGHTtoMQTT/ftcd"
-#define WATTSM2 Base_Topic Gateway_Name "/LIGHTtoMQTT/wattsm2"
+#define subjectTSL12561toMQTT Base_Topic Gateway_Name "/LIGHTtoMQTT"
//Time used to wait for an interval before resending measured values
unsigned long timetsl2561 = 0;
diff --git a/lib/Adafruit_TSL2561/.github/ISSUE_TEMPLATE.md b/lib/Adafruit_TSL2561/.github/ISSUE_TEMPLATE.md
new file mode 100644
index 00000000..f0e26146
--- /dev/null
+++ b/lib/Adafruit_TSL2561/.github/ISSUE_TEMPLATE.md
@@ -0,0 +1,46 @@
+Thank you for opening an issue on an Adafruit Arduino library repository. To
+improve the speed of resolution please review the following guidelines and
+common troubleshooting steps below before creating the issue:
+
+- **Do not use GitHub issues for troubleshooting projects and issues.** Instead use
+ the forums at http://forums.adafruit.com to ask questions and troubleshoot why
+ something isn't working as expected. In many cases the problem is a common issue
+ that you will more quickly receive help from the forum community. GitHub issues
+ are meant for known defects in the code. If you don't know if there is a defect
+ in the code then start with troubleshooting on the forum first.
+
+- **If following a tutorial or guide be sure you didn't miss a step.** Carefully
+ check all of the steps and commands to run have been followed. Consult the
+ forum if you're unsure or have questions about steps in a guide/tutorial.
+
+- **For Arduino projects check these very common issues to ensure they don't apply**:
+
+ - For uploading sketches or communicating with the board make sure you're using
+ a **USB data cable** and **not** a **USB charge-only cable**. It is sometimes
+ very hard to tell the difference between a data and charge cable! Try using the
+ cable with other devices or swapping to another cable to confirm it is not
+ the problem.
+
+ - **Be sure you are supplying adequate power to the board.** Check the specs of
+ your board and plug in an external power supply. In many cases just
+ plugging a board into your computer is not enough to power it and other
+ peripherals.
+
+ - **Double check all soldering joints and connections.** Flakey connections
+ cause many mysterious problems. See the [guide to excellent soldering](https://learn.adafruit.com/adafruit-guide-excellent-soldering/tools) for examples of good solder joints.
+
+ - **Ensure you are using an official Arduino or Adafruit board.** We can't
+ guarantee a clone board will have the same functionality and work as expected
+ with this code and don't support them.
+
+If you're sure this issue is a defect in the code and checked the steps above
+please fill in the following fields to provide enough troubleshooting information.
+You may delete the guideline and text above to just leave the following details:
+
+- Arduino board: **INSERT ARDUINO BOARD NAME/TYPE HERE**
+
+- Arduino IDE version (found in Arduino -> About Arduino menu): **INSERT ARDUINO
+ VERSION HERE**
+
+- List the steps to reproduce the problem below (if possible attach a sketch or
+ copy the sketch code in too): **LIST REPRO STEPS BELOW**
diff --git a/lib/Adafruit_TSL2561/.github/PULL_REQUEST_TEMPLATE.md b/lib/Adafruit_TSL2561/.github/PULL_REQUEST_TEMPLATE.md
new file mode 100644
index 00000000..7b641eb8
--- /dev/null
+++ b/lib/Adafruit_TSL2561/.github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,26 @@
+Thank you for creating a pull request to contribute to Adafruit's GitHub code!
+Before you open the request please review the following guidelines and tips to
+help it be more easily integrated:
+
+- **Describe the scope of your change--i.e. what the change does and what parts
+ of the code were modified.** This will help us understand any risks of integrating
+ the code.
+
+- **Describe any known limitations with your change.** For example if the change
+ doesn't apply to a supported platform of the library please mention it.
+
+- **Please run any tests or examples that can exercise your modified code.** We
+ strive to not break users of the code and running tests/examples helps with this
+ process.
+
+Thank you again for contributing! We will try to test and integrate the change
+as soon as we can, but be aware we have many GitHub repositories to manage and
+can't immediately respond to every request. There is no need to bump or check in
+on a pull request (it will clutter the discussion of the request).
+
+Also don't be worried if the request is closed or not integrated--sometimes the
+priorities of Adafruit's GitHub code (education, ease of use) might not match the
+priorities of the pull request. Don't fret, the open source community thrives on
+forks and GitHub makes it easy to keep your changes in a forked repo.
+
+After reviewing the guidelines above you can delete this text from the pull request.
diff --git a/lib/Adafruit_TSL2561/.travis.yml b/lib/Adafruit_TSL2561/.travis.yml
new file mode 100644
index 00000000..a22fcb56
--- /dev/null
+++ b/lib/Adafruit_TSL2561/.travis.yml
@@ -0,0 +1,27 @@
+language: c
+sudo: false
+
+# Blacklist
+branches:
+ except:
+ - gh-pages
+
+env:
+ global:
+ - PRETTYNAME="Adafruit TSL2561 Arduino Library"
+# Optional, will default to "$TRAVIS_BUILD_DIR/Doxyfile"
+# - DOXYFILE: $TRAVIS_BUILD_DIR/Doxyfile
+
+before_install:
+ - source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/install.sh)
+
+install:
+ - arduino --install-library "Adafruit Unified Sensor"
+
+script:
+ - build_main_platforms
+
+# Generate and deploy documentation
+after_success:
+ - source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/library_check.sh)
+ - source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/doxy_gen_and_deploy.sh)
\ No newline at end of file
diff --git a/lib/Adafruit_TSL2561/Adafruit_TSL2561_U.cpp b/lib/Adafruit_TSL2561/Adafruit_TSL2561_U.cpp
index 0111ef64..69663fa9 100644
--- a/lib/Adafruit_TSL2561/Adafruit_TSL2561_U.cpp
+++ b/lib/Adafruit_TSL2561/Adafruit_TSL2561_U.cpp
@@ -1,179 +1,58 @@
-/**************************************************************************/
/*!
- @file Adafruit_TSL2561.cpp
- @author K.Townsend (Adafruit Industries)
- @license BSD (see license.txt)
-
- Driver for the TSL2561 digital luminosity (light) sensors.
-
- Pick one up at http://www.adafruit.com/products/439
-
- Adafruit invests time and resources providing this open source code,
- please support Adafruit and open-source hardware by purchasing
- products from Adafruit!
-
- @section HISTORY
-
- v2.0 - Rewrote driver for Adafruit_Sensor and Auto-Gain support, and
- added lux clipping check (returns 0 lux on sensor saturation)
- v1.0 - First release (previously TSL2561)
+ * @file Adafruit_TSL2561_U.cpp
+ *
+ * @mainpage Adafruit TSL2561 Light/Lux sensor driver
+ *
+ * @section intro_sec Introduction
+ *
+ * This is the documentation for Adafruit's TSL2561 driver for the
+ * Arduino platform. It is designed specifically to work with the
+ * Adafruit TSL2561 breakout: http://www.adafruit.com/products/439
+ *
+ * These sensors use I2C to communicate, 2 pins (SCL+SDA) are required
+ * to interface with the breakout.
+ *
+ * Adafruit invests time and resources providing this open source code,
+ * please support Adafruit and open-source hardware by purchasing
+ * products from Adafruit!
+ *
+ * @section dependencies Dependencies
+ *
+ * This library depends on
+ * Adafruit_Sensor being present on your system. Please make sure you have
+ * installed the latest version before using this library.
+ *
+ * @section author Author
+ *
+ * Written by Kevin "KTOWN" Townsend for Adafruit Industries.
+ *
+ * @section license License
+ *
+ * BSD license, all text here must be included in any redistribution.
+ *
+ * @section HISTORY
+ *
+ * v2.0 - Rewrote driver for Adafruit_Sensor and Auto-Gain support, and
+ * added lux clipping check (returns 0 lux on sensor saturation)
+ * v1.0 - First release (previously TSL2561)
*/
/**************************************************************************/
-#if defined(__AVR__)
-#include
-#include
-#else
-#include "pgmspace.h"
-#endif
-#include
#include "Adafruit_TSL2561_U.h"
-#define TSL2561_DELAY_INTTIME_13MS (15)
-#define TSL2561_DELAY_INTTIME_101MS (120)
-#define TSL2561_DELAY_INTTIME_402MS (450)
-
-/*========================================================================*/
-/* PRIVATE FUNCTIONS */
-/*========================================================================*/
-
-/**************************************************************************/
-/*!
- @brief Writes a register and an 8 bit value over I2C
-*/
-/**************************************************************************/
-void Adafruit_TSL2561_Unified::write8 (uint8_t reg, uint32_t value)
-{
- Wire.beginTransmission(_addr);
- #if ARDUINO >= 100
- Wire.write(reg);
- Wire.write(value & 0xFF);
- #else
- Wire.send(reg);
- Wire.send(value & 0xFF);
- #endif
- Wire.endTransmission();
-}
-
-/**************************************************************************/
-/*!
- @brief Reads an 8 bit value over I2C
-*/
-/**************************************************************************/
-uint8_t Adafruit_TSL2561_Unified::read8(uint8_t reg)
-{
- Wire.beginTransmission(_addr);
- #if ARDUINO >= 100
- Wire.write(reg);
- #else
- Wire.send(reg);
- #endif
- Wire.endTransmission();
-
- Wire.requestFrom(_addr, 1);
- #if ARDUINO >= 100
- return Wire.read();
- #else
- return Wire.receive();
- #endif
-}
-
-/**************************************************************************/
-/*!
- @brief Reads a 16 bit values over I2C
-*/
-/**************************************************************************/
-uint16_t Adafruit_TSL2561_Unified::read16(uint8_t reg)
-{
- uint16_t x; uint16_t t;
-
- Wire.beginTransmission(_addr);
- #if ARDUINO >= 100
- Wire.write(reg);
- #else
- Wire.send(reg);
- #endif
- Wire.endTransmission();
-
- Wire.requestFrom(_addr, 2);
- #if ARDUINO >= 100
- t = Wire.read();
- x = Wire.read();
- #else
- t = Wire.receive();
- x = Wire.receive();
- #endif
- x <<= 8;
- x |= t;
- return x;
-}
-
-/**************************************************************************/
-/*!
- Enables the device
-*/
-/**************************************************************************/
-void Adafruit_TSL2561_Unified::enable(void)
-{
- /* Enable the device by setting the control bit to 0x03 */
- write8(TSL2561_COMMAND_BIT | TSL2561_REGISTER_CONTROL, TSL2561_CONTROL_POWERON);
-}
-
-/**************************************************************************/
-/*!
- Disables the device (putting it in lower power sleep mode)
-*/
-/**************************************************************************/
-void Adafruit_TSL2561_Unified::disable(void)
-{
- /* Turn the device off to save power */
- write8(TSL2561_COMMAND_BIT | TSL2561_REGISTER_CONTROL, TSL2561_CONTROL_POWEROFF);
-}
-
-/**************************************************************************/
-/*!
- Private function to read luminosity on both channels
-*/
-/**************************************************************************/
-void Adafruit_TSL2561_Unified::getData (uint16_t *broadband, uint16_t *ir)
-{
- /* Enable the device by setting the control bit to 0x03 */
- enable();
-
- /* Wait x ms for ADC to complete */
- switch (_tsl2561IntegrationTime)
- {
- case TSL2561_INTEGRATIONTIME_13MS:
- delay(TSL2561_DELAY_INTTIME_13MS); // KTOWN: Was 14ms
- break;
- case TSL2561_INTEGRATIONTIME_101MS:
- delay(TSL2561_DELAY_INTTIME_101MS); // KTOWN: Was 102ms
- break;
- default:
- delay(TSL2561_DELAY_INTTIME_402MS); // KTOWN: Was 403ms
- break;
- }
-
- /* Reads a two byte value from channel 0 (visible + infrared) */
- *broadband = read16(TSL2561_COMMAND_BIT | TSL2561_WORD_BIT | TSL2561_REGISTER_CHAN0_LOW);
-
- /* Reads a two byte value from channel 1 (infrared) */
- *ir = read16(TSL2561_COMMAND_BIT | TSL2561_WORD_BIT | TSL2561_REGISTER_CHAN1_LOW);
-
- /* Turn the device off to save power */
- disable();
-}
-
/*========================================================================*/
/* CONSTRUCTORS */
/*========================================================================*/
/**************************************************************************/
/*!
- Constructor
+ @brief Constructor
+ @param addr The I2C address this chip can be found on, 0x29, 0x39 or 0x49
+ @param sensorID An optional ID that will be placed in sensor events to help
+ keep track if you have many sensors in use
*/
/**************************************************************************/
-Adafruit_TSL2561_Unified::Adafruit_TSL2561_Unified(uint8_t addr, int32_t sensorID)
+Adafruit_TSL2561_Unified::Adafruit_TSL2561_Unified(uint8_t addr, int32_t sensorID)
{
_addr = addr;
_tsl2561Initialised = false;
@@ -189,18 +68,46 @@ Adafruit_TSL2561_Unified::Adafruit_TSL2561_Unified(uint8_t addr, int32_t sensorI
/**************************************************************************/
/*!
- Initializes I2C and configures the sensor (call this function before
- doing anything else)
+ @brief Initializes I2C and configures the sensor with default Wire I2C
+ (call this function before doing anything else)
+ @returns True if sensor is found and initialized, false otherwise.
*/
/**************************************************************************/
-boolean Adafruit_TSL2561_Unified::begin(void)
+boolean Adafruit_TSL2561_Unified::begin()
{
- Wire.begin();
+ _i2c = &Wire;
+ _i2c->begin();
+ return init();
+}
+/**************************************************************************/
+/*!
+ @brief Initializes I2C and configures the sensor with provided I2C device
+ (call this function before doing anything else)
+ @param theWire A pointer to any I2C interface (e.g. &Wire1)
+ @returns True if sensor is found and initialized, false otherwise.
+*/
+/**************************************************************************/
+boolean Adafruit_TSL2561_Unified::begin(TwoWire *theWire)
+{
+ _i2c = theWire;
+ _i2c-> begin();
+ return init();
+}
+
+/**************************************************************************/
+/*!
+ @brief Initializes I2C connection and settings.
+ Attempts to determine if the sensor is contactable, then sets up a default
+ integration time and gain. Then powers down the chip.
+ @returns True if sensor is found and initialized, false otherwise.
+*/
+/**************************************************************************/
+boolean Adafruit_TSL2561_Unified::init()
+{
/* Make sure we're actually connected */
uint8_t x = read8(TSL2561_REGISTER_ID);
- if (!(x & 0x0A))
- {
+ if (x & 0xF0 != 0x10) { // ID code for TSL2561
return false;
}
_tsl2561Initialised = true;
@@ -214,11 +121,12 @@ boolean Adafruit_TSL2561_Unified::begin(void)
return true;
}
-
+
/**************************************************************************/
/*!
@brief Enables or disables the auto-gain settings when reading
data from the sensor
+ @param enable Set to true to enable, False to disable
*/
/**************************************************************************/
void Adafruit_TSL2561_Unified::enableAutoRange(bool enable)
@@ -228,7 +136,10 @@ void Adafruit_TSL2561_Unified::enableAutoRange(bool enable)
/**************************************************************************/
/*!
- Sets the integration time for the TSL2561
+ @brief Sets the integration time for the TSL2561. Higher time means
+ more light captured (better for low light conditions) but will
+ take longer to run readings.
+ @param time The amount of time we'd like to add up values
*/
/**************************************************************************/
void Adafruit_TSL2561_Unified::setIntegrationTime(tsl2561IntegrationTime_t time)
@@ -250,7 +161,8 @@ void Adafruit_TSL2561_Unified::setIntegrationTime(tsl2561IntegrationTime_t time)
/**************************************************************************/
/*!
- Adjusts the gain on the TSL2561 (adjusts the sensitivity to light)
+ @brief Adjusts the gain on the TSL2561 (adjusts the sensitivity to light)
+ @param gain The value we'd like to set the gain to
*/
/**************************************************************************/
void Adafruit_TSL2561_Unified::setGain(tsl2561Gain_t gain)
@@ -274,6 +186,10 @@ void Adafruit_TSL2561_Unified::setGain(tsl2561Gain_t gain)
/*!
@brief Gets the broadband (mixed lighting) and IR only values from
the TSL2561, adjusting gain if auto-gain is enabled
+ @param broadband Pointer to a uint16_t we will fill with a sensor
+ reading from the IR+visible light diode.
+ @param ir Pointer to a uint16_t we will fill with a sensor the
+ IR-only light diode.
*/
/**************************************************************************/
void Adafruit_TSL2561_Unified::getLuminosity (uint16_t *broadband, uint16_t *ir)
@@ -358,18 +274,87 @@ void Adafruit_TSL2561_Unified::getLuminosity (uint16_t *broadband, uint16_t *ir)
} while (!valid);
}
+
+
/**************************************************************************/
/*!
- Converts the raw sensor values to the standard SI lux equivalent.
- Returns 0 if the sensor is saturated and the values are unreliable.
+ Enables the device
+*/
+/**************************************************************************/
+void Adafruit_TSL2561_Unified::enable(void)
+{
+ /* Enable the device by setting the control bit to 0x03 */
+ write8(TSL2561_COMMAND_BIT | TSL2561_REGISTER_CONTROL, TSL2561_CONTROL_POWERON);
+}
+
+/**************************************************************************/
+/*!
+ Disables the device (putting it in lower power sleep mode)
+*/
+/**************************************************************************/
+void Adafruit_TSL2561_Unified::disable(void)
+{
+ /* Turn the device off to save power */
+ write8(TSL2561_COMMAND_BIT | TSL2561_REGISTER_CONTROL, TSL2561_CONTROL_POWEROFF);
+}
+
+/**************************************************************************/
+/*!
+ Private function to read luminosity on both channels
+*/
+/**************************************************************************/
+void Adafruit_TSL2561_Unified::getData (uint16_t *broadband, uint16_t *ir)
+{
+ /* Enable the device by setting the control bit to 0x03 */
+ enable();
+
+ /* Wait x ms for ADC to complete */
+ switch (_tsl2561IntegrationTime)
+ {
+ case TSL2561_INTEGRATIONTIME_13MS:
+ delay(TSL2561_DELAY_INTTIME_13MS); // KTOWN: Was 14ms
+ break;
+ case TSL2561_INTEGRATIONTIME_101MS:
+ delay(TSL2561_DELAY_INTTIME_101MS); // KTOWN: Was 102ms
+ break;
+ default:
+ delay(TSL2561_DELAY_INTTIME_402MS); // KTOWN: Was 403ms
+ break;
+ }
+
+ /* Reads a two byte value from channel 0 (visible + infrared) */
+ *broadband = read16(TSL2561_COMMAND_BIT | TSL2561_WORD_BIT | TSL2561_REGISTER_CHAN0_LOW);
+
+ /* Reads a two byte value from channel 1 (infrared) */
+ *ir = read16(TSL2561_COMMAND_BIT | TSL2561_WORD_BIT | TSL2561_REGISTER_CHAN1_LOW);
+
+ /* Turn the device off to save power */
+ disable();
+}
+
+
+/**************************************************************************/
+/*!
+ @brief Converts the raw sensor values to the standard SI lux equivalent.
+ @param broadband The 16-bit sensor reading from the IR+visible light diode.
+ @param ir The 16-bit sensor reading from the IR-only light diode.
+ @returns The integer Lux value we calcuated.
+ Returns 0 if the sensor is saturated and the values are
+ unreliable, or 65536 if the sensor is saturated.
+*/
+/**************************************************************************/
+/**************************************************************************/
+/*!
+
+ Returns
*/
/**************************************************************************/
uint32_t Adafruit_TSL2561_Unified::calculateLux(uint16_t broadband, uint16_t ir)
{
unsigned long chScale;
unsigned long channel1;
- unsigned long channel0;
-
+ unsigned long channel0;
+
/* Make sure the sensor isn't saturated! */
uint16_t clipThreshold;
switch (_tsl2561IntegrationTime)
@@ -385,10 +370,10 @@ uint32_t Adafruit_TSL2561_Unified::calculateLux(uint16_t broadband, uint16_t ir)
break;
}
- /* Return 0 lux if the sensor is saturated */
+ /* Return 65536 lux if the sensor is saturated */
if ((broadband > clipThreshold) || (ir > clipThreshold))
{
- return 0;
+ return 65536;
}
/* Get the correct scale depending on the intergration time */
@@ -476,15 +461,19 @@ uint32_t Adafruit_TSL2561_Unified::calculateLux(uint16_t broadband, uint16_t ir)
/**************************************************************************/
/*!
@brief Gets the most recent sensor event
+ @param event Pointer to a sensor_event_t type that will be filled
+ with the lux value, timestamp, data type and sensor ID.
+ @returns True if sensor reading is between 0 and 65535 lux,
+ false if sensor is saturated
*/
/**************************************************************************/
bool Adafruit_TSL2561_Unified::getEvent(sensors_event_t *event)
{
uint16_t broadband, ir;
-
+
/* Clear the event */
memset(event, 0, sizeof(sensors_event_t));
-
+
event->version = sizeof(sensors_event_t);
event->sensor_id = _tsl2561SensorID;
event->type = SENSOR_TYPE_LIGHT;
@@ -493,13 +482,18 @@ bool Adafruit_TSL2561_Unified::getEvent(sensors_event_t *event)
/* Calculate the actual lux value */
getLuminosity(&broadband, &ir);
event->light = calculateLux(broadband, ir);
-
+
+ if (event->light == 65536) {
+ return false;
+ }
return true;
}
/**************************************************************************/
/*!
@brief Gets the sensor_t data
+ @param sensor A pointer to a sensor_t structure that we will fill with
+ details about the TSL2561 and its capabilities
*/
/**************************************************************************/
void Adafruit_TSL2561_Unified::getSensor(sensor_t *sensor)
@@ -515,6 +509,67 @@ void Adafruit_TSL2561_Unified::getSensor(sensor_t *sensor)
sensor->type = SENSOR_TYPE_LIGHT;
sensor->min_delay = 0;
sensor->max_value = 17000.0; /* Based on trial and error ... confirm! */
- sensor->min_value = 0.0;
+ sensor->min_value = 1.0;
sensor->resolution = 1.0;
}
+
+
+
+/*========================================================================*/
+/* PRIVATE FUNCTIONS */
+/*========================================================================*/
+
+/**************************************************************************/
+/*!
+ @brief Writes a register and an 8 bit value over I2C
+ @param reg I2C register to write the value to
+ @param value The 8-bit value we're writing to the register
+*/
+/**************************************************************************/
+void Adafruit_TSL2561_Unified::write8 (uint8_t reg, uint8_t value)
+{
+ _i2c->beginTransmission(_addr);
+ _i2c->write(reg);
+ _i2c->write(value);
+ _i2c->endTransmission();
+}
+
+/**************************************************************************/
+/*!
+ @brief Reads an 8 bit value over I2C
+ @param reg I2C register to read from
+ @returns 8-bit value containing single byte data read
+*/
+/**************************************************************************/
+uint8_t Adafruit_TSL2561_Unified::read8(uint8_t reg)
+{
+ _i2c->beginTransmission(_addr);
+ _i2c->write(reg);
+ _i2c->endTransmission();
+
+ _i2c->requestFrom(_addr, 1);
+ return _i2c-> read();
+}
+
+/**************************************************************************/
+/*!
+ @brief Reads a 16 bit values over I2C
+ @param reg I2C register to read from
+ @returns 16-bit value containing 2-byte data read
+*/
+/**************************************************************************/
+uint16_t Adafruit_TSL2561_Unified::read16(uint8_t reg)
+{
+ uint16_t x, t;
+
+ _i2c->beginTransmission(_addr);
+ _i2c->write(reg);
+ _i2c->endTransmission();
+
+ _i2c->requestFrom(_addr, 2);
+ t = _i2c->read();
+ x = _i2c->read();
+ x <<= 8;
+ x |= t;
+ return x;
+}
diff --git a/lib/Adafruit_TSL2561/Adafruit_TSL2561_U.h b/lib/Adafruit_TSL2561/Adafruit_TSL2561_U.h
index 48990e44..e1aa191f 100644
--- a/lib/Adafruit_TSL2561/Adafruit_TSL2561_U.h
+++ b/lib/Adafruit_TSL2561/Adafruit_TSL2561_U.h
@@ -1,158 +1,146 @@
-/**************************************************************************/
-/*!
- @file Adafruit_TSL2561.h
- @author K. Townsend (Adafruit Industries)
+/*!
+ * @file Adafruit_TSL2561_U.h
+ *
+ * This is part of Adafruit's FXOS8700 driver for the Arduino platform. It is
+ * designed specifically to work with the Adafruit FXOS8700 breakout:
+ * https://www.adafruit.com/products/3463
+ *
+ * These sensors use I2C to communicate, 2 pins (SCL+SDA) are required
+ * to interface with the breakout.
+ *
+ * Adafruit invests time and resources providing this open source code,
+ * please support Adafruit and open-source hardware by purchasing
+ * products from Adafruit!
+ *
+ * Written by Kevin "KTOWN" Townsend for Adafruit Industries.
+ *
+ * BSD license, all text here must be included in any redistribution.
+ *
+ */
- @section LICENSE
+#ifndef ADAFRUIT_TSL2561_H_
+#define ADAFRUIT_TSL2561_H_
- Software License Agreement (BSD License)
-
- Copyright (c) 2013, Adafruit Industries
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holders nor the
- names of its contributors may be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-/**************************************************************************/
-#ifndef _TSL2561_H_
-#define _TSL2561_H_
-
-#if ARDUINO >= 100
- #include
-#else
- #include
-#endif
+#include
#include
#include
-#define TSL2561_VISIBLE 2 // channel 0 - channel 1
-#define TSL2561_INFRARED 1 // channel 1
-#define TSL2561_FULLSPECTRUM 0 // channel 0
+#define TSL2561_VISIBLE 2 ///< channel 0 - channel 1
+#define TSL2561_INFRARED 1 ///< channel 1
+#define TSL2561_FULLSPECTRUM 0 ///< channel 0
// I2C address options
-#define TSL2561_ADDR_LOW (0x29)
-#define TSL2561_ADDR_FLOAT (0x39) // Default address (pin left floating)
-#define TSL2561_ADDR_HIGH (0x49)
+#define TSL2561_ADDR_LOW (0x29) ///< Default address (pin pulled low)
+#define TSL2561_ADDR_FLOAT (0x39) ///< Default address (pin left floating)
+#define TSL2561_ADDR_HIGH (0x49) ///< Default address (pin pulled high)
// Lux calculations differ slightly for CS package
-//#define TSL2561_PACKAGE_CS
-#define TSL2561_PACKAGE_T_FN_CL
+//#define TSL2561_PACKAGE_CS ///< Chip scale package
+#define TSL2561_PACKAGE_T_FN_CL ///< Dual Flat No-Lead package
-#define TSL2561_COMMAND_BIT (0x80) // Must be 1
-#define TSL2561_CLEAR_BIT (0x40) // Clears any pending interrupt (write 1 to clear)
-#define TSL2561_WORD_BIT (0x20) // 1 = read/write word (rather than byte)
-#define TSL2561_BLOCK_BIT (0x10) // 1 = using block read/write
+#define TSL2561_COMMAND_BIT (0x80) ///< Must be 1
+#define TSL2561_CLEAR_BIT (0x40) ///< Clears any pending interrupt (write 1 to clear)
+#define TSL2561_WORD_BIT (0x20) ///< 1 = read/write word (rather than byte)
+#define TSL2561_BLOCK_BIT (0x10) ///< 1 = using block read/write
-#define TSL2561_CONTROL_POWERON (0x03)
-#define TSL2561_CONTROL_POWEROFF (0x00)
+#define TSL2561_CONTROL_POWERON (0x03) ///< Control register setting to turn on
+#define TSL2561_CONTROL_POWEROFF (0x00) ///< Control register setting to turn off
-#define TSL2561_LUX_LUXSCALE (14) // Scale by 2^14
-#define TSL2561_LUX_RATIOSCALE (9) // Scale ratio by 2^9
-#define TSL2561_LUX_CHSCALE (10) // Scale channel values by 2^10
-#define TSL2561_LUX_CHSCALE_TINT0 (0x7517) // 322/11 * 2^TSL2561_LUX_CHSCALE
-#define TSL2561_LUX_CHSCALE_TINT1 (0x0FE7) // 322/81 * 2^TSL2561_LUX_CHSCALE
+#define TSL2561_LUX_LUXSCALE (14) ///< Scale by 2^14
+#define TSL2561_LUX_RATIOSCALE (9) ///< Scale ratio by 2^9
+#define TSL2561_LUX_CHSCALE (10) ///< Scale channel values by 2^10
+#define TSL2561_LUX_CHSCALE_TINT0 (0x7517) ///< 322/11 * 2^TSL2561_LUX_CHSCALE
+#define TSL2561_LUX_CHSCALE_TINT1 (0x0FE7) ///< 322/81 * 2^TSL2561_LUX_CHSCALE
// T, FN and CL package values
-#define TSL2561_LUX_K1T (0x0040) // 0.125 * 2^RATIO_SCALE
-#define TSL2561_LUX_B1T (0x01f2) // 0.0304 * 2^LUX_SCALE
-#define TSL2561_LUX_M1T (0x01be) // 0.0272 * 2^LUX_SCALE
-#define TSL2561_LUX_K2T (0x0080) // 0.250 * 2^RATIO_SCALE
-#define TSL2561_LUX_B2T (0x0214) // 0.0325 * 2^LUX_SCALE
-#define TSL2561_LUX_M2T (0x02d1) // 0.0440 * 2^LUX_SCALE
-#define TSL2561_LUX_K3T (0x00c0) // 0.375 * 2^RATIO_SCALE
-#define TSL2561_LUX_B3T (0x023f) // 0.0351 * 2^LUX_SCALE
-#define TSL2561_LUX_M3T (0x037b) // 0.0544 * 2^LUX_SCALE
-#define TSL2561_LUX_K4T (0x0100) // 0.50 * 2^RATIO_SCALE
-#define TSL2561_LUX_B4T (0x0270) // 0.0381 * 2^LUX_SCALE
-#define TSL2561_LUX_M4T (0x03fe) // 0.0624 * 2^LUX_SCALE
-#define TSL2561_LUX_K5T (0x0138) // 0.61 * 2^RATIO_SCALE
-#define TSL2561_LUX_B5T (0x016f) // 0.0224 * 2^LUX_SCALE
-#define TSL2561_LUX_M5T (0x01fc) // 0.0310 * 2^LUX_SCALE
-#define TSL2561_LUX_K6T (0x019a) // 0.80 * 2^RATIO_SCALE
-#define TSL2561_LUX_B6T (0x00d2) // 0.0128 * 2^LUX_SCALE
-#define TSL2561_LUX_M6T (0x00fb) // 0.0153 * 2^LUX_SCALE
-#define TSL2561_LUX_K7T (0x029a) // 1.3 * 2^RATIO_SCALE
-#define TSL2561_LUX_B7T (0x0018) // 0.00146 * 2^LUX_SCALE
-#define TSL2561_LUX_M7T (0x0012) // 0.00112 * 2^LUX_SCALE
-#define TSL2561_LUX_K8T (0x029a) // 1.3 * 2^RATIO_SCALE
-#define TSL2561_LUX_B8T (0x0000) // 0.000 * 2^LUX_SCALE
-#define TSL2561_LUX_M8T (0x0000) // 0.000 * 2^LUX_SCALE
+#define TSL2561_LUX_K1T (0x0040) ///< 0.125 * 2^RATIO_SCALE
+#define TSL2561_LUX_B1T (0x01f2) ///< 0.0304 * 2^LUX_SCALE
+#define TSL2561_LUX_M1T (0x01be) ///< 0.0272 * 2^LUX_SCALE
+#define TSL2561_LUX_K2T (0x0080) ///< 0.250 * 2^RATIO_SCALE
+#define TSL2561_LUX_B2T (0x0214) ///< 0.0325 * 2^LUX_SCALE
+#define TSL2561_LUX_M2T (0x02d1) ///< 0.0440 * 2^LUX_SCALE
+#define TSL2561_LUX_K3T (0x00c0) ///< 0.375 * 2^RATIO_SCALE
+#define TSL2561_LUX_B3T (0x023f) ///< 0.0351 * 2^LUX_SCALE
+#define TSL2561_LUX_M3T (0x037b) ///< 0.0544 * 2^LUX_SCALE
+#define TSL2561_LUX_K4T (0x0100) ///< 0.50 * 2^RATIO_SCALE
+#define TSL2561_LUX_B4T (0x0270) ///< 0.0381 * 2^LUX_SCALE
+#define TSL2561_LUX_M4T (0x03fe) ///< 0.0624 * 2^LUX_SCALE
+#define TSL2561_LUX_K5T (0x0138) ///< 0.61 * 2^RATIO_SCALE
+#define TSL2561_LUX_B5T (0x016f) ///< 0.0224 * 2^LUX_SCALE
+#define TSL2561_LUX_M5T (0x01fc) ///< 0.0310 * 2^LUX_SCALE
+#define TSL2561_LUX_K6T (0x019a) ///< 0.80 * 2^RATIO_SCALE
+#define TSL2561_LUX_B6T (0x00d2) ///< 0.0128 * 2^LUX_SCALE
+#define TSL2561_LUX_M6T (0x00fb) ///< 0.0153 * 2^LUX_SCALE
+#define TSL2561_LUX_K7T (0x029a) ///< 1.3 * 2^RATIO_SCALE
+#define TSL2561_LUX_B7T (0x0018) ///< 0.00146 * 2^LUX_SCALE
+#define TSL2561_LUX_M7T (0x0012) ///< 0.00112 * 2^LUX_SCALE
+#define TSL2561_LUX_K8T (0x029a) ///< 1.3 * 2^RATIO_SCALE
+#define TSL2561_LUX_B8T (0x0000) ///< 0.000 * 2^LUX_SCALE
+#define TSL2561_LUX_M8T (0x0000) ///< 0.000 * 2^LUX_SCALE
// CS package values
-#define TSL2561_LUX_K1C (0x0043) // 0.130 * 2^RATIO_SCALE
-#define TSL2561_LUX_B1C (0x0204) // 0.0315 * 2^LUX_SCALE
-#define TSL2561_LUX_M1C (0x01ad) // 0.0262 * 2^LUX_SCALE
-#define TSL2561_LUX_K2C (0x0085) // 0.260 * 2^RATIO_SCALE
-#define TSL2561_LUX_B2C (0x0228) // 0.0337 * 2^LUX_SCALE
-#define TSL2561_LUX_M2C (0x02c1) // 0.0430 * 2^LUX_SCALE
-#define TSL2561_LUX_K3C (0x00c8) // 0.390 * 2^RATIO_SCALE
-#define TSL2561_LUX_B3C (0x0253) // 0.0363 * 2^LUX_SCALE
-#define TSL2561_LUX_M3C (0x0363) // 0.0529 * 2^LUX_SCALE
-#define TSL2561_LUX_K4C (0x010a) // 0.520 * 2^RATIO_SCALE
-#define TSL2561_LUX_B4C (0x0282) // 0.0392 * 2^LUX_SCALE
-#define TSL2561_LUX_M4C (0x03df) // 0.0605 * 2^LUX_SCALE
-#define TSL2561_LUX_K5C (0x014d) // 0.65 * 2^RATIO_SCALE
-#define TSL2561_LUX_B5C (0x0177) // 0.0229 * 2^LUX_SCALE
-#define TSL2561_LUX_M5C (0x01dd) // 0.0291 * 2^LUX_SCALE
-#define TSL2561_LUX_K6C (0x019a) // 0.80 * 2^RATIO_SCALE
-#define TSL2561_LUX_B6C (0x0101) // 0.0157 * 2^LUX_SCALE
-#define TSL2561_LUX_M6C (0x0127) // 0.0180 * 2^LUX_SCALE
-#define TSL2561_LUX_K7C (0x029a) // 1.3 * 2^RATIO_SCALE
-#define TSL2561_LUX_B7C (0x0037) // 0.00338 * 2^LUX_SCALE
-#define TSL2561_LUX_M7C (0x002b) // 0.00260 * 2^LUX_SCALE
-#define TSL2561_LUX_K8C (0x029a) // 1.3 * 2^RATIO_SCALE
-#define TSL2561_LUX_B8C (0x0000) // 0.000 * 2^LUX_SCALE
-#define TSL2561_LUX_M8C (0x0000) // 0.000 * 2^LUX_SCALE
+#define TSL2561_LUX_K1C (0x0043) ///< 0.130 * 2^RATIO_SCALE
+#define TSL2561_LUX_B1C (0x0204) ///< 0.0315 * 2^LUX_SCALE
+#define TSL2561_LUX_M1C (0x01ad) ///< 0.0262 * 2^LUX_SCALE
+#define TSL2561_LUX_K2C (0x0085) ///< 0.260 * 2^RATIO_SCALE
+#define TSL2561_LUX_B2C (0x0228) ///< 0.0337 * 2^LUX_SCALE
+#define TSL2561_LUX_M2C (0x02c1) ///< 0.0430 * 2^LUX_SCALE
+#define TSL2561_LUX_K3C (0x00c8) ///< 0.390 * 2^RATIO_SCALE
+#define TSL2561_LUX_B3C (0x0253) ///< 0.0363 * 2^LUX_SCALE
+#define TSL2561_LUX_M3C (0x0363) ///< 0.0529 * 2^LUX_SCALE
+#define TSL2561_LUX_K4C (0x010a) ///< 0.520 * 2^RATIO_SCALE
+#define TSL2561_LUX_B4C (0x0282) ///< 0.0392 * 2^LUX_SCALE
+#define TSL2561_LUX_M4C (0x03df) ///< 0.0605 * 2^LUX_SCALE
+#define TSL2561_LUX_K5C (0x014d) ///< 0.65 * 2^RATIO_SCALE
+#define TSL2561_LUX_B5C (0x0177) ///< 0.0229 * 2^LUX_SCALE
+#define TSL2561_LUX_M5C (0x01dd) ///< 0.0291 * 2^LUX_SCALE
+#define TSL2561_LUX_K6C (0x019a) ///< 0.80 * 2^RATIO_SCALE
+#define TSL2561_LUX_B6C (0x0101) ///< 0.0157 * 2^LUX_SCALE
+#define TSL2561_LUX_M6C (0x0127) ///< 0.0180 * 2^LUX_SCALE
+#define TSL2561_LUX_K7C (0x029a) ///< 1.3 * 2^RATIO_SCALE
+#define TSL2561_LUX_B7C (0x0037) ///< 0.00338 * 2^LUX_SCALE
+#define TSL2561_LUX_M7C (0x002b) ///< 0.00260 * 2^LUX_SCALE
+#define TSL2561_LUX_K8C (0x029a) ///< 1.3 * 2^RATIO_SCALE
+#define TSL2561_LUX_B8C (0x0000) ///< 0.000 * 2^LUX_SCALE
+#define TSL2561_LUX_M8C (0x0000) ///< 0.000 * 2^LUX_SCALE
// Auto-gain thresholds
-#define TSL2561_AGC_THI_13MS (4850) // Max value at Ti 13ms = 5047
-#define TSL2561_AGC_TLO_13MS (100)
-#define TSL2561_AGC_THI_101MS (36000) // Max value at Ti 101ms = 37177
-#define TSL2561_AGC_TLO_101MS (200)
-#define TSL2561_AGC_THI_402MS (63000) // Max value at Ti 402ms = 65535
-#define TSL2561_AGC_TLO_402MS (500)
+#define TSL2561_AGC_THI_13MS (4850) ///< Max value at Ti 13ms = 5047
+#define TSL2561_AGC_TLO_13MS (100) ///< Min value at Ti 13ms = 100
+#define TSL2561_AGC_THI_101MS (36000) ///< Max value at Ti 101ms = 37177
+#define TSL2561_AGC_TLO_101MS (200) ///< Min value at Ti 101ms = 200
+#define TSL2561_AGC_THI_402MS (63000) ///< Max value at Ti 402ms = 65535
+#define TSL2561_AGC_TLO_402MS (500) ///< Min value at Ti 402ms = 500
// Clipping thresholds
-#define TSL2561_CLIPPING_13MS (4900)
-#define TSL2561_CLIPPING_101MS (37000)
-#define TSL2561_CLIPPING_402MS (65000)
+#define TSL2561_CLIPPING_13MS (4900) ///< # Counts that trigger a change in gain/integration
+#define TSL2561_CLIPPING_101MS (37000) ///< # Counts that trigger a change in gain/integration
+#define TSL2561_CLIPPING_402MS (65000) ///< # Counts that trigger a change in gain/integration
+// Delay for integration times
+#define TSL2561_DELAY_INTTIME_13MS (15) ///< Wait 15ms for 13ms integration
+#define TSL2561_DELAY_INTTIME_101MS (120) ///< Wait 120ms for 101ms integration
+#define TSL2561_DELAY_INTTIME_402MS (450) ///< Wait 450ms for 402ms integration
+
+/** TSL2561 I2C Registers */
enum
{
- TSL2561_REGISTER_CONTROL = 0x00,
- TSL2561_REGISTER_TIMING = 0x01,
- TSL2561_REGISTER_THRESHHOLDL_LOW = 0x02,
- TSL2561_REGISTER_THRESHHOLDL_HIGH = 0x03,
- TSL2561_REGISTER_THRESHHOLDH_LOW = 0x04,
- TSL2561_REGISTER_THRESHHOLDH_HIGH = 0x05,
- TSL2561_REGISTER_INTERRUPT = 0x06,
- TSL2561_REGISTER_CRC = 0x08,
- TSL2561_REGISTER_ID = 0x0A,
- TSL2561_REGISTER_CHAN0_LOW = 0x0C,
- TSL2561_REGISTER_CHAN0_HIGH = 0x0D,
- TSL2561_REGISTER_CHAN1_LOW = 0x0E,
- TSL2561_REGISTER_CHAN1_HIGH = 0x0F
+ TSL2561_REGISTER_CONTROL = 0x00, // Control/power register
+ TSL2561_REGISTER_TIMING = 0x01, // Set integration time register
+ TSL2561_REGISTER_THRESHHOLDL_LOW = 0x02, // Interrupt low threshold low-byte
+ TSL2561_REGISTER_THRESHHOLDL_HIGH = 0x03, // Interrupt low threshold high-byte
+ TSL2561_REGISTER_THRESHHOLDH_LOW = 0x04, // Interrupt high threshold low-byte
+ TSL2561_REGISTER_THRESHHOLDH_HIGH = 0x05, // Interrupt high threshold high-byte
+ TSL2561_REGISTER_INTERRUPT = 0x06, // Interrupt settings
+ TSL2561_REGISTER_CRC = 0x08, // Factory use only
+ TSL2561_REGISTER_ID = 0x0A, // TSL2561 identification setting
+ TSL2561_REGISTER_CHAN0_LOW = 0x0C, // Light data channel 0, low byte
+ TSL2561_REGISTER_CHAN0_HIGH = 0x0D, // Light data channel 0, high byte
+ TSL2561_REGISTER_CHAN1_LOW = 0x0E, // Light data channel 1, low byte
+ TSL2561_REGISTER_CHAN1_HIGH = 0x0F // Light data channel 1, high byte
};
+/** Three options for how long to integrate readings for */
typedef enum
{
TSL2561_INTEGRATIONTIME_13MS = 0x00, // 13.7ms
@@ -161,6 +149,7 @@ typedef enum
}
tsl2561IntegrationTime_t;
+/** TSL2561 offers 2 gain settings */
typedef enum
{
TSL2561_GAIN_1X = 0x00, // No gain
@@ -168,10 +157,19 @@ typedef enum
}
tsl2561Gain_t;
+
+
+/**************************************************************************/
+/*!
+ @brief Class that stores state and functions for interacting with TSL2561 Light Sensor
+*/
+/**************************************************************************/
class Adafruit_TSL2561_Unified : public Adafruit_Sensor {
public:
Adafruit_TSL2561_Unified(uint8_t addr, int32_t sensorID = -1);
boolean begin(void);
+ boolean begin(TwoWire *theWire);
+ boolean init();
/* TSL2561 Functions */
void enableAutoRange(bool enable);
@@ -185,6 +183,8 @@ class Adafruit_TSL2561_Unified : public Adafruit_Sensor {
void getSensor(sensor_t*);
private:
+ TwoWire *_i2c;
+
int8_t _addr;
boolean _tsl2561Initialised;
boolean _tsl2561AutoGain;
@@ -194,9 +194,10 @@ class Adafruit_TSL2561_Unified : public Adafruit_Sensor {
void enable (void);
void disable (void);
- void write8 (uint8_t reg, uint32_t value);
+ void write8 (uint8_t reg, uint8_t value);
uint8_t read8 (uint8_t reg);
uint16_t read16 (uint8_t reg);
void getData (uint16_t *broadband, uint16_t *ir);
};
-#endif
+
+#endif // ADAFRUIT_TSL2561_H
diff --git a/lib/Adafruit_TSL2561/README.md b/lib/Adafruit_TSL2561/README.md
index abd25c16..87dd30f4 100644
--- a/lib/Adafruit_TSL2561/README.md
+++ b/lib/Adafruit_TSL2561/README.md
@@ -1,7 +1,10 @@
-#Adafruit TSL2561 Light Sensor Driver #
+# Adafruit TSL2561 Light Sensor Driver [](https://travis-ci.org/adafruit/Adafruit_TSL2561)
This driver is for the Adafruit TSL2561 Breakout, and is based on Adafruit's Unified Sensor Library (Adafruit_Sensor).
+
+
+
The driver supports manual or 'auto' gain. Adjusting the gain allows you to make the sensor more or less 'sensitive' to light (depending on if you are indoors or outdoors, for example):
```
tsl.setGain(TSL2561_GAIN_1X); /* No gain ... use in bright light to avoid sensor saturation */
@@ -9,7 +12,7 @@ tsl.setGain(TSL2561_GAIN_16X); /* 16x gain ... use in low light to boost sen
tsl.enableAutoGain(true); /* Auto-gain ... switches automatically between 1x and 16x */
```
-The driver also supports as automatic clipping detection, and will return '0' lux when the sensor is saturated and data is unreliable.
+The driver also supports as automatic clipping detection, and will return '65536' lux when the sensor is saturated and data is unreliable. tsl.getEvent will return false in case of saturation and true in case of valid light data.
## About the TSL2561 ##
@@ -44,4 +47,4 @@ Light sensors will always report units in lux, gyroscopes will always report uni
Adafruit invests time and resources providing this open source code. Please support Adafruit and open-source hardware by purchasing products from Adafruit!
-Written by Kevin (KTOWN) Townsend for Adafruit Industries.
\ No newline at end of file
+Written by Kevin (KTOWN) Townsend for Adafruit Industries.
diff --git a/lib/Adafruit_TSL2561/examples/sensorapi/sensorapi.pde b/lib/Adafruit_TSL2561/examples/sensorapi/sensorapi.ino
similarity index 94%
rename from lib/Adafruit_TSL2561/examples/sensorapi/sensorapi.pde
rename to lib/Adafruit_TSL2561/examples/sensorapi/sensorapi.ino
index cacf9a7f..665d579e 100644
--- a/lib/Adafruit_TSL2561/examples/sensorapi/sensorapi.pde
+++ b/lib/Adafruit_TSL2561/examples/sensorapi/sensorapi.ino
@@ -16,9 +16,9 @@
Connections
===========
- Connect SCL to analog 5
- Connect SDA to analog 4
- Connect VDD to 3.3V DC
+ Connect SCL to I2C SCL Clock
+ Connect SDA to I2C SDA Data
+ Connect VDD to 3.3V or 5V (whatever your logic level is)
Connect GROUND to common ground
I2C Address
@@ -94,9 +94,11 @@ void setup(void)
Serial.println("Light Sensor Test"); Serial.println("");
/* Initialise the sensor */
+ //use tsl.begin() to default to Wire,
+ //tsl.begin(&Wire2) directs api to use Wire2, etc.
if(!tsl.begin())
{
- /* There was a problem detecting the ADXL345 ... check your connections */
+ /* There was a problem detecting the TSL2561 ... check your connections */
Serial.print("Ooops, no TSL2561 detected ... Check your wiring or I2C ADDR!");
while(1);
}
diff --git a/lib/Adafruit_TSL2561/library.properties b/lib/Adafruit_TSL2561/library.properties
index 45b50919..7656b9da 100644
--- a/lib/Adafruit_TSL2561/library.properties
+++ b/lib/Adafruit_TSL2561/library.properties
@@ -1,5 +1,5 @@
name=Adafruit TSL2561
-version=1.0.0
+version=1.0.2
author=Adafruit
maintainer=Adafruit
sentence=Unified sensor driver for Adafruit's TSL2561 breakouts
diff --git a/lib/Adafruit_TSL2561/pgmspace.h b/lib/Adafruit_TSL2561/pgmspace.h
deleted file mode 100644
index c4fb2e4d..00000000
--- a/lib/Adafruit_TSL2561/pgmspace.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/**************************************************************************/
-/*!
- @file pgmspace.h
- @author Mike Roberts
-
- @section LICENSE
-
- Software License Agreement (BSD License)
-
- Copyright (c) 2013, Mike Roberts
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holders nor the
- names of its contributors may be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-/**************************************************************************/
-
-#ifndef delorean_pgmspace_h
-#define delorean_pgmspace_h
-
-#include
-
-#define PROGMEM
-#define PGM_P const char *
-#define PSTR(str) (str)
-
-typedef void prog_void;
-typedef char prog_char;
-typedef unsigned char prog_uchar;
-typedef int8_t prog_int8_t;
-typedef uint8_t prog_uint8_t;
-typedef int16_t prog_int16_t;
-typedef uint16_t prog_uint16_t;
-typedef int32_t prog_int32_t;
-typedef uint32_t prog_uint32_t;
-
-#define strcpy_P(dest, src) strcpy((dest), (src))
-#define strcat_P(dest, src) strcat((dest), (src))
-#define strcmp_P(a, b) strcmp((a), (b))
-
-#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
-#define pgm_read_word(addr) (*(const unsigned short *)(addr))
-#define pgm_read_dword(addr) (*(const unsigned long *)(addr))
-#define pgm_read_float(addr) (*(const float *)(addr))
-
-#define pgm_read_byte_near(addr) pgm_read_byte(addr)
-#define pgm_read_word_near(addr) pgm_read_word(addr)
-#define pgm_read_dword_near(addr) pgm_read_dword(addr)
-#define pgm_read_float_near(addr) pgm_read_float(addr)
-#define pgm_read_byte_far(addr) pgm_read_byte(addr)
-#define pgm_read_word_far(addr) pgm_read_word(addr)
-#define pgm_read_dword_far(addr) pgm_read_dword(addr)
-#define pgm_read_float_far(addr) pgm_read_float(addr)
-
-#endif
diff --git a/lib/ArduinoJson/.clang-format b/lib/ArduinoJson/.clang-format
deleted file mode 100644
index 36809363..00000000
--- a/lib/ArduinoJson/.clang-format
+++ /dev/null
@@ -1,5 +0,0 @@
-# http://clang.llvm.org/docs/ClangFormatStyleOptions.html
-
-BasedOnStyle: Google
-Standard: Cpp03
-AllowShortFunctionsOnASingleLine: Empty
diff --git a/lib/ArduinoJson/.gitattributes b/lib/ArduinoJson/.gitattributes
deleted file mode 100644
index 526c8a38..00000000
--- a/lib/ArduinoJson/.gitattributes
+++ /dev/null
@@ -1 +0,0 @@
-*.sh text eol=lf
\ No newline at end of file
diff --git a/lib/ArduinoJson/.gitignore b/lib/ArduinoJson/.gitignore
deleted file mode 100644
index 567dc13b..00000000
--- a/lib/ArduinoJson/.gitignore
+++ /dev/null
@@ -1,11 +0,0 @@
-.DS_Store
-/.idea
-/build
-/bin
-/lib
-/sftp-config.json
-.tags
-.tags_sorted_by_file
-/fuzzing/*_fuzzer
-/fuzzing/*_fuzzer.options
-/fuzzing/*_fuzzer_seed_corpus.zip
diff --git a/lib/ArduinoJson/.mbedignore b/lib/ArduinoJson/.mbedignore
deleted file mode 100644
index b52329d1..00000000
--- a/lib/ArduinoJson/.mbedignore
+++ /dev/null
@@ -1,6 +0,0 @@
-.github/
-examples/
-fuzzing/
-scripts/
-test/
-third-party/
diff --git a/lib/ArduinoJson/.travis.yml b/lib/ArduinoJson/.travis.yml
deleted file mode 100644
index 9a9dddcd..00000000
--- a/lib/ArduinoJson/.travis.yml
+++ /dev/null
@@ -1,96 +0,0 @@
-sudo: false
-language: cpp
-matrix:
- include:
- - compiler: gcc
- addons:
- apt:
- sources: ['ubuntu-toolchain-r-test']
- packages: ['g++-4.4']
- env: SCRIPT=cmake GCC=4.4
- - compiler: gcc
- addons:
- apt:
- sources: ['ubuntu-toolchain-r-test']
- packages: ['g++-4.6']
- env: SCRIPT=cmake GCC=4.6
- - compiler: gcc
- addons:
- apt:
- sources: ['ubuntu-toolchain-r-test']
- packages: ['g++-4.7']
- env: SCRIPT=cmake GCC=4.7
- - compiler: gcc
- addons:
- apt:
- sources: ['ubuntu-toolchain-r-test']
- packages: ['g++-4.8']
- env: SCRIPT=cmake GCC=4.8 SANITIZE=address
- - compiler: gcc
- addons:
- apt:
- sources: ['ubuntu-toolchain-r-test']
- packages: ['g++-4.9']
- env: SCRIPT=cmake GCC=4.9 SANITIZE=leak
- - compiler: gcc
- addons:
- apt:
- sources: ['ubuntu-toolchain-r-test']
- packages: ['g++-5']
- env: SCRIPT=cmake GCC=5 SANITIZE=undefined
- - compiler: gcc
- addons:
- apt:
- sources: ['ubuntu-toolchain-r-test']
- packages: ['g++-6']
- env: SCRIPT=cmake GCC=6
- - compiler: gcc
- addons:
- apt:
- sources: ['ubuntu-toolchain-r-test']
- packages: ['g++-7']
- env: SCRIPT=cmake GCC=7
- - compiler: clang
- env: SCRIPT=cmake
- - compiler: clang
- addons:
- apt:
- sources: ['ubuntu-toolchain-r-test','llvm-toolchain-precise-3.5']
- packages: ['clang-3.5']
- env: SCRIPT=cmake CLANG=3.5 SANITIZE=address
- - compiler: clang
- addons:
- apt:
- sources: ['ubuntu-toolchain-r-test','llvm-toolchain-precise-3.6']
- packages: ['clang-3.6']
- env: SCRIPT=cmake CLANG=3.6 SANITIZE=leak
- - compiler: clang
- addons:
- apt:
- sources: ['ubuntu-toolchain-r-test','llvm-toolchain-precise-3.7']
- packages: ['clang-3.7']
- env: SCRIPT=cmake CLANG=3.7
- - compiler: clang
- addons:
- apt:
- sources: ['ubuntu-toolchain-r-test','llvm-toolchain-precise-3.8']
- packages: ['clang-3.8']
- env: SCRIPT=cmake CLANG=3.8 SANITIZE=undefined
- - compiler: gcc
- env: SCRIPT=coverage
- - os: osx
- osx_image: xcode6.4
- compiler: clang
- env: SCRIPT=cmake
- - os: osx
- osx_image: xcode7.3
- compiler: clang
- env: SCRIPT=cmake SANITIZE=address
- - env: SCRIPT=arduino VERSION=1.6.7 BOARD=arduino:avr:uno
- - env: SCRIPT=arduino VERSION=1.8.2 BOARD=arduino:avr:uno
- - env: SCRIPT=platformio BOARD=uno
- - env: SCRIPT=platformio BOARD=esp01
-cache:
- directories:
- - "~/.platformio"
-script: scripts/travis/$SCRIPT.sh
diff --git a/lib/ArduinoJson/CHANGELOG.md b/lib/ArduinoJson/CHANGELOG.md
index 1924bd24..dc5206f0 100644
--- a/lib/ArduinoJson/CHANGELOG.md
+++ b/lib/ArduinoJson/CHANGELOG.md
@@ -1,6 +1,21 @@
ArduinoJson: change log
=======================
+v5.13.3
+-------
+
+* Improved float serialization when `-fsingle-precision-constant` is used
+* Fixed `JsonVariant::is()` that returned true for empty strings
+* Fixed `JsonVariant::is()` (closes #763)
+
+v5.13.2
+-------
+
+* Fixed `JsonBuffer::parse()` not respecting nesting limit correctly (issue #693)
+* Fixed inconsistencies in nesting level counting (PR #695 from Zhenyu Wu)
+* Fixed null values that could be pass to `strcmp()` (PR #745 from Mike Karlesky)
+* Added macros `ARDUINOJSON_VERSION`, `ARDUINOJSON_VERSION_MAJOR`...
+
v5.13.1
-------
diff --git a/lib/ArduinoJson/CMakeLists.txt b/lib/ArduinoJson/CMakeLists.txt
deleted file mode 100644
index 66c565b5..00000000
--- a/lib/ArduinoJson/CMakeLists.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-# ArduinoJson - arduinojson.org
-# Copyright Benoit Blanchon 2014-2018
-# MIT License
-
-cmake_minimum_required(VERSION 3.0)
-project(ArduinoJson)
-
-enable_testing()
-
-if(${COVERAGE})
- set(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
-endif()
-
-include_directories(${CMAKE_CURRENT_LIST_DIR}/src)
-add_subdirectory(third-party/catch)
-add_subdirectory(test)
diff --git a/lib/ArduinoJson/CONTRIBUTING.md b/lib/ArduinoJson/CONTRIBUTING.md
deleted file mode 100644
index 5d4b96cf..00000000
--- a/lib/ArduinoJson/CONTRIBUTING.md
+++ /dev/null
@@ -1,11 +0,0 @@
-# Contribution to ArduinoJson
-
-First, thank you for taking the time to contribute to this project.
-
-You can submit changes via GitHub Pull Requests.
-
-Please:
-
-1. Unit test every change in behavior
-2. Use clang-format in "file" mode to format the code
-3. Consider using the Continuous Integration (Travis and AppVeyor)
diff --git a/lib/ArduinoJson/SUPPORT.md b/lib/ArduinoJson/SUPPORT.md
deleted file mode 100644
index c47e1b1b..00000000
--- a/lib/ArduinoJson/SUPPORT.md
+++ /dev/null
@@ -1,27 +0,0 @@
-# ArduinoJson Support
-
-First off, thank you very much for using ArduinoJson.
-
-We'll be very happy to help you, but first please read the following.
-
-## Before asking for help
-
-1. Read the [FAQ](https://arduinojson.org/faq/?utm_source=github&utm_medium=support)
-2. Search in the [API Reference](https://arduinojson.org/api/?utm_source=github&utm_medium=support)
-
-If you did not find the answer, please create a [new issue on GitHub](https://github.com/bblanchon/ArduinoJson/issues/new).
-
-It is OK to add a comment to a currently opened issue, but please avoid adding comments to a closed issue.
-
-## Before hitting the Submit button
-
-Please provide all the relevant information:
-
-* Good title
-* Short description of the problem
-* Target platform
-* Compiler model and version
-* [MVCE](https://stackoverflow.com/help/mcve)
-* Compiler output
-
-Good questions get fast answers!
diff --git a/lib/ArduinoJson/appveyor.yml b/lib/ArduinoJson/appveyor.yml
deleted file mode 100644
index f5d79b18..00000000
--- a/lib/ArduinoJson/appveyor.yml
+++ /dev/null
@@ -1,20 +0,0 @@
-version: 5.13.1.{build}
-environment:
- matrix:
- - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
- CMAKE_GENERATOR: Visual Studio 15 2017
- - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- CMAKE_GENERATOR: Visual Studio 14 2015
- - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
- CMAKE_GENERATOR: Visual Studio 12 2013
- - CMAKE_GENERATOR: Visual Studio 11 2012
- - CMAKE_GENERATOR: Visual Studio 10 2010
- - CMAKE_GENERATOR: MinGW Makefiles
-configuration: Debug
-before_build:
-- set PATH=C:\MinGW\bin;%PATH:C:\Program Files\Git\usr\bin;=% # Workaround for CMake not wanting sh.exe on PATH for MinGW
-- cmake -DCMAKE_BUILD_TYPE=%CONFIGURATION% -G "%CMAKE_GENERATOR%" .
-build_script:
-- cmake --build . --config %CONFIGURATION%
-test_script:
-- ctest --output-on-failure .
diff --git a/lib/ArduinoJson/banner.svg b/lib/ArduinoJson/banner.svg
deleted file mode 100644
index 51760962..00000000
--- a/lib/ArduinoJson/banner.svg
+++ /dev/null
@@ -1,367 +0,0 @@
-
-
-
-
diff --git a/lib/ArduinoJson/examples/JsonConfigFile/JsonConfigFile.ino b/lib/ArduinoJson/examples/JsonConfigFile/JsonConfigFile.ino
index ce6dca3e..2ccf7d67 100644
--- a/lib/ArduinoJson/examples/JsonConfigFile/JsonConfigFile.ino
+++ b/lib/ArduinoJson/examples/JsonConfigFile/JsonConfigFile.ino
@@ -133,12 +133,12 @@ void loop() {
// See also
// --------
//
-// The website arduinojson.org contains the documentation for all the functions
+// https://arduinojson.org/ contains the documentation for all the functions
// used above. It also includes an FAQ that will help you solve any
// serialization or deserialization problem.
-// Please check it out at: https://arduinojson.org/
//
// The book "Mastering ArduinoJson" contains a case study of a project that has
// a complex configuration with nested members.
// Contrary to this example, the project in the book uses the SPIFFS filesystem.
-// Please check it out at: https://arduinojson.org/book/
\ No newline at end of file
+// Learn more at https://arduinojson.org/book/
+// Use the coupon code TWENTY for a 20% discount ❤❤❤❤❤
diff --git a/lib/ArduinoJson/examples/JsonGeneratorExample/JsonGeneratorExample.ino b/lib/ArduinoJson/examples/JsonGeneratorExample/JsonGeneratorExample.ino
index d9efaba1..7b38227b 100644
--- a/lib/ArduinoJson/examples/JsonGeneratorExample/JsonGeneratorExample.ino
+++ b/lib/ArduinoJson/examples/JsonGeneratorExample/JsonGeneratorExample.ino
@@ -70,12 +70,12 @@ void loop() {
// See also
// --------
//
-// The website arduinojson.org contains the documentation for all the functions
+// https://arduinojson.org/ contains the documentation for all the functions
// used above. It also includes an FAQ that will help you solve any
// serialization problem.
-// Please check it out at: https://arduinojson.org/
//
// The book "Mastering ArduinoJson" contains a tutorial on serialization.
// It begins with a simple example, like the one above, and then adds more
// features like serializing directly to a file or an HTTP request.
-// Please check it out at: https://arduinojson.org/book/
\ No newline at end of file
+// Learn more at https://arduinojson.org/book/
+// Use the coupon code TWENTY for a 20% discount ❤❤❤❤❤
diff --git a/lib/ArduinoJson/examples/JsonHttpClient/JsonHttpClient.ino b/lib/ArduinoJson/examples/JsonHttpClient/JsonHttpClient.ino
index 6e5c05ef..4ce1c20d 100644
--- a/lib/ArduinoJson/examples/JsonHttpClient/JsonHttpClient.ino
+++ b/lib/ArduinoJson/examples/JsonHttpClient/JsonHttpClient.ino
@@ -100,13 +100,13 @@ void loop() {
// See also
// --------
//
-// The website arduinojson.org contains the documentation for all the functions
+// https://arduinojson.org/ contains the documentation for all the functions
// used above. It also includes an FAQ that will help you solve any
// serialization problem.
-// Please check it out at: https://arduinojson.org/
//
// The book "Mastering ArduinoJson" contains a tutorial on deserialization
// showing how to parse the response from Yahoo Weather. In the last chapter,
// it shows how to parse the huge documents from OpenWeatherMap
// and Weather Underground.
-// Please check it out at: https://arduinojson.org/book/
\ No newline at end of file
+// Learn more at https://arduinojson.org/book/
+// Use the coupon code TWENTY for a 20% discount ❤❤❤❤❤
diff --git a/lib/ArduinoJson/examples/JsonParserExample/JsonParserExample.ino b/lib/ArduinoJson/examples/JsonParserExample/JsonParserExample.ino
index 0c771ab0..6c16211b 100644
--- a/lib/ArduinoJson/examples/JsonParserExample/JsonParserExample.ino
+++ b/lib/ArduinoJson/examples/JsonParserExample/JsonParserExample.ino
@@ -67,12 +67,12 @@ void loop() {
// See also
// --------
//
-// The website arduinojson.org contains the documentation for all the functions
+// https://arduinojson.org/ contains the documentation for all the functions
// used above. It also includes an FAQ that will help you solve any
// deserialization problem.
-// Please check it out at: https://arduinojson.org/
//
// The book "Mastering ArduinoJson" contains a tutorial on deserialization.
// It begins with a simple example, like the one above, and then adds more
// features like deserializing directly from a file or an HTTP request.
-// Please check it out at: https://arduinojson.org/book/
\ No newline at end of file
+// Learn more at https://arduinojson.org/book/
+// Use the coupon code TWENTY for a 20% discount ❤❤❤❤❤
diff --git a/lib/ArduinoJson/examples/JsonServer/JsonServer.ino b/lib/ArduinoJson/examples/JsonServer/JsonServer.ino
index 229e289a..e693ae17 100644
--- a/lib/ArduinoJson/examples/JsonServer/JsonServer.ino
+++ b/lib/ArduinoJson/examples/JsonServer/JsonServer.ino
@@ -98,12 +98,12 @@ void loop() {
// See also
// --------
//
-// The website arduinojson.org contains the documentation for all the functions
+// https://arduinojson.org/ contains the documentation for all the functions
// used above. It also includes an FAQ that will help you solve any
// serialization problem.
-// Please check it out at: https://arduinojson.org/
//
// The book "Mastering ArduinoJson" contains a tutorial on serialization.
// It begins with a simple example, then adds more features like serializing
// directly to a file or an HTTP client.
-// Please check it out at: https://arduinojson.org/book/
\ No newline at end of file
+// Learn more at https://arduinojson.org/book/
+// Use the coupon code TWENTY for a 20% discount ❤❤❤❤❤
diff --git a/lib/ArduinoJson/examples/JsonUdpBeacon/JsonUdpBeacon.ino b/lib/ArduinoJson/examples/JsonUdpBeacon/JsonUdpBeacon.ino
index eb9f19a6..b2328a62 100644
--- a/lib/ArduinoJson/examples/JsonUdpBeacon/JsonUdpBeacon.ino
+++ b/lib/ArduinoJson/examples/JsonUdpBeacon/JsonUdpBeacon.ino
@@ -90,12 +90,12 @@ void loop() {
// See also
// --------
//
-// The website arduinojson.org contains the documentation for all the functions
+// https://arduinojson.org/ contains the documentation for all the functions
// used above. It also includes an FAQ that will help you solve any
// serialization problem.
-// Please check it out at: https://arduinojson.org/
//
// The book "Mastering ArduinoJson" contains a tutorial on serialization.
// It begins with a simple example, then adds more features like serializing
// directly to a file or any stream.
-// Please check it out at: https://arduinojson.org/book/
\ No newline at end of file
+// Learn more at https://arduinojson.org/book/
+// Use the coupon code TWENTY for a 20% discount ❤❤❤❤❤
diff --git a/lib/ArduinoJson/examples/ProgmemExample/ProgmemExample.ino b/lib/ArduinoJson/examples/ProgmemExample/ProgmemExample.ino
index 15be8ed1..ddde8fd1 100644
--- a/lib/ArduinoJson/examples/ProgmemExample/ProgmemExample.ino
+++ b/lib/ArduinoJson/examples/ProgmemExample/ProgmemExample.ino
@@ -59,12 +59,12 @@ void loop() {
// See also
// --------
//
-// The website arduinojson.org contains the documentation for all the functions
+// https://arduinojson.org/ contains the documentation for all the functions
// used above. It also includes an FAQ that will help you solve any memory
// problem.
-// Please check it out at: https://arduinojson.org/
//
// The book "Mastering ArduinoJson" contains a quick C++ course that explains
// how your microcontroller stores strings in memory. It also tells why you
// should not abuse Flash strings with ArduinoJson.
-// Please check it out at: https://arduinojson.org/book/
\ No newline at end of file
+// Learn more at https://arduinojson.org/book/
+// Use the coupon code TWENTY for a 20% discount ❤❤❤❤❤
diff --git a/lib/ArduinoJson/examples/StringExample/StringExample.ino b/lib/ArduinoJson/examples/StringExample/StringExample.ino
index d5994ffb..fc7503d0 100644
--- a/lib/ArduinoJson/examples/StringExample/StringExample.ino
+++ b/lib/ArduinoJson/examples/StringExample/StringExample.ino
@@ -64,11 +64,11 @@ void loop() {
// See also
// --------
//
-// The website arduinojson.org contains the documentation for all the functions
+// https://arduinojson.org/ contains the documentation for all the functions
// used above. It also includes an FAQ that will help you solve any problem.
-// Please check it out at: https://arduinojson.org/
//
// The book "Mastering ArduinoJson" contains a quick C++ course that explains
// how your microcontroller stores strings in memory. On several occasions, it
// shows how you can avoid String in your program.
-// Please check it out at: https://arduinojson.org/book/
\ No newline at end of file
+// Learn more at https://arduinojson.org/book/
+// Use the coupon code TWENTY for a 20% discount ❤❤❤❤❤
diff --git a/lib/ArduinoJson/fuzzing/Makefile b/lib/ArduinoJson/fuzzing/Makefile
deleted file mode 100644
index f3ed397f..00000000
--- a/lib/ArduinoJson/fuzzing/Makefile
+++ /dev/null
@@ -1,19 +0,0 @@
-# CAUTION: this file is invoked by https://github.com/google/oss-fuzz
-
-CXXFLAGS += -I../src
-
-all: \
- $(OUT)/json_fuzzer \
- $(OUT)/json_fuzzer_seed_corpus.zip \
- $(OUT)/json_fuzzer.options
-
-$(OUT)/json_fuzzer: fuzzer.cpp $(shell find ../src -type f)
- $(CXX) $(CXXFLAGS) $< -o$@ $(LIB_FUZZING_ENGINE)
-
-$(OUT)/json_fuzzer_seed_corpus.zip: seed_corpus/*
- zip -j $@ $?
-
-$(OUT)/json_fuzzer.options:
- @echo "[libfuzzer]" > $@
- @echo "max_len = 256" >> $@
- @echo "timeout = 10" >> $@
diff --git a/lib/ArduinoJson/fuzzing/fuzz.sh b/lib/ArduinoJson/fuzzing/fuzz.sh
deleted file mode 100644
index e9f28c39..00000000
--- a/lib/ArduinoJson/fuzzing/fuzz.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/bash
-# This script mimics an invocation from https://github.com/google/oss-fuzz
-
-cd $(dirname $0)
-export CXX='clang++'
-export CXXFLAGS='-fsanitize-coverage=trace-pc-guard -fsanitize=address'
-export LIB_FUZZING_ENGINE=-lFuzzer
-make OUT=.
-./json_fuzzer my_corpus seed_corpus -max_len=1024 -timeout=10
diff --git a/lib/ArduinoJson/fuzzing/fuzzer.cpp b/lib/ArduinoJson/fuzzing/fuzzer.cpp
deleted file mode 100644
index 24b2f191..00000000
--- a/lib/ArduinoJson/fuzzing/fuzzer.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-#include
-
-class memstream : public std::istream {
- struct membuf : std::streambuf {
- membuf(const uint8_t *p, size_t l) {
- setg((char *)p, (char *)p, (char *)p + l);
- }
- };
- membuf _buffer;
-
- public:
- memstream(const uint8_t *p, size_t l)
- : std::istream(&_buffer), _buffer(p, l) {
- rdbuf(&_buffer);
- }
-};
-
-extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
- DynamicJsonBuffer jsonBuffer;
- memstream json(data, size);
- JsonVariant variant = jsonBuffer.parse(json);
- if (variant.success()) {
- variant.as(); // <- serialize to JSON
- }
- return 0;
-}
diff --git a/lib/ArduinoJson/fuzzing/my_corpus/.gitignore b/lib/ArduinoJson/fuzzing/my_corpus/.gitignore
deleted file mode 100644
index d6b7ef32..00000000
--- a/lib/ArduinoJson/fuzzing/my_corpus/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-*
-!.gitignore
diff --git a/lib/ArduinoJson/fuzzing/seed_corpus/Comments.json b/lib/ArduinoJson/fuzzing/seed_corpus/Comments.json
deleted file mode 100644
index bcc4cece..00000000
--- a/lib/ArduinoJson/fuzzing/seed_corpus/Comments.json
+++ /dev/null
@@ -1,10 +0,0 @@
-//comment
-/*comment*/
-[ //comment
-/*comment*/"comment"/*comment*/,//comment
-/*comment*/{//comment
-/* comment*/"key"//comment
-: //comment
-"value"//comment
-}/*comment*/
-]//comment
\ No newline at end of file
diff --git a/lib/ArduinoJson/fuzzing/seed_corpus/EmptyArray.json b/lib/ArduinoJson/fuzzing/seed_corpus/EmptyArray.json
deleted file mode 100644
index 0637a088..00000000
--- a/lib/ArduinoJson/fuzzing/seed_corpus/EmptyArray.json
+++ /dev/null
@@ -1 +0,0 @@
-[]
\ No newline at end of file
diff --git a/lib/ArduinoJson/fuzzing/seed_corpus/EmptyObject.json b/lib/ArduinoJson/fuzzing/seed_corpus/EmptyObject.json
deleted file mode 100644
index 9e26dfee..00000000
--- a/lib/ArduinoJson/fuzzing/seed_corpus/EmptyObject.json
+++ /dev/null
@@ -1 +0,0 @@
-{}
\ No newline at end of file
diff --git a/lib/ArduinoJson/fuzzing/seed_corpus/ExcessiveNesting.json b/lib/ArduinoJson/fuzzing/seed_corpus/ExcessiveNesting.json
deleted file mode 100644
index 9285019a..00000000
--- a/lib/ArduinoJson/fuzzing/seed_corpus/ExcessiveNesting.json
+++ /dev/null
@@ -1 +0,0 @@
-[1,[2,[3,[4,[5,[6,[7,[8,[9,[10,[11,[12,[13,[14,[15,[16,[17,[18,[19,[20,[21,[22,[23,[24,[25,[26,[27,[28,[29,[30,[31,[32,[33,[34,[35,[36,[37,[38,[39,[40,[41,[42,[43,[44,[45,[46,[47,[48,[49,[50,[51,[52,[53,[54,[55,[56,[57,[58,[59,[60,[61,[62,[63,[64,[65,[66,[67,[68,[69,[70,[71,[72,[73,[74,[75,[76,[77,[78,[79,[80,[81,[82,[83,[84,[85,[86,[87,[88,[89,[90,[91,[92,[93,[94,[95,[96,[97,[98,[99,[100,[101,[102,[103,[104,[105,[106,[107,[108,[109,[110,[111,[112,[113,[114,[115,[116,[117,[118,[119,[120]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
\ No newline at end of file
diff --git a/lib/ArduinoJson/fuzzing/seed_corpus/Numbers.json b/lib/ArduinoJson/fuzzing/seed_corpus/Numbers.json
deleted file mode 100644
index f6b94194..00000000
--- a/lib/ArduinoJson/fuzzing/seed_corpus/Numbers.json
+++ /dev/null
@@ -1,24 +0,0 @@
-[
- 123,
- -123,
- 123.456,
- -123.456,
- 12e34,
- 12e-34,
- 12e+34,
- 12E34,
- 12E-34,
- 12E+34,
- 12.34e56,
- 12.34e-56,
- 12.34e+56,
- 12.34E56,
- 12.34E-56,
- 12.34E+56,
- NaN,
- -NaN,
- +NaN,
- Infinity,
- +Infinity,
- -Infinity
-]
\ No newline at end of file
diff --git a/lib/ArduinoJson/fuzzing/seed_corpus/OpenWeatherMap.json b/lib/ArduinoJson/fuzzing/seed_corpus/OpenWeatherMap.json
deleted file mode 100644
index 27d6bafd..00000000
--- a/lib/ArduinoJson/fuzzing/seed_corpus/OpenWeatherMap.json
+++ /dev/null
@@ -1,53 +0,0 @@
-{
- "coord": {
- "lon": -0.13,
- "lat": 51.51
- },
- "weather": [
- {
- "id": 301,
- "main": "Drizzle",
- "description": "drizzle",
- "icon": "09n"
- },
- {
- "id": 701,
- "main": "Mist",
- "description": "mist",
- "icon": "50n"
- },
- {
- "id": 741,
- "main": "Fog",
- "description": "fog",
- "icon": "50n"
- }
- ],
- "base": "stations",
- "main": {
- "temp": 281.87,
- "pressure": 1032,
- "humidity": 100,
- "temp_min": 281.15,
- "temp_max": 283.15
- },
- "visibility": 2900,
- "wind": {
- "speed": 1.5
- },
- "clouds": {
- "all": 90
- },
- "dt": 1483820400,
- "sys": {
- "type": 1,
- "id": 5091,
- "message": 0.0226,
- "country": "GB",
- "sunrise": 1483776245,
- "sunset": 1483805443
- },
- "id": 2643743,
- "name": "London",
- "cod": 200
-}
diff --git a/lib/ArduinoJson/fuzzing/seed_corpus/Strings.json b/lib/ArduinoJson/fuzzing/seed_corpus/Strings.json
deleted file mode 100644
index 3ffa235e..00000000
--- a/lib/ArduinoJson/fuzzing/seed_corpus/Strings.json
+++ /dev/null
@@ -1,8 +0,0 @@
-[
- "hello",
- 'hello',
- hello,
- {"hello":"world"},
- {'hello':'world'},
- {hello:world}
-]
\ No newline at end of file
diff --git a/lib/ArduinoJson/fuzzing/seed_corpus/WeatherUnderground.json b/lib/ArduinoJson/fuzzing/seed_corpus/WeatherUnderground.json
deleted file mode 100644
index d53ce006..00000000
--- a/lib/ArduinoJson/fuzzing/seed_corpus/WeatherUnderground.json
+++ /dev/null
@@ -1,90 +0,0 @@
-{
- "response": {
- "version": "0.1",
- "termsofService": "http://www.wunderground.com/weather/api/d/terms.html",
- "features": {
- "conditions": 1
- }
- },
- "current_observation": {
- "image": {
- "url": "http://icons-ak.wxug.com/graphics/wu2/logo_130x80.png",
- "title": "Weather Underground",
- "link": "http://www.wunderground.com"
- },
- "display_location": {
- "full": "San Francisco, CA",
- "city": "San Francisco",
- "state": "CA",
- "state_name": "California",
- "country": "US",
- "country_iso3166": "US",
- "zip": "94101",
- "latitude": "37.77500916",
- "longitude": "-122.41825867",
- "elevation": "47.00000000"
- },
- "observation_location": {
- "full": "SOMA - Near Van Ness, San Francisco, California",
- "city": "SOMA - Near Van Ness, San Francisco",
- "state": "California",
- "country": "US",
- "country_iso3166": "US",
- "latitude": "37.773285",
- "longitude": "-122.417725",
- "elevation": "49 ft"
- },
- "estimated": {},
- "station_id": "KCASANFR58",
- "observation_time": "Last Updated on June 27, 5:27 PM PDT",
- "observation_time_rfc822": "Wed, 27 Jun 2012 17:27:13 -0700",
- "observation_epoch": "1340843233",
- "local_time_rfc822": "Wed, 27 Jun 2012 17:27:14 -0700",
- "local_epoch": "1340843234",
- "local_tz_short": "PDT",
- "local_tz_long": "America/Los_Angeles",
- "local_tz_offset": "-0700",
- "weather": "Partly Cloudy",
- "temperature_string": "66.3 F (19.1 C)",
- "temp_f": 66.3,
- "temp_c": 19.1,
- "relative_humidity": "65%",
- "wind_string": "From the NNW at 22.0 MPH Gusting to 28.0 MPH",
- "wind_dir": "NNW",
- "wind_degrees": 346,
- "wind_mph": 22,
- "wind_gust_mph": "28.0",
- "wind_kph": 35.4,
- "wind_gust_kph": "45.1",
- "pressure_mb": "1013",
- "pressure_in": "29.93",
- "pressure_trend": "+",
- "dewpoint_string": "54 F (12 C)",
- "dewpoint_f": 54,
- "dewpoint_c": 12,
- "heat_index_string": "NA",
- "heat_index_f": "NA",
- "heat_index_c": "NA",
- "windchill_string": "NA",
- "windchill_f": "NA",
- "windchill_c": "NA",
- "feelslike_string": "66.3 F (19.1 C)",
- "feelslike_f": "66.3",
- "feelslike_c": "19.1",
- "visibility_mi": "10.0",
- "visibility_km": "16.1",
- "solarradiation": "",
- "UV": "5",
- "precip_1hr_string": "0.00 in ( 0 mm)",
- "precip_1hr_in": "0.00",
- "precip_1hr_metric": " 0",
- "precip_today_string": "0.00 in (0 mm)",
- "precip_today_in": "0.00",
- "precip_today_metric": "0",
- "icon": "partlycloudy",
- "icon_url": "http://icons-ak.wxug.com/i/c/k/partlycloudy.gif",
- "forecast_url": "http://www.wunderground.com/US/CA/San_Francisco.html",
- "history_url": "http://www.wunderground.com/history/airport/KCASANFR58/2012/6/27/DailyHistory.html",
- "ob_url": "http://www.wunderground.com/cgi-bin/findweather/getForecast?query=37.773285,-122.417725"
- }
-}
diff --git a/lib/ArduinoJson/library.json b/lib/ArduinoJson/library.json
deleted file mode 100644
index eb790b92..00000000
--- a/lib/ArduinoJson/library.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "name": "ArduinoJson",
- "keywords": "json, rest, http, web",
- "description": "An elegant and efficient JSON library for embedded systems",
- "homepage": "https://arduinojson.org/?utm_source=meta&utm_medium=library.json",
- "repository": {
- "type": "git",
- "url": "https://github.com/bblanchon/ArduinoJson.git"
- },
- "version": "5.13.1",
- "authors": {
- "name": "Benoit Blanchon",
- "url": "https://blog.benoitblanchon.fr"
- },
- "exclude": [
- "fuzzing",
- "scripts",
- "test",
- "third-party"
- ],
- "frameworks": "arduino",
- "platforms": "*"
-}
diff --git a/lib/ArduinoJson/library.properties b/lib/ArduinoJson/library.properties
index 97e2f03a..f9dd1dd1 100644
--- a/lib/ArduinoJson/library.properties
+++ b/lib/ArduinoJson/library.properties
@@ -1,5 +1,5 @@
name=ArduinoJson
-version=5.13.1
+version=5.13.3
author=Benoit Blanchon
maintainer=Benoit Blanchon
sentence=An efficient and elegant JSON library for Arduino.
diff --git a/lib/ArduinoJson/scripts/build-arduino-package.sh b/lib/ArduinoJson/scripts/build-arduino-package.sh
deleted file mode 100644
index 6976bcd3..00000000
--- a/lib/ArduinoJson/scripts/build-arduino-package.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/bash
-
-TAG=$(git describe)
-OUTPUT="ArduinoJson-$TAG.zip"
-
-cd $(dirname $0)/../..
-
-# remove existing file
-rm -f $OUTPUT
-
-# create zip
-7z a $OUTPUT \
- ArduinoJson/CHANGELOG.md \
- ArduinoJson/examples \
- ArduinoJson/src \
- ArduinoJson/keywords.txt \
- ArduinoJson/library.properties \
- ArduinoJson/LICENSE.md \
- ArduinoJson/README.md \
- ArduinoJson/ArduinoJson.h
diff --git a/lib/ArduinoJson/scripts/build-single-header.sh b/lib/ArduinoJson/scripts/build-single-header.sh
deleted file mode 100644
index b09e91f6..00000000
--- a/lib/ArduinoJson/scripts/build-single-header.sh
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/bin/bash
-
-TAG=$(git describe)
-RE_INCLUDE='^#include[[:space:]]*["<](.*)[">]'
-RE_EMPTY='^(#pragma[[:space:]]+once)?[[:space:]]*(//.*)?$'
-
-declare -A INCLUDED
-
-process()
-{
- local PARENT=$1
- local FOLDER=$(dirname $1)
- local SHOW_COMMENT=$2
- while IFS= read -r LINE; do
- if [[ $LINE =~ $RE_INCLUDE ]]; then
- local CHILD=${BASH_REMATCH[1]}
- pushd "$FOLDER" > /dev/null
- if [[ -e $CHILD ]]; then
- local CHILD_PATH=$(realpath $CHILD)
- if [[ ! ${INCLUDED[$CHILD_PATH]} ]]; then
- #echo "// $PARENT -> $CHILD"
- INCLUDED[$CHILD_PATH]=true
- process "$CHILD" false
- fi
- else
- if [[ ! ${INCLUDED[$CHILD]} ]]; then
- echo "$LINE"
- INCLUDED[$CHILD]=true
- fi
- fi
- popd > /dev/null
- elif [[ "${SHOW_COMMENT}" = "true" ]] ; then
- echo "$LINE"
- elif [[ ! $LINE =~ $RE_EMPTY ]]; then
- echo "$LINE"
- fi
- done < $PARENT
-}
-
-cd $(dirname $0)/../
-INCLUDED=()
-process src/ArduinoJson.h true > ../ArduinoJson-$TAG.h
-g++ -x c++ -c -o ../smoketest.o - < ../ArduinoJson-$TAG.hpp
-g++ -x c++ -c -o ../smoketest.o - < $OUTPUT
-
-cd $(dirname $(dirname $0))
-
-git tag | while read TAG
-do
-
- git checkout -q tags/$TAG
-
- DATE=$(git log -1 --date=short --pretty=format:%cd)
- PARSER_SIZE=$(arduino --verify examples/JsonParserExample/JsonParserExample.ino 2>/dev/null | grep -e 'Sketch uses' | sed 's/.*uses \([0-9]*\).\([0-9]\+\).*/\1\2/')
-
- if [ -e 'examples/JsonGeneratorExample/JsonGeneratorExample.ino' ]; then
- GENERATOR_SIZE=$(arduino --verify examples/JsonGeneratorExample/JsonGeneratorExample.ino 2>/dev/null | grep -e 'Sketch uses' | sed 's/.*uses \([0-9]*\).\([0-9]\+\).*/\1\2/')
- else
- GENERATOR_SIZE=""
- fi
-
- echo $TAG
- if [ ! -z "$PARSER_SIZE" ]
- then
- echo "JsonParserExample = $PARSER_SIZE bytes"
- else
- echo "JsonParserExample compilation failed."
- fi
-
- if [ ! -z "$GENERATOR_SIZE" ]
- then
- echo "JsonGeneratorExample = $GENERATOR_SIZE bytes"
- else
- echo "JsonGeneratorExample compilation failed."
- fi
-
- echo "$TAG;$DATE;$PARSER_SIZE;$GENERATOR_SIZE" >> $OUTPUT
-
-done
diff --git a/lib/ArduinoJson/scripts/oss-fuzz/.gitignore b/lib/ArduinoJson/scripts/oss-fuzz/.gitignore
deleted file mode 100644
index d50ee772..00000000
--- a/lib/ArduinoJson/scripts/oss-fuzz/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-/.vagrant/
-*.log
diff --git a/lib/ArduinoJson/scripts/oss-fuzz/Vagrantfile b/lib/ArduinoJson/scripts/oss-fuzz/Vagrantfile
deleted file mode 100644
index 252c191c..00000000
--- a/lib/ArduinoJson/scripts/oss-fuzz/Vagrantfile
+++ /dev/null
@@ -1,33 +0,0 @@
-# A virtual machine to run https://github.com/google/oss-fuzz
-Vagrant.configure(2) do |config|
- config.vm.box = "ubuntu/xenial64"
-
- config.vm.synced_folder "E:\\Git\\Arduino\\libraries\\ArduinoJson", "/host/ArduinoJson"
- config.vm.synced_folder "E:\\Git\\oss-fuzz", "/host/oss-fuzz"
-
- config.vm.network "forwarded_port", guest: 8001, host: 8001
-
- config.vm.provision "shell", privileged: false, inline: <<-SHELL
- set -x
-
- sudo apt-get update
- sudo apt-get install -y make git docker.io zip
- sudo groupadd docker
- sudo usermod -aG docker $USER
-
- git clone https://github.com/google/fuzzer-test-suite.git FTS
- ./FTS/tutorial/install-deps.sh # Get deps
- ./FTS/tutorial/install-clang.sh # Get fresh clang binaries
- # Get libFuzzer sources and build it
- svn co http://llvm.org/svn/llvm-project/llvm/trunk/lib/Fuzzer
- Fuzzer/build.sh
- sudo mv libFuzzer.a /usr/local/lib/
-
- echo "export PROJECT_NAME='arduinojson'" >> $HOME/.profile
- echo "export CC='clang'" >> $HOME/.profile
- echo "export CXX='clang++'" >> $HOME/.profile
- echo "export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/" >> $HOME/.profile
-
- echo "Run /host/ArduinoJson/fuzzing/fuzz.sh" | sudo tee /etc/motd
- SHELL
-end
diff --git a/lib/ArduinoJson/scripts/travis/arduino.sh b/lib/ArduinoJson/scripts/travis/arduino.sh
deleted file mode 100644
index 4de24c15..00000000
--- a/lib/ArduinoJson/scripts/travis/arduino.sh
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh -eux
-
-/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16
-sleep 3
-export DISPLAY=:1.0
-
-mkdir -p /tmp/arduino
-curl -sS http://downloads.arduino.cc/arduino-$VERSION-linux64.tar.xz | tar xJ -C /tmp/arduino --strip 1 ||
-curl -sS http://downloads.arduino.cc/arduino-$VERSION-linux64.tgz | tar xz -C /tmp/arduino --strip 1
-export PATH=$PATH:/tmp/arduino/
-
-ln -s $PWD /tmp/arduino/libraries/ArduinoJson
-
-for EXAMPLE in $PWD/examples/*/*.ino; do
- arduino --verify --board $BOARD $EXAMPLE
-done
diff --git a/lib/ArduinoJson/scripts/travis/cmake.sh b/lib/ArduinoJson/scripts/travis/cmake.sh
deleted file mode 100644
index 56691d9b..00000000
--- a/lib/ArduinoJson/scripts/travis/cmake.sh
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/bin/sh -ex
-
-if [ $(uname) = 'Darwin' ]; then
- URL=https://cmake.org/files/v3.4/cmake-3.4.3-Darwin-x86_64.tar.gz
- CMAKE=/tmp/CMake.app/Contents/bin/cmake
- CTEST=/tmp/CMake.app/Contents/bin/ctest
-else
- URL=https://cmake.org/files/v3.4/cmake-3.4.3-Linux-x86_64.tar.gz
- CMAKE=/tmp/bin/cmake
- CTEST=/tmp/bin/ctest
-fi
-curl -sS $URL | tar xz -C /tmp --strip 1
-
-if [ -n "$GCC" ]; then
- export CC="gcc-$GCC"
- export CXX="g++-$GCC"
-fi
-
-if [ -n "$CLANG" ]; then
- export CC="clang-$CLANG"
- export CXX="clang++-$CLANG"
-fi
-
-if [ -n "$SANITIZE" ]; then
- export CXXFLAGS="-fsanitize=$SANITIZE"
-fi
-
-$CMAKE .
-$CMAKE --build .
-$CTEST --output-on-failure .
diff --git a/lib/ArduinoJson/scripts/travis/coverage.sh b/lib/ArduinoJson/scripts/travis/coverage.sh
deleted file mode 100644
index 20de1e6a..00000000
--- a/lib/ArduinoJson/scripts/travis/coverage.sh
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/sh -eux
-
-curl https://cmake.org/files/v3.4/cmake-3.4.0-Linux-x86_64.tar.gz | tar xz -C /tmp --strip 1
-
-/tmp/bin/cmake -DCOVERAGE=true .
-make
-make test
-
-pip install --user cpp-coveralls 'requests[security]'
-coveralls --exclude third-party --gcov-options '\-lp'; fi
diff --git a/lib/ArduinoJson/scripts/travis/platformio.sh b/lib/ArduinoJson/scripts/travis/platformio.sh
deleted file mode 100644
index 4bb7a4c9..00000000
--- a/lib/ArduinoJson/scripts/travis/platformio.sh
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/sh -eux
-
-pip install --user platformio
-
-rm -r test
-
-for EXAMPLE in $PWD/examples/*/*.ino;
-do
- platformio ci $EXAMPLE -l '.' -b $BOARD
-done
diff --git a/lib/ArduinoJson/src/ArduinoJson.hpp b/lib/ArduinoJson/src/ArduinoJson.hpp
index 445a2c8a..c493c06a 100644
--- a/lib/ArduinoJson/src/ArduinoJson.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson.hpp
@@ -4,6 +4,8 @@
#pragma once
+#include "ArduinoJson/version.hpp"
+
#include "ArduinoJson/DynamicJsonBuffer.hpp"
#include "ArduinoJson/JsonArray.hpp"
#include "ArduinoJson/JsonObject.hpp"
diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/JsonParser.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/JsonParser.hpp
index c348e759..4cbaf454 100644
--- a/lib/ArduinoJson/src/ArduinoJson/Deserialization/JsonParser.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/Deserialization/JsonParser.hpp
@@ -44,7 +44,6 @@ class JsonParser {
const char *parseString();
bool parseAnythingTo(JsonVariant *destination);
- FORCE_INLINE bool parseAnythingToUnsafe(JsonVariant *destination);
inline bool parseArrayTo(JsonVariant *destination);
inline bool parseObjectTo(JsonVariant *destination);
diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/JsonParserImpl.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/JsonParserImpl.hpp
index 33ad42e9..50426735 100644
--- a/lib/ArduinoJson/src/ArduinoJson/Deserialization/JsonParserImpl.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/Deserialization/JsonParserImpl.hpp
@@ -20,17 +20,6 @@ template
inline bool
ArduinoJson::Internals::JsonParser::parseAnythingTo(
JsonVariant *destination) {
- if (_nestingLimit == 0) return false;
- _nestingLimit--;
- bool success = parseAnythingToUnsafe(destination);
- _nestingLimit++;
- return success;
-}
-
-template
-inline bool
-ArduinoJson::Internals::JsonParser::parseAnythingToUnsafe(
- JsonVariant *destination) {
skipSpacesAndComments(_reader);
switch (_reader.current()) {
@@ -48,6 +37,9 @@ ArduinoJson::Internals::JsonParser::parseAnythingToUnsafe(
template
inline ArduinoJson::JsonArray &
ArduinoJson::Internals::JsonParser::parseArray() {
+ if (_nestingLimit == 0) return JsonArray::invalid();
+ _nestingLimit--;
+
// Create an empty array
JsonArray &array = _buffer->createArray();
@@ -69,6 +61,7 @@ ArduinoJson::Internals::JsonParser::parseArray() {
SUCCESS_EMPTY_ARRAY:
SUCCES_NON_EMPTY_ARRAY:
+ _nestingLimit++;
return array;
ERROR_INVALID_VALUE:
@@ -91,6 +84,9 @@ inline bool ArduinoJson::Internals::JsonParser::parseArrayTo(
template
inline ArduinoJson::JsonObject &
ArduinoJson::Internals::JsonParser::parseObject() {
+ if (_nestingLimit == 0) return JsonObject::invalid();
+ _nestingLimit--;
+
// Create an empty object
JsonObject &object = _buffer->createObject();
@@ -117,6 +113,7 @@ ArduinoJson::Internals::JsonParser::parseObject() {
SUCCESS_EMPTY_OBJECT:
SUCCESS_NON_EMPTY_OBJECT:
+ _nestingLimit++;
return object;
ERROR_INVALID_KEY:
diff --git a/lib/ArduinoJson/src/ArduinoJson/JsonObject.hpp b/lib/ArduinoJson/src/ArduinoJson/JsonObject.hpp
index c03bfa51..caf698a3 100644
--- a/lib/ArduinoJson/src/ArduinoJson/JsonObject.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/JsonObject.hpp
@@ -286,15 +286,21 @@ class JsonObject : public Internals::JsonPrintable,
template
bool set_impl(TStringRef key, TValueRef value) {
+ // ignore null key
+ if (Internals::StringTraits::is_null(key)) return false;
+
+ // search a matching key
iterator it = findKey(key);
if (it == end()) {
+ // add the key
it = Internals::List::add();
if (it == end()) return false;
-
bool key_ok =
Internals::ValueSaver::save(_buffer, it->key, key);
if (!key_ok) return false;
}
+
+ // save the value
return Internals::ValueSaver::save(_buffer, it->value, value);
}
@@ -318,5 +324,5 @@ struct JsonVariantDefault {
return JsonObject::invalid();
}
};
-}
-}
+} // namespace Internals
+} // namespace ArduinoJson
diff --git a/lib/ArduinoJson/src/ArduinoJson/JsonVariant.hpp b/lib/ArduinoJson/src/ArduinoJson/JsonVariant.hpp
index 8326cbe8..43c51b77 100644
--- a/lib/ArduinoJson/src/ArduinoJson/JsonVariant.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/JsonVariant.hpp
@@ -274,9 +274,11 @@ class JsonVariant : public Internals::JsonVariantBase {
//
// bool is() const;
// bool is() const;
+ // bool is() const;
template
typename Internals::EnableIf::value ||
- Internals::IsSame::value,
+ Internals::IsSame::value ||
+ Internals::StringTraits::has_append,
bool>::type
is() const {
return variantIsString();
@@ -352,4 +354,4 @@ DEPRECATED("Decimal places are ignored, use the double value instead")
inline JsonVariant double_with_n_digits(double value, uint8_t) {
return JsonVariant(value);
}
-}
+} // namespace ArduinoJson
diff --git a/lib/ArduinoJson/src/ArduinoJson/JsonVariantComparisons.hpp b/lib/ArduinoJson/src/ArduinoJson/JsonVariantComparisons.hpp
index cae53372..47f9d632 100644
--- a/lib/ArduinoJson/src/ArduinoJson/JsonVariantComparisons.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/JsonVariantComparisons.hpp
@@ -129,10 +129,11 @@ class JsonVariantComparisons {
if (is() && right.template is())
return as() == right.template as();
if (is() && right.template is())
- return strcmp(as(), right.template as()) == 0;
+ return StringTraits::equals(as(),
+ right.template as());
return false;
}
};
-}
-}
+} // namespace Internals
+} // namespace ArduinoJson
diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/isInteger.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/isInteger.hpp
index 21f16689..8049079a 100644
--- a/lib/ArduinoJson/src/ArduinoJson/Polyfills/isInteger.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/Polyfills/isInteger.hpp
@@ -10,10 +10,10 @@ namespace ArduinoJson {
namespace Internals {
inline bool isInteger(const char* s) {
- if (!s) return false;
+ if (!s || !*s) return false;
if (issign(*s)) s++;
while (isdigit(*s)) s++;
return *s == '\0';
}
-}
-}
+} // namespace Internals
+} // namespace ArduinoJson
diff --git a/lib/ArduinoJson/src/ArduinoJson/StringTraits/CharPointer.hpp b/lib/ArduinoJson/src/ArduinoJson/StringTraits/CharPointer.hpp
index a9f30f78..98896ccf 100644
--- a/lib/ArduinoJson/src/ArduinoJson/StringTraits/CharPointer.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/StringTraits/CharPointer.hpp
@@ -30,7 +30,9 @@ struct CharPointerTraits {
};
static bool equals(const TChar* str, const char* expected) {
- return strcmp(reinterpret_cast(str), expected) == 0;
+ const char* actual = reinterpret_cast(str);
+ if (!actual || !expected) return actual == expected;
+ return strcmp(actual, expected) == 0;
}
static bool is_null(const TChar* str) {
@@ -58,5 +60,5 @@ struct CharPointerTraits {
template
struct StringTraits::value>::type>
: CharPointerTraits {};
-}
-}
+} // namespace Internals
+} // namespace ArduinoJson
diff --git a/lib/ArduinoJson/src/ArduinoJson/StringTraits/FlashString.hpp b/lib/ArduinoJson/src/ArduinoJson/StringTraits/FlashString.hpp
index 95f555d2..0701b9ba 100644
--- a/lib/ArduinoJson/src/ArduinoJson/StringTraits/FlashString.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/StringTraits/FlashString.hpp
@@ -31,7 +31,9 @@ struct StringTraits {
};
static bool equals(const __FlashStringHelper* str, const char* expected) {
- return strcmp_P(expected, (const char*)str) == 0;
+ const char* actual = reinterpret_cast(str);
+ if (!actual || !expected) return actual == expected;
+ return strcmp_P(expected, actual) == 0;
}
static bool is_null(const __FlashStringHelper* str) {
@@ -53,7 +55,7 @@ struct StringTraits {
static const bool has_equals = true;
static const bool should_duplicate = true;
};
-}
-}
+} // namespace Internals
+} // namespace ArduinoJson
#endif
diff --git a/lib/ArduinoJson/src/ArduinoJson/StringTraits/StdString.hpp b/lib/ArduinoJson/src/ArduinoJson/StringTraits/StdString.hpp
index 39124dac..35f4461d 100644
--- a/lib/ArduinoJson/src/ArduinoJson/StringTraits/StdString.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/StringTraits/StdString.hpp
@@ -40,7 +40,10 @@ struct StdStringTraits {
};
static bool equals(const TString& str, const char* expected) {
- return 0 == strcmp(str.c_str(), expected);
+ // Arduino's String::c_str() can return NULL
+ const char* actual = str.c_str();
+ if (!actual || !expected) return actual == expected;
+ return 0 == strcmp(actual, expected);
}
static void append(TString& str, char c) {
@@ -68,7 +71,7 @@ struct StringTraits : StdStringTraits {
template <>
struct StringTraits : StdStringTraits {};
#endif
-}
-}
+} // namespace Internals
+} // namespace ArduinoJson
#endif
diff --git a/lib/ArduinoJson/src/ArduinoJson/TypeTraits/FloatTraits.hpp b/lib/ArduinoJson/src/ArduinoJson/TypeTraits/FloatTraits.hpp
index 5044807a..648cc82f 100644
--- a/lib/ArduinoJson/src/ArduinoJson/TypeTraits/FloatTraits.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/TypeTraits/FloatTraits.hpp
@@ -44,28 +44,46 @@ struct FloatTraits {
static T positiveBinaryPowerOfTen(int index) {
static T factors[] = {
- 1e1, 1e2, 1e4, 1e8, 1e16, 1e32,
- // workaround to support platforms with single precision literals
- forge(0x4D384F03, 0xE93FF9F5), forge(0x5A827748, 0xF9301D32),
- forge(0x75154FDD, 0x7F73BF3C)};
+ 1e1,
+ 1e2,
+ 1e4,
+ 1e8,
+ 1e16,
+ forge(0x4693B8B5, 0xB5056E17), // 1e32
+ forge(0x4D384F03, 0xE93FF9F5), // 1e64
+ forge(0x5A827748, 0xF9301D32), // 1e128
+ forge(0x75154FDD, 0x7F73BF3C) // 1e256
+ };
return factors[index];
}
static T negativeBinaryPowerOfTen(int index) {
static T factors[] = {
- 1e-1, 1e-2, 1e-4, 1e-8, 1e-16, 1e-32,
- // workaround to support platforms with single precision literals
- forge(0x32A50FFD, 0x44F4A73D), forge(0x255BBA08, 0xCF8C979D),
- forge(0x0AC80628, 0x64AC6F43)};
+ forge(0x3FB99999, 0x9999999A), // 1e-1
+ forge(0x3F847AE1, 0x47AE147B), // 1e-2
+ forge(0x3F1A36E2, 0xEB1C432D), // 1e-4
+ forge(0x3E45798E, 0xE2308C3A), // 1e-8
+ forge(0x3C9CD2B2, 0x97D889BC), // 1e-16
+ forge(0x3949F623, 0xD5A8A733), // 1e-32
+ forge(0x32A50FFD, 0x44F4A73D), // 1e-64
+ forge(0x255BBA08, 0xCF8C979D), // 1e-128
+ forge(0x0AC80628, 0x64AC6F43) // 1e-256
+ };
return factors[index];
}
static T negativeBinaryPowerOfTenPlusOne(int index) {
static T factors[] = {
- 1e0, 1e-1, 1e-3, 1e-7, 1e-15, 1e-31,
- // workaround to support platforms with single precision literals
- forge(0x32DA53FC, 0x9631D10D), forge(0x25915445, 0x81B7DEC2),
- forge(0x0AFE07B2, 0x7DD78B14)};
+ 1e0,
+ forge(0x3FB99999, 0x9999999A), // 1e-1
+ forge(0x3F50624D, 0xD2F1A9FC), // 1e-3
+ forge(0x3E7AD7F2, 0x9ABCAF48), // 1e-7
+ forge(0x3CD203AF, 0x9EE75616), // 1e-15
+ forge(0x398039D6, 0x65896880), // 1e-31
+ forge(0x32DA53FC, 0x9631D10D), // 1e-63
+ forge(0x25915445, 0x81B7DEC2), // 1e-127
+ forge(0x0AFE07B2, 0x7DD78B14) // 1e-255
+ };
return factors[index];
}
@@ -77,6 +95,9 @@ struct FloatTraits {
return forge(0x7ff00000, 0x00000000);
}
+ // constructs a double floating point values from its binary representation
+ // we use this function to workaround platforms with single precision literals
+ // (for example, when -fsingle-precision-constant is passed to GCC)
static T forge(uint32_t msb, uint32_t lsb) {
union {
uint64_t integerBits;
diff --git a/lib/ArduinoJson/src/ArduinoJson/version.hpp b/lib/ArduinoJson/src/ArduinoJson/version.hpp
new file mode 100644
index 00000000..e5fa1e2e
--- /dev/null
+++ b/lib/ArduinoJson/src/ArduinoJson/version.hpp
@@ -0,0 +1,10 @@
+// ArduinoJson - arduinojson.org
+// Copyright Benoit Blanchon 2014-2018
+// MIT License
+
+#pragma once
+
+#define ARDUINOJSON_VERSION "5.13.3"
+#define ARDUINOJSON_VERSION_MAJOR 5
+#define ARDUINOJSON_VERSION_MINOR 13
+#define ARDUINOJSON_VERSION_REVISION 3
diff --git a/lib/ArduinoJson/test/CMakeLists.txt b/lib/ArduinoJson/test/CMakeLists.txt
deleted file mode 100644
index 4fee0ea1..00000000
--- a/lib/ArduinoJson/test/CMakeLists.txt
+++ /dev/null
@@ -1,76 +0,0 @@
-# ArduinoJson - arduinojson.org
-# Copyright Benoit Blanchon 2014-2018
-# MIT License
-
-if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
- add_compile_options(
- -pedantic
- -Wall
- -Wcast-align
- -Wcast-qual
- -Wconversion
- -Wctor-dtor-privacy
- -Wdisabled-optimization
- -Werror
- -Wextra
- -Wformat=2
- -Winit-self
- -Wmissing-include-dirs
- -Wnon-virtual-dtor
- -Wold-style-cast
- -Woverloaded-virtual
- -Wparentheses
- -Wredundant-decls
- -Wshadow
- -Wsign-promo
- -Wstrict-aliasing
- -Wstrict-overflow=5
- -Wundef
- )
-
- if(NOT MINGW)
- add_compile_options(
- -std=c++98
- )
- endif()
-endif()
-
-if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
- add_compile_options(
- -Wstrict-null-sentinel
- )
-
- if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.5)
- add_compile_options(-Wlogical-op) # the flag exists in 4.4 but is buggy
- endif()
-
- if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.6)
- add_compile_options(-Wnoexcept)
- endif()
-endif()
-
-if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
- add_compile_options(
- -Wc++11-compat
- -Wdeprecated-register
- )
-endif()
-
-if(MSVC)
- add_definitions(-D_CRT_SECURE_NO_WARNINGS)
- add_compile_options(
- /W4 # Set warning level
- /WX # Treats all compiler warnings as errors.
- )
-endif()
-
-add_subdirectory(DynamicJsonBuffer)
-add_subdirectory(IntegrationTests)
-add_subdirectory(JsonArray)
-add_subdirectory(JsonBuffer)
-add_subdirectory(JsonObject)
-add_subdirectory(JsonVariant)
-add_subdirectory(JsonWriter)
-add_subdirectory(Misc)
-add_subdirectory(Polyfills)
-add_subdirectory(StaticJsonBuffer)
\ No newline at end of file
diff --git a/lib/ArduinoJson/test/DynamicJsonBuffer/CMakeLists.txt b/lib/ArduinoJson/test/DynamicJsonBuffer/CMakeLists.txt
deleted file mode 100644
index 9030f376..00000000
--- a/lib/ArduinoJson/test/DynamicJsonBuffer/CMakeLists.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-# ArduinoJson - arduinojson.org
-# Copyright Benoit Blanchon 2014-2018
-# MIT License
-
-add_executable(DynamicJsonBufferTests
- alloc.cpp
- createArray.cpp
- createObject.cpp
- no_memory.cpp
- size.cpp
- startString.cpp
-)
-
-target_link_libraries(DynamicJsonBufferTests catch)
-add_test(DynamicJsonBuffer DynamicJsonBufferTests)
diff --git a/lib/ArduinoJson/test/DynamicJsonBuffer/alloc.cpp b/lib/ArduinoJson/test/DynamicJsonBuffer/alloc.cpp
deleted file mode 100644
index c45e6866..00000000
--- a/lib/ArduinoJson/test/DynamicJsonBuffer/alloc.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-// ArduinoJson - arduinojson.org
-// Copyright Benoit Blanchon 2014-2018
-// MIT License
-
-#include
-#include
-#include
-
-using namespace ArduinoJson::Internals;
-
-static bool isAligned(void* ptr) {
- const size_t mask = sizeof(void*) - 1;
- size_t addr = reinterpret_cast(ptr);
- return (addr & mask) == 0;
-}
-
-std::stringstream allocatorLog;
-
-struct SpyingAllocator : DefaultAllocator {
- void* allocate(size_t n) {
- allocatorLog << "A" << (n - DynamicJsonBuffer::EmptyBlockSize);
- return DefaultAllocator::allocate(n);
- }
- void deallocate(void* p) {
- allocatorLog << "F";
- return DefaultAllocator::deallocate(p);
- }
-};
-
-TEST_CASE("DynamicJsonBuffer::alloc()") {
- SECTION("Returns different pointers") {
- DynamicJsonBuffer buffer;
- void* p1 = buffer.alloc(1);
- void* p2 = buffer.alloc(2);
- REQUIRE(p1 != p2);
- }
-
- SECTION("Doubles allocation size when full") {
- allocatorLog.str("");
- {
- DynamicJsonBufferBase buffer(1);
- buffer.alloc(1);
- buffer.alloc(1);
- }
- REQUIRE(allocatorLog.str() == "A1A2FF");
- }
-
- SECTION("Resets allocation size after clear()") {
- allocatorLog.str("");
- {
- DynamicJsonBufferBase buffer(1);
- buffer.alloc(1);
- buffer.alloc(1);
- buffer.clear();
- buffer.alloc(1);
- }
- REQUIRE(allocatorLog.str() == "A1A2FFA1F");
- }
-
- SECTION("Makes a big allocation when needed") {
- allocatorLog.str("");
- {
- DynamicJsonBufferBase buffer(1);
- buffer.alloc(42);
- }
- REQUIRE(allocatorLog.str() == "A42F");
- }
-
- SECTION("Alignment") {
- // make room for two but not three
- DynamicJsonBuffer tinyBuf(2 * sizeof(void*) + 1);
-
- REQUIRE(isAligned(tinyBuf.alloc(1))); // this on is aligned by design
- REQUIRE(isAligned(tinyBuf.alloc(1))); // this one fits in the first block
- REQUIRE(isAligned(tinyBuf.alloc(1))); // this one requires a new block
- }
-}
diff --git a/lib/ArduinoJson/test/DynamicJsonBuffer/createArray.cpp b/lib/ArduinoJson/test/DynamicJsonBuffer/createArray.cpp
deleted file mode 100644
index 34ab07e9..00000000
--- a/lib/ArduinoJson/test/DynamicJsonBuffer/createArray.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-// ArduinoJson - arduinojson.org
-// Copyright Benoit Blanchon 2014-2018
-// MIT License
-
-#include
-#include
-
-TEST_CASE("DynamicJsonBuffer::createArray()") {
- DynamicJsonBuffer jsonBuffer;
- JsonArray &array = jsonBuffer.createArray();
-
- SECTION("GrowsWithArray") {
- REQUIRE(JSON_ARRAY_SIZE(0) == jsonBuffer.size());
-
- array.add("hello");
- REQUIRE(JSON_ARRAY_SIZE(1) == jsonBuffer.size());
-
- array.add("world");
- REQUIRE(JSON_ARRAY_SIZE(2) == jsonBuffer.size());
- }
-
- SECTION("CanAdd1000Values") {
- for (size_t i = 1; i <= 1000; i++) {
- array.add("hello");
- REQUIRE(array.size() == i);
- }
- }
-}
diff --git a/lib/ArduinoJson/test/DynamicJsonBuffer/createObject.cpp b/lib/ArduinoJson/test/DynamicJsonBuffer/createObject.cpp
deleted file mode 100644
index 2193a659..00000000
--- a/lib/ArduinoJson/test/DynamicJsonBuffer/createObject.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-// ArduinoJson - arduinojson.org
-// Copyright Benoit Blanchon 2014-2018
-// MIT License
-
-#include
-#include
-
-TEST_CASE("DynamicJsonBuffer::createObject()") {
- DynamicJsonBuffer json;
-
- JsonObject &obj = json.createObject();
- REQUIRE(JSON_OBJECT_SIZE(0) == json.size());
-
- obj["hello"] = 1;
- REQUIRE(JSON_OBJECT_SIZE(1) == json.size());
-
- obj["world"] = 2;
- REQUIRE(JSON_OBJECT_SIZE(2) == json.size());
-
- obj["world"] = 3; // <- same key, should not grow
- REQUIRE(JSON_OBJECT_SIZE(2) == json.size());
-}
diff --git a/lib/ArduinoJson/test/DynamicJsonBuffer/no_memory.cpp b/lib/ArduinoJson/test/DynamicJsonBuffer/no_memory.cpp
deleted file mode 100644
index 824d968c..00000000
--- a/lib/ArduinoJson/test/DynamicJsonBuffer/no_memory.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-// ArduinoJson - arduinojson.org
-// Copyright Benoit Blanchon 2014-2018
-// MIT License
-
-#include
-#include
-
-using namespace ArduinoJson::Internals;
-
-struct NoMemoryAllocator {
- void* allocate(size_t) {
- return NULL;
- }
- void deallocate(void*) {}
-};
-
-TEST_CASE("DynamicJsonBuffer no memory") {
- DynamicJsonBufferBase _jsonBuffer;
-
- SECTION("FixCodeCoverage") {
- // call this function to fix code coverage
- NoMemoryAllocator().deallocate(NULL);
- }
-
- SECTION("createArray()") {
- REQUIRE_FALSE(_jsonBuffer.createArray().success());
- }
-
- SECTION("createObject()") {
- REQUIRE_FALSE(_jsonBuffer.createObject().success());
- }
-
- SECTION("parseArray()") {
- char json[] = "[]";
- REQUIRE_FALSE(_jsonBuffer.parseArray(json).success());
- }
-
- SECTION("parseObject()") {
- char json[] = "{}";
- REQUIRE_FALSE(_jsonBuffer.parseObject(json).success());
- }
-
- SECTION("startString()") {
- DynamicJsonBufferBase::String str =
- _jsonBuffer.startString();
- str.append('!');
- REQUIRE(0 == str.c_str());
- }
-}
diff --git a/lib/ArduinoJson/test/DynamicJsonBuffer/size.cpp b/lib/ArduinoJson/test/DynamicJsonBuffer/size.cpp
deleted file mode 100644
index 8ebba424..00000000
--- a/lib/ArduinoJson/test/DynamicJsonBuffer/size.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-// ArduinoJson - arduinojson.org
-// Copyright Benoit Blanchon 2014-2018
-// MIT License
-
-#include
-#include
-
-TEST_CASE("DynamicJsonBuffer::size()") {
- DynamicJsonBuffer buffer;
-
- SECTION("Initial size is 0") {
- REQUIRE(0 == buffer.size());
- }
-
- SECTION("Increases after alloc()") {
- buffer.alloc(1);
- REQUIRE(1U <= buffer.size());
- buffer.alloc(1);
- REQUIRE(2U <= buffer.size());
- }
-
- SECTION("Goes back to 0 after clear()") {
- buffer.alloc(1);
- buffer.clear();
- REQUIRE(0 == buffer.size());
- }
-}
diff --git a/lib/ArduinoJson/test/DynamicJsonBuffer/startString.cpp b/lib/ArduinoJson/test/DynamicJsonBuffer/startString.cpp
deleted file mode 100644
index 2e5bef7f..00000000
--- a/lib/ArduinoJson/test/DynamicJsonBuffer/startString.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-// ArduinoJson - arduinojson.org
-// Copyright Benoit Blanchon 2014-2018
-// MIT License
-
-#include
-#include
-
-TEST_CASE("DynamicJsonBuffer::startString()") {
- SECTION("WorksWhenBufferIsBigEnough") {
- DynamicJsonBuffer jsonBuffer(6);
-
- DynamicJsonBuffer::String str = jsonBuffer.startString();
- str.append('h');
- str.append('e');
- str.append('l');
- str.append('l');
- str.append('o');
-
- REQUIRE(std::string("hello") == str.c_str());
- }
-
- SECTION("GrowsWhenBufferIsTooSmall") {
- DynamicJsonBuffer jsonBuffer(5);
-
- DynamicJsonBuffer::String str = jsonBuffer.startString();
- str.append('h');
- str.append('e');
- str.append('l');
- str.append('l');
- str.append('o');
-
- REQUIRE(std::string("hello") == str.c_str());
- }
-
- SECTION("SizeIncreases") {
- DynamicJsonBuffer jsonBuffer(5);
-
- DynamicJsonBuffer::String str = jsonBuffer.startString();
- REQUIRE(0 == jsonBuffer.size());
-
- str.append('h');
- REQUIRE(1 == jsonBuffer.size());
-
- str.c_str();
- REQUIRE(2 == jsonBuffer.size());
- }
-}
diff --git a/lib/ArduinoJson/test/IntegrationTests/CMakeLists.txt b/lib/ArduinoJson/test/IntegrationTests/CMakeLists.txt
deleted file mode 100644
index 9294bbbf..00000000
--- a/lib/ArduinoJson/test/IntegrationTests/CMakeLists.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-# ArduinoJson - arduinojson.org
-# Copyright Benoit Blanchon 2014-2018
-# MIT License
-
-add_executable(IntegrationTests
- gbathree.cpp
- round_trip.cpp
-)
-
-if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
- target_compile_options(IntegrationTests
- PUBLIC
- -fsingle-precision-constant # issue 544
- )
-endif()
-
-target_link_libraries(IntegrationTests catch)
-add_test(IntegrationTests IntegrationTests)
diff --git a/lib/ArduinoJson/test/IntegrationTests/gbathree.cpp b/lib/ArduinoJson/test/IntegrationTests/gbathree.cpp
deleted file mode 100644
index 9a514425..00000000
--- a/lib/ArduinoJson/test/IntegrationTests/gbathree.cpp
+++ /dev/null
@@ -1,208 +0,0 @@
-// ArduinoJson - arduinojson.org
-// Copyright Benoit Blanchon 2014-2018
-// MIT License
-
-#include
-#include
-
-TEST_CASE("Gbathree") {
- DynamicJsonBuffer _buffer;
-
- const JsonObject& _object = _buffer.parseObject(
- "{\"protocol_name\":\"fluorescence\",\"repeats\":1,\"wait\":0,"
- "\"averages\":1,\"measurements\":3,\"meas2_light\":15,\"meas1_"
- "baseline\":0,\"act_light\":20,\"pulsesize\":25,\"pulsedistance\":"
- "10000,\"actintensity1\":50,\"actintensity2\":255,\"measintensity\":"
- "255,\"calintensity\":255,\"pulses\":[50,50,50],\"act\":[2,1,2,2],"
- "\"red\":[2,2,2,2],\"detectors\":[[34,34,34,34],[34,34,34,34],[34,"
- "34,34,34],[34,34,34,34]],\"alta\":[2,2,2,2],\"altb\":[2,2,2,2],"
- "\"measlights\":[[15,15,15,15],[15,15,15,15],[15,15,15,15],[15,15,"
- "15,15]],\"measlights2\":[[15,15,15,15],[15,15,15,15],[15,15,15,15],"
- "[15,15,15,15]],\"altc\":[2,2,2,2],\"altd\":[2,2,2,2]}");
-
- SECTION("Success") {
- REQUIRE(_object.success());
- }
-
- SECTION("ProtocolName") {
- REQUIRE("fluorescence" == _object["protocol_name"]);
- }
-
- SECTION("Repeats") {
- REQUIRE(1 == _object["repeats"]);
- }
-
- SECTION("Wait") {
- REQUIRE(0 == _object["wait"]);
- }
-
- SECTION("Measurements") {
- REQUIRE(3 == _object["measurements"]);
- }
-
- SECTION("Meas2_Light") {
- REQUIRE(15 == _object["meas2_light"]);
- }
-
- SECTION("Meas1_Baseline") {
- REQUIRE(0 == _object["meas1_baseline"]);
- }
-
- SECTION("Act_Light") {
- REQUIRE(20 == _object["act_light"]);
- }
-
- SECTION("Pulsesize") {
- REQUIRE(25 == _object["pulsesize"]);
- }
-
- SECTION("Pulsedistance") {
- REQUIRE(10000 == _object["pulsedistance"]);
- }
-
- SECTION("Actintensity1") {
- REQUIRE(50 == _object["actintensity1"]);
- }
-
- SECTION("Actintensity2") {
- REQUIRE(255 == _object["actintensity2"]);
- }
-
- SECTION("Measintensity") {
- REQUIRE(255 == _object["measintensity"]);
- }
-
- SECTION("Calintensity") {
- REQUIRE(255 == _object["calintensity"]);
- }
-
- SECTION("Pulses") {
- // "pulses":[50,50,50]
-
- JsonArray& array = _object["pulses"];
- REQUIRE(array.success());
-
- REQUIRE(3 == array.size());
-
- for (size_t i = 0; i < 3; i++) {
- REQUIRE(50 == array[i]);
- }
- }
-
- SECTION("Act") {
- // "act":[2,1,2,2]
-
- JsonArray& array = _object["act"];
- REQUIRE(array.success());
-
- REQUIRE(4 == array.size());
- REQUIRE(2 == array[0]);
- REQUIRE(1 == array[1]);
- REQUIRE(2 == array[2]);
- REQUIRE(2 == array[3]);
- }
-
- SECTION("Detectors") {
- // "detectors":[[34,34,34,34],[34,34,34,34],[34,34,34,34],[34,34,34,34]]
-
- JsonArray& array = _object["detectors"];
- REQUIRE(array.success());
- REQUIRE(4 == array.size());
-
- for (size_t i = 0; i < 4; i++) {
- JsonArray& nestedArray = array[i];
- REQUIRE(4 == nestedArray.size());
-
- for (size_t j = 0; j < 4; j++) {
- REQUIRE(34 == nestedArray[j]);
- }
- }
- }
-
- SECTION("Alta") {
- // alta:[2,2,2,2]
-
- JsonArray& array = _object["alta"];
- REQUIRE(array.success());
-
- REQUIRE(4 == array.size());
-
- for (size_t i = 0; i < 4; i++) {
- REQUIRE(2 == array[i]);
- }
- }
-
- SECTION("Altb") {
- // altb:[2,2,2,2]
-
- JsonArray& array = _object["altb"];
- REQUIRE(array.success());
-
- REQUIRE(4 == array.size());
-
- for (size_t i = 0; i < 4; i++) {
- REQUIRE(2 == array[i]);
- }
- }
-
- SECTION("Measlights") {
- // "measlights":[[15,15,15,15],[15,15,15,15],[15,15,15,15],[15,15,15,15]]
-
- JsonArray& array = _object["measlights"];
- REQUIRE(array.success());
- REQUIRE(4 == array.size());
-
- for (size_t i = 0; i < 4; i++) {
- JsonArray& nestedArray = array[i];
-
- REQUIRE(4 == nestedArray.size());
-
- for (size_t j = 0; j < 4; j++) {
- REQUIRE(15 == nestedArray[j]);
- }
- }
- }
-
- SECTION("Measlights2") {
- // "measlights2":[[15,15,15,15],[15,15,15,15],[15,15,15,15],[15,15,15,15]]
-
- JsonArray& array = _object["measlights2"];
- REQUIRE(array.success());
- REQUIRE(4 == array.size());
-
- for (size_t i = 0; i < 4; i++) {
- JsonArray& nestedArray = array[i];
- REQUIRE(4 == nestedArray.size());
-
- for (size_t j = 0; j < 4; j++) {
- REQUIRE(15 == nestedArray[j]);
- }
- }
- }
-
- SECTION("Altc") {
- // altc:[2,2,2,2]
-
- JsonArray& array = _object["altc"];
- REQUIRE(array.success());
-
- REQUIRE(4 == array.size());
-
- for (size_t i = 0; i < 4; i++) {
- REQUIRE(2 == array[i]);
- }
- }
-
- SECTION("Altd") {
- // altd:[2,2,2,2]
-
- JsonArray& array = _object["altd"];
- REQUIRE(array.success());
-
- REQUIRE(4 == array.size());
-
- for (size_t i = 0; i < 4; i++) {
- REQUIRE(2 == array[i]);
- }
- }
-}
diff --git a/lib/ArduinoJson/test/IntegrationTests/round_trip.cpp b/lib/ArduinoJson/test/IntegrationTests/round_trip.cpp
deleted file mode 100644
index ec8c0b0c..00000000
--- a/lib/ArduinoJson/test/IntegrationTests/round_trip.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-// ArduinoJson - arduinojson.org
-// Copyright Benoit Blanchon 2014-2018
-// MIT License
-
-#include
-#include
-
-void check(std::string originalJson) {
- DynamicJsonBuffer jb;
-
- std::string prettyJson;
- jb.parseObject(originalJson).prettyPrintTo(prettyJson);
-
- std::string finalJson;
- jb.parseObject(prettyJson).printTo(finalJson);
-
- REQUIRE(originalJson == finalJson);
-}
-
-TEST_CASE("Round Trip: parse -> prettyPrint -> parse -> print") {
- SECTION("OpenWeatherMap") {
- check(
- "{\"coord\":{\"lon\":145.77,\"lat\":-16.92},\"sys\":{\"type\":1,\"id\":"
- "8166,\"message\":0.1222,\"country\":\"AU\",\"sunrise\":1414784325,"
- "\"sunset\":1414830137},\"weather\":[{\"id\":801,\"main\":\"Clouds\","
- "\"description\":\"few clouds\",\"icon\":\"02n\"}],\"base\":\"cmc "
- "stations\",\"main\":{\"temp\":296.15,\"pressure\":1014,\"humidity\":"
- "83,\"temp_min\":296.15,\"temp_max\":296.15},\"wind\":{\"speed\":2.22,"
- "\"deg\":114.501},\"clouds\":{\"all\":20},\"dt\":1414846800,\"id\":"
- "2172797,\"name\":\"Cairns\",\"cod\":200}");
- }
-
- SECTION("YahooQueryLanguage") {
- check(
- "{\"query\":{\"count\":40,\"created\":\"2014-11-01T14:16:49Z\","
- "\"lang\":\"fr-FR\",\"results\":{\"item\":[{\"title\":\"Burkina army "
- "backs Zida as interim leader\"},{\"title\":\"British jets intercept "
- "Russian bombers\"},{\"title\":\"Doubts chip away at nation's most "
- "trusted agencies\"},{\"title\":\"Cruise ship stuck off Norway, no "
- "damage\"},{\"title\":\"U.S. military launches 10 air strikes in "
- "Syria, Iraq\"},{\"title\":\"Blackout hits Bangladesh as line from "
- "India fails\"},{\"title\":\"Burkina Faso president in Ivory Coast "
- "after ouster\"},{\"title\":\"Kurds in Turkey rally to back city "
- "besieged by IS\"},{\"title\":\"A majority of Scots would vote for "
- "independence now:poll\"},{\"title\":\"Tunisia elections possible "
- "model for region\"},{\"title\":\"Islamic State kills 85 more members "
- "of Iraqi tribe\"},{\"title\":\"Iraqi officials:IS extremists line "
- "up, kill 50\"},{\"title\":\"Burkina Faso army backs presidential "
- "guard official to lead transition\"},{\"title\":\"Kurdish peshmerga "
- "arrive with weapons in Syria's Kobani\"},{\"title\":\"Driver sought "
- "in crash that killed 3 on Halloween\"},{\"title\":\"Ex-Marine arrives "
- "in US after release from Mexico jail\"},{\"title\":\"UN panel "
- "scrambling to finish climate report\"},{\"title\":\"Investigators, "
- "Branson go to spacecraft crash site\"},{\"title\":\"Soldiers vie for "
- "power after Burkina Faso president quits\"},{\"title\":\"For a man "
- "without a party, turnout is big test\"},{\"title\":\"'We just had a "
- "hunch':US marshals nab Eric Frein\"},{\"title\":\"Boko Haram leader "
- "threatens to kill German hostage\"},{\"title\":\"Nurse free to move "
- "about as restrictions eased\"},{\"title\":\"Former Burkina president "
- "Compaore arrives in Ivory Coast:sources\"},{\"title\":\"Libyan port "
- "rebel leader refuses to hand over oil ports to rival "
- "group\"},{\"title\":\"Iraqi peshmerga fighters prepare for Syria "
- "battle\"},{\"title\":\"1 Dem Senate candidate welcoming Obama's "
- "help\"},{\"title\":\"Bikers cancel party after police recover "
- "bar\"},{\"title\":\"New question in Texas:Can Davis survive "
- "defeat?\"},{\"title\":\"Ukraine rebels to hold election, despite "
- "criticism\"},{\"title\":\"Iraqi officials say Islamic State group "
- "lines up, kills 50 tribesmen, women in Anbar "
- "province\"},{\"title\":\"James rebounds, leads Cavaliers past "
- "Bulls\"},{\"title\":\"UK warns travelers they could be terror "
- "targets\"},{\"title\":\"Hello Kitty celebrates 40th "
- "birthday\"},{\"title\":\"A look at people killed during space "
- "missions\"},{\"title\":\"Nigeria's purported Boko Haram leader says "
- "has 'married off' girls:AFP\"},{\"title\":\"Mexico orders immediate "
- "release of Marine veteran\"},{\"title\":\"As election closes in, "
- "Obama on center stage\"},{\"title\":\"Body of Zambian president "
- "arrives home\"},{\"title\":\"South Africa arrests 2 Vietnamese for "
- "poaching\"}]}}}");
- }
-}
diff --git a/lib/ArduinoJson/test/JsonArray/CMakeLists.txt b/lib/ArduinoJson/test/JsonArray/CMakeLists.txt
deleted file mode 100644
index ec0e5206..00000000
--- a/lib/ArduinoJson/test/JsonArray/CMakeLists.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-# ArduinoJson - arduinojson.org
-# Copyright Benoit Blanchon 2014-2018
-# MIT License
-
-add_executable(JsonArrayTests
- add.cpp
- basics.cpp
- copyFrom.cpp
- copyTo.cpp
- invalid.cpp
- iterator.cpp
- prettyPrintTo.cpp
- printTo.cpp
- remove.cpp
- set.cpp
- size.cpp
- subscript.cpp
-)
-
-target_link_libraries(JsonArrayTests catch)
-add_test(JsonArray JsonArrayTests)
diff --git a/lib/ArduinoJson/test/JsonArray/add.cpp b/lib/ArduinoJson/test/JsonArray/add.cpp
deleted file mode 100644
index 2e10754e..00000000
--- a/lib/ArduinoJson/test/JsonArray/add.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-// ArduinoJson - arduinojson.org
-// Copyright Benoit Blanchon 2014-2018
-// MIT License
-
-#include
-#include
-
-TEST_CASE("JsonArray::add()") {
- DynamicJsonBuffer _jsonBuffer;
- JsonArray& _array = _jsonBuffer.createArray();
-
- SECTION("int") {
- _array.add(123);
- REQUIRE(123 == _array[0].as());
- REQUIRE(_array[0].is());
- REQUIRE(_array[0].is());
- }
-
- SECTION("double") {
- _array.add(123.45);
- REQUIRE(123.45 == _array[0].as());
- REQUIRE(_array[0].is());
- REQUIRE_FALSE(_array[0].is());
- }
-
- SECTION("bool") {
- _array.add(true);
- REQUIRE(true == _array[0].as());
- REQUIRE(_array[0].is());
- REQUIRE_FALSE(_array[0].is());
- }
-
- SECTION("const char*") {
- const char* str = "hello";
- _array.add(str);
- REQUIRE(str == _array[0].as());
- REQUIRE(_array[0].is());
- REQUIRE_FALSE(_array[0].is());
- }
-
- SECTION("nested array") {
- JsonArray& arr = _jsonBuffer.createArray();
-
- _array.add(arr);
-
- REQUIRE(&arr == &_array[0].as());
- REQUIRE(_array[0].is());
- REQUIRE_FALSE(_array[0].is());
- }
-
- SECTION("nested object") {
- JsonObject& obj = _jsonBuffer.createObject();
-
- _array.add(obj);
-
- REQUIRE(&obj == &_array[0].as());
- REQUIRE(_array[0].is());
- REQUIRE_FALSE(_array[0].is());
- }
-
- SECTION("array subscript") {
- const char* str = "hello";
- JsonArray& arr = _jsonBuffer.createArray();
- arr.add(str);
-
- _array.add(arr[0]);
-
- REQUIRE(str == _array[0]);
- }
-
- SECTION("object subscript") {
- const char* str = "hello";
- JsonObject& obj = _jsonBuffer.createObject();
- obj["x"] = str;
-
- _array.add(obj["x"]);
-
- REQUIRE(str == _array[0]);
- }
-
- SECTION("should not duplicate const char*") {
- _array.add("world");
- const size_t expectedSize = JSON_ARRAY_SIZE(1);
- REQUIRE(expectedSize == _jsonBuffer.size());
- }
-
- SECTION("should duplicate char*") {
- _array.add(const_cast("world"));
- const size_t expectedSize = JSON_ARRAY_SIZE(1) + 6;
- REQUIRE(expectedSize == _jsonBuffer.size());
- }
-
- SECTION("should duplicate std::string") {
- _array.add(std::string("world"));
- const size_t expectedSize = JSON_ARRAY_SIZE(1) + 6;
- REQUIRE(expectedSize == _jsonBuffer.size());
- }
-
- SECTION("should not duplicate RawJson(const char*)") {
- _array.add(RawJson("{}"));
- const size_t expectedSize = JSON_ARRAY_SIZE(1);
- REQUIRE(expectedSize == _jsonBuffer.size());
- }
-
- SECTION("should duplicate RawJson(char*)") {
- _array.add(RawJson(const_cast("{}")));
- const size_t expectedSize = JSON_ARRAY_SIZE(1) + 3;
- REQUIRE(expectedSize == _jsonBuffer.size());
- }
-}
diff --git a/lib/ArduinoJson/test/JsonArray/basics.cpp b/lib/ArduinoJson/test/JsonArray/basics.cpp
deleted file mode 100644
index eada17e2..00000000
--- a/lib/ArduinoJson/test/JsonArray/basics.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-// ArduinoJson - arduinojson.org
-// Copyright Benoit Blanchon 2014-2018
-// MIT License
-
-#include
-#include
-
-TEST_CASE("JsonArray basics") {
- DynamicJsonBuffer jb;
- JsonArray& array = jb.createArray();
-
- SECTION("SuccessIsTrue") {
- REQUIRE(array.success());
- }
-
- SECTION("InitialSizeIsZero") {
- REQUIRE(0U == array.size());
- }
-
- SECTION("CreateNestedArray") {
- JsonArray& arr = array.createNestedArray();
- REQUIRE(&arr == &array[0].as());
- }
-
- SECTION("CreateNestedObject") {
- JsonObject& obj = array.createNestedObject();
- REQUIRE(&obj == &array[0].as());
- }
-}
diff --git a/lib/ArduinoJson/test/JsonArray/copyFrom.cpp b/lib/ArduinoJson/test/JsonArray/copyFrom.cpp
deleted file mode 100644
index 850301a7..00000000
--- a/lib/ArduinoJson/test/JsonArray/copyFrom.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-// ArduinoJson - arduinojson.org
-// Copyright Benoit Blanchon 2014-2018
-// MIT License
-
-#include
-#include
-
-TEST_CASE("JsonArray::copyFrom()") {
- SECTION("OneDimension") {
- DynamicJsonBuffer jsonBuffer;
- JsonArray& array = jsonBuffer.createArray();
- char json[32];
- int source[] = {1, 2, 3};
-
- bool ok = array.copyFrom(source);
- REQUIRE(ok);
-
- array.printTo(json, sizeof(json));
- REQUIRE(std::string("[1,2,3]") == json);
- }
-
- SECTION("OneDimension_JsonBufferTooSmall") {
- const size_t SIZE = JSON_ARRAY_SIZE(2);
- StaticJsonBuffer jsonBuffer;
- JsonArray& array = jsonBuffer.createArray();
- char json[32];
- int source[] = {1, 2, 3};
-
- bool ok = array.copyFrom(source);
- REQUIRE_FALSE(ok);
-
- array.printTo(json, sizeof(json));
- REQUIRE(std::string("[1,2]") == json);
- }
-
- SECTION("TwoDimensions") {
- DynamicJsonBuffer jsonBuffer;
- JsonArray& array = jsonBuffer.createArray();
- char json[32];
- int source[][3] = {{1, 2, 3}, {4, 5, 6}};
-
- bool ok = array.copyFrom(source);
- REQUIRE(ok);
-
- array.printTo(json, sizeof(json));
- REQUIRE(std::string("[[1,2,3],[4,5,6]]") == json);
- }
-
- SECTION("TwoDimensions_JsonBufferTooSmall") {
- const size_t SIZE =
- JSON_ARRAY_SIZE(2) + JSON_ARRAY_SIZE(3) + JSON_ARRAY_SIZE(2);
- StaticJsonBuffer jsonBuffer;
- JsonArray& array = jsonBuffer.createArray();
- char json[32];
- int source[][3] = {{1, 2, 3}, {4, 5, 6}};
-
- bool ok = array.copyFrom(source);
- REQUIRE_FALSE(ok);
-
- array.printTo(json, sizeof(json));
- REQUIRE(std::string("[[1,2,3],[4,5]]") == json);
- }
-}
diff --git a/lib/ArduinoJson/test/JsonArray/copyTo.cpp b/lib/ArduinoJson/test/JsonArray/copyTo.cpp
deleted file mode 100644
index 90150590..00000000
--- a/lib/ArduinoJson/test/JsonArray/copyTo.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-// ArduinoJson - arduinojson.org
-// Copyright Benoit Blanchon 2014-2018
-// MIT License
-
-#include
-#include
-
-TEST_CASE("JsonArray::copyTo()") {
- DynamicJsonBuffer jsonBuffer;
-
- SECTION("BiggerOneDimensionIntegerArray") {
- char json[] = "[1,2,3]";
- JsonArray& array = jsonBuffer.parseArray(json);
-
- int destination[4] = {0};
- size_t result = array.copyTo(destination);
-
- REQUIRE(3 == result);
- REQUIRE(1 == destination[0]);
- REQUIRE(2 == destination[1]);
- REQUIRE(3 == destination[2]);
- REQUIRE(0 == destination[3]);
- }
-
- SECTION("SmallerOneDimensionIntegerArray") {
- char json[] = "[1,2,3]";
- JsonArray& array = jsonBuffer.parseArray(json);
-
- int destination[2] = {0};
- size_t result = array.copyTo(destination);
-
- REQUIRE(2 == result);
- REQUIRE(1 == destination[0]);
- REQUIRE(2 == destination[1]);
- }
-
- SECTION("TwoOneDimensionIntegerArray") {
- char json[] = "[[1,2],[3],[4]]";
-
- JsonArray& array = jsonBuffer.parseArray(json);
-
- int destination[3][2] = {{0}};
- array.copyTo(destination);
-
- REQUIRE(1 == destination[0][0]);
- REQUIRE(2 == destination[0][1]);
- REQUIRE(3 == destination[1][0]);
- REQUIRE(0 == destination[1][1]);
- REQUIRE(4 == destination[2][0]);
- REQUIRE(0 == destination[2][1]);
- }
-}
diff --git a/lib/ArduinoJson/test/JsonArray/invalid.cpp b/lib/ArduinoJson/test/JsonArray/invalid.cpp
deleted file mode 100644
index 045517ba..00000000
--- a/lib/ArduinoJson/test/JsonArray/invalid.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-// ArduinoJson - arduinojson.org
-// Copyright Benoit Blanchon 2014-2018
-// MIT License
-
-#include
-#include
-
-using namespace Catch::Matchers;
-
-TEST_CASE("JsonArray::invalid()") {
- SECTION("SubscriptFails") {
- REQUIRE_FALSE(JsonArray::invalid()[0].success());
- }
-
- SECTION("AddFails") {
- JsonArray& array = JsonArray::invalid();
- array.add(1);
- REQUIRE(0 == array.size());
- }
-
- SECTION("CreateNestedArrayFails") {
- REQUIRE_FALSE(JsonArray::invalid().createNestedArray().success());
- }
-
- SECTION("CreateNestedObjectFails") {
- REQUIRE_FALSE(JsonArray::invalid().createNestedObject().success());
- }
-
- SECTION("PrintToWritesBrackets") {
- char buffer[32];
- JsonArray::invalid().printTo(buffer, sizeof(buffer));
- REQUIRE_THAT(buffer, Equals("[]"));
- }
-}
diff --git a/lib/ArduinoJson/test/JsonArray/iterator.cpp b/lib/ArduinoJson/test/JsonArray/iterator.cpp
deleted file mode 100644
index fff81964..00000000
--- a/lib/ArduinoJson/test/JsonArray/iterator.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-// ArduinoJson - arduinojson.org
-// Copyright Benoit Blanchon 2014-2018
-// MIT License
-
-#include
-#include
-
-template
-static void run_iterator_test() {
- StaticJsonBuffer jsonBuffer;
-
- JsonArray &array = jsonBuffer.createArray();
- array.add(12);
- array.add(34);
-
- TIterator it = array.begin();
- TIterator end = array.end();
-
- REQUIRE(end != it);
- REQUIRE(12 == it->template as());
- REQUIRE(12 == static_cast(*it));
- ++it;
- REQUIRE(end != it);
- REQUIRE(34 == it->template as());
- REQUIRE(34 == static_cast(*it));
- ++it;
- REQUIRE(end == it);
-}
-
-TEST_CASE("JsonArray::begin()/end()") {
- SECTION("Mutable") {
- run_iterator_test();
- }
-
- SECTION("Const") {
- run_iterator_test();
- }
-}
diff --git a/lib/ArduinoJson/test/JsonArray/prettyPrintTo.cpp b/lib/ArduinoJson/test/JsonArray/prettyPrintTo.cpp
deleted file mode 100644
index fc5c526d..00000000
--- a/lib/ArduinoJson/test/JsonArray/prettyPrintTo.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-// ArduinoJson - arduinojson.org
-// Copyright Benoit Blanchon 2014-2018
-// MIT License
-
-#include
-#include
-
-static void check(JsonArray& array, std::string expected) {
- std::string actual;
- size_t actualLen = array.prettyPrintTo(actual);
- size_t measuredLen = array.measurePrettyLength();
- CHECK(actualLen == expected.size());
- CHECK(measuredLen == expected.size());
- REQUIRE(expected == actual);
-}
-
-TEST_CASE("JsonArray::prettyPrintTo()") {
- DynamicJsonBuffer jb;
- JsonArray& array = jb.createArray();
-
- SECTION("Empty") {
- check(array, "[]");
- }
-
- SECTION("OneElement") {
- array.add(1);
-
- check(array,
- "[\r\n"
- " 1\r\n"
- "]");
- }
-
- SECTION("TwoElements") {
- array.add(1);
- array.add(2);
-
- check(array,
- "[\r\n"
- " 1,\r\n"
- " 2\r\n"
- "]");
- }
-
- SECTION("EmptyNestedArrays") {
- array.createNestedArray();
- array.createNestedArray();
-
- check(array,
- "[\r\n"
- " [],\r\n"
- " []\r\n"
- "]");
- }
-
- SECTION("NestedArrays") {
- JsonArray& nested1 = array.createNestedArray();
- nested1.add(1);
- nested1.add(2);
-
- JsonObject& nested2 = array.createNestedObject();
- nested2["key"] = 3;
-
- check(array,
- "[\r\n"
- " [\r\n"
- " 1,\r\n"
- " 2\r\n"
- " ],\r\n"
- " {\r\n"
- " \"key\": 3\r\n"
- " }\r\n"
- "]");
- }
-}
diff --git a/lib/ArduinoJson/test/JsonArray/printTo.cpp b/lib/ArduinoJson/test/JsonArray/printTo.cpp
deleted file mode 100644
index 6b7f003c..00000000
--- a/lib/ArduinoJson/test/JsonArray/printTo.cpp
+++ /dev/null
@@ -1,132 +0,0 @@
-// ArduinoJson - arduinojson.org
-// Copyright Benoit Blanchon 2014-2018
-// MIT License
-
-#include
-#include
-
-static void check(JsonArray &array, std::string expected) {
- std::string actual;
- size_t actualLen = array.printTo(actual);
- REQUIRE(expected == actual);
- REQUIRE(actualLen == expected.size());
- size_t measuredLen = array.measureLength();
- REQUIRE(measuredLen == expected.size());
-}
-
-TEST_CASE("JsonArray::printTo()") {
- StaticJsonBuffer jb;
- JsonArray &array = jb.createArray();
-
- SECTION("Empty") {
- check(array, "[]");
- }
-
- SECTION("Null") {
- array.add(static_cast(0));
-
- check(array, "[null]");
- }
-
- SECTION("OneString") {
- array.add("hello");
-
- check(array, "[\"hello\"]");
- }
-
- SECTION("TwoStrings") {
- array.add("hello");
- array.add("world");
-
- check(array, "[\"hello\",\"world\"]");
- }
-
- SECTION("OneStringOverCapacity") {
- array.add("hello");
- array.add("world");
- array.add("lost");
-
- check(array, "[\"hello\",\"world\"]");
- }
-
- SECTION("One double") {
- array.add(3.1415927);
- check(array, "[3.1415927]");
- }
-
- SECTION("OneInteger") {
- array.add(1);
-
- check(array, "[1]");
- }
-
- SECTION("TwoIntegers") {
- array.add(1);
- array.add(2);
-
- check(array, "[1,2]");
- }
-
- SECTION("RawJson(const char*)") {
- array.add(RawJson("{\"key\":\"value\"}"));
-
- check(array, "[{\"key\":\"value\"}]");
- }
-
- SECTION("RawJson(char*)") {
- DynamicJsonBuffer jb2;
- JsonArray &arr = jb2.createArray();
-
- char tmp[] = "{\"key\":\"value\"}";
- arr.add(RawJson(tmp));
-
- check(arr, "[{\"key\":\"value\"}]");
- }
-
- SECTION("OneIntegerOverCapacity") {
- array.add(1);
- array.add(2);
- array.add(3);
-
- check(array, "[1,2]");
- }
-
- SECTION("OneTrue") {
- array.add(true);
-
- check(array, "[true]");
- }
-
- SECTION("OneFalse") {
- array.add(false);
-
- check(array, "[false]");
- }
-
- SECTION("TwoBooleans") {
- array.add(false);
- array.add(true);
-
- check(array, "[false,true]");
- }
-
- SECTION("OneBooleanOverCapacity") {
- array.add(false);
- array.add(true);
- array.add(false);
-
- check(array, "[false,true]");
- }
-
- SECTION("OneEmptyNestedArray") {
- array.createNestedArray();
-
- check(array, "[[]]");
- }
-
- SECTION("OneEmptyNestedHash") {
- array.createNestedObject();
-
- check(array, "[{}]");
- }
-}
diff --git a/lib/ArduinoJson/test/JsonArray/remove.cpp b/lib/ArduinoJson/test/JsonArray/remove.cpp
deleted file mode 100644
index 08935818..00000000
--- a/lib/ArduinoJson/test/JsonArray/remove.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-// ArduinoJson - arduinojson.org
-// Copyright Benoit Blanchon 2014-2018
-// MIT License
-
-#include
-#include
-
-TEST_CASE("JsonArray::remove()") {
- DynamicJsonBuffer _jsonBuffer;
- JsonArray& _array = _jsonBuffer.createArray();
- _array.add(1);
- _array.add(2);
- _array.add(3);
-
- SECTION("RemoveFirstByIndex") {
- _array.remove(0);
-
- REQUIRE(2 == _array.size());
- REQUIRE(_array[0] == 2);
- REQUIRE(_array[1] == 3);
- }
-
- SECTION("RemoveMiddleByIndex") {
- _array.remove(1);
-
- REQUIRE(2 == _array.size());
- REQUIRE(_array[0] == 1);
- REQUIRE(_array[1] == 3);
- }
-
- SECTION("RemoveLastByIndex") {
- _array.remove(2);
-
- REQUIRE(2 == _array.size());
- REQUIRE(_array[0] == 1);
- REQUIRE(_array[1] == 2);
- }
-
- SECTION("RemoveFirstByIterator") {
- JsonArray::iterator it = _array.begin();
- _array.remove(it);
-
- REQUIRE(2 == _array.size());
- REQUIRE(_array[0] == 2);
- REQUIRE(_array[1] == 3);
- }
-
- SECTION("RemoveMiddleByIterator") {
- JsonArray::iterator it = _array.begin();
- ++it;
- _array.remove(it);
-
- REQUIRE(2 == _array.size());
- REQUIRE(_array[0] == 1);
- REQUIRE(_array[1] == 3);
- }
-
- SECTION("RemoveLastByIterator") {
- JsonArray::iterator it = _array.begin();
- ++it;
- ++it;
- _array.remove(it);
-
- REQUIRE(2 == _array.size());
- REQUIRE(_array[0] == 1);
- REQUIRE(_array[1] == 2);
- }
-}
diff --git a/lib/ArduinoJson/test/JsonArray/set.cpp b/lib/ArduinoJson/test/JsonArray/set.cpp
deleted file mode 100644
index 901f9054..00000000
--- a/lib/ArduinoJson/test/JsonArray/set.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-// ArduinoJson - arduinojson.org
-// Copyright Benoit Blanchon 2014-2018
-// MIT License
-
-#include
-#include
-
-using namespace Catch::Matchers;
-
-TEST_CASE("JsonArray::set()") {
- DynamicJsonBuffer _jsonBuffer;
- JsonArray& _array = _jsonBuffer.createArray();
- _array.add(0);
-
- SECTION("int") {
- _array.set(0, 123);
- REQUIRE(123 == _array[0].as());
- REQUIRE(_array[0].is());
- REQUIRE_FALSE(_array[0].is());
- }
-
- SECTION("double") {
- _array.set(0, 123.45);
- REQUIRE(123.45 == _array[0].as());
- REQUIRE(_array[0].is());
- REQUIRE_FALSE(_array[0].is());
- }
-
- SECTION("bool") {
- _array.set(0, true);
- REQUIRE(true == _array[0].as());
- REQUIRE(_array[0].is());
- REQUIRE_FALSE(_array[0].is());
- }
-
- SECTION("const char*") {
- _array.set(0, "hello");
- REQUIRE_THAT(_array[0].as(), Equals("hello"));
- REQUIRE(_array[0].is());
- REQUIRE_FALSE(_array[0].is());
- }
-
- SECTION("nested array") {
- JsonArray& arr = _jsonBuffer.createArray();
-
- _array.set(0, arr);
-
- REQUIRE(&arr == &_array[0].as());
- REQUIRE(_array[0].is());
- REQUIRE_FALSE(_array[0].is());
- }
-
- SECTION("nested object") {
- JsonObject& obj = _jsonBuffer.createObject();
-
- _array.set(0, obj);
-
- REQUIRE(&obj == &_array[0].as());
- REQUIRE(_array[0].is());
- REQUIRE_FALSE(_array[0].is());
- }
-
- SECTION("array subscript") {
- JsonArray& arr = _jsonBuffer.createArray();
- arr.add("hello");
-
- _array.set(0, arr[0]);
-
- REQUIRE_THAT(_array[0].as(), Equals("hello"));
- }
-
- SECTION("object subscript") {
- JsonObject& obj = _jsonBuffer.createObject();
- obj["x"] = "hello";
-
- _array.set(0, obj["x"]);
-
- REQUIRE_THAT(_array[0].as(), Equals("hello"));
- }
-
- SECTION("should not duplicate const char*") {
- _array.set(0, "world");
- const size_t expectedSize = JSON_ARRAY_SIZE(1);
- REQUIRE(expectedSize == _jsonBuffer.size());
- }
-
- SECTION("should duplicate char*") {
- _array.set(0, const_cast("world"));
- const size_t expectedSize = JSON_ARRAY_SIZE(1) + 6;
- REQUIRE(expectedSize == _jsonBuffer.size());
- }
-
- SECTION("should duplicate std::string") {
- _array.set(0, std::string("world"));
- const size_t expectedSize = JSON_ARRAY_SIZE(1) + 6;
- REQUIRE(expectedSize == _jsonBuffer.size());
- }
-}
diff --git a/lib/ArduinoJson/test/JsonArray/size.cpp b/lib/ArduinoJson/test/JsonArray/size.cpp
deleted file mode 100644
index c45fe30e..00000000
--- a/lib/ArduinoJson/test/JsonArray/size.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-// ArduinoJson - arduinojson.org
-// Copyright Benoit Blanchon 2014-2018
-// MIT License
-
-#include
-#include
-
-TEST_CASE("JsonArray::size()") {
- DynamicJsonBuffer _jsonBuffer;
- JsonArray& _array = _jsonBuffer.createArray();
-
- SECTION("increases after add()") {
- _array.add("hello");
- REQUIRE(1U == _array.size());
-
- _array.add("world");
- REQUIRE(2U == _array.size());
- }
-
- SECTION("remains the same after set()") {
- _array.add("hello");
- REQUIRE(1U == _array.size());
-
- _array.set(0, "hello");
- REQUIRE(1U == _array.size());
- }
-
- SECTION("remains the same after assigment") {
- _array.add("hello");
- REQUIRE(1U == _array.size());
-
- _array[0] = "hello";
- REQUIRE(1U == _array.size());
- }
-}
diff --git a/lib/ArduinoJson/test/JsonArray/subscript.cpp b/lib/ArduinoJson/test/JsonArray/subscript.cpp
deleted file mode 100644
index 69893c53..00000000
--- a/lib/ArduinoJson/test/JsonArray/subscript.cpp
+++ /dev/null
@@ -1,119 +0,0 @@
-// ArduinoJson - arduinojson.org
-// Copyright Benoit Blanchon 2014-2018
-// MIT License
-
-#include
-#include
-#include
-
-TEST_CASE("JsonArray::operator[]") {
- DynamicJsonBuffer _jsonBuffer;
- JsonArray& _array = _jsonBuffer.createArray();
- _array.add(0);
-
- SECTION("int") {
- _array[0] = 123;
- REQUIRE(123 == _array[0].as());
- REQUIRE(true == _array[0].is());
- REQUIRE(false == _array[0].is());
- }
-
-#if ARDUINOJSON_USE_LONG_LONG || ARDUINOJSON_USE_INT64
- SECTION("long long") {
- _array[0] = 9223372036854775807;
- REQUIRE(9223372036854775807 == _array[0].as());
- REQUIRE(true == _array[0].is());
- REQUIRE(false == _array[0].is());
- }
-#endif
-
- SECTION("double") {
- _array[0] = 123.45;
- REQUIRE(123.45 == _array[0].as());
- REQUIRE(true == _array[0].is());
- REQUIRE(false == _array[0].is());
- }
-
- SECTION("bool") {
- _array[0] = true;
- REQUIRE(true == _array[0].as());
- REQUIRE(true == _array[0].is());
- REQUIRE(false == _array[0].is());
- }
-
- SECTION("const char*") {
- const char* str = "hello";
-
- _array[0] = str;
- REQUIRE(str == _array[0].as());
- REQUIRE(str == _array[0].as()); // <- short hand
- REQUIRE(true == _array[0].is());
- REQUIRE(false == _array[0].is());
- }
-
- SECTION("nested array") {
- JsonArray& arr = _jsonBuffer.createArray();
-
- _array[0] = arr;
-
- REQUIRE(&arr == &_array[0].as());
- REQUIRE(&arr == &_array[0].as()); // <- short hand
- REQUIRE(&arr == &_array[0].as());
- REQUIRE(&arr == &_array[0].as()); // <- short hand
- REQUIRE(true == _array[0].is());
- REQUIRE(false == _array[0].is());
- }
-
- SECTION("nested object") {
- JsonObject& obj = _jsonBuffer.createObject();
-
- _array[0] = obj;
-
- REQUIRE(&obj == &_array[0].as());
- REQUIRE(&obj == &_array[0].as()); // <- short hand
- REQUIRE(&obj == &_array[0].as());
- REQUIRE(&obj == &_array[0].as()); // <- short hand
- REQUIRE(true == _array[0].is());
- REQUIRE(false == _array[0].is());
- }
-
- SECTION("array subscript") {
- JsonArray& arr = _jsonBuffer.createArray();
- const char* str = "hello";
-
- arr.add(str);
-
- _array[0] = arr[0];
-
- REQUIRE(str == _array[0]);
- }
-
- SECTION("object subscript") {
- JsonObject& obj = _jsonBuffer.createObject();
- const char* str = "hello";
-
- obj["x"] = str;
-
- _array[0] = obj["x"];
-
- REQUIRE(str == _array[0]);
- }
-
- SECTION("should not duplicate const char*") {
- _array[0] = "world";
- const size_t expectedSize = JSON_ARRAY_SIZE(1);
- REQUIRE(expectedSize == _jsonBuffer.size());
- }
-
- SECTION("should duplicate char*") {
- _array[0] = const_cast("world");
- const size_t expectedSize = JSON_ARRAY_SIZE(1) + 6;
- REQUIRE(expectedSize == _jsonBuffer.size());
- }
-
- SECTION("should duplicate std::string") {
- _array[0] = std::string("world");
- const size_t expectedSize = JSON_ARRAY_SIZE(1) + 6;
- REQUIRE(expectedSize == _jsonBuffer.size());
- }
-}
diff --git a/lib/ArduinoJson/test/JsonBuffer/CMakeLists.txt b/lib/ArduinoJson/test/JsonBuffer/CMakeLists.txt
deleted file mode 100644
index 34b3e735..00000000
--- a/lib/ArduinoJson/test/JsonBuffer/CMakeLists.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-# ArduinoJson - arduinojson.org
-# Copyright Benoit Blanchon 2014-2018
-# MIT License
-
-add_executable(JsonBufferTests
- nested.cpp
- nestingLimit.cpp
- parse.cpp
- parseArray.cpp
- parseObject.cpp
-)
-
-target_link_libraries(JsonBufferTests catch)
-add_test(JsonBuffer JsonBufferTests)
diff --git a/lib/ArduinoJson/test/JsonBuffer/nested.cpp b/lib/ArduinoJson/test/JsonBuffer/nested.cpp
deleted file mode 100644
index 263e40e6..00000000
--- a/lib/ArduinoJson/test/JsonBuffer/nested.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-// ArduinoJson - arduinojson.org
-// Copyright Benoit Blanchon 2014-2018
-// MIT License
-
-#include
-#include
-
-TEST_CASE("JsonBuffer nested objects") {
- SECTION("ArrayNestedInObject") {
- DynamicJsonBuffer jsonBuffer;
- char jsonString[] = " { \"ab\" : [ 1 , 2 ] , \"cd\" : [ 3 , 4 ] } ";
-
- JsonObject &object = jsonBuffer.parseObject(jsonString);
- JsonArray &array1 = object["ab"];
- const JsonArray &array2 = object["cd"];
- JsonArray &array3 = object["ef"];
-
- REQUIRE(true == object.success());
-
- REQUIRE(true == array1.success());
- REQUIRE(true == array2.success());
- REQUIRE(false == array3.success());
-
- REQUIRE(2 == array1.size());
- REQUIRE(2 == array2.size());
- REQUIRE(0 == array3.size());
-
- REQUIRE(1 == array1[0].as());
- REQUIRE(2 == array1[1].as());
-
- REQUIRE(3 == array2[0].as());
- REQUIRE(4 == array2[1].as