Skip to content

Commit

Permalink
setModel()
Browse files Browse the repository at this point in the history
  • Loading branch information
Kacp3r3 committed Nov 12, 2020
1 parent caa1d0e commit 0cee386
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 33 deletions.
1 change: 1 addition & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ setSecurity KEYWORD2
enableDebug KEYWORD2
setClientID KEYWORD2
setDecoder KEYWORD2
setModel KEYWORD2
debugEnabled KEYWORD2
addTimestamp KEYWORD2
addLocation KEYWORD2
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ category=Communication
url=https://github.com/DatavenueLiveObjects/LiveObjects_SDK_for_Arduino
architectures=*
includes=LiveObjects.h
depends=WiFiNINA,MKRNB,ArduinoJson,MKRGSM,WiFi101
depends=WiFiNINA,MKRNB,ArduinoJson,MKRGSM,WiFi101,PubSubClient
25 changes: 0 additions & 25 deletions src/ArduinoMqttClient.h

This file was deleted.

10 changes: 8 additions & 2 deletions src/LiveObjectsBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ LiveObjectsBase::LiveObjectsBase()
lastKeepAliveNetwork(5000)
,m_sPayload()
,m_sDecoder()
,m_sModel("Orange")
,m_Security(NONE)
,m_bDebug(false)
,m_bInitialized(false)
Expand Down Expand Up @@ -277,7 +278,7 @@ void LiveObjectsBase::sendData() {
{
if(m_Encoding==TEXT)
{
easyDataPayload[JSONMODEL] = JSONMODELNAME;
easyDataPayload[JSONMODEL] = m_sModel;
publishMessage(m_sTopic, easyDataPayload);
easyDataPayload.clear();
}
Expand All @@ -294,7 +295,7 @@ void LiveObjectsBase::sendData(const String customPayload) {
{
StaticJsonDocument<PAYLOAD_DATA_SIZE> payload;
deserializeJson(payload, customPayload);
if (!payload.containsKey(JSONMODEL)) payload[JSONMODEL] = JSONMODELNAME;
if (!payload.containsKey(JSONMODEL)) payload[JSONMODEL] = m_sModel;
publishMessage(m_sTopic, payload);
}
else publishMessage(m_sTopic, const_cast<String&>(customPayload));
Expand Down Expand Up @@ -388,6 +389,11 @@ void LiveObjectsBase::setDecoder(String s)
m_sDecoder += s;
}

void LiveObjectsBase::setModel(String s)
{
m_sModel = s;
}

void LiveObjectsBase::addTimestamp(time_t timestamp)
{
#ifndef ARDUINO_ARCH_AVR
Expand Down
3 changes: 2 additions & 1 deletion src/LiveObjectsBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#define JSONCFGTYPE "t"
#define JSONMODEL "model"
#define JSONVALUE "value"
#define JSONMODELNAME "Orange_Pollution_Shield"
/******************************************************************************
INCLUDES
******************************************************************************/
Expand Down Expand Up @@ -157,6 +156,7 @@ class LiveObjectsBase
void enableDebug(bool b);
void setClientID(const String id);
void setDecoder(String s);
void setModel(String s);

public:
bool debugEnabled();
Expand Down Expand Up @@ -258,6 +258,7 @@ class LiveObjectsBase
String m_sPayload;
String m_sTopic;
String m_sDecoder;
String m_sModel;
uint16_t m_nPort;
Protocol m_Protocol;
Security m_Security;
Expand Down
2 changes: 2 additions & 0 deletions src/LiveObjectsCellular.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ void LiveObjectsCellular::connectNetwork()
}
}
}

m_sModel = m_sMqttid;
}


Expand Down
1 change: 1 addition & 0 deletions src/LiveObjectsESP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ void LiveObjectsESP::connectNetwork()
// outputDebug(INFO, m_sIP," ", m_sMqttid, " ", m_sMac);
// delay(500);
// }
m_sModel = m_sMac;
}

void LiveObjectsESP::checkNetwork()
Expand Down
10 changes: 8 additions & 2 deletions src/LiveObjectsFona.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ void LiveObjectsFona::connect()
}
Serial.println("[INFO] Connected to Cellular!");
delay(5000); // wait a few seconds to stabilize connection
m_Fona.getIMEI(m_sClientID);
setModel(m_sClientID);
if(m_Protocol==MQTT)
{
m_Fona.getIMEI(m_sClientID);
connectMQTT();
}
}
Expand All @@ -54,7 +55,7 @@ void LiveObjectsFona::sendData()
{
if(m_Encoding==TEXT)
{
m_Payload[JSONMODEL] = JSONMODELNAME;
m_Payload[JSONMODEL] = m_sModel;
publishMessage(MQTT_PUBDATA, m_Payload);
}
//else publishMessage(m_sTopic+m_sDecoder, m_sPayload);
Expand Down Expand Up @@ -113,6 +114,11 @@ void LiveObjectsFona::setDecoder(char* s)
//Serial.print("[ERROR] This board doesn't support this function");
}

void LiveObjectsFona::setModel(char* s)
{
strcpy(m_sModel,s);
}

void LiveObjectsFona::addTimestamp(time_t timestamp)
{
//Serial.print("[ERROR] This board doesn't support this function");
Expand Down
3 changes: 2 additions & 1 deletion src/LiveObjectsFona.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#define JSONCFGTYPE "t"
#define JSONMODEL "model"
#define JSONVALUE "value"
#define JSONMODELNAME "Orange_Pollution_Shield"

#include <SoftwareSerial.h>
#include <Adafruit_FONA.h>
Expand Down Expand Up @@ -153,6 +152,7 @@ struct LiveObjects_parameter
void setSecurity(Security s);
void enableDebug(bool b);
void setDecoder(char* s);
void setModel(char* s);
void addTimestamp(time_t timestamp);
void addLocation(double lat, double lon, double alt);
void addPowerStatus();
Expand Down Expand Up @@ -181,6 +181,7 @@ struct LiveObjects_parameter
Encoding m_Encoding;
Security m_Security;
char m_sClientID[16];
char m_sModel[16];
char m_BufferPayload[PAYLOAD_DATA_SIZE];
uint16_t m_nPort;
unsigned long lastKeepAliveNetwork;
Expand Down
2 changes: 1 addition & 1 deletion src/LiveObjectsMKR.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
MKR BOARDS BASE CLASS
******************************************************************************/
#include "LiveObjectsBase.h"
#include "ArduinoMqttClient.h"
#include "MqttClient.h"
class LiveObjectsMKR : public LiveObjectsBase
{
protected:
Expand Down
1 change: 1 addition & 0 deletions src/LiveObjectsWiFi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ void LiveObjectsWiFi::connectNetwork()
}
if(i!=0) m_sMac += ':';
}
m_sModel = m_sMqttid;
}
void LiveObjectsWiFi::checkNetwork()
{
Expand Down

0 comments on commit 0cee386

Please sign in to comment.