Skip to content

Commit

Permalink
Merge pull request #14 from tomekmalek/master
Browse files Browse the repository at this point in the history
Change client id naming
  • Loading branch information
tomekmalek authored Apr 20, 2022
2 parents 74cf865 + a154404 commit 9c6e969
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 30 deletions.
2 changes: 1 addition & 1 deletion examples/1_send_data/1_send_data.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion examples/1_send_data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/2_simple_parameters/2_simple_parameters.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion examples/2_simple_parameters/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'.
Expand Down
3 changes: 2 additions & 1 deletion examples/3_Parameter_with_callback/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ This is how callback function will look like:<br>
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
Expand Down
6 changes: 3 additions & 3 deletions examples/4_Simple_command/4_Simple_command.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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\"}";
}
Expand All @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion examples/4_Simple_command/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:**<br>
Expand Down
12 changes: 6 additions & 6 deletions examples/5_Command_with_arguments/5_Command_with_arguments.ino
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ 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++) {
digitalWrite(LED_BUILTIN, HIGH);
delay(timeOn);
digitalWrite(LED_BUILTIN, LOW);
delay(timeOn);
digitalWrite(LED_BUILTIN, HIGH);
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}"
}
Expand All @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion examples/5_Command_with_arguments/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:**<br>
Expand Down
2 changes: 1 addition & 1 deletion examples/6_sms_send_data/6_sms_send_data.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 3 additions & 2 deletions src/LiveObjectsBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"


/******************************************************************************
Expand All @@ -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"
Expand Down Expand Up @@ -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;
Expand Down
15 changes: 6 additions & 9 deletions src/LiveObjectsCellular.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/LiveObjectsESP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 9c6e969

Please sign in to comment.