nRF5 SDK for Mesh v5.0.0
sensor_setup_server.h
1 /* Copyright (c) 2010 - 2020, Nordic Semiconductor ASA
2  * All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without modification,
5  * are permitted provided that the following conditions are met:
6  *
7  * 1. Redistributions of source code must retain the above copyright notice, this
8  * list of conditions and the following disclaimer.
9  *
10  * 2. Redistributions in binary form, except as embedded into a Nordic
11  * Semiconductor ASA integrated circuit in a product or a software update for
12  * such product, must reproduce the above copyright notice, this list of
13  * conditions and the following disclaimer in the documentation and/or other
14  * materials provided with the distribution.
15  *
16  * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
17  * contributors may be used to endorse or promote products derived from this
18  * software without specific prior written permission.
19  *
20  * 4. This software, with or without modification, must only be used with a
21  * Nordic Semiconductor ASA integrated circuit.
22  *
23  * 5. Any software provided in binary form under this license must not be reverse
24  * engineered, decompiled, modified and/or disassembled.
25  *
26  * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
28  * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
29  * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
30  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
32  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
35  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 #ifndef SENSOR_SERVER_H__
39 #define SENSOR_SERVER_H__
40 
41 #include <stdint.h>
42 #include "access.h"
43 #include "sensor_common.h"
44 #include "model_common.h"
45 #include "sensor_messages.h"
46 
55 #define SENSOR_SERVER_MODEL_ID 0x1100
56 
58 #define SENSOR_SETUP_SERVER_MODEL_ID 0x1101
59 
60 /* Forward declaration */
61 typedef struct __sensor_server_t sensor_server_t;
62 
63 /* Forward declaration */
64 typedef struct __sensor_setup_server_t sensor_setup_server_t;
65 
66 
76 typedef void (*sensor_descriptor_get_cb_t)(const sensor_setup_server_t * p_self,
77  const access_message_rx_meta_t * p_meta,
78  uint16_t property_id,
80  uint16_t * p_out_bytes);
81 
91 typedef void (*sensor_state_get_cb_t)(const sensor_setup_server_t * p_self,
92  const access_message_rx_meta_t * p_meta,
93  uint16_t property_id,
94  sensor_status_msg_pkt_t ** pp_out,
95  uint16_t * p_out_bytes);
96 
108 typedef void (*sensor_column_get_cb_t)(const sensor_setup_server_t * p_self,
109  const access_message_rx_meta_t * p_meta,
110  const sensor_column_get_msg_pkt_t * p_in,
111  uint16_t in_bytes,
113  uint16_t * p_out_bytes);
114 
126 typedef void (*sensor_series_get_cb_t)(const sensor_setup_server_t * p_self,
127  const access_message_rx_meta_t * p_meta,
128  const sensor_series_get_msg_pkt_t * p_in,
129  uint16_t in_bytes,
131  uint16_t * p_out_bytes);
132 
133 
143 typedef void (*sensor_cadence_get_cb_t)(const sensor_setup_server_t * p_self,
144  const access_message_rx_meta_t * p_meta,
145  uint16_t property_id,
146  sensor_cadence_status_msg_pkt_t ** pp_out,
147  uint16_t * p_out_bytes);
148 
160 typedef void (*sensor_cadence_set_cb_t)(const sensor_setup_server_t * p_self,
161  const access_message_rx_meta_t * p_meta,
162  uint16_t property_id,
163  const sensor_cadence_set_msg_pkt_t * p_in,
164  uint16_t in_bytes,
165  sensor_cadence_status_msg_pkt_t ** pp_out,
166  uint16_t * p_out_bytes);
176 typedef void (*sensor_settings_get_cb_t)(const sensor_setup_server_t * p_self,
177  const access_message_rx_meta_t * p_meta,
178  uint16_t property_id,
180  uint16_t * p_out_bytes);
181 
192 typedef void (*sensor_setting_get_cb_t)(const sensor_setup_server_t * p_self,
193  const access_message_rx_meta_t * p_meta,
194  uint16_t property_id,
195  uint16_t setting_property_id,
197  uint16_t * p_out_bytes);
198 
211 typedef void (*sensor_setting_set_cb_t)(const sensor_setup_server_t * p_self,
212  const access_message_rx_meta_t * p_meta,
213  uint16_t property_id,
214  uint16_t settings_property_id,
215  const sensor_setting_set_msg_pkt_t * p_in,
216  uint16_t in_bytes,
218  uint16_t * p_out_bytes);
219 
225 typedef void (*sensor_publication_schedule_cb_t)(const sensor_setup_server_t * p_self);
226 
230 typedef struct
231 {
238 
239  /* There are no callbacks for the state for this model, these callbacks are defined for the setup
240  * server.
241  */
243 
246 {
250 
254 };
255 
259 typedef struct
260 {
261  sensor_descriptor_get_cb_t descriptor_get_cb;
262  sensor_state_get_cb_t get_cb;
263  sensor_column_get_cb_t column_get_cb;
264  sensor_series_get_cb_t series_get_cb;
265  sensor_cadence_get_cb_t cadence_get_cb;
266  sensor_cadence_set_cb_t cadence_set_cb;
267  sensor_settings_get_cb_t settings_get_cb;
268  sensor_setting_get_cb_t setting_get_cb;
269  sensor_setting_set_cb_t setting_set_cb;
270  sensor_publication_schedule_cb_t publication_schedule_cb;
272 
276 typedef struct
277 {
282 
286 typedef struct
287 {
288  uint16_t element_index;
295 
299  uint16_t * property_array;
300 
304 
307 {
311 
314  sensor_server_t sensor_srv;
315 
319 };
320 
343 uint32_t sensor_server_status_publish(const sensor_server_t * p_server,
344  const sensor_status_msg_pkt_t * p_data,
345  uint16_t data_length,
346  sensor_opcode_t status_opcode);
347 
370 uint32_t sensor_server_setup_status_publish(const sensor_setup_server_t * p_s_server,
371  const sensor_status_msg_pkt_t * p_data,
372  uint16_t data_length,
373  sensor_opcode_t status_opcode);
374 
393 uint32_t sensor_setup_server_init(sensor_setup_server_t * p_server, uint16_t element_index);
394 
396 #endif /* SENSOR_SERVER_H__ */
uint16_t * property_array
The list of property ids supported by this device.
void(* sensor_publication_schedule_cb_t)(const sensor_setup_server_t *p_self)
Callback type for scheduling sensor publications.
void(* sensor_cadence_set_cb_t)(const sensor_setup_server_t *p_self, const access_message_rx_meta_t *p_meta, uint16_t property_id, const sensor_cadence_set_msg_pkt_t *p_in, uint16_t in_bytes, sensor_cadence_status_msg_pkt_t **pp_out, uint16_t *p_out_bytes)
Callback type for Sensor Cadence Set message.
Message format for the Sensor Descriptor Status message.
Sensor server callback list.
uint16_t access_model_handle_t
Access layer handle type.
Definition: access.h:162
const sensor_setup_server_callbacks_t * p_callbacks
Callback list.
void(* sensor_cadence_get_cb_t)(const sensor_setup_server_t *p_self, const access_message_rx_meta_t *p_meta, uint16_t property_id, sensor_cadence_status_msg_pkt_t **pp_out, uint16_t *p_out_bytes)
Callback type for Sensor Cadence Get message.
access_model_handle_t model_handle
Model handle assigned to this instance.
Message format for the Sensor Column Status message 4.2.16 Sensor Column Status Sensor Column Status ...
Message format for the Sensor Cadence Set/Set Unacknowledged message (partial) 4.2.4 Sensor Cadence Set Sensor Cadence Set is an acknowledged message used to set the Sensor Cadence state of an element (see Section 4.1.3).
void(* sensor_descriptor_get_cb_t)(const sensor_setup_server_t *p_self, const access_message_rx_meta_t *p_meta, uint16_t property_id, sensor_descriptor_status_msg_pkt_t **pp_out, uint16_t *p_out_bytes)
Callback type for Sensor descriptor get message.
uint32_t sensor_server_setup_status_publish(const sensor_setup_server_t *p_s_server, const sensor_status_msg_pkt_t *p_data, uint16_t data_length, sensor_opcode_t status_opcode)
Publishes unsolicited Status message.
User provided settings and callbacks for the model instance.
Message format for the Sensor Series Status message 4.2.18 Sensor Series Status Sensor Series Status ...
bool force_segmented
If server should force outgoing messages as segmented messages.
void(* sensor_setting_set_cb_t)(const sensor_setup_server_t *p_self, const access_message_rx_meta_t *p_meta, uint16_t property_id, uint16_t settings_property_id, const sensor_setting_set_msg_pkt_t *p_in, uint16_t in_bytes, sensor_setting_status_msg_pkt_t **pp_out, uint16_t *p_out_bytes)
Callback type for Sensor Setting Set message.
sensor_server_t sensor_srv
Parent model context for - Sensor server.
uint32_t sensor_setup_server_init(sensor_setup_server_t *p_server, uint16_t element_index)
Initializes Sensor Setup server.
void(* sensor_state_get_cb_t)(const sensor_setup_server_t *p_self, const access_message_rx_meta_t *p_meta, uint16_t property_id, sensor_status_msg_pkt_t **pp_out, uint16_t *p_out_bytes)
Callback type for Sensor Get message.
sensor_setup_server_settings_t settings
Model settings and callbacks for this instance.
User provided settings and callbacks for the model instance.
nrf_mesh_transmic_size_t transmic_size
TransMIC size used by the outgoing server messages.
Metadata for received messages.
Definition: access.h:196
nrf_mesh_transmic_size_t transmic_size
TransMIC size used by the outgoing server messages.
Message format for the Sensor Setting Set/Set Unacknowledged message (partial) 4.2.10 Sensor Setting Set Sensor Setting Set is an acknowledged message used to set the Sensor Setting state of an element (see Section 4.1.2).
uint32_t sensor_server_status_publish(const sensor_server_t *p_server, const sensor_status_msg_pkt_t *p_data, uint16_t data_length, sensor_opcode_t status_opcode)
Publishes unsolicited Status message.
bool force_segmented
If server should force outgoing messages as segmented messages.
Transaction callbacks for the Sensor state.
void(* sensor_column_get_cb_t)(const sensor_setup_server_t *p_self, const access_message_rx_meta_t *p_meta, const sensor_column_get_msg_pkt_t *p_in, uint16_t in_bytes, sensor_column_status_msg_pkt_t **pp_out, uint16_t *p_out_bytes)
Callback type for Sensor Column Get message.
void(* sensor_settings_get_cb_t)(const sensor_setup_server_t *p_self, const access_message_rx_meta_t *p_meta, uint16_t property_id, sensor_settings_status_msg_pkt_t **pp_out, uint16_t *p_out_bytes)
Callback type for Sensor Settings Get message.
Message format for the Sensor Column Get message (partial) 4.2.15 Sensor Column Get Sensor Column Get...
nrf_mesh_transmic_size_t
Message MIC size selection.
Definition: nrf_mesh.h:385
access_model_handle_t model_handle
Model handle assigned to this instance.
Message format for the Sensor Settings Status message.
sensor_setup_server_cbs_t sensor_cbs
Callbacks for the level state.
void(* sensor_series_get_cb_t)(const sensor_setup_server_t *p_self, const access_message_rx_meta_t *p_meta, const sensor_series_get_msg_pkt_t *p_in, uint16_t in_bytes, sensor_series_status_msg_pkt_t **pp_out, uint16_t *p_out_bytes)
Callback type for Sensor Series Get message.
void(* sensor_setting_get_cb_t)(const sensor_setup_server_t *p_self, const access_message_rx_meta_t *p_meta, uint16_t property_id, uint16_t setting_property_id, sensor_setting_status_msg_pkt_t **pp_out, uint16_t *p_out_bytes)
Callback type for Sensor Setting Get message.
Message format for the Sensor Series Get message (partial) 4.2.17 Sensor Series Get Sensor Series Get...
sensor_server_settings_t settings
Model settings and callbacks for this instance.
Message format for the Sensor Setting Status message.

Documentation feedback | Developer Zone | Subscribe | Updated