thingtalk icon indicating copy to clipboard operation
thingtalk copied to clipboard

Refactor: new api

Open hidaris opened this issue 3 years ago • 0 comments

  1. Thing => ExposedThing
  2. add CosumedThing
  3. add Servient to support ExposedThing and CosumedThing
  4. move thing container to Sevient

example:

servient = Servient()
servient.addServer(
    HttpServer({
        port: 8081
    })
)


wot = await servient.start()

thing = wot.produce({
        "@context": "https://www.w3.org/2019/wot/td/v1",
        title: "MyCounter",
        properties: {
            count: {
                type: "integer",
            },
        },
    })

logger.info("Produced " + thing.getThingDescription().title)
thing.writeProperty("count", 0)

await thing.expose()
            
logger.info(thing.getThingDescription().title + " ready")
logger.info("TD : " + json.dumps(thing.getThingDescription()))
        
c = thing.readProperty("count")
logger.info("cound is " + c)

hidaris avatar Dec 09 '21 13:12 hidaris