Skip to content

Commit 0cee386

Browse files
committed
setModel()
1 parent caa1d0e commit 0cee386

11 files changed

+27
-33
lines changed

keywords.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ setSecurity KEYWORD2
1313
enableDebug KEYWORD2
1414
setClientID KEYWORD2
1515
setDecoder KEYWORD2
16+
setModel KEYWORD2
1617
debugEnabled KEYWORD2
1718
addTimestamp KEYWORD2
1819
addLocation KEYWORD2

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ category=Communication
88
url=https://github.com/DatavenueLiveObjects/LiveObjects_SDK_for_Arduino
99
architectures=*
1010
includes=LiveObjects.h
11-
depends=WiFiNINA,MKRNB,ArduinoJson,MKRGSM,WiFi101
11+
depends=WiFiNINA,MKRNB,ArduinoJson,MKRGSM,WiFi101,PubSubClient

src/ArduinoMqttClient.h

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/LiveObjectsBase.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LiveObjectsBase::LiveObjectsBase()
55
lastKeepAliveNetwork(5000)
66
,m_sPayload()
77
,m_sDecoder()
8+
,m_sModel("Orange")
89
,m_Security(NONE)
910
,m_bDebug(false)
1011
,m_bInitialized(false)
@@ -277,7 +278,7 @@ void LiveObjectsBase::sendData() {
277278
{
278279
if(m_Encoding==TEXT)
279280
{
280-
easyDataPayload[JSONMODEL] = JSONMODELNAME;
281+
easyDataPayload[JSONMODEL] = m_sModel;
281282
publishMessage(m_sTopic, easyDataPayload);
282283
easyDataPayload.clear();
283284
}
@@ -294,7 +295,7 @@ void LiveObjectsBase::sendData(const String customPayload) {
294295
{
295296
StaticJsonDocument<PAYLOAD_DATA_SIZE> payload;
296297
deserializeJson(payload, customPayload);
297-
if (!payload.containsKey(JSONMODEL)) payload[JSONMODEL] = JSONMODELNAME;
298+
if (!payload.containsKey(JSONMODEL)) payload[JSONMODEL] = m_sModel;
298299
publishMessage(m_sTopic, payload);
299300
}
300301
else publishMessage(m_sTopic, const_cast<String&>(customPayload));
@@ -388,6 +389,11 @@ void LiveObjectsBase::setDecoder(String s)
388389
m_sDecoder += s;
389390
}
390391

392+
void LiveObjectsBase::setModel(String s)
393+
{
394+
m_sModel = s;
395+
}
396+
391397
void LiveObjectsBase::addTimestamp(time_t timestamp)
392398
{
393399
#ifndef ARDUINO_ARCH_AVR

src/LiveObjectsBase.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#define JSONCFGTYPE "t"
3131
#define JSONMODEL "model"
3232
#define JSONVALUE "value"
33-
#define JSONMODELNAME "Orange_Pollution_Shield"
3433
/******************************************************************************
3534
INCLUDES
3635
******************************************************************************/
@@ -157,6 +156,7 @@ class LiveObjectsBase
157156
void enableDebug(bool b);
158157
void setClientID(const String id);
159158
void setDecoder(String s);
159+
void setModel(String s);
160160

161161
public:
162162
bool debugEnabled();
@@ -258,6 +258,7 @@ class LiveObjectsBase
258258
String m_sPayload;
259259
String m_sTopic;
260260
String m_sDecoder;
261+
String m_sModel;
261262
uint16_t m_nPort;
262263
Protocol m_Protocol;
263264
Security m_Security;

src/LiveObjectsCellular.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ void LiveObjectsCellular::connectNetwork()
157157
}
158158
}
159159
}
160+
161+
m_sModel = m_sMqttid;
160162
}
161163

162164

src/LiveObjectsESP.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ void LiveObjectsESP::connectNetwork()
9393
// outputDebug(INFO, m_sIP," ", m_sMqttid, " ", m_sMac);
9494
// delay(500);
9595
// }
96+
m_sModel = m_sMac;
9697
}
9798

9899
void LiveObjectsESP::checkNetwork()

src/LiveObjectsFona.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ void LiveObjectsFona::connect()
4141
}
4242
Serial.println("[INFO] Connected to Cellular!");
4343
delay(5000); // wait a few seconds to stabilize connection
44+
m_Fona.getIMEI(m_sClientID);
45+
setModel(m_sClientID);
4446
if(m_Protocol==MQTT)
4547
{
46-
m_Fona.getIMEI(m_sClientID);
4748
connectMQTT();
4849
}
4950
}
@@ -54,7 +55,7 @@ void LiveObjectsFona::sendData()
5455
{
5556
if(m_Encoding==TEXT)
5657
{
57-
m_Payload[JSONMODEL] = JSONMODELNAME;
58+
m_Payload[JSONMODEL] = m_sModel;
5859
publishMessage(MQTT_PUBDATA, m_Payload);
5960
}
6061
//else publishMessage(m_sTopic+m_sDecoder, m_sPayload);
@@ -113,6 +114,11 @@ void LiveObjectsFona::setDecoder(char* s)
113114
//Serial.print("[ERROR] This board doesn't support this function");
114115
}
115116

117+
void LiveObjectsFona::setModel(char* s)
118+
{
119+
strcpy(m_sModel,s);
120+
}
121+
116122
void LiveObjectsFona::addTimestamp(time_t timestamp)
117123
{
118124
//Serial.print("[ERROR] This board doesn't support this function");

src/LiveObjectsFona.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#define JSONCFGTYPE "t"
3232
#define JSONMODEL "model"
3333
#define JSONVALUE "value"
34-
#define JSONMODELNAME "Orange_Pollution_Shield"
3534

3635
#include <SoftwareSerial.h>
3736
#include <Adafruit_FONA.h>
@@ -153,6 +152,7 @@ struct LiveObjects_parameter
153152
void setSecurity(Security s);
154153
void enableDebug(bool b);
155154
void setDecoder(char* s);
155+
void setModel(char* s);
156156
void addTimestamp(time_t timestamp);
157157
void addLocation(double lat, double lon, double alt);
158158
void addPowerStatus();
@@ -181,6 +181,7 @@ struct LiveObjects_parameter
181181
Encoding m_Encoding;
182182
Security m_Security;
183183
char m_sClientID[16];
184+
char m_sModel[16];
184185
char m_BufferPayload[PAYLOAD_DATA_SIZE];
185186
uint16_t m_nPort;
186187
unsigned long lastKeepAliveNetwork;

src/LiveObjectsMKR.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
MKR BOARDS BASE CLASS
44
******************************************************************************/
55
#include "LiveObjectsBase.h"
6-
#include "ArduinoMqttClient.h"
6+
#include "MqttClient.h"
77
class LiveObjectsMKR : public LiveObjectsBase
88
{
99
protected:

0 commit comments

Comments
 (0)