nRF5 SDK for Mesh v5.0.0
Data Structures | Macros | Typedefs | Functions
Sensor Server behaviour

Application level Sensor server behavioral structures, functions, and callbacks. More...

Data Structures

struct  app_sensor_state_t
 Internal structure to hold state. More...
 
struct  app_sensor_server_t
 Application level structure holding the Sensor server model context and sensor state representation. More...
 

Macros

#define APP_SENSOR_SERVER_DEF(_name, _force_segmented, _mic_size, _get_cb, _settings_get_cb, _setting_set_cb, _setting_get_cb, _column_get_cb, _series_get_cb, _property_array, _cadence_timer_ids, _min_interval_timer_ids, _descriptor_struct_array, _num_descs, _p_message_buffer, _message_buffer_bytes)
 Macro to create application level app_sensor_server_t context. More...
 

Typedefs

typedef uint8_t pir_data_size_t
 
typedef uint8_t descriptor_status_t
 
typedef void(* app_sensor_get_cb_t) (const app_sensor_server_t *p_server, uint16_t property_id, uint8_t *p_out, uint16_t *p_out_bytes)
 Application state read callback prototype. More...
 
typedef void(* app_sensor_settings_get_cb_t) (const app_sensor_server_t *p_server, uint16_t property_id, sensor_settings_status_msg_pkt_t *p_out, uint16_t *p_out_bytes)
 Application state read settings callback prototype. More...
 
typedef void(* app_sensor_setting_set_cb_t) (const app_sensor_server_t *p_server, uint16_t property_id, uint16_t setting_property_id, const sensor_setting_set_msg_pkt_t *p_in, uint16_t in_bytes, sensor_setting_status_msg_pkt_t *p_out, uint16_t *p_out_bytes)
 Application state set setting callback prototype. More...
 
typedef void(* app_sensor_setting_get_cb_t) (const app_sensor_server_t *p_server, uint16_t property_id, uint16_t setting_property_id, sensor_setting_status_msg_pkt_t *p_out, uint16_t *p_out_bytes)
 Application state read single setting callback prototype. More...
 
typedef void(* app_sensor_column_get_cb_t) (const app_sensor_server_t *p_server, const sensor_column_get_msg_pkt_t *p_in, uint16_t in_bytes, sensor_column_status_msg_pkt_t *p_out, uint16_t *p_out_bytes)
 Application state read column callback prototype. More...
 
typedef void(* app_sensor_series_get_cb_t) (const app_sensor_server_t *p_server, const sensor_series_get_msg_pkt_t *p_in, uint16_t in_bytes, sensor_series_status_msg_pkt_t *p_out, uint16_t *p_out_bytes)
 Application state read series callback prototype. More...
 

Functions

uint32_t app_sensor_init (app_sensor_server_t *p_server, uint16_t element_index)
 Initializes the behavioral module for the Sensor model. More...
 

Detailed Description

Application level Sensor server behavioral structures, functions, and callbacks.

This module implements the behavioral requirements of the Sensor server model.

The application should use the set callback provided by this module to set the hardware state. The hardware state could be changed by reflecting the value provided by the set callback on the GPIO or by sending this value to the connected lighting peripheral using some other interface (e.g. serial interface). Similarly, the application should use the get callback provided by this module to read the hardware state.

This module triggers the set callback only when it determines that it is time to inform the user application. It is possible that the client can send multiple overlapping set commands. In such case any transition in progress will be abandoned and fresh transition will be started if required.

Warning
To comply with the Bluetooth Mesh Model Specification (MshMDLv1.0.1) test cases, the application must adhere to the requirements defined in the following sections:
  • Bluetooth Mesh Model Specification (MshMDLv1.0.1) section 4 (Sensors).
  • Bluetooth Mesh Profile Specification (MshPRFv1.0.1) section 3.7.6.1 (Publish).

These requirements are documented at appropriate places in the module source code.

Macro Definition Documentation

◆ APP_SENSOR_SERVER_DEF

#define APP_SENSOR_SERVER_DEF (   _name,
  _force_segmented,
  _mic_size,
  _get_cb,
  _settings_get_cb,
  _setting_set_cb,
  _setting_get_cb,
  _column_get_cb,
  _series_get_cb,
  _property_array,
  _cadence_timer_ids,
  _min_interval_timer_ids,
  _descriptor_struct_array,
  _num_descs,
  _p_message_buffer,
  _message_buffer_bytes 
)
Value:
; \
static uint8_t m_descriptor_buf[_num_descs * SENSOR_DESCRIPTOR_MSG_SIZE]; \
static app_sensor_server_t _name = \
{ \
.server.settings.force_segmented = _force_segmented, \
.server.settings.transmic_size = _mic_size, \
.sensor_get_cb = _get_cb, \
.sensor_settings_get_cb = _settings_get_cb, \
.sensor_setting_set_cb = _setting_set_cb, \
.sensor_setting_get_cb = _setting_get_cb, \
.sensor_column_get_cb = _column_get_cb, \
.sensor_series_get_cb = _series_get_cb, \
.p_sensor_property_array = _property_array, \
.p_cadence_timer_ids = _cadence_timer_ids, \
.p_min_interval_timer_ids = _min_interval_timer_ids, \
.p_sensor_descriptor = _descriptor_struct_array, \
.p_descriptor_message = m_descriptor_buf, \
.sensor_num_desc = _num_descs, \
.p_message_buffer = _p_message_buffer, \
.message_buffer_bytes = _message_buffer_bytes \
};
#define SENSOR_DESCRIPTOR_MSG_SIZE
Sensor Descriptor size.
Definition: sensor_common.h:81

Macro to create application level app_sensor_server_t context.

Timer for cadence. This is separate from when we send status when we get an interrupt from the PIR sensor

Parameters
[in]_nameName of the app_sensor_server_t instance
[in]_force_segmentedIf the Sensor server shall use force segmentation of messages
[in]_mic_sizeMIC size to be used by Sensor server
[in]_get_cbCallback for reading the state from the application.
[in]_settings_get_cbCallback for reading settings data from the application.
[in]_setting_set_cbCallback for setting a setting value from the application.
[in]_setting_get_cbCallback for reading setting data from the application.
[in]_column_get_cbCallback for reading column data from the application.
[in]_series_get_cbCallback for reading series from the application.
[in]_property_arrayThe array of supported properties.
[in]_cadence_timer_idsAn array of timer Ids; one for each supported property.
[in]_min_interval_timer_idsAn array of timer Ids; one for each supported property.
[in]_descriptor_struct_arrayThe array of descriptors.
[in]_num_descsThe number of descriptors.
[in]_p_message_bufferBuffer used for storing messages used by the sensor model.
[in]_message_buffer_bytesThe number of bytes available in _p_message_buffer.

Definition at line 109 of file app_sensor.h.

Typedef Documentation

◆ app_sensor_get_cb_t

typedef void(* app_sensor_get_cb_t) (const app_sensor_server_t *p_server, uint16_t property_id, uint8_t *p_out, uint16_t *p_out_bytes)

Application state read callback prototype.

This callback is called by this module whenever application sensor state is required to be read.

Parameters
[in]p_serverPointer to __app_sensor_server_t [app_sensor_server_t] context
[in]property_idProperty id of the sensor to be read
[in]p_outThe address of the response message.
[out]p_out_bytesThe number of message bytes at p_out.

Definition at line 158 of file app_sensor.h.

◆ app_sensor_settings_get_cb_t

typedef void(* app_sensor_settings_get_cb_t) (const app_sensor_server_t *p_server, uint16_t property_id, sensor_settings_status_msg_pkt_t *p_out, uint16_t *p_out_bytes)

Application state read settings callback prototype.

This callback is called by this module whenever application settings state is required to be read.

Parameters
[in]p_serverPointer to __app_sensor_server_t [app_sensor_server_t] context
[in]property_idProperty id of the sensor to query
[out]p_outPointer to the response message.
[out]p_out_bytesThe number of message bytes at *pp_out.

Definition at line 174 of file app_sensor.h.

◆ app_sensor_setting_set_cb_t

typedef void(* app_sensor_setting_set_cb_t) (const app_sensor_server_t *p_server, uint16_t property_id, uint16_t setting_property_id, const sensor_setting_set_msg_pkt_t *p_in, uint16_t in_bytes, sensor_setting_status_msg_pkt_t *p_out, uint16_t *p_out_bytes)

Application state set setting callback prototype.

This callback is called by the this module whenever application is required to be informed to reflect the desired setting state value, as a result of the received SET setting message.

Parameters
[in]p_serverPointer to __app_sensor_server_t [app_sensor_server_t] context
[in]property_idProperty id of the sensor to be set
[in]setting_property_idSetting property id of the sensor setting to be set
[in]p_inThe setting set command.
[in]in_bytesThe number of bytes in p_in.
[out]p_outPointer to the response message.
[out]p_out_bytesThe number of message bytes at *pp_out.

Definition at line 192 of file app_sensor.h.

◆ app_sensor_setting_get_cb_t

typedef void(* app_sensor_setting_get_cb_t) (const app_sensor_server_t *p_server, uint16_t property_id, uint16_t setting_property_id, sensor_setting_status_msg_pkt_t *p_out, uint16_t *p_out_bytes)

Application state read single setting callback prototype.

This callback is called by this module whenever a setting state is required to be read.

Parameters
[in]p_serverPointer to __app_sensor_server_t [app_sensor_server_t] context
[in]property_idProperty id of the sensor to query
[in]setting_property_idSetting property id of the sensor setting to be set
[out]p_outPointer to the response message.
[out]p_out_bytesThe number of message bytes at *pp_out.

Definition at line 210 of file app_sensor.h.

◆ app_sensor_column_get_cb_t

typedef void(* app_sensor_column_get_cb_t) (const app_sensor_server_t *p_server, const sensor_column_get_msg_pkt_t *p_in, uint16_t in_bytes, sensor_column_status_msg_pkt_t *p_out, uint16_t *p_out_bytes)

Application state read column callback prototype.

This callback is called by the app_sensor.c whenever application sensor state is required to be read. The User application provides the pointer to formatted data in pp_out.

Note
Unlike other model APIs, the buffer is not provided by the app_sensor.c module. Instead the user application must allocate some buffer of desired size and provide a pointer to it. This buffer must contain a formatted Sensor Column Status message data.
Parameters
[in]p_serverPointer to __app_sensor_server_t [app_sensor_server_t] context.
[in]p_inPointer to the Sensor Column Get message parameters. This contains requested property id.
[in]in_bytesPointer to the number of bytes at p_in.
[out]p_outPointer to the response message buffer. This buffer must be provided by the application.
[out]p_out_bytesThe number of message bytes at *pp_out.

Definition at line 234 of file app_sensor.h.

◆ app_sensor_series_get_cb_t

typedef void(* app_sensor_series_get_cb_t) (const app_sensor_server_t *p_server, const sensor_series_get_msg_pkt_t *p_in, uint16_t in_bytes, sensor_series_status_msg_pkt_t *p_out, uint16_t *p_out_bytes)

Application state read series callback prototype.

This callback is called by the app_sensor.c whenever application sensor state is required to be read. The User application provides the pointer to formatted data in pp_out.

Note
Unlike other model APIs, the buffer is not provided by the app_sensor.c module. Instead the user application must allocate some buffer of desired size and provide a pointer to it. This buffer must contain a formatted Sensor Series Status message data.
Parameters
[in]p_serverPointer to __app_sensor_server_t [app_sensor_server_t] context
[in]p_inPointer to the Sensor Series Get message parameters. This contains requested property id.
[in]in_bytesPointer to the number of bytes at p_in.
[out]p_outPointer to the response message. This buffer must be provided by the application.
[out]p_out_bytesThe number of message bytes at *pp_out.

Definition at line 257 of file app_sensor.h.

Function Documentation

◆ app_sensor_init()

uint32_t app_sensor_init ( app_sensor_server_t *  p_server,
uint16_t  element_index 
)

Initializes the behavioral module for the Sensor model.

Parameters
[in]p_serverPointer to the application server server structure array.
[in]element_indexElement index on which this server will be instantiated.
Return values
NRF_SUCCESSThe model is initialized successfully.
NRF_ERROR_NULLNULL pointer is supplied to the function or to the required member variable pointers.
NRF_ERROR_NO_MEMACCESS_MODEL_COUNT number of models already allocated or no more subscription lists available in memory pool (see ACCESS_SUBSCRIPTION_LIST_COUNT).
NRF_ERROR_FORBIDDENMultiple model instances per element are not allowed or changes to device composition are not allowed. Adding a new model after device is provisioned is not allowed.
NRF_ERROR_NOT_FOUNDInvalid access element index.

Documentation feedback | Developer Zone | Subscribe | Updated