38 #ifndef SENSOR_UTILS_H__ 39 #define SENSOR_UTILS_H__ 44 #include "access_config.h" 46 #include "nrf_mesh_assert.h" 49 #define SENSOR_PROP_ID_INDEX0 0 50 #define SENSOR_PROP_ID_INDEX1 1 53 #define SENSOR_SETTINGS_SPID_INDEX 2 56 #define SENSOR_SETTING_PROP_ID_INDEX0 2 57 #define SENSOR_SETTING_PROP_ID_INDEX1 3 58 #define SENSOR_SETTING_ACCESS_INDEX 4 59 #define SENSOR_SETTING_RAW_INDEX 5 63 #define SENSOR_MPID_A_BYTES 2 64 #define SENSOR_MPID_B_BYTES 3 66 #define SENSOR_FORMAT_A_BIT 0 67 #define SENSOR_FORMAT_B_BIT 1 69 #define SENSOR_MPID_B_ZERO_DATA_BYTES (0x7F) 82 typedef struct __attribute((packed))
91 typedef struct __attribute((packed))
112 for (uint16_t i = 1; i <= p_properties[0]; i++)
114 if (property_id == p_properties[i])
120 __LOG(LOG_SRC_APP, LOG_LEVEL_ERROR,
"property_id 0x%04x not supported\n", property_id);
134 uint8_t publish_steps = 0;
137 uint64_t resolution_ms = 0;
139 if (NRF_SUCCESS == status)
141 switch (publish_resolution) {
146 resolution_ms = 1000;
149 resolution_ms = 10000;
152 resolution_ms = 10000 * 6;
155 __LOG(LOG_SRC_APP, LOG_LEVEL_ERROR,
156 "invalid publish resolution (%d) = (value).\n",
165 return MS_TO_US(resolution_ms * publish_steps);
184 p_mpid->
format = SENSOR_FORMAT_A_BIT;
185 p_mpid->
length = data_bytes;
204 p_mpid->
format = SENSOR_FORMAT_B_BIT;
205 p_mpid->
length = data_bytes;
Step resolution: 100ms / step.
uint16_t access_model_handle_t
Access layer handle type.
#define NRF_MESH_ASSERT(cond)
Run-time assertion.
uint16_t property_id
Property identifying a sensor.
access_publish_resolution_t
Periodic publishing step resolution.
uint16_t property_id
Property identifying a sensor.
static void sensor_mpid_a_create(uint16_t property_id, uint8_t data_bytes, uint8_t *p_buffer)
Create format A of the Marshalled Property ID (MPID) field.
static uint64_t publish_period_get(access_model_handle_t model_handle)
Gets the publish period for the given model in microseconds.
static void sensor_mpid_b_create(uint16_t property_id, uint8_t data_bytes, uint8_t *p_buffer)
Create format B of the Marshalled Property ID (MPID) field.
uint8_t length
Length of the Property Value.
uint16_t length
Length of the Property Value.
Step resolution: 10s / step.
Format B of the Marshalled Property ID (MPID) field.
Step resolution: 1s / step.
static bool sensor_property_id_supported(uint16_t *p_properties, uint16_t property_id)
Look through the supported property_id list to check for property_id support.
uint32_t access_model_publish_period_get(access_model_handle_t handle, access_publish_resolution_t *p_resolution, uint8_t *p_step_number)
Gets the publish period for the given model.
uint8_t format
Format B tag, 0b1.
uint16_t format
Format A tag, 0b0.
Step resolution: 10min / step.
Format A of the Marshalled Property ID (MPID) field.