diff --git a/Thing.h b/Thing.h index 25a6ea3..2f45f13 100644 --- a/Thing.h +++ b/Thing.h @@ -470,6 +470,7 @@ class ThingDevice { String id; String title; String description; + JsonObject context; const char **type; #if !defined(WITHOUT_WS) && (defined(ESP8266) || defined(ESP32)) AsyncWebSocket *ws = nullptr; @@ -481,6 +482,9 @@ class ThingDevice { ThingEvent *firstEvent = nullptr; ThingEventObject *eventQueue = nullptr; + ThingDevice(const char *_id, const char *_title, const char **_type, JsonObject _context) + : id(_id), title(_title), type(_type), context(_context) {} + ThingDevice(const char *_id, const char *_title, const char **_type) : id(_id), title(_title), type(_type) {} @@ -698,7 +702,11 @@ class ThingDevice { void serialize(JsonObject descr, String ip, uint16_t port) { descr["id"] = this->id; descr["title"] = this->title; - descr["@context"] = "https://webthings.io/schemas"; + if (this->context) { + descr["@context"] = this->context; + } else { + descr["@context"] = "https://webthings.io/schemas"; + } if (this->description != "") { descr["description"] = this->description;