Infineon Logo AIROC BTSDK v4.7 - Documentation
 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Mesh Light Lightness Server

The AIROC Mesh Light Lightness Server module provides a way for an application to implement a dimmable light device which can be controlled specifically by setting the brightness, but also can be 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_LIGHT_LIGHTNESS_SERVER
 Mesh Light Lightness Server Device. More...
 

Typedefs

typedef void( wiced_bt_mesh_light_lightness_server_callback_t )(uint8_t element_idx, uint16_t event, void *p_data)
 Light Lightness Server callback. More...
 

Functions

void wiced_bt_mesh_model_light_lightness_server_init (uint8_t element_idx, wiced_bt_mesh_light_lightness_server_callback_t *p_callback, wiced_bool_t is_provisioned)
 Light Lightness Server Module initialization. More...
 
void wiced_bt_mesh_model_light_lightness_actual_changed (uint8_t element_idx, uint16_t value)
 Light Lightness Actual changed. More...
 
void wiced_bt_mesh_model_light_lightness_linear_changed (uint8_t element_idx, uint16_t value)
 Light Lightness Linear changed. More...
 
wiced_bool_t wiced_bt_mesh_model_light_lightness_server_message_handler (wiced_bt_mesh_event_t *p_event, uint8_t *p_data, uint16_t data_len)
 Light Lightness Server Message Handler. More...
 
wiced_bool_t wiced_bt_mesh_model_light_lightness_setup_server_message_handler (wiced_bt_mesh_event_t *p_event, uint8_t *p_data, uint16_t data_len)
 Light Lightness Setup Server Message Handler. More...
 
void wiced_bt_mesh_model_light_lightness_set_parent (uint8_t element_idx, wiced_bt_mesh_light_lightness_server_callback_t *p_callback)
 Light Lightness Server Set Parent. More...
 
uint16_t wiced_bt_mesh_model_light_lightness_server_scene_store_handler (uint8_t element_idx, uint8_t *p_buffer, uint16_t buffer_len)
 Light Lightness Server Scene Store Handler. More...
 
uint16_t wiced_bt_mesh_model_light_lightness_server_scene_recall_handler (uint8_t element_idx, uint8_t *p_buffer, uint16_t buffer_len, uint32_t transition_time, uint32_t delay)
 Light Lightness Server Scene Restore Handler. More...
 

Detailed Description

The AIROC Mesh Light Lightness Server module provides a way for an application to implement a dimmable light device which can be controlled specifically by setting the brightness, but also can be 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 include the Mesh Models support for the Light Lightness Server model the application includes WICED_BT_MESH_MODEL_LIGHT_LIGHTNESS_SERVER in the device definition. If the device supports several elements with Light Lightness Server, for example, a light fixture or a chandelier with several dimmable lights, the WICED_BT_MESH_MODEL_LIGHT_LIGHTNESS_SERVER shall be included for each element.

In addition to the definition, the application shall initialize the Light Lightness module by calling wiced_bt_mesh_model_light_lightness_server_init function for each element where the light dimming functionality is required providing the wiced_bt_mesh_light_lightness_server_callback_t callback that will be executed when the brightness level of the device needs to be changed.

Note: The Light Lightness module is used internally by the mesh models library in color light scenarios where dimming is one of the methods controlling the light. In that case, the application shall not implicitely include WICED_BT_MESH_MODEL_LIGHT_LIGHTNESS_SERVER and shall not perform module initialization.

While performing initialization the application provides the callback that will be executed when the library needs to change the brightness of a light due to a request received over the mesh network, or due to the internal schedule.

If brightness of the dimmable light is changed locally the application should call the wiced_bt_mesh_model_light_lightness_status_changed so that the library can maintain correct state and send an appropriate status message if it is configured to do so.

Most of the functionality of the Light Lightness server device is implemented in the Mesh Models Library. The application only needs to set hardware appropriately on receiving WICED_BT_MESH_LIGHT_LIGHTNESS_STATUS event. If client requests to change the brightness 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_LIGHT_LIGHTNESS_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_LIGHT_LIGHTNESS_SETUP_SRV, wiced_bt_mesh_model_light_lightness_setup_server_message_handler, NULL, NULL }
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_light_lightness_server_message_handler(wiced_bt_mesh_event_t *p_event, uint8_t *p_data, uint16_t data_len)
Light Lightness Server Message Handler.
uint16_t wiced_bt_mesh_model_light_lightness_server_scene_store_handler(uint8_t element_idx, uint8_t *p_buffer, uint16_t buffer_len)
Light Lightness Server Scene Store 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_light_lightness_setup_server_message_handler(wiced_bt_mesh_event_t *p_event, uint8_t *p_data, uint16_t data_len)
Light Lightness Setup 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.
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.
uint16_t wiced_bt_mesh_model_light_lightness_server_scene_recall_handler(uint8_t element_idx, uint8_t *p_buffer, uint16_t buffer_len, uint32_t transition_time, uint32_t delay)
Light Lightness Server Scene Restore Handler.

Mesh Light Lightness Server Device.

The Mesh Light Lightness Server Device device implements all required models for a dimmable bulb. The time and scheduler models are optional and can be commented out to reduce memory footprint.

Typedef Documentation

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

Light Lightness Server callback.

Light Lightness Server callback is executed by the Mesh Models library when the application is required to adjust the amount of light emitted by the device. The application is responsible for setting the hardware (for example, by controlling PWM) to comply with the value requested by the library.

If peer device requested to transition to the new brightness level over a period of time, the callback will be executed repeatedly. Mesh Library calculates the present lightness level and submits to the application to update the hardware.

The p_data parameter points to the wiced_bt_mesh_light_lightness_status_t structure. Typically the application will only need to use the value of the lightness_linear_present field which specify the lightness of the device which shall be set at this particular moment. If the remaining_time field is not zero, the transition to the new target level is in progress and the Mesh Library will execute the callback at least once more before the transition is completed.

Parameters
element_idxElement index of the primary element
eventThe only event that the application should process is WICED_BT_MESH_LIGHT_LIGHTNESS_STATUS
p_dataPointer to the wiced_bt_mesh_light_lightness_status_t structure
Returns
None

Function Documentation

void wiced_bt_mesh_model_light_lightness_actual_changed ( uint8_t  element_idx,
uint16_t  value 
)

Light Lightness Actual changed.

An application shall call this function to notify the Models Library that the value of Lightness has been changed locally.

Parameters
element_idxElement index for which lightness value has changed
valueNew value of lightness
Returns
None
void wiced_bt_mesh_model_light_lightness_linear_changed ( uint8_t  element_idx,
uint16_t  value 
)

Light Lightness Linear changed.

An application shall call this function to notify the Models Library that the value of Lightness has been changed locally.

Parameters
element_idxElement index for which lightness value has changed
valueNew value of lightness
Returns
None
void wiced_bt_mesh_model_light_lightness_server_init ( uint8_t  element_idx,
wiced_bt_mesh_light_lightness_server_callback_t p_callback,
wiced_bool_t  is_provisioned 
)

Light Lightness Server Module initialization.

A Mesh application which contains Light Lightness Server (for example, an application for a dimmable light) should call this function during application initialization passing element index of the element. If application needs to support multiple dimmable lights, the initialization shall be called multiple times, once per each element.

The application shall not call this function if the Light Lightness is not the top level function of the device, for example, when the Light Lightness is included as a part of the HSL Light.

The application callback wiced_bt_mesh_light_lightness_server_callback_t will be executed by the Model Library when it is required to set amount of light emitted by the light to a certain level.

Parameters
element_idxElement index where the server is located.
p_callbackApplication or Parent model callback that will be executed to control the device hardware.
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
wiced_bool_t wiced_bt_mesh_model_light_lightness_server_message_handler ( wiced_bt_mesh_event_t p_event,
uint8_t *  p_data,
uint16_t  data_len 
)

Light Lightness Server Message Handler.

The Light Lightness Server Message Handler 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 returns WICED_TRUE if the message is destined for this 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_light_lightness_server_scene_recall_handler ( uint8_t  element_idx,
uint8_t *  p_buffer,
uint16_t  buffer_len,
uint32_t  transition_time,
uint32_t  delay 
)

Light Lightness Server Scene Restore 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. When Scene Server receives Scene Recall message it calls this function with data previously stored in the NVRAM.

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_light_lightness_server_scene_store_handler ( uint8_t  element_idx,
uint8_t *  p_buffer,
uint16_t  buffer_len 
)

Light Lightness Server Scene Store 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 Scene Server calls this function so that the module can store required data for the scene.

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
void wiced_bt_mesh_model_light_lightness_set_parent ( uint8_t  element_idx,
wiced_bt_mesh_light_lightness_server_callback_t p_callback 
)

Light Lightness Server Set Parent.

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. In multi server applications, for example a color light which supports both HSL and CTL controls, only one model should receive Get/Set for lightness, level and on/onff messages. This function should be called when the startup controller changes.

Parameters
element_idxDevice element to where model is used
p_callbackApplication or Parent model callback that will be executed on receiving a message
Returns
WICED_TRUE if initialization was successful
wiced_bool_t wiced_bt_mesh_model_light_lightness_setup_server_message_handler ( wiced_bt_mesh_event_t p_event,
uint8_t *  p_data,
uint16_t  data_len 
)

Light Lightness Setup Server Message Handler.

The Light Lightness Server Message Handler 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 returns WICED_TRUE if the message is destined for this 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.