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

Synchronize RSSI measurements

I'm working on a project where two devices are trying to get an estimate of the channel between them by taking RSSI measurements over a period of time. I am having a problem however where the two devices are not sampling at the same time. How can I go about getting them to sample at a similar time?

At the moment, the devices are connected and I tried implementing a sort of baton passing system where device A sends a message to B and then measures the channel. Device B upon receiving that message, measures the RSSI and sends back the message to restart that cycle. This does not seem to be working however as device A just seems to get ahead of device B.

I've attached a snippet of this below. Also note each has a separate segment of code that sets baton to one when the sampling message is received.

Is there some way of setting up a timer of sorts?

//Device A code
case BLE_GAP_EVT_RSSI_CHANGED:
            if(RSSICount <= noVal-1){
              if(baton == 1) {
                ble_nus_string_send(&m_nus, tx, &size);
                sd_ble_gap_rssi_get(p_ble_evt->evt.gap_evt.conn_handle, &RSSItemp);
                RSSI[RSSICount] = (float)RSSItemp;
                NRF_LOG_INFO("\nRSSI = %f RSSI Count = %d", RSSI[RSSICount], RSSICount);
                RSSICount++;
                baton = 0;
              }
            }
            
//Device B Code
case BLE_GAP_EVT_RSSI_CHANGED://
            if(RSSICount <=noVal-1){
              if(baton == 1) {
                sd_ble_gap_rssi_get(p_ble_evt->evt.gap_evt.conn_handle, &RSSItemp);
                RSSI[RSSICount] = (float)RSSItemp;
                NRF_LOG_INFO("\nRSSI = %f RSSI Count = %d\n", RSSI[RSSICount], RSSICount);
                RSSICount++;
                baton = 0;
                ble_nus_c_string_send(&m_ble_nus_c, tx, size);
              }
            }

Parents Reply Children
Related