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

The AIROC Mesh On/Off Client module of the Mesh Models library provides a way for an application to send OnOff commands to the server and optionally receive status information. More...

Macros

#define WICED_BT_MESH_MODEL_ONOFF_CLIENT   { MESH_COMPANY_ID_BT_SIG, WICED_BT_MESH_CORE_MODEL_ID_GENERIC_ONOFF_CLNT, wiced_bt_mesh_model_onoff_client_message_handler, NULL, NULL }
 Mesh On/Off Client Device. More...
 

Typedefs

typedef void( wiced_bt_mesh_onoff_client_callback_t )(uint16_t event, wiced_bt_mesh_event_t *p_event, void *p_data)
 On/Off Client callback is called by the Mesh Models library on receiving a On/Off status message from the peer. More...
 

Functions

void wiced_bt_mesh_model_onoff_client_init (uint8_t element_idx, wiced_bt_mesh_onoff_client_callback_t *p_callback, wiced_bool_t is_provisioned)
 On/Off Client Module initialization. More...
 
wiced_bool_t wiced_bt_mesh_model_onoff_client_message_handler (wiced_bt_mesh_event_t *p_event, uint8_t *p_data, uint16_t data_len)
 On/Off Client Message Handler. More...
 
wiced_result_t wiced_bt_mesh_model_onoff_client_get (uint8_t element_idx)
 The application can call this function to send get On/Off state client message to the server. More...
 
wiced_result_t wiced_bt_mesh_model_onoff_client_send_get (wiced_bt_mesh_event_t *p_event)
 The application can call this function to send get On/Off state client message to the server. More...
 
wiced_result_t wiced_bt_mesh_model_onoff_client_set (uint8_t element_idx, wiced_bt_mesh_onoff_set_data_t *p_data)
 The application can call this function to send On/Off command. More...
 
wiced_result_t wiced_bt_mesh_model_onoff_client_send_set (wiced_bt_mesh_event_t *p_event, wiced_bt_mesh_onoff_set_data_t *p_data)
 The application can call this function to send Set OnOff client message to the server. More...
 

Detailed Description

The AIROC Mesh On/Off Client module of the Mesh Models library provides a way for an application to send OnOff commands to the server and optionally receive status information.

To include On/Off functionality, the device description shall contain WICED_BT_MESH_MODEL_ONOFF_CLIENT. To implement a device which supports multiple switches, the WICED_BT_MESH_MODEL_ONOFF_CLIENT shall be included in multiple elements. Based on this information, the device that performs configuration will be able to specify different destination for every switch.

In a simplest form, an application needs to initialize using the wiced_bt_mesh_model_onoff_client_init function and then call wiced_bt_mesh_model_onoff_client_set to tell the Mesh Library to send a command. The configuration of the destination address and security credential is done during the provisioning/configuration process and the application does not need to worry about it.

If an application needs more control of how messages are sent out, it can use wiced_bt_mesh_model_onoff_client_send_get and wiced_bt_mesh_model_onoff_client_send_set functions. These functions require to use the p_event parameter which include among others address of the desgination, application key index, retrnansmission parameters, TTL, and various others. After creating the event, the application can adjust the paramters as needed.

To receive On/Off status information, an application during initialization specifies the callback that will be executed when OnOff status message is received. The status information can be received as a result of sending On/Off Get and Set commands. In addition to that, the On/Off server can be configured to send the status information to the device that implements the OnOff Client module, or to a group of the devices to which the OnOff Client belongs.

Macro Definition Documentation

#define WICED_BT_MESH_MODEL_ONOFF_CLIENT   { MESH_COMPANY_ID_BT_SIG, WICED_BT_MESH_CORE_MODEL_ID_GENERIC_ONOFF_CLNT, wiced_bt_mesh_model_onoff_client_message_handler, NULL, NULL }

Mesh On/Off Client Device.

The device implements a Generic On/Off switch. The device can be configured to control any device that supports Generic On/Off Server model (WICED_BT_MESH_CORE_MODEL_ID_GENERIC_ONOFF_SRV). For example, a WICED_BT_MESH_MODEL_LIGHT_CTL_SERVER, WICED_BT_MESH_MODEL_LIGHT_HSL_SERVER,...

Typedef Documentation

typedef void( wiced_bt_mesh_onoff_client_callback_t)(uint16_t event, wiced_bt_mesh_event_t *p_event, void *p_data)

On/Off Client callback is called by the Mesh Models library on receiving a On/Off status message from the peer.

Parameters
eventThe event that the application should process (see Mesh On/Off Events)
p_eventinformation about the message received. It is application responsibility to release the event using wiced_bt_mesh_release_event.
p_dataPointer to the data to send
Returns
None

Function Documentation

wiced_result_t wiced_bt_mesh_model_onoff_client_get ( uint8_t  element_idx)

The application can call this function to send get On/Off state client message to the server.

Model library will send the message out only if the OnOff Client model is configured by the provisioner for publication.

If the application has registerd the callback during the initialization, the callback will be executed twice, first with WICED_BT_MESH_TX_COMPLETE event indicating that the event has been sent out and then with WICED_BT_MESH_ONOFF_STATUS event with the status information.

Parameters
element_idxElement Index of the model
Returns
WICED_BT_SUCCESS if message has been queued for transmission.
void wiced_bt_mesh_model_onoff_client_init ( uint8_t  element_idx,
wiced_bt_mesh_onoff_client_callback_t p_callback,
wiced_bool_t  is_provisioned 
)

On/Off Client Module initialization.

The function shall be called to initialize the On/Off Module of the Mesh Models library. For multi element applications, the initialization shall be done for each element that supports On/Off get/set functionality. The p_callback parameter may be set to NULL if no On/Off Status processing is required.

Parameters
element_idxDevice element to where model is used
p_callbackThe application callback function that will be executed by the mesh models library when application action is required, or when a reply for the application request has been received.
is_provisionedIf TRUE, the application is being restarted after being provisioned or after a power loss.
Returns
None
wiced_bool_t wiced_bt_mesh_model_onoff_client_message_handler ( wiced_bt_mesh_event_t p_event,
uint8_t *  p_data,
uint16_t  data_len 
)

On/Off Client Message Handler.

This is an internal Mesh Models library function and does not need to be implemented or called by the application, unless application wants to replace the library functionality. The Mesh Core library calls this function for each message received. The function shall return 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.
wiced_result_t wiced_bt_mesh_model_onoff_client_send_get ( wiced_bt_mesh_event_t p_event)

The application can call this function to send get On/Off state client message to the server.

Parameters
p_eventMesh event with the information about the message that has been created by the app for unsolicited message.
Returns
WICED_BT_SUCCESS if message has been queued for transmission.
wiced_result_t wiced_bt_mesh_model_onoff_client_send_set ( wiced_bt_mesh_event_t p_event,
wiced_bt_mesh_onoff_set_data_t p_data 
)

The application can call this function to send Set OnOff client message to the server.

Parameters
p_eventMesh event with the information about the message that has been created by the app for unsolicited message.
p_dataPointer to the data to send
Returns
WICED_BT_SUCCESS if message has been queued for transmission.
wiced_result_t wiced_bt_mesh_model_onoff_client_set ( uint8_t  element_idx,
wiced_bt_mesh_onoff_set_data_t p_data 
)

The application can call this function to send On/Off command.

The application does not need to know the destination of the command or application key that will be used to secure the packet. The Mesh Models library will send the message out only if the OnOff Client model of the referenced element is configured by the provisioner for publication.

If the application has registered the callback during the initialization, the callback will be executed with WICED_BT_MESH_TX_COMPLETE event indicating that the event has been sent out. The OnOff command is sent not requiring acknowledgment. The WICED_BT_MESH_ONOFF_STATUS event will only be executed only if the provisioner configured the recipient of the command to publish the status data to this element, or to a group to which this element belongs to.

Parameters
element_idxElement Index of the model
p_dataPointer to the data to send
Returns
WICED_BT_SUCCESS if message has been queued for transmission.