AIROC™ BTSDK v4.8 - Documentation | ||||
The AIROC Mesh Power Level Server module of the Mesh Models library provides a way to implement functionality of a power plug type of a device that can be controlled using a Level slider (Generic Level client) and On/Off switch (Generic On/Off client). More...
Macros | |
#define | WICED_BT_MESH_MODEL_POWER_LEVEL_SERVER |
Mesh Power Level Server Device Composition Data. More... | |
Typedefs | |
typedef void( | wiced_bt_mesh_power_level_server_callback_t )(uint8_t element_idx, uint16_t event, void *p_data) |
Generic Power Level Server callback. More... | |
Functions | |
void | wiced_bt_mesh_model_power_level_server_init (uint8_t element_idx, wiced_bt_mesh_power_level_server_callback_t *p_callback, wiced_bool_t is_provisioned) |
Power Level Module initialization. More... | |
void | wiced_bt_mesh_model_power_level_server_level_changed (uint8_t element_idx, uint16_t level) |
Power Level Changed. More... | |
wiced_bool_t | wiced_bt_mesh_model_power_level_server_message_handler (wiced_bt_mesh_event_t *p_event, uint8_t *p_data, uint16_t data_len) |
Power Level Server Message Handler. More... | |
wiced_bool_t | wiced_bt_mesh_model_power_level_setup_server_message_handler (wiced_bt_mesh_event_t *p_event, uint8_t *p_data, uint16_t data_len) |
Power Level Setup Server Message Handler. More... | |
uint16_t | wiced_bt_mesh_model_power_level_server_scene_store_handler (uint8_t element_idx, uint8_t *p_buffer, uint16_t buffer_len) |
Power Level Server Scene Store Handler. More... | |
uint16_t | wiced_bt_mesh_model_power_level_server_scene_recall_handler (uint8_t element_idx, uint8_t *p_buffer, uint16_t buffer_len, uint32_t transition_time, uint32_t delay) |
Power Level Server Scene Store Handler. More... | |
The AIROC Mesh Power Level Server module of the Mesh Models library provides a way to implement functionality of a power plug type of a device that can be controlled using a Level slider (Generic Level client) and On/Off switch (Generic On/Off client).
In addition to that the device supports a default transition time server functionality and the application can specify on power up behavior.
To instantiate the Power Level Server module, that application includes the WICED_BT_MESH_MODEL_POWER_LEVEL_SERVER in the device definition. In addition to that, the application shall call wiced_bt_mesh_model_power_level_server_init function providing the wiced_bt_mesh_power_level_server_callback_t callback that will be executed when power level of the device needs to be changed.
If the device supports several elements with the Power Level Server, for example a power strip with several power plugs, the WICED_BT_MESH_MODEL_POWER_LEVEL_SERVER shall be included for each element.
The Mesh Power Level Server module in the Mesh Models library maintains the On/Off and Level states and notifies the application on the state changes. The application shall call the wiced_bt_mesh_model_power_level_server_level_changed function when the power level of the device is changed locally.
Most of the functionality of the Mesh Power Level server device is implemented in the Mesh Models Library. The application only needs to set hardware appropriately on receiving WICED_BT_MESH_POWER_LEVEL_STATUS event. If client requests to change power to the target value over a period of time, the library will maintain the timer and will periodically call the application with appropriate power level.
The default transition time is managed by the Mesh Models library. The application provides factory default in the default_transition_time element of the wiced_bt_mesh_core_config_t configuration structure. The default value is used unless overwritten by the default transition time client.
The on power up behavior is managed by the Mesh Models library. The application provides factory default in the onpowerup_state element of the wiced_bt_mesh_core_config_t configuration structure. The default value is used unless overwritten by the default transition time client.
#define WICED_BT_MESH_MODEL_POWER_LEVEL_SERVER |
Mesh Power Level Server Device Composition Data.
The Mesh Power Level Server device combines power level and power onoff server functionality with default transition time and on power up behavior. The model can be used standalone, for example, to implement a power plug with adjustible level. The time and scheduler models are optional and can be commented out to reduce memory footprint.
typedef void( wiced_bt_mesh_power_level_server_callback_t)(uint8_t element_idx, uint16_t event, void *p_data) |
Generic Power Level Server callback.
Generic Power Level Server callback is executed by the Mesh Models library to change the power level of the device. The p_data parameter points to the wiced_bt_mesh_power_level_status_data_t structure. Typically the application will only need to use the value of the present_power field which specify the power level of the device which shall be set at this particular moment. If the remaining_time field is not zero, the Mesh Library will execute the callback at least once more before the transition is completed.
If peer device requested to transition to the power level over a period of time, the callback will be executed repeatedly. Mesh Library calculates the present power level and submits to the application to update the hardware.
element_idx | Element Index of the model |
event | The event that the application should process (see Power Level Events) |
p_data | Pointer to the power level data |
void wiced_bt_mesh_model_power_level_server_init | ( | uint8_t | element_idx, |
wiced_bt_mesh_power_level_server_callback_t * | p_callback, | ||
wiced_bool_t | is_provisioned | ||
) |
Power Level Module initialization.
A Mesh application which contains Power Level Server should call this function for each element where the Power Level Server is present. If application needs to support multiple Power Level servers, the initialization shall be called multiple times, once for each element of the device.
The application callback will be executed by the Model Library when it is required to set hardware to the desired power level to a certain level.
element_idx | Device element to where model is used |
p_callback | Application callback that will be executed to set the hardware to the specified level. |
is_provisioned | If TRUE, the application is being restarted after being provisioned or after a power loss. If FALSE the Mesh Models Library deletes this module's configuration data stored in the NVRAM. |
void wiced_bt_mesh_model_power_level_server_level_changed | ( | uint8_t | element_idx, |
uint16_t | level | ||
) |
Power Level Changed.
The application shall call this function if the power level of the device has been changed locally. The Power Level module stores new state information and publishes the status change if appropriate.
element_idx | Element index for which onoff state has changed |
level | New value of the power level |
wiced_bool_t wiced_bt_mesh_model_power_level_server_message_handler | ( | wiced_bt_mesh_event_t * | p_event, |
uint8_t * | p_data, | ||
uint16_t | data_len | ||
) |
Power Level 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.
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_power_level_server_scene_recall_handler | ( | uint8_t | element_idx, |
uint8_t * | p_buffer, | ||
uint16_t | buffer_len, | ||
uint32_t | transition_time, | ||
uint32_t | delay | ||
) |
Power Level Server Scene Store Handler.
When Scene Server receives Scene Recall message it calls this function with data previously stored in the NVRAM. This function is implemented by Mesh Models library and does not need to be replicated by the application or any other module.
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_power_level_server_scene_store_handler | ( | uint8_t | element_idx, |
uint8_t * | p_buffer, | ||
uint16_t | buffer_len | ||
) |
Power Level Server Scene Store Handler.
The mesh Scene Server calls this function so that the module can store required data for the scene. This function is implemented by Mesh Models library and does not need to be replicated by the application or any other module.
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 |
wiced_bool_t wiced_bt_mesh_model_power_level_setup_server_message_handler | ( | wiced_bt_mesh_event_t * | p_event, |
uint8_t * | p_data, | ||
uint16_t | data_len | ||
) |
Power Level Setup 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.
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 |