Communication command and event
Communication command and event is a mechanism that allows you to interact with the lower layer (hardware) of the device.
Communication command
Comm Command
is short for communication command.
Comm Command
is a request from the upper layer to the lower layer.
The user input will eventually be converted to some instructions to make device perform some actions.
For example, when the user clicks a button, the button will send a request to the lower layer to instruct the device to connect to WiFi. Comm Command
is the way to wrap and send the request to the lower layer.
Comm Command
just provides the capability to send the request, and it doesn't cover any of the business logic. It's up to the device maker to implement the business logic, in other words, it's up to the device maker to decide what kind of commands are available.
Communication event
Comm Event
is short for communication event.
Comm Event
is a notification from the lower layer to the upper layer.
When something happens in the lower layer, the lower layer will send a notification to the upper layer to update UI.
For example, when the device is connected to WiFi, the device will send a notification to the upper layer to update UI. Comm Event
is the way to wrap and send the notification to the upper layer.
Comm Event
just provides the capability to send the notification, and it doesn't cover any of the business logic. It's up to the device maker to implement the business logic, in other words, it's up to the device maker to decide what kind of events are available.
Status and Action of Comm Event
From UI perspecitve, usually there's something need to be updated when receiving an event, updating the label text or icons etc according to specific condition.
As for comm events, we use a status and action to make it easier to update the UI. You can configure the status and the action for status accordingly.
For example:
You might want to configure for an image
widget to receive a bluetooth status event, and to show an icon for BT disconnected and an icon for BT connected respectively.
-
Right click on the
image
widget, and add aComm Event
ofBT Status Changed
-
Configure the status of event:
- Status: 0 (BT disconnected) Action: set image for BT disconnected
- Status: 1 (BT connected) Action: set image for BT connected
How would you what status
code to use? This is provided by your device provider. You should have the document of your device, describing what kind of status code you can use. The status
code is determined by the lower layer business logic.
Default available commands and events
Although Comm Command
and Comm Event
are binded to the device, but we still provide some default available commands and events for you to use.
-
Time update
-
Bluetooth connected/disconnected
-
WiFi connected/disconnected
-
Battery level changed
These are device commands/events, the implementation is a simulation, need to be replaced by the real implementation.
-
Drawer opened/closed
This is a UI command/event, not a device event.
When the project is created, these commands/events are available, you can directly use these commands and events, or modify them to fit your business logic.
Communication command and event is strongly binded with the device, if you want to use full support of the device's capability, let your device provider contact us, we can provide builtin support for the device.