Hi,
I'm trying to display data from a particulate matter (PM) sensor on my device using nRF Mesh App for Android. The app is on version 3.2.4.
Since there is no entry in the Mesh Device Properties document for PM sensors, I've decided to use the Luminaire Identification Number (0x009A) property ID which has a Fixed String 24 format. Here is my formatted string:
/// @brief Reads PMS5003I data and converts it to Fixed String 24 format
/// @param p_out
/// @return Size of data for required_out_bytes
static uint16_t sensor_read_pm(uint8_t * p_out)
{
pms5003i_data_t pm_data;
bool success = pms5003i_read(&twi_instance_0, PMS5003I_ADDR, &pm_data);
char pm_data_str[24];
uint16_t len = sprintf(pm_data_str, "PM1:%03u,2.5:%03u,10:%03u", pm_data.pm1, pm_data.pm2_5, pm_data.pm10);
memcpy(p_out, pm_data_str, len);
return len + 1;
}
Which would return len of 24 including the null byte. This function is called by app_sensor_get_cb which returns the string in p_out with the size of the string in the variable required_out_bytes. However, tapping the Get button on the nRF Mesh app does not get any response and it times out. I can see the TX of the message on RTT:
<t: 6618536>, x31.c, 94, App Sensor Get <t: 6618710>, sht31.c, 46, 26.83, 64.63 <t: 6618713>, x31.c, 126, Temperature: 2683 <t: 6618717>, x31.c, 94, App Sensor Get <t: 6618891>, sht31.c, 46, 26.85, 64.63 <t: 6618894>, x31.c, 137, RH: 6462 <t: 6618898>, x31.c, 94, App Sensor Get <t: 6618953>, ds_co2_20.c, 16, Receiving data 0. <t: 6618956>, ds_co2_20.c, 17, CO2: 424D DATA: 0698. <t: 6618960>, x31.c, 94, App Sensor Get <t: 6618968>, pms5003i.c, 29, Receiving data 33281. <t: 6618972>, pms5003i.c, 30, PM: 0000 DATA: 00 00 00. <t: 6618978>, x31.c, 145, PM Sensor Out Bytes: 24 <t: 6618989>, network.c, 304, Net TX: 741401E01100420020DF004403B27A3A314582136EF3A9B96467AC582B <t: 6619003>, network.c, 304, Net TX: 741401E01200420020DF004423F92836793C73EF3E0B43E53CA1492C57 <t: 6619013>, network.c, 304, Net TX: 741401E01300420020DF00444393E8FF91BF49D55550AF90000D38E7FF <t: 6619025>, network.c, 304, Net TX: 741401E01400420020DF004463CF3781BBE0C472C9E82470799C609701 <t: 6619034>, transport.c, 1376, TX:SAR packet: B27A3A314582136EF3A9B964F92836793C73EF3E0B43E53C93E8FF91BF49D55550AF9000CF3781BBE0C472C9 <t: 6619040>, transport.c, 1887, Upper TX Segmented: 0 <t: 6619045>, proxy.c, 683, TX complete <t: 6619051>, proxy.c, 683, TX complete <t: 6619829>, proxy.c, 683, TX complete <t: 6620649>, net_packet.c, 228, Unencrypted data: : 0020DF004403B27A3A314582136EF3A9B964 <t: 6620654>, network.c, 356, Net RX (unenc): 741301E01100420020DF004403B27A3A314582136EF3A9B964E000E037 <t: 6620659>, proxy.c, 683, TX complete <t: 6622441>, net_packet.c, 228, Unencrypted data: : 0020DF004423F92836793C73EF3E0B43E53C <t: 6622446>, network.c, 356, Net RX (unenc): 741301E01200420020DF004423F92836793C73EF3E0B43E53CE000E039 <t: 6624072>, net_packet.c, 228, Unencrypted data: : 0020DF00444393E8FF91BF49D55550AF9000 <t: 6624077>, network.c, 356, Net RX (unenc): 741301E01300420020DF00444393E8FF91BF49D55550AF9000E000E03B <t: 6625717>, net_packet.c, 228, Unencrypted data: : 0020DF004463CF3781BBE0C472C9 <t: 6625721>, network.c, 356, Net RX (unenc): 741301E01400420020DF004463CF3781BBE0C472C900000000
I have other sensors on my board as well. When I remove the PM Sensor property from my firmware, everything works fine and I can see the other sensors' values on the app. The only difference is that the PM Sensor property is one of Fixed String 24 value whereas the other properties are of integer types. I think I'm doing something wrong with either formatting my string or copying it to p_out. Can you tell me what's wrong?


