Open archerindigo opened 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
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
Updated topics according to the operator's JSON payload format
Payload format: <method>: <state> [<data>]
Refer: https://github.com/ubilab-ws21/operator#message-protocol
(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.
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:
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:
retained
flag to make sure the subscriber can know the UID when they are reset.Subscriber:
Note:
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:
status
to solved
when a fully charged battery is present Subscriber:
Operator should publish the followings:
5/battery/x/level
5/battery/1/uid
Updated topics according to the operator's JSON payload format
Payload format: <method>: <state> [<data>]
Refer: https://github.com/ubilab-ws21/operator#message-protocol
(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.
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:
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:
retained
flag to make sure the subscriber can know the UID when they are reset.Subscriber:
Note:
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:
{"method": "status", "state": "solved"}
when a fully charged battery is presentSubscriber:
{"method": "status", "state": "active"}
Operator should publish the followings:
{"method": "message", "data": 0}
to topic 5/battery/1/level
. Retained flag is required.{"method": "status", "state": "active"}
to topic 5/control_room/power
. Retained flag is optional.5/battery/1/uid
. Retained flag is recommended.
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.