nRF5 SDK for Mesh v5.0.0
sensor_client.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_CLIENT_H__
39 #define SENSOR_CLIENT_H__
40 
41 
42 #include <stdint.h>
43 #include "access.h"
44 #include "access_reliable.h"
45 #include "sensor_common.h"
46 #include "sensor_messages.h"
54 #define SENSOR_CLIENT_MODEL_ID 0x1102
55 
56 typedef struct
57 {
58  uint8_t format; /* only 1 bit */
59  uint8_t length; /* 4 or 7 bits */
60  uint16_t property_id; /* 11 or 16 bits */
62 
63 
64 
65 typedef struct
66 {
68  uint8_t * raw_value;
70 
71 
72 /* Forward declaration */
73 typedef struct __sensor_client_t sensor_client_t;
74 
83 typedef void (*sensor_state_status_cb_t)(const sensor_client_t * p_self,
84  const access_message_rx_meta_t * p_meta,
85  const sensor_status_msg_pkt_t * p_in,
86  uint16_t bytes);
87 
96 typedef void (*sensor_descriptor_state_status_cb_t)(const sensor_client_t * p_self,
97  const access_message_rx_meta_t * p_meta,
98  const sensor_descriptor_t * p_in,
99  uint16_t num_descriptors);
100 
109 typedef void (*sensor_cadence_state_status_cb_t)(const sensor_client_t *p_self,
110  const access_message_rx_meta_t *p_meta,
111  const sensor_cadence_status_msg_pkt_t *p_in,
112  uint16_t length);
113 
122 typedef void (*sensor_column_state_status_cb_t)(const sensor_client_t *p_self,
123  const access_message_rx_meta_t *p_meta,
124  const sensor_column_status_msg_pkt_t *p_in,
125  uint16_t length);
126 
135 typedef void (*sensor_series_state_status_cb_t)(const sensor_client_t * p_self,
136  const access_message_rx_meta_t * p_meta,
137  const sensor_series_status_msg_pkt_t * p_in,
138  uint16_t length);
139 
148 typedef void (*sensor_settings_state_status_cb_t)(const sensor_client_t * p_self,
149  const access_message_rx_meta_t * p_meta,
151  uint16_t length);
152 
161 typedef void (*sensor_setting_state_status_cb_t)(const sensor_client_t * p_self,
162  const access_message_rx_meta_t * p_meta,
163  const sensor_setting_status_msg_pkt_t * p_in,
164  uint16_t length);
165 
166 typedef struct
167 {
170  sensor_descriptor_state_status_cb_t sensor_descriptor_status_cb;
171  sensor_cadence_state_status_cb_t sensor_cadence_status_cb;
172  sensor_column_state_status_cb_t sensor_column_status_cb;
173  sensor_series_state_status_cb_t sensor_series_status_cb;
174  sensor_settings_state_status_cb_t sensor_settings_status_cb;
175  sensor_setting_state_status_cb_t sensor_setting_status_cb;
176 
182 
186 typedef struct
187 {
191  uint32_t timeout;
198 
202 
205 {
208 
211 
214 
217  uint8_t * p_message_buffer;
218 
222 };
223 
243 uint32_t sensor_client_init(sensor_client_t *p_client, uint16_t element_index);
244 
263 uint32_t sensor_client_cadence_set(sensor_client_t * p_client,
264  const sensor_cadence_set_msg_pkt_t * p_params,
265  uint16_t length);
266 
290 uint32_t sensor_client_cadence_set_unack(sensor_client_t * p_client,
291  const sensor_cadence_set_msg_pkt_t * p_params,
292  uint16_t length,
293  uint8_t repeats);
294 
313 uint32_t sensor_client_setting_set(sensor_client_t * p_client,
314  const sensor_setting_set_msg_pkt_t * p_params,
315  uint16_t length);
339 uint32_t sensor_client_setting_set_unack(sensor_client_t * p_client,
340  const sensor_setting_set_msg_pkt_t * p_params,
341  uint16_t length,
342  uint8_t repeats);
360 uint32_t sensor_client_get(sensor_client_t * p_client, uint16_t property_id);
361 
379 uint32_t sensor_client_descriptor_get(sensor_client_t * p_client, uint16_t property_id);
380 
398 uint32_t sensor_client_cadence_get(sensor_client_t * p_client, uint16_t property_id);
399 
417 uint32_t sensor_client_settings_get(sensor_client_t * p_client, uint16_t property_id);
418 
437 uint32_t sensor_client_setting_get(sensor_client_t * p_client,
438  uint16_t property_id,
439  uint16_t setting_property_id);
440 
459 uint32_t sensor_client_column_get(sensor_client_t * p_client,
460  sensor_column_get_msg_pkt_t * p_rawbuf,
461  uint16_t length);
462 
481 uint32_t sensor_client_series_get(sensor_client_t * p_client,
482  sensor_series_get_msg_pkt_t * p_raw_colbuf,
483  uint16_t length);
484 
485 
487 #endif /* SENSOR_CLIENT_H__ */
User provided settings and callbacks for the model instance.
uint16_t access_model_handle_t
Access layer handle type.
Definition: access.h:162
access_reliable_cb_t ack_transaction_status_cb
Callback to call after the acknowledged transaction has ended.
uint32_t sensor_client_descriptor_get(sensor_client_t *p_client, uint16_t property_id)
Sends a Descriptor Get message to the server.
uint8_t * p_message_buffer
Pointer to memory to store reliable messages.
const sensor_client_callbacks_t * p_callbacks
Callback list.
Message format for the Sensor Column Status message 4.2.16 Sensor Column Status Sensor Column Status ...
uint32_t sensor_client_settings_get(sensor_client_t *p_client, uint16_t property_id)
Sends a Settings Get message to the server.
void(* sensor_setting_state_status_cb_t)(const sensor_client_t *p_self, const access_message_rx_meta_t *p_meta, const sensor_setting_status_msg_pkt_t *p_in, uint16_t length)
Callback type for setting state related transactions.
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).
sensor_client_settings_t settings
Model settings and callbacks for this instance.
void(* sensor_column_state_status_cb_t)(const sensor_client_t *p_self, const access_message_rx_meta_t *p_meta, const sensor_column_status_msg_pkt_t *p_in, uint16_t length)
Callback type for column state related transactions.
void(* sensor_settings_state_status_cb_t)(const sensor_client_t *p_self, const access_message_rx_meta_t *p_meta, const sensor_settings_status_msg_pkt_t *p_in, uint16_t length)
Callback type for settings state related transactions.
uint32_t sensor_client_cadence_set_unack(sensor_client_t *p_client, const sensor_cadence_set_msg_pkt_t *p_params, uint16_t length, uint8_t repeats)
Sends a Set Cadence Unacknowledged message to the server.
void(* access_publish_timeout_cb_t)(access_model_handle_t handle, void *p_args)
Access layer publish timeout event callback.
Definition: access.h:170
Message format for the Sensor Series Status message 4.2.18 Sensor Series Status Sensor Series Status ...
void(* sensor_state_status_cb_t)(const sensor_client_t *p_self, const access_message_rx_meta_t *p_meta, const sensor_status_msg_pkt_t *p_in, uint16_t bytes)
Callback type for incoming sensor data.
Definition: sensor_client.h:83
bool force_segmented
If server should force outgoing messages as segmented messages See mesh_model_force_segmented.
uint32_t timeout
Reliable message timeout in microseconds.
void(* sensor_descriptor_state_status_cb_t)(const sensor_client_t *p_self, const access_message_rx_meta_t *p_meta, const sensor_descriptor_t *p_in, uint16_t num_descriptors)
Callback type for sensor descriptor state related transactions.
Definition: sensor_client.h:96
nrf_mesh_transmic_size_t transmic_size
TransMIC size used by the outgoing server messages.
uint32_t sensor_client_cadence_set(sensor_client_t *p_client, const sensor_cadence_set_msg_pkt_t *p_params, uint16_t length)
Sends a Set cadence message to the server.
uint32_t sensor_client_series_get(sensor_client_t *p_client, sensor_series_get_msg_pkt_t *p_raw_colbuf, uint16_t length)
Sends a Series Get message to the server.
sensor_state_status_cb_t sensor_status_cb
Client model response message callback.
uint32_t sensor_client_setting_set_unack(sensor_client_t *p_client, const sensor_setting_set_msg_pkt_t *p_params, uint16_t length, uint8_t repeats)
Sends a Set Setting Unacknowledged message to the server.
Metadata for received messages.
Definition: access.h:196
uint32_t sensor_client_cadence_get(sensor_client_t *p_client, uint16_t property_id)
Sends a Cadence Get message to the server.
void(* sensor_series_state_status_cb_t)(const sensor_client_t *p_self, const access_message_rx_meta_t *p_meta, const sensor_series_status_msg_pkt_t *p_in, uint16_t length)
Callback type for series state related transactions.
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_client_setting_set(sensor_client_t *p_client, const sensor_setting_set_msg_pkt_t *p_params, uint16_t length)
Sends a Set setting message to the server.
Access layer acknowledged publish parameter structure.
uint32_t sensor_client_get(sensor_client_t *p_client, uint16_t property_id)
Sends a Get message to the server.
access_reliable_t access_message
Acknowledged message context variable.
Message format for the Sensor Column Get message (partial) 4.2.15 Sensor Column Get Sensor Column Get...
uint32_t sensor_client_column_get(sensor_client_t *p_client, sensor_column_get_msg_pkt_t *p_rawbuf, uint16_t length)
Sends a Column Get message to the server.
nrf_mesh_transmic_size_t
Message MIC size selection.
Definition: nrf_mesh.h:385
uint32_t sensor_client_setting_get(sensor_client_t *p_client, uint16_t property_id, uint16_t setting_property_id)
Sends a Setting Get message to the server.
access_model_handle_t model_handle
Model handle assigned to this instance.
void(* access_reliable_cb_t)(access_model_handle_t model_handle, void *p_args, access_reliable_status_t status)
Access layer acknowledged message callback type.
void(* sensor_cadence_state_status_cb_t)(const sensor_client_t *p_self, const access_message_rx_meta_t *p_meta, const sensor_cadence_status_msg_pkt_t *p_in, uint16_t length)
Callback type for cadence related transactions.
Message format for the Sensor Settings Status message.
uint32_t sensor_client_init(sensor_client_t *p_client, uint16_t element_index)
Initializes Sensor Client.
access_publish_timeout_cb_t periodic_publish_cb
Callback called at the end of the each period for the publishing.
Message format for the Sensor Series Get message (partial) 4.2.17 Sensor Series Get Sensor Series Get...
Parameters for the Sensor Descriptor.
uint16_t message_buffer_bytes
Size of memory buffer in bytes to store reliable messages.
Message format for the Sensor Setting Status message.

Documentation feedback | Developer Zone | Subscribe | Updated