Skip to content

Commit

Permalink
New feature
Browse files Browse the repository at this point in the history
New function addTag() to tag the data message with custom tags
  • Loading branch information
mdelain authored Jan 11, 2025
1 parent d9747a8 commit cf772a1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/LiveObjectsBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,13 @@ void LiveObjectsBase::addLocation(double lat, double lon, double alt)
else addToStringPayload(lat,lon,alt);
}

void LiveObjectsBase::addTag(const char* tag)
{
if (!easyDataPayload[JSONTAGS].is<JsonArray>())
tags = easyDataPayload.createNestedArray(JSONTAGS);
tags.add(tag);
}

void LiveObjectsBase::clearPayload()
{
easyDataPayload.clear();
Expand Down
4 changes: 4 additions & 0 deletions src/LiveObjectsBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#define JSONCFGTYPE "t"
#define JSONMODEL "model"
#define JSONVALUE "value"
#define JSONTAGS "tags"

/******************************************************************************
INCLUDES
Expand Down Expand Up @@ -176,6 +177,7 @@ class LiveObjectsBase
public:
void addTimestamp(time_t timestamp);
void addLocation(double lat, double lon, double alt);
void addTag(const char* tag);
virtual void addPowerStatus()=0;
virtual void addNetworkInfo()=0;
void clearPayload();
Expand Down Expand Up @@ -259,6 +261,8 @@ class LiveObjectsBase
LinkedList<LiveObjects_parameter> parameters;
LiveObjects_networkStatus networkStatus = DISCONNECTED;
StaticJsonDocument<PAYLOAD_DATA_SIZE> easyDataPayload;
JsonArray tags;

/******************************************************************************
VARIABLES
******************************************************************************/
Expand Down

0 comments on commit cf772a1

Please sign in to comment.