This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Issues with sensor model in SDK For Mesh v5.0.0

Trying out the Sensor Model supplied with SDK For Mesh v5.0.0 raise a few concerns.

The way sensor_initialize() is made requires all supported PropertyId helper functions to be included in the final binary as they would be referenced  regardless if they are actually used or not. Better to have the user supply pointers to these functions.

The cadence state isn't save to flash.

When the application calls sensor_status_publish() due to the sensor has read a new value there is not check to see if the value is in_fast_region() but rather wait until the regular periodic publish period has triggered. This doesn't match the specification as it expects the status message to be sent directly if it's in the fast region. Say that you publish period is rather long, several minutes and you want to divide this down to a few seconds in the fast region there can be several minutes of delay.

The opposite is also a problem in sensor_status_publish() as it doesn't stop the cadence timer if the value is no longer in the fast region and the cadence timer was running.

The following patch solves at least the two last problems.

diff --git a/examples/common/src/app_sensor_utils.c b/examples/common/src/app_sensor_utils.c
index 6a20685..b9230db 100644
--- a/examples/common/src/app_sensor_utils.c
+++ b/examples/common/src/app_sensor_utils.c
@@ -1234,8 +1234,6 @@ uint32_t sensor_cadence_publication_abort(app_sensor_server_t * p_server)
 
 uint32_t sensor_status_publish(app_sensor_server_t * p_server, uint16_t property_id)
 {
-    sensor_status_msg_pkt_t * p_out = (sensor_status_msg_pkt_t *)p_server->p_message_buffer;
-    uint16_t bytes;
     sensor_cadence_t * p = cadence_instance_get(p_server, property_id);
 
     if (p == NULL)
@@ -1243,7 +1241,10 @@ uint32_t sensor_status_publish(app_sensor_server_t * p_server, uint16_t property
         return NRF_ERROR_NOT_FOUND;
     }
 
-    cadence_status_get(p, p_out, &bytes);
+    sensor_current_value_set(p);
+    uint64_t period = publish_period_get(p_server->server.sensor_srv.model_handle);
+    (void) cadence_activate(p, period);
+
     if (!p->delta_trigger_fast(p))
     {
         return NRF_SUCCESS;

I hope there are improvements to the Sensor model in the next release as it looks like could use some more work.

Thanks.

Related