Subscriptions
General
Subscribe
The communication protocol allows for subscribing to specific scale events. The corresponding information will then be sent when an event occurs.
Warning
Once a subscription is activated, the protocol can no longer be regarded as purely synchronous, since Response packets can be sent at any time. Make use of the message_id field to track Response/Request pairs.
The following events are available:
Info
Clicking on the response field tag will redirect you to the page where you can find more information about the selected response.
Event | Payload | Response field | Description |
---|---|---|---|
SUBSCRIBE_WEIGHT |
Scale number (uint 32) | WeighingResult_ext |
Get regularly updated with the weight from the scale |
SUBSCRIBE_PARAMETER |
None | ParameterDescription |
Get updates when a parameter value is changed |
SUBSCRIBE_DEBUG_LOG |
None | log |
Get all debug information from the scale |
SUBSCRIBE_POWER_EVENTS |
None | PowerEvent |
Get updates over battery/ sleep modes |
SUBSCRIBE_WIM |
Scale number (uint 32) | wim_result |
Get Weigh in Motion status |
SUBSCRIBE_PRINTER |
None | PrinterEvent |
Get status updates from the printer |
Unsubscribe
Event | Payload |
---|---|
UNSUBSCRIBE_WEIGHT |
Scale number (uint 32) |
UNSUBSCRIBE_PARAMETER |
None |
UNSUBSCRIBE_DEBUG_LOG |
None |
UNSUBSCRIBE_POWER_EVENTS |
None |
UNSUBSCRIBE_WIM |
Scale number (uint 32) |
UNSUBSCRIBE_PRINTER |
None |
Sequence diagram
The following diagram describes the sequence when subscribing to event X and event Y:
sequenceDiagram
Client->>RedBox: Request subscription X
RedBox-->>Client: Response status
Client->>RedBox: Request subscription Y
RedBox-->>Client: Response status
loop Every x ms
RedBox->>Client: Response subscription X
RedBox->>Client: Response subscription Y
end
Client->>RedBox: Request unsubscription X
RedBox-->>Client: Response status
Client->>RedBox: Request unsubscription Y
RedBox-->>Client: Response status
Sending subscription example
The code example below shows a client that is subscribed to the weight updates and power event from a Ravas RedBox.
Example
See also: protocol_send_basic_request() for an example how to send the request.
#define DEFAULT_SCALE_INDEX 0
void protocol_send_subs()
{
protocol_send_basic_request(Request_Type_SUBSCRIBE_WEIGHT, DEFAULT_SCALE_INDEX);
protocol_send_basic_request(Request_Type_SUBSCRIBE_POWER_EVENTS, DEFAULT_SCALE_INDEX);
}