orchestracities / lego-diorama-usi-2022

This repository hosts code, configuration and documentation to deploy Orchestra Cities lego diorama.
Apache License 2.0
0 stars 0 forks source link

formatting topics according to fiware iot-agents #18

Closed chicco785 closed 2 years ago

chicco785 commented 2 years ago

instead of passing the topic as variable, let's compose it inside the code following fiware protocol

a topic will be formed by:

a topic to read/write sensor values will be as follow: /<protocol>/<service_api_key>/<sensor_id>/attrs

i.e. supposed that the protocol is json, the service api key is 4jggokgpepnvsb2uv4s40d59ov and the sensor is urn:streetlight:001: /json/4jggokgpepnvsb2uv4s40d59ov/urn:streetlight:001/attrs

a message to update attributes is a json payload serialized as a string that maps attribute names to values:

{"attribute_name": "value"}

e.g.:

{"h": 70, "t": 15}

i.e., updating the sensor values will be a mqtt command as:

$ mosquitto_pub -t /json/4jggokgpepnvsb2uv4s40d59ov/urn:streetlight:001/attrs -m '{"h": 70, "t": 15}' -h <mosquitto_broker> -p <mosquitto_port> -u <user> -P <password>

a topic to receive commands will be as follow: /<protocol>/<service_api_key>/<sensor_id>/cmd

i.e. supposed that the protocol is json, the service api key is 4jggokgpepnvsb2uv4s40d59ov and the sensor is urn:streetlight:001: /json/4jggokgpepnvsb2uv4s40d59ov/urn:streetlight:001/cmd

a message to receive command is a json payload serialized as a string that maps command names to passed parameters and their values:

{ "command name": { "command parameter":  "value" } }

e.g.

{ "light": { "switch":  "on" } }

last, but not least, once a sensor receive a commands and execute it, it should confirm the execution (or report error) on the topic: /<protocol>/<service_api_key>/<sensor_id>/cmdexe

i.e. supposed that the protocol is json, the service api key is 4jggokgpepnvsb2uv4s40d59ov and the sensor is urn:streetlight:001: /json/4jggokgpepnvsb2uv4s40d59ov/urn:streetlight:001/cmdexe

the message to be sent is a json payload serialized as a string that maps attribute names to values:

{ "command name": { "command parameter":  "value" } }

e.g.

{ "light": { "switch":  "ok" } }
inchesg commented 2 years ago

@casarf when done with milestone 0.2 jump on this task and help @Solargi

Solargi commented 2 years ago

we have decided that the group of street lights on street 1 will be part of a single sensor id, and the lights on street 2 will be part of another single sensor id since we want to control all the lights on a particular street at once.