From d2ae73fd44fa3a8692de28977e7f31de0754bd86 Mon Sep 17 00:00:00 2001 From: Tomasz Malek Date: Fri, 15 Apr 2022 15:31:12 +0200 Subject: [PATCH 1/7] Adding prefix 'Arduino' in client id for MKR boards --- src/LiveObjectsBase.h | 3 ++- src/LiveObjectsCellular.cpp | 15 ++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/LiveObjectsBase.h b/src/LiveObjectsBase.h index eb70959..b6283ec 100644 --- a/src/LiveObjectsBase.h +++ b/src/LiveObjectsBase.h @@ -24,6 +24,7 @@ #else #define MQTT_BROKER "liveobjects.orange-business.com" #endif +#define SDK_PREFIX "Arduino:" #define MQTT_USER "json+device" #define MQTT_PUBDATA "dev/data" #define MQTT_PUBDATA_BINARY "dev/v1/data/binary" @@ -265,7 +266,7 @@ class LiveObjectsBase private: unsigned long lastKeepAliveNetwork; protected: - String m_sMqttid; + String m_sMqttid = SDK_PREFIX; String m_sPayload; String m_sTopic; String m_sDecoder; diff --git a/src/LiveObjectsCellular.cpp b/src/LiveObjectsCellular.cpp index 8a20827..18cd490 100644 --- a/src/LiveObjectsCellular.cpp +++ b/src/LiveObjectsCellular.cpp @@ -102,17 +102,14 @@ void LiveObjectsCellular::connectNetwork() #endif if(modem.begin()) { - if(m_sMqttid.length()==0) + String imei=""; + for(int i=1;i<=3;i++) { - String imei=""; - for(int i=1;i<=3;i++) - { - imei=modem.getIMEI(); - if(imei.length()!=0) break; - delay(100*i); - } - m_sMqttid = imei; + imei=modem.getIMEI(); + if(imei.length()!=0) break; + delay(100*i); } + m_sMqttid += imei; } else { From 217bfd9080e3320cf26d1fb2016a64ddeb7995f7 Mon Sep 17 00:00:00 2001 From: Tomasz Malek Date: Fri, 15 Apr 2022 15:51:13 +0200 Subject: [PATCH 2/7] Version update --- src/LiveObjectsBase.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LiveObjectsBase.h b/src/LiveObjectsBase.h index b6283ec..dece2da 100644 --- a/src/LiveObjectsBase.h +++ b/src/LiveObjectsBase.h @@ -12,7 +12,7 @@ ******************************************************************************/ #define PAYLOAD_DATA_SIZE 1024 #define KEEP_ALIVE_NETWORK 1000 -#define SW_REVISION "2.0.2" +#define SW_REVISION "2.0.3" /****************************************************************************** From e17c71bf19f40f5949e3a55d9cc5e2740615fe30 Mon Sep 17 00:00:00 2001 From: Tomasz Malek Date: Fri, 15 Apr 2022 15:59:58 +0200 Subject: [PATCH 3/7] Adding prefix 'Arduino' in client id for ESP8266 boards --- src/LiveObjectsESP.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LiveObjectsESP.cpp b/src/LiveObjectsESP.cpp index 2f7dc65..a19de85 100644 --- a/src/LiveObjectsESP.cpp +++ b/src/LiveObjectsESP.cpp @@ -94,7 +94,7 @@ void LiveObjectsESP::connectNetwork() // outputDebug(INFO, m_sIP," ", m_sMqttid, " ", m_sMac); // delay(500); // } - m_sModel = m_sMac; + m_sModel = m_sMqttid; } void LiveObjectsESP::checkNetwork() From 873118a4e61995c7f36bf7802fc2faef65e7ced9 Mon Sep 17 00:00:00 2001 From: Tomasz Malek Date: Tue, 19 Apr 2022 10:05:26 +0200 Subject: [PATCH 4/7] Editorial amendment --- examples/1_send_data/1_send_data.ino | 2 +- examples/2_simple_parameters/2_simple_parameters.ino | 2 +- .../3_Parameter_with_callback/3_Parameter_with_callback.ino | 2 +- examples/4_Simple_command/4_Simple_command.ino | 2 +- examples/5_Command_with_arguments/5_Command_with_arguments.ino | 2 +- examples/6_sms_send_data/6_sms_send_data.ino | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/1_send_data/1_send_data.ino b/examples/1_send_data/1_send_data.ino index 19658a0..688ba3f 100644 --- a/examples/1_send_data/1_send_data.ino +++ b/examples/1_send_data/1_send_data.ino @@ -17,7 +17,7 @@ void setup() { Serial.begin(115200); Serial.print("\n*** Live Objects for Arduino MKR boards, revision "); Serial.print(SW_REVISION); - Serial.println("***"); + Serial.println(" ***"); lo.setSecurity(TLS); lo.begin(MQTT, TEXT, true); lo.connect(); // connects to the network + Live Objects diff --git a/examples/2_simple_parameters/2_simple_parameters.ino b/examples/2_simple_parameters/2_simple_parameters.ino index 1797e13..19d5f0f 100644 --- a/examples/2_simple_parameters/2_simple_parameters.ino +++ b/examples/2_simple_parameters/2_simple_parameters.ino @@ -22,7 +22,7 @@ void setup() { Serial.begin(115200); Serial.print("\n*** Live Objects on Arduino MKR NB boards, revision "); Serial.print(SW_REVISION); - Serial.println("***"); + Serial.println(" ***"); // Declaring a simple parameter stored in the variable 'messageRate'. // This parameter will become available for modification over the air from Live Objects diff --git a/examples/3_Parameter_with_callback/3_Parameter_with_callback.ino b/examples/3_Parameter_with_callback/3_Parameter_with_callback.ino index afc2373..fef5063 100644 --- a/examples/3_Parameter_with_callback/3_Parameter_with_callback.ino +++ b/examples/3_Parameter_with_callback/3_Parameter_with_callback.ino @@ -30,7 +30,7 @@ void setup() { Serial.begin(115200); Serial.print("\n*** Live Objects on Arduino MKR boards, revision "); Serial.print(SW_REVISION); - Serial.println("***"); + Serial.println(" ***"); // Declaring a parameter with a callback function 'processMsgRate'. // This function will be called after the update of the variable 'messageRate'. diff --git a/examples/4_Simple_command/4_Simple_command.ino b/examples/4_Simple_command/4_Simple_command.ino index cf24df5..fc19d62 100644 --- a/examples/4_Simple_command/4_Simple_command.ino +++ b/examples/4_Simple_command/4_Simple_command.ino @@ -34,7 +34,7 @@ void setup() { Serial.begin(115200); Serial.print("\n*** Live Objects on Arduino MKR boards, revision "); Serial.print(SW_REVISION); - Serial.println("***"); + Serial.println(" ***"); // Declaring a simple commands hadled by the function 'blinkLED5times'. lo.addCommand("blink", blinkLED5times); diff --git a/examples/5_Command_with_arguments/5_Command_with_arguments.ino b/examples/5_Command_with_arguments/5_Command_with_arguments.ino index b08cadc..b5f20d6 100644 --- a/examples/5_Command_with_arguments/5_Command_with_arguments.ino +++ b/examples/5_Command_with_arguments/5_Command_with_arguments.ino @@ -54,7 +54,7 @@ void setup() { Serial.begin(115200); Serial.print("\n*** Live Objects on Arduino MKR boards, revision "); Serial.print(SW_REVISION); - Serial.println("***"); + Serial.println(" ***"); // Declaring a simple commands hadled by the function 'blinkLED'. lo.addCommand("blink", blinkLED); diff --git a/examples/6_sms_send_data/6_sms_send_data.ino b/examples/6_sms_send_data/6_sms_send_data.ino index 1eebc1f..35a35c3 100644 --- a/examples/6_sms_send_data/6_sms_send_data.ino +++ b/examples/6_sms_send_data/6_sms_send_data.ino @@ -17,7 +17,7 @@ void setup() { Serial.begin(115200); Serial.print("\n*** Live Objects for Arduino MKR boards, revision "); Serial.print(SW_REVISION); - Serial.println("***"); + Serial.println(" ***"); lo.begin(SMS, TEXT, true); lo.connect(); // connects to the network + Live Objects } From 3e7e648de42897ba4f369d2ca5ab698be1a3c668 Mon Sep 17 00:00:00 2001 From: Tomasz Malek Date: Tue, 19 Apr 2022 10:24:14 +0200 Subject: [PATCH 5/7] Update of README.md files concerning security mode --- examples/1_send_data/README.md | 3 ++- examples/2_simple_parameters/README.md | 3 ++- examples/3_Parameter_with_callback/README.md | 3 ++- examples/4_Simple_command/README.md | 3 ++- examples/5_Command_with_arguments/README.md | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/examples/1_send_data/README.md b/examples/1_send_data/README.md index 9ed017b..690ff8d 100644 --- a/examples/1_send_data/README.md +++ b/examples/1_send_data/README.md @@ -7,7 +7,8 @@ This example shows how to send some sample data (device uptime) to Live Objects First of all, be sure that you installed the required libraries and generated an API key mentioned in the main README file, then: 1. Open "1_send_data.ino" sketch using Arduino IDE 2. Replace ```const char SECRET_LIVEOBJECTS_API_KEY[]="...";``` in arduino_secrets.h with API key you generated -3. Upload *1_send_data.ino* sketch to your Arduino MKR NB 1500 board +3. In ```lo.setSecurity()``` select security mode using ```TLS``` or ```NONE``` according to board abilities shown in **Compatibility** point in main **README.md** +4. Upload *1_send_data.ino* sketch to your Arduino MKR NB 1500 board ## Verify diff --git a/examples/2_simple_parameters/README.md b/examples/2_simple_parameters/README.md index 2ce04a4..d8f4750 100644 --- a/examples/2_simple_parameters/README.md +++ b/examples/2_simple_parameters/README.md @@ -8,7 +8,8 @@ Parameters give you ability to configure your device over the air from Live Obje First of all, be sure that you installed the required libraries and generated an API key mentioned in the main README file, then: 1. Open "2_simple_parameters.ino" sketch using Arduino IDE 2. Replace ```const char SECRET_LIVEOBJECTS_API_KEY[]="...";``` in arduino_secrets.h with API key you generated -3. Upload *2_simple_parameters.ino* sketch to your Arduino MKR NB 1500 board +3. In ```lo.setSecurity()``` select security mode using ```TLS``` or ```NONE``` according to board abilities shown in **Compatibility** point in main **README.md** +4. Upload *2_simple_parameters.ino* sketch to your Arduino MKR NB 1500 board ## Verify diff --git a/examples/3_Parameter_with_callback/README.md b/examples/3_Parameter_with_callback/README.md index 2e29002..de5fb7d 100644 --- a/examples/3_Parameter_with_callback/README.md +++ b/examples/3_Parameter_with_callback/README.md @@ -16,7 +16,8 @@ This is how callback function will look like:
First of all, be sure that you installed the required libraries and generated an API key mentioned in the main README file, then: 1. Open "3_parameter_with_callback.ino" sketch using Arduino IDE 2. Replace ```const char SECRET_LIVEOBJECTS_API_KEY[]="...";``` in arduino_secrets.h with API key you generated -3. Upload *3_parameter_with_callback.ino* sketch to your Arduino MKR NB 1500 board +3. In ```lo.setSecurity()``` select security mode using ```TLS``` or ```NONE``` according to board abilities shown in **Compatibility** point in main **README.md** +4. Upload *3_parameter_with_callback.ino* sketch to your Arduino MKR NB 1500 board ## Verify diff --git a/examples/4_Simple_command/README.md b/examples/4_Simple_command/README.md index 42b258b..c6063cd 100644 --- a/examples/4_Simple_command/README.md +++ b/examples/4_Simple_command/README.md @@ -11,7 +11,8 @@ In this example we will use command to make Arduino onboard LED blink. First of all, be sure that you installed the required libraries and generated an API key mentioned in the main README file, then: 1. Open "4_simple_command.ino" sketch using Arduino IDE 2. Replace ```const char SECRET_LIVEOBJECTS_API_KEY[]="...";``` in arduino_secrets.h with API key you generated -3. Upload *4_simple_command.ino* sketch to your Arduino MKR NB 1500 board +3. In ```lo.setSecurity()``` select security mode using ```TLS``` or ```NONE``` according to board abilities shown in **Compatibility** point in main **README.md** +4. Upload *4_simple_command.ino* sketch to your Arduino MKR NB 1500 board ## Verify **Is device online:**
diff --git a/examples/5_Command_with_arguments/README.md b/examples/5_Command_with_arguments/README.md index 0c8e6a3..3f909e3 100644 --- a/examples/5_Command_with_arguments/README.md +++ b/examples/5_Command_with_arguments/README.md @@ -11,7 +11,8 @@ In this example we will use command to make Arduino onboard LED blink. Unlike in First of all, be sure that you installed the required libraries and generated an API key mentioned in the main README file, then: 1. Open "5_simple_command.ino" sketch using Arduino IDE 2. Replace ```const char SECRET_LIVEOBJECTS_API_KEY[]="...";``` in arduino_secrets.h with API key you generated -3. Upload *5_simple_command.ino* sketch to your Arduino MKR NB 1500 board +3. In ```lo.setSecurity()``` select security mode using ```TLS``` or ```NONE``` according to board abilities shown in **Compatibility** point in main **README.md** +4. Upload *5_simple_command.ino* sketch to your Arduino MKR NB 1500 board ## Verify **Is device online:**
From 833ca12daab620ba19cca91c1335ed49c299078b Mon Sep 17 00:00:00 2001 From: Tomasz Malek Date: Tue, 19 Apr 2022 11:57:53 +0200 Subject: [PATCH 6/7] Typo correction --- .../5_Command_with_arguments/5_Command_with_arguments.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/5_Command_with_arguments/5_Command_with_arguments.ino b/examples/5_Command_with_arguments/5_Command_with_arguments.ino index b5f20d6..06a21a1 100644 --- a/examples/5_Command_with_arguments/5_Command_with_arguments.ino +++ b/examples/5_Command_with_arguments/5_Command_with_arguments.ino @@ -31,7 +31,7 @@ void blinkLED(const String arguments, String &response) { int timeOn = incomingArguments["time ON"]; // arguments are now accessible using their name int timeOff = incomingArguments["time OFF"]; int reps = incomingArguments["repetitions"]; - unsigned long elaspedTime = millis(); // will keep track of time in order to compute the animation duration + unsigned long elapsedTime = millis(); // will keep track of time in order to compute the animation duration pinMode(LED_BUILTIN, OUTPUT); for (byte i = 0; i < reps; i++) { @@ -41,10 +41,10 @@ void blinkLED(const String arguments, String &response) { delay(timeOff); } - elaspedTime = millis() - elaspedTime; + elapsedTime = millis() - elapsedTime; StaticJsonDocument<128> outgoingResponse; // creation of a JSON document that will hold the response - outgoingResponse["animation duration (milliseconds)"] = elaspedTime; // adding reponse item (you can add several by repeating the line): + outgoingResponse["animation duration (milliseconds)"] = elapsedTime; // adding reponse item (you can add several by repeating the line): serializeJson(outgoingResponse, response); // exporting JSON in 'reponse' String // example of 'response' content: "{\"animation duration (milliseconds)\":5000}" } From a154404d603493a6fa7d01ed8e638c5ce9befa8e Mon Sep 17 00:00:00 2001 From: Tomasz Malek Date: Tue, 19 Apr 2022 14:12:34 +0200 Subject: [PATCH 7/7] Improvement connected with LED blinking --- examples/4_Simple_command/4_Simple_command.ino | 4 ++-- .../5_Command_with_arguments/5_Command_with_arguments.ino | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/4_Simple_command/4_Simple_command.ino b/examples/4_Simple_command/4_Simple_command.ino index fc19d62..a2bee0b 100644 --- a/examples/4_Simple_command/4_Simple_command.ino +++ b/examples/4_Simple_command/4_Simple_command.ino @@ -21,10 +21,10 @@ unsigned long lastMessageTime = 0; // stores the time when last data message w void blinkLED5times(const String arguments, String &response) { pinMode(LED_BUILTIN, OUTPUT); for (byte i = 0; i < 5; i++) { - digitalWrite(LED_BUILTIN, HIGH); - delay(250); digitalWrite(LED_BUILTIN, LOW); delay(250); + digitalWrite(LED_BUILTIN, HIGH); + delay(250); } response = "{\"blinked\":\"5 times\"}"; } diff --git a/examples/5_Command_with_arguments/5_Command_with_arguments.ino b/examples/5_Command_with_arguments/5_Command_with_arguments.ino index 06a21a1..a120a8b 100644 --- a/examples/5_Command_with_arguments/5_Command_with_arguments.ino +++ b/examples/5_Command_with_arguments/5_Command_with_arguments.ino @@ -35,9 +35,9 @@ void blinkLED(const String arguments, String &response) { pinMode(LED_BUILTIN, OUTPUT); for (byte i = 0; i < reps; i++) { - digitalWrite(LED_BUILTIN, HIGH); - delay(timeOn); digitalWrite(LED_BUILTIN, LOW); + delay(timeOn); + digitalWrite(LED_BUILTIN, HIGH); delay(timeOff); }