AIROC™ BTSDK v4.9 - Documentation | ||||
The AIROC Mesh OnOff Server module of the Mesh Models library provides a way to implement functionality for the devices that can be controlled using a simple On/Off switch, aka On/Off client. More...
Macros | |
#define | WICED_BT_MESH_MODEL_ONOFF_SERVER |
Mesh OnOff Server Device. More... | |
Typedefs | |
typedef void( | wiced_bt_mesh_onoff_server_callback_t )(uint8_t element_idx, uint16_t event, void *p_data) |
Generic On/Off Server callback. More... | |
Functions | |
void | wiced_bt_mesh_model_onoff_server_init (uint8_t element_idx, wiced_bt_mesh_onoff_server_callback_t *p_callback, uint32_t transition_interval, wiced_bool_t is_provisioned) |
On/Off Server Module initialization. More... | |
wiced_bool_t | wiced_bt_mesh_model_onoff_server_message_handler (wiced_bt_mesh_event_t *p_event, uint8_t *p_data, uint16_t data_len) |
On/Off Server Message Handler. More... | |
uint16_t | wiced_bt_mesh_model_onoff_server_scene_store_handler (uint8_t element_idx, uint8_t *p_buffer, uint16_t buffer_len) |
On/Off Server Scene Store Handler. More... | |
uint16_t | wiced_bt_mesh_model_onoff_server_scene_recall_handler (uint8_t element_idx, uint8_t *p_buffer, uint16_t buffer_len, uint32_t transition_time, uint32_t delay) |
On/Off Server Scene Recall Handler. More... | |
void | wiced_bt_mesh_model_onoff_changed (uint8_t element_idx, uint8_t onoff) |
If On/Off state of the device can be changed locally, the application shall call this function to notify OnOff library that the value has been changed. More... | |
The AIROC Mesh OnOff Server module of the Mesh Models library provides a way to implement functionality for the devices that can be controlled using a simple On/Off switch, aka On/Off client.
The OnOff Server module is typically not used by a target applications. It is used by other modules that extend OnOff functionality. A simple example is a Power Plug application. Instead of using OnOff module, the application uses Power On/Off, which in addition to OnOff provides On Power Up behavior, i.e. the library saves in the NVRAM configuration of the state required when device is powered up and controls application accordingly. Similarly, an application for dimmable light uses Light Lightness module. If peer sends OnOff command, the application receives a callback from the Light Lightness module that the lightness is set to zero.
To use the OnOff Server, on startup an application or a module that extends the OnOff functionality should call wiced_bt_mesh_model_onoff_server_init function providing the callback that will be executed when an OnOff request is received to turn the device on or off.
The module which extends OnOff server should call the wiced_bt_mesh_model_onoff_changed function when the OnOff state of the device is changed locally.
#define WICED_BT_MESH_MODEL_ONOFF_SERVER |
Mesh OnOff Server Device.
The model is used as a base for multiple other models. This device is typically not used standalone. The closest is Power OnOff Device which adds on power up behavior to the device and then can be used standalone. With the TIME_AND_SCHEDULER_SUPPORT the model TIME_CLNT is needed just to send TIME_GET message. Therefore message_handler is NULL.
typedef void( wiced_bt_mesh_onoff_server_callback_t)(uint8_t element_idx, uint16_t event, void *p_data) |
Generic On/Off Server callback.
The Generic On/Off Server callback is executed by the Mesh Models library on receiving a SET message from the peer. The callback is provided by the application or by the mesh model which extends the Generic On/Off server during the initialization.
element_idx | Element Index of the model |
event | The event that the application should process (see On/Off Events) |
p_data | Pointer to the on/off state data |
void wiced_bt_mesh_model_onoff_changed | ( | uint8_t | element_idx, |
uint8_t | onoff | ||
) |
If On/Off state of the device can be changed locally, the application shall call this function to notify OnOff library that the value has been changed.
element_idx | Element index for which onoff state has changed |
onoff | New value of onoff |
void wiced_bt_mesh_model_onoff_server_init | ( | uint8_t | element_idx, |
wiced_bt_mesh_onoff_server_callback_t * | p_callback, | ||
uint32_t | transition_interval, | ||
wiced_bool_t | is_provisioned | ||
) |
On/Off Server Module initialization.
The function shall be called to initialize the On/Off Server Module of the Mesh Models library. For multi element applications, the initialization shall be done for each element that supports on/off get, on/off set functionality.
element_idx | Device element where OnOff model is used |
p_callback | Application or Parent model callback that will be executed on receiving a message |
transition_interval | Interval in milliseconds to update application during transition change with STATUS messages. If 0, library will send a single SET message when the transition should start. |
is_provisioned | If TRUE, the application is being restarted after being provisioned or after a power loss. If FALSE, the device is unprovisioned. |
wiced_bool_t wiced_bt_mesh_model_onoff_server_message_handler | ( | wiced_bt_mesh_event_t * | p_event, |
uint8_t * | p_data, | ||
uint16_t | data_len | ||
) |
On/Off Server Message Handler.
The Mesh Core library calls this function for each message received. This function is implemented by Mesh Models library and does not need to be replicated by the application or any other module. The function returns WICED_TRUE if the message is destined for this specific model, and returns WICED_FALSE otherwise. The function parses the message and if appropriate calls the parent to perform functionality.
p_event | Mesh event with information about received message. |
p_data | Pointer to the data portion of the message |
data_len | Length of the data in the message |
uint16_t wiced_bt_mesh_model_onoff_server_scene_recall_handler | ( | uint8_t | element_idx, |
uint8_t * | p_buffer, | ||
uint16_t | buffer_len, | ||
uint32_t | transition_time, | ||
uint32_t | delay | ||
) |
On/Off Server Scene Recall Handler.
When the Scene Server receives the Scene Recall message it calls this function with data previously stored in the NVRAM. The function is implemented in the Mesh Models library and does not need to be replicated by the application. To extend library functionality, the application can replace the function in the WICED_BT_MESH_MODEL_ONOFF_SERVER, performs its functionality and then call this function directly.
element_idx | Element index for which scene information is being recalled |
p_buffer | Pointer to a buffer where model's data is located |
buf_size | Maximum amount of data a model can get from the buffer |
transition_time | Specified time in milliseconds to transition to the target state |
delay | Specifies time in milliseconds before starting to transition to the target state |
uint16_t wiced_bt_mesh_model_onoff_server_scene_store_handler | ( | uint8_t | element_idx, |
uint8_t * | p_buffer, | ||
uint16_t | buffer_len | ||
) |
On/Off Server Scene Store Handler.
The mesh Scene Server calls this function so that the module can store required data for the scene. The function is implemented in the Mesh Models library and does not need to be replicated by the application. To extend library functionality, the application can replace the function in the WICED_BT_MESH_MODEL_ONOFF_SERVER, performs its functionality and then call this function directly.
element_idx | Element index for which scene information is being stored |
p_buffer | Pointer to a buffer where data should be stored |
buf_size | Maximum amount of data a model can store |