orchestracities/lego-diorama-usi-2022

formatting topics according to fiware iot-agents

Closed this issue · 2 comments

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

a topic will be formed by:

  • protocol (share across multiple sensors)
  • service_api_key (share across multiple sensors of the same time, e.g. streetlights)
  • sensor_id (different for each sensor)

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" } }

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

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.