Skip to content

Commit 3b12484

Browse files
authored
Merge pull request #19 from Citrullin/TD_fixes
Some fixes in the TD
2 parents ba8a111 + 17e0334 commit 3b12484

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

Thing.h

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -555,10 +555,10 @@ class ThingDevice {
555555
}
556556

557557
void serialize(JsonObject descr, String ip, uint16_t port) {
558-
descr["id"] = this->id;
558+
descr["id"] = "uri:" + this->id;
559559
descr["title"] = this->title;
560560
JsonArray context = descr.createNestedArray("@context");
561-
context.add("https://www.w3.org./2019/wot/td/v1");
561+
context.add("https://www.w3.org/2019/wot/td/v1");
562562

563563
if (this->description != "") {
564564
descr["description"] = this->description;
@@ -575,28 +575,26 @@ class ThingDevice {
575575
descr.createNestedObject("securityDefinitions");
576576
JsonObject nosecSc = securityDefinitions.createNestedObject("nosec_sc");
577577
nosecSc["scheme"] = "nosec";
578-
descr["security"] = "nosec_sc";
578+
JsonArray securityJson = descr.createNestedArray("security");
579+
securityJson.add("nosec_sc");
579580

580581
JsonArray typeJson = descr.createNestedArray("@type");
581582
const char **type = this->type;
582583
while ((*type) != nullptr) {
583584
typeJson.add(*type);
584585
type++;
585586
}
586-
587-
JsonArray forms = descr.createNestedArray("forms");
588-
{
587+
588+
ThingProperty *property = this->firstProperty;
589+
if (property != nullptr) {
590+
JsonArray forms = descr.createNestedArray("forms");
589591
JsonObject forms_prop = forms.createNestedObject();
590592
forms_prop["rel"] = "properties";
591593
JsonArray context = forms_prop.createNestedArray("op");
592594
context.add("readallproperties");
593595
context.add("writeallproperties");
594596
forms_prop["href"] = "/things/" + this->id + "/properties";
595-
}
596597

597-
598-
ThingProperty *property = this->firstProperty;
599-
if (property != nullptr) {
600598
JsonObject properties = descr.createNestedObject("properties");
601599
while (property != nullptr) {
602600
JsonObject obj = properties.createNestedObject(property->id);

0 commit comments

Comments
 (0)