Skip to content

Commit 621fc57

Browse files
committed
Support richer context in the BaseThing
1 parent 98b916e commit 621fc57

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Thing.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ class ThingDevice {
470470
String id;
471471
String title;
472472
String description;
473+
JsonObject context;
473474
const char **type;
474475
#if !defined(WITHOUT_WS) && (defined(ESP8266) || defined(ESP32))
475476
AsyncWebSocket *ws = nullptr;
@@ -484,6 +485,9 @@ class ThingDevice {
484485
ThingDevice(const char *_id, const char *_title, const char **_type)
485486
: id(_id), title(_title), type(_type) {}
486487

488+
ThingDevice(const char *_id, const char *_title, const char **_type, JsonObject _context)
489+
: id(_id), title(_title), type(_type), context(_context) {}
490+
487491
~ThingDevice() {
488492
#if !defined(WITHOUT_WS) && (defined(ESP8266) || defined(ESP32))
489493
if (ws)
@@ -698,7 +702,11 @@ class ThingDevice {
698702
void serialize(JsonObject descr, String ip, uint16_t port) {
699703
descr["id"] = this->id;
700704
descr["title"] = this->title;
701-
descr["@context"] = "https://webthings.io/schemas";
705+
if (this->context) {
706+
descr["@context"] = this->context;
707+
} else {
708+
descr["@context"] = "https://webthings.io/schemas";
709+
}
702710

703711
if (this->description != "") {
704712
descr["description"] = this->description;

0 commit comments

Comments
 (0)