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

Multi-byte data using Mesh Sensor Model

Hello,

I am trying to adapt the new Mesh Sensor Model examples in v4.2.0 of the SDK for Mesh to allow sending >1 byte sensor data over the mesh network. I have two nRF52840DK boards, with one running the sensor server example and the other running the sensor client example. I have been able to successfully use the stock example code to transmit 1 byte of data from server to client. 

I tried modifying the code to send 4 data bytes by modifying the sensor server example file "main.c". I first modified the code on line 192 from

required_out_bytes = 1;
  to

required_out_bytes = 4;

Then I replaced lines 225-227 with the following lines:

p_out[0] = 0x00; p_out[1] = 0xC0; p_out[2] = 0xFF; p_out[3] = 0xEE;
*p_out_bytes = 4;

The modified code builds with no errors, but when I press RTT key 8 on the client side to send the status GET message for the Motion Sensed property I receive the following error in the server RTT terminal:

<t:     175638>, main.c,  240, inadequate buffer (0x0042 (66), 4, 1) = (property id, required, actual)
<t:     175645>, app_sensor_utils.c,  705, ERR: sensor_get_cb() failed (1, 0) = (bytes expected, bytes returned).
<t:     175649>, app_error_weak.c,  105, Mesh assert at 0x00028512 (:0)

Upon further inspection, it seems the line that throws this error comes from the file "app_sensor_utils.c" inside the "sensor_current_value_set(sensor_cadence_t * p)" function.

if (bytes != p->range_value_bytes_allocated)
    {
        __LOG(LOG_SRC_APP, LOG_LEVEL_ERROR,
              "ERR: sensor_get_cb() failed (%d, %d) = (bytes expected, bytes returned).\n",
              p->range_value_bytes_allocated,
              bytes);

        NRF_MESH_ASSERT(false);
    }

I have attempted to work back from this point to find where the "range_value_bytes_allocated" value is set, but I have not been able to find it.

I appreciate any and all assistance you can provide me in resolving this issue!

Parents Reply Children
No Data
Related