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

The AIROC Mesh Power 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_POWER_ONOFF_SERVER
 Mesh Power OnOff Server Device. More...
 

Typedefs

typedef void( wiced_bt_mesh_power_onoff_server_callback_t )(uint8_t element_idx, uint16_t event, void *p_data)
 Generic Power On/Off Server callback. More...
 

Functions

void wiced_bt_mesh_model_power_onoff_server_init (uint8_t element_idx, wiced_bt_mesh_power_onoff_server_callback_t *p_callback, uint32_t transition_interval, wiced_bool_t is_provisioned)
 Power On/Off Server Module initialization. More...
 
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. More...
 
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. More...
 
void wiced_bt_mesh_model_power_onoff_server_onoff_changed (uint8_t element_idx, uint8_t onoff)
 

Detailed Description

The AIROC Mesh Power 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.

In addition to that the device would support a default transition time server functionality and application can specify On Power Up behavior. The default transition time and behavior of the device on power up is managed by the Mesh Models library and is not exposed to the application. The library stores in the persistent storage the configured values and controls application based on the configuration.

To instantiate the Power OnOff Server module, that application includes the WICED_BT_MESH_MODEL_POWER_ONOFF_SERVER in the device definition. In addition to that, the application shall call wiced_bt_mesh_model_power_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 Mesh Power OnOff Server module maintains the On/Off state and notifies the application when the state changes. The application shall call the wiced_bt_mesh_model_power_onoff_server_onoff_changed function when the OnOff state of the device is changed locally.

Macro Definition Documentation

#define WICED_BT_MESH_MODEL_POWER_ONOFF_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_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 }
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.
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_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_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.
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.
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.
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_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 OnOff Server Device.

The device combines onoff server functionality with default on power up behavior. The model can be used standalone, for example, to implement a power plug. The time and scheduler models are optional and can be commented out to reduce memory footprint.

Typedef Documentation

typedef void( wiced_bt_mesh_power_onoff_server_callback_t)(uint8_t element_idx, uint16_t event, void *p_data)

Generic Power On/Off Server callback.

The Generic Power On/Off Server callback is executed by the Mesh Models library on receiving a On/Off Set message from the peer. The callback is provided by the application during the initialization.

Parameters
element_idxElement Index of the model
eventThe event that the application should process (see On/Off Events)
p_dataPointer to the on/off state data
Returns
None

Function Documentation

void wiced_bt_mesh_model_power_onoff_server_init ( uint8_t  element_idx,
wiced_bt_mesh_power_onoff_server_callback_t p_callback,
uint32_t  transition_interval,
wiced_bool_t  is_provisioned 
)

Power On/Off Server Module initialization.

The function shall be called to initialize the Power On/Off Server Module of the Mesh Models library. For multi element applications, the initialization shall be done for each element that supports Power On/Off functionality.

Parameters
element_idxDevice element to where model is used
p_callbackApplication or Parent model callback that will be executed when application action is required, for example, to adjust the hardware.
transition_intervalInterval 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_provisionedIf TRUE, the application is being restarted after being provisioned or after a power loss. If FALSE the model cleans up NVRAM.
Returns
None
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.

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.

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.
void wiced_bt_mesh_model_power_onoff_server_onoff_changed ( uint8_t  element_idx,
uint8_t  onoff 
)

The application shall call this function if the onoff status has changed locally. The Power On/Off module stores new state information and publishes the status change if appropriate.

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

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.

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.