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... | |
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.
These requirements are documented at appropriate places in the module source code.
#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.
Timer for cadence. This is separate from when we send status when we get an interrupt from the PIR sensor
[in] | _name | Name of the app_sensor_server_t instance |
[in] | _force_segmented | If the Sensor server shall use force segmentation of messages |
[in] | _mic_size | MIC size to be used by Sensor server |
[in] | _get_cb | Callback for reading the state from the application. |
[in] | _settings_get_cb | Callback for reading settings data from the application. |
[in] | _setting_set_cb | Callback for setting a setting value from the application. |
[in] | _setting_get_cb | Callback for reading setting data from the application. |
[in] | _column_get_cb | Callback for reading column data from the application. |
[in] | _series_get_cb | Callback for reading series from the application. |
[in] | _property_array | The array of supported properties. |
[in] | _cadence_timer_ids | An array of timer Ids; one for each supported property. |
[in] | _min_interval_timer_ids | An array of timer Ids; one for each supported property. |
[in] | _descriptor_struct_array | The array of descriptors. |
[in] | _num_descs | The number of descriptors. |
[in] | _p_message_buffer | Buffer used for storing messages used by the sensor model. |
[in] | _message_buffer_bytes | The number of bytes available in _p_message_buffer. |
Definition at line 109 of file app_sensor.h.
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.
[in] | p_server | Pointer to __app_sensor_server_t [app_sensor_server_t] context |
[in] | property_id | Property id of the sensor to be read |
[in] | p_out | The address of the response message. |
[out] | p_out_bytes | The number of message bytes at p_out. |
Definition at line 158 of file app_sensor.h.
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.
[in] | p_server | Pointer to __app_sensor_server_t [app_sensor_server_t] context |
[in] | property_id | Property id of the sensor to query |
[out] | p_out | Pointer to the response message. |
[out] | p_out_bytes | The number of message bytes at *pp_out. |
Definition at line 174 of file app_sensor.h.
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.
[in] | p_server | Pointer to __app_sensor_server_t [app_sensor_server_t] context |
[in] | property_id | Property id of the sensor to be set |
[in] | setting_property_id | Setting property id of the sensor setting to be set |
[in] | p_in | The setting set command. |
[in] | in_bytes | The number of bytes in p_in. |
[out] | p_out | Pointer to the response message. |
[out] | p_out_bytes | The number of message bytes at *pp_out. |
Definition at line 192 of file app_sensor.h.
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.
[in] | p_server | Pointer to __app_sensor_server_t [app_sensor_server_t] context |
[in] | property_id | Property id of the sensor to query |
[in] | setting_property_id | Setting property id of the sensor setting to be set |
[out] | p_out | Pointer to the response message. |
[out] | p_out_bytes | The number of message bytes at *pp_out. |
Definition at line 210 of file app_sensor.h.
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
.
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.[in] | p_server | Pointer to __app_sensor_server_t [app_sensor_server_t] context. |
[in] | p_in | Pointer to the Sensor Column Get message parameters. This contains requested property id. |
[in] | in_bytes | Pointer to the number of bytes at p_in. |
[out] | p_out | Pointer to the response message buffer. This buffer must be provided by the application. |
[out] | p_out_bytes | The number of message bytes at *pp_out. |
Definition at line 234 of file app_sensor.h.
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
.
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.[in] | p_server | Pointer to __app_sensor_server_t [app_sensor_server_t] context |
[in] | p_in | Pointer to the Sensor Series Get message parameters. This contains requested property id. |
[in] | in_bytes | Pointer to the number of bytes at p_in. |
[out] | p_out | Pointer to the response message. This buffer must be provided by the application. |
[out] | p_out_bytes | The number of message bytes at *pp_out. |
Definition at line 257 of file app_sensor.h.
uint32_t app_sensor_init | ( | app_sensor_server_t * | p_server, |
uint16_t | element_index | ||
) |
Initializes the behavioral module for the Sensor model.
[in] | p_server | Pointer to the application server server structure array. |
[in] | element_index | Element index on which this server will be instantiated. |
NRF_SUCCESS | The model is initialized successfully. |
NRF_ERROR_NULL | NULL pointer is supplied to the function or to the required member variable pointers. |
NRF_ERROR_NO_MEM | ACCESS_MODEL_COUNT number of models already allocated or no more subscription lists available in memory pool (see ACCESS_SUBSCRIPTION_LIST_COUNT). |
NRF_ERROR_FORBIDDEN | Multiple 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_FOUND | Invalid access element index. |