AIROC™ BTSDK v4.0 - Documentation | ||||
The AIROC Mesh Level Server module of the Mesh Models library provides a way to implement functionality for the devices that can be controlled using a simple level slider, aka Level client. More...
Macros | |
#define | WICED_BT_MESH_MODEL_LEVEL_SERVER |
Mesh Level Server Device. More... | |
Typedefs | |
typedef void( | wiced_bt_mesh_level_server_callback_t )(uint8_t element_idx, uint16_t event, void *p_data) |
Generic Level Server callback is called by the Mesh Models library when the level needs to be changed. More... | |
Functions | |
void | wiced_bt_mesh_model_level_server_init (uint8_t element_idx, wiced_bt_mesh_level_server_callback_t *p_callback, wiced_bool_t is_provisioned) |
Level Server Module initialization. More... | |
wiced_bool_t | wiced_bt_mesh_model_level_server_message_handler (wiced_bt_mesh_event_t *p_event, uint8_t *p_data, uint16_t data_len) |
Level Server Message Handler. More... | |
uint16_t | wiced_bt_mesh_model_level_server_scene_store_handler (uint8_t element_idx, uint8_t *p_buffer, uint16_t buffer_len) |
Level Server Scene Store Handler. More... | |
uint16_t | wiced_bt_mesh_model_level_server_scene_recall_handler (uint8_t element_idx, uint8_t *p_buffer, uint16_t buffer_len, uint32_t transition_time, uint32_t delay) |
Level Server Scene Store Handler. More... | |
void | wiced_bt_mesh_model_level_changed (uint8_t element_idx, int16_t value) |
An application can call this function to notify Generic Level library that the value has been changed locally. More... | |
The AIROC Mesh Level Server module of the Mesh Models library provides a way to implement functionality for the devices that can be controlled using a simple level slider, aka Level client.
The Level Server module is typically not used by a target applications. It is used by other modules that extend Level functionality. For example a power adapter with controllable power level uses a Power Level module which in addition to Level provides Power On/Off and On Power Up control. Similarly, an application for a dimmable light uses Light Lightness module. While the client sends Level command, the application receives callback from the Light Lightness module that the lightness is changed appropriately.
To use the Level Server, on startup an application or a module that extends the Level functionality should call wiced_bt_mesh_model_level_server_init function providing the callback that will be executed when the change of the level is requested.
Note, that the Mesh Models library implements the transition state machine. For example, when the change in the level is requested over some transition time, the application will be called periodically while transition is in progress.
If the application initializes the Level server directly it should call the wiced_bt_mesh_model_level_changed function when the Level state of the device is changed locally.
#define WICED_BT_MESH_MODEL_LEVEL_SERVER |
Mesh Level Server Device.
The model is used as a base for multiple other models. It is typically not used standalone. The closest is Power Level Device which adds on power up behavior to the device and then can be used standalone.
typedef void( wiced_bt_mesh_level_server_callback_t)(uint8_t element_idx, uint16_t event, void *p_data) |
Generic Level Server callback is called by the Mesh Models library when the level needs to be changed.
If peer device sends Set Level, Delta Level or Move Level command specifying not zero transition interval, the callback will be called periodically. The only event that the application needs to process is WICED_BT_MESH_LEVEL_STATUS.
element_idx | Element Index of the model |
event | The event that the application should process (see Level Events) |
p_data | Pointer to the level state data |
void wiced_bt_mesh_model_level_changed | ( | uint8_t | element_idx, |
int16_t | value | ||
) |
An application can call this function to notify Generic Level library that the value has been changed locally.
element_idx | Element index for which level state has changed |
value | New value of level |
void wiced_bt_mesh_model_level_server_init | ( | uint8_t | element_idx, |
wiced_bt_mesh_level_server_callback_t * | p_callback, | ||
wiced_bool_t | is_provisioned | ||
) |
Level Server Module initialization.
The function shall be called to initialize the Level Module of the Mesh Models library. For multi element applications, the initialization shall be done for each element that supports level get, level set, level delta, or level move functionality.
element_idx | Device element to where model is used |
p_callback | Application or Parent model callback that will be executed on receiving a message |
is_provisioned | If TRUE, the application is being restarted after being provisioned or after a power loss. If FALSE the model cleans up NVRAM on startup. |
wiced_bool_t wiced_bt_mesh_model_level_server_message_handler | ( | wiced_bt_mesh_event_t * | p_event, |
uint8_t * | p_data, | ||
uint16_t | data_len | ||
) |
Level Server Message Handler.
The Mesh Core library calls this function for each message received. The function returns WICED_TRUE if the message is destined for this specific model and successfully processed, and returns WICED_FALSE otherwise.
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_level_server_scene_recall_handler | ( | uint8_t | element_idx, |
uint8_t * | p_buffer, | ||
uint16_t | buffer_len, | ||
uint32_t | transition_time, | ||
uint32_t | delay | ||
) |
Level Server Scene Store Handler.
When Scene Server receives Scene Recall message it calls this function with data previously stored in the NVRAM.
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_level_server_scene_store_handler | ( | uint8_t | element_idx, |
uint8_t * | p_buffer, | ||
uint16_t | buffer_len | ||
) |
Level Server Scene Store Handler.
The mesh Scene Server calls this function so that the module can store required data for the scene.
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 |