Infineon Logo AIROC BTSDK v4.8 - Documentation
 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Mesh Power Level Server

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...
 

Detailed Description

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.

Macro Definition Documentation

#define WICED_BT_MESH_MODEL_POWER_LEVEL_SERVER
Value:
{ MESH_COMPANY_ID_BT_SIG, WICED_BT_MESH_CORE_MODEL_ID_GENERIC_DEFTT_SRV, wiced_bt_mesh_model_default_transition_time_server_message_handler, NULL, NULL }, \
{ MESH_COMPANY_ID_BT_SIG, WICED_BT_MESH_CORE_MODEL_ID_SCENE_SRV, wiced_bt_mesh_model_scene_server_message_handler, NULL, NULL }, \
{ MESH_COMPANY_ID_BT_SIG, WICED_BT_MESH_CORE_MODEL_ID_SCENE_SETUP_SRV, wiced_bt_mesh_model_scene_setup_server_message_handler, NULL, NULL }, \
{ MESH_COMPANY_ID_BT_SIG, WICED_BT_MESH_CORE_MODEL_ID_GENERIC_ONOFF_SRV, wiced_bt_mesh_model_onoff_server_message_handler, NULL, NULL }, \
{ MESH_COMPANY_ID_BT_SIG, WICED_BT_MESH_CORE_MODEL_ID_GENERIC_POWER_ONOFF_SRV, wiced_bt_mesh_model_power_onoff_server_message_handler, NULL, NULL }, \
{ MESH_COMPANY_ID_BT_SIG, WICED_BT_MESH_CORE_MODEL_ID_GENERIC_POWER_ONOFF_SETUP_SRV, wiced_bt_mesh_model_power_onoff_setup_server_message_handler, NULL, NULL }, \
{ MESH_COMPANY_ID_BT_SIG, WICED_BT_MESH_CORE_MODEL_ID_GENERIC_LEVEL_SRV, wiced_bt_mesh_model_level_server_message_handler, NULL, NULL }, \
{ MESH_COMPANY_ID_BT_SIG, WICED_BT_MESH_CORE_MODEL_ID_GENERIC_POWER_LEVEL_SETUP_SRV, wiced_bt_mesh_model_power_level_setup_server_message_handler, NULL, NULL }
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.
wiced_bool_t wiced_bt_mesh_model_power_onoff_setup_server_message_handler(wiced_bt_mesh_event_t *p_event, uint8_t *p_data, uint16_t data_len)
Power On/Off Setup Server Message Handler.
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.
wiced_bool_t wiced_bt_mesh_model_default_transition_time_server_message_handler(wiced_bt_mesh_event_t *p_event, uint8_t *p_data, uint16_t data_len)
Default Transition Time Server Message Handler.
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.
wiced_bool_t wiced_bt_mesh_model_scene_setup_server_message_handler(wiced_bt_mesh_event_t *p_event, uint8_t *p_data, uint16_t data_len)
Scene Setup Server Message Handler.
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.
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.
wiced_bool_t wiced_bt_mesh_model_scene_server_message_handler(wiced_bt_mesh_event_t *p_event, uint8_t *p_data, uint16_t data_len)
Scene Server Message Handler.
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.
wiced_bool_t wiced_bt_mesh_model_power_onoff_server_message_handler(wiced_bt_mesh_event_t *p_event, uint8_t *p_data, uint16_t data_len)
Power On/Off Server Message Handler.

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 Documentation

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.

Parameters
element_idxElement Index of the model
eventThe event that the application should process (see Power Level Events)
p_dataPointer to the power level data
Returns
None

Function Documentation

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.

Parameters
element_idxDevice element to where model is used
p_callbackApplication callback that will be executed to set the hardware to the specified level.
is_provisionedIf 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.
Returns
WICED_TRUE if initialization was successful
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.

Parameters
element_idxElement index for which onoff state has changed
levelNew value of the power level
Returns
None
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.

Parameters
p_eventMesh event with information about received message.
p_dataPointer to the data portion of the message
data_lenLength of the data in the message
Returns
WICED_TRUE if the message is for this company ID/Model/Element Index combination, WICED_FALSE otherwise.
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.

Parameters
element_idxElement index for which scene information is being recalled
p_bufferPointer to a buffer where model's data is located
buf_sizeMaximum amount of data a model can get from the buffer
transition_timeSpecified time in milliseconds to transition to the target state
delaySpecifies time in milliseconds before starting to transition to the target state
Returns
Number of bytes the model read from the provided buffer
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.

Parameters
element_idxElement index for which scene information is being stored
p_bufferPointer to a buffer where data should be stored
buf_sizeMaximum amount of data a model can store
Returns
Number of bytes the model wrote into the provided buffer
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.

Parameters
p_eventMesh event with information about received message.
p_dataPointer to the data portion of the message
data_lenLength of the data in the message
Returns
WICED_TRUE if the message is for this company ID/Model/Element Index combination, WICED_FALSE otherwise.