ubilab-ws21 / puzzle-5

0 stars 1 forks source link

MQTT specification between our puzzle and the operator #30

Open archerindigo opened 2 years ago

archerindigo commented 2 years ago

The electric box and the charger box need to exchange data with the operator to:

One the operator knows a fully charged battery is present at the electric box, it should resume the power of the control room and enable puzzle 3.

Task: Define the actual protocol.

archerindigo commented 2 years ago

Basic idea:

Topic: 5/battery/level Description: The supposed battery level

Topic: 5/battery/location Description: The current location of the battery

Topic: 5/charger/lock Description: status of the lock of the charger box

archerindigo commented 2 years ago

The existing code of the safe contain some MQTT protocol:

Topic: 5/safe/control Methods:

Since we're reusing the safe, the topic is still useful.

Additional trigger is needed for unlocking the safe remotely

archerindigo commented 2 years ago

Updated topics according to the operator's JSON payload format

Payload format: <method>: <state> [<data>]

Refer: https://github.com/ubilab-ws21/operator#message-protocol

Topic: 5/battery/x/level

(x = battery id, there is only 1 battery in plan A, so only the topic "5/battery/1/level" is enough atm.)

Description: The supposed battery level

Method state data Description
message N/A number([0-100]) All subscribers should store the battery's level according to this message.

Publishers should set the retained flag so that other subscribers can synchronize the battery level in case they're reset unexpectedly

Payload: byte[1] (range: 0-100)

Reset value: 0

Publisher:

Subscriber:

Note: Upon power-on of charger/ battery dock, they will treat the battery level as 0 until they receive MQTT message regarding the battery level.

Topic: 5/battery/1/location

Description: The current location of the battery

Method state data Description
message N/A number(enum BATTERY_LOC) The latest location of the battery should be published through this

enum BATTERY_LOC { LOC_CHARGER, LOC_ELEC_BOX, LOC_UNKNOWN=255 };

Reset value: LOC_UNKNOWN

Publisher:

Subscriber:

Topic: 5/battery/1/uid

Description: The NFC UID of the battery

Method state data Description
message N/A string("AA:BB:CC:DD") Send the UID through this message to set the UID of the battery

Publisher:

Subscriber:

Note:

Topic: 5/control_room/power

Description: power status of the control room

Method state data Description
status [N/A] [inactive|active|solved] To announce the status of the puzzle
trigger "on" | "off" N/A When on is received, the operator should resume the power of the control room and enable the next puzzle

Publisher:

Subscriber:

Reset procedure

Operator should publish the followings:

archerindigo commented 2 years ago

Updated topics according to the operator's JSON payload format

Payload format: <method>: <state> [<data>]

Refer: https://github.com/ubilab-ws21/operator#message-protocol

Topic: 5/battery/x/level

(x = battery id, there is only 1 battery in plan A, so only the topic "5/battery/1/level" is enough atm.)

Description: The supposed battery level

Method state data Description
message N/A number([0-100]) All subscribers should store the battery's level according to this message.

Publishers should set the retained flag so that other subscribers can synchronize the battery level in case they're reset unexpectedly

Default value: 0

Publisher:

Subscriber:

Note: Upon power-on of charger/ battery dock, they will treat the battery level as 0 until they receive MQTT message regarding the battery level.

Topic: 5/battery/1/location

Description: The current location of the battery

Method state data Description
message N/A number(enum BATTERY_LOC) The latest location of the battery should be published through this

enum BATTERY_LOC { LOC_CHARGER, LOC_ELEC_BOX, LOC_UNKNOWN=255 };

Default value: LOC_UNKNOWN

Publisher:

Subscriber:

Topic: 5/battery/1/uid

Description: The NFC UID of the battery

Method state data Description
message N/A string("AA:BB:CC:DD") Send the UID through this message to set the UID of the battery

Publisher:

Subscriber:

Note:

Topic: 5/control_room/power

Description: power status of the control room

Method state data Description
status [inactive|active|solved] To announce the status of the puzzle. If state "active" is received, the puzzle should reset

Publisher:

Subscriber:

Reset procedure

Operator should publish the followings: