AIROC™ BTSDK v4.0 - Documentation | ||||
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... | |
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.
#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 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.
event | The event that the application should process (see Mesh On/Off Events) |
p_event | information about the message received. It is application responsibility to release the event using wiced_bt_mesh_release_event. |
p_data | Pointer to the data to send |
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.
element_idx | Element Index of the model |
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.
element_idx | Device element to where model is used |
p_callback | The 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_provisioned | If TRUE, the application is being restarted after being provisioned or after a power loss. |
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.
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 |
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.
p_event | Mesh event with the information about the message that has been created by the app for unsolicited message. |
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.
p_event | Mesh event with the information about the message that has been created by the app for unsolicited message. |
p_data | Pointer to the data to send |
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.
element_idx | Element Index of the model |
p_data | Pointer to the data to send |