Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

SCAN_REQ and SCAN_RSP logging

Hello, I have a question about the scan request event.

I checked the logs of BLE_GAP_EVT_SCAN_REQ_REPORT.  If this event is received, does Softdevice recognize the packet as SCAN_REQ properly and surely send back SCAN_RSP?  If there are any problems in receiving a SCAN_REQ packet (e.g. CRC error), can I see any logs/messages?  Or if there are any problems in sending a SCAN_RSP packet, can I see any logs/messages as well?

I am looking for any tools/methods to make sure the scan response procedure works in the software level.

[Environment]

nRF52832 custom board

nRF5 SDK 17.1.0

Softdevice S132 v7.0.1, 7.2.0, 7.3.0

Sample source code : ble_peripheral\ble_app_blinky

 

[Modification]

I added the following lines in main.c and built a debug module.  The log messages are seen.

// In advertising_init

    adv_params.scan_req_notification  = 1;

 // In ble_evt_handler

         case BLE_GAP_EVT_SCAN_REQ_REPORT:

            NRF_LOG_INFO("SCAN_REQ");

            break;

Parents
  • Hi Vidar

    Thank you for reply.

    I am colleague of Toru. I asked him to contact you.

    I took two images about this phenomenon.

    There are snapshots of power consumption wave form.

    X axis is time(ms) and Y axis power consumption(mA)

    AS you can see, OK file shows Advertise->SCAN_REQ->SCAN_RSEP.

    On the other hand, NG file show Advertise->SCAN_REQ.

    Our nRF52832 does not respond SCAN_RSEP.

     

    Advertise interval is 40ms.

    The phenomenon is happened about once or twice per 1second.

     

    First I used softdevice version 7.0.1.

    Then we found s132_nrf52_7.3.0 improve missing scan request reception.

    So we update softdevice from 7.0.1 to 7.3.0.

    However the result is the same.

    Do you have any suggestion?

    For example I might miss some improvement information/errata, 

    or I can get debug? how to debug?

    If you can indicate me to put some debug coed and help you to analyze, please let me know.

  • Hi,

    Based on the DRGN-15484 description, I would only expect reception to potentially improve in v7.3.0 if you are advertising with a timeout. I still believe the most likely explanation to the missed response is that the scan request failed to be received by the nRF. To confirm this, you could try to monitor the RADIO crc match event (EVENTS_CRCOK) as done in the snippet below.

    #define MONITOR_RADIO_CRC_MATCH 1
    
    #if MONITOR_RADIO_CRC_MATCH
    
    void SWI3_IRQHandler(void)
    {
        /* Clear event register */
        NRF_EGU3->EVENTS_TRIGGERED[0] = 0;
        NRF_LOG_INFO("Packet received with CRC ok");
    }
    
    void monitor_radio_crc_match(void)
    {
        /* 6 is the default int. priority used in SDK drivers */
        NVIC_SetPriority(SWI3_IRQn, 6);
        NVIC_EnableIRQ(SWI3_IRQn);
    
        NRF_EGU3->INTENSET = EGU_INTEN_TRIGGERED0_Msk;
    
        NRF_PPI->CH[0].EEP = (uint32_t) &NRF_RADIO->EVENTS_CRCOK;
        NRF_PPI->CH[0].TEP = (uint32_t) &NRF_EGU3->TASKS_TRIGGER[0];
    
        NRF_PPI->CHENSET = PPI_CHENSET_CH0_Msk;
    }
    #endif //MONITOR_RADIO_CRC_MATCH
    
    
    /**@brief Application main function.
     */
    int main(void)
    {
        ...
        ble_stack_init();
    #if MONITOR_RADIO_CRC_MATCH
        monitor_radio_crc_match();
    #endif //MONITOR_RADIO_CRC_MATCH
        ...

  • Hi Vidar,

    Thank you for your suggestion.  I tested it in my environment and it shows CRC match messages like this :

    [00:00:00.000,000] <info> app: Packet received with CRC ok
    [00:00:00.000,000] <info> app: SCAN_REQ
    [00:00:00.000,000] <info> app: Peer Address = 0x6A:C1:0E:B3:30:36
    [00:00:00.000,000] <info> app: RSSI value = -56 dBm
    [00:00:00.000,000] <info> app: Packet received with CRC ok
    [00:00:00.000,000] <info> app: SCAN_REQ
    [00:00:00.000,000] <info> app: Peer Address = 0x6A:C1:0E:B3:30:36
    [00:00:00.000,000] <info> app: RSSI value = -56 dBm

    (Please ignore the timestamp)

    But how can I find the CRC mismatch?  Should I tried to use "&NRF_RADIO->EVENTS_CRCERROR" instead?

    I tried it but I have not seen the repro yet.

Reply
  • Hi Vidar,

    Thank you for your suggestion.  I tested it in my environment and it shows CRC match messages like this :

    [00:00:00.000,000] <info> app: Packet received with CRC ok
    [00:00:00.000,000] <info> app: SCAN_REQ
    [00:00:00.000,000] <info> app: Peer Address = 0x6A:C1:0E:B3:30:36
    [00:00:00.000,000] <info> app: RSSI value = -56 dBm
    [00:00:00.000,000] <info> app: Packet received with CRC ok
    [00:00:00.000,000] <info> app: SCAN_REQ
    [00:00:00.000,000] <info> app: Peer Address = 0x6A:C1:0E:B3:30:36
    [00:00:00.000,000] <info> app: RSSI value = -56 dBm

    (Please ignore the timestamp)

    But how can I find the CRC mismatch?  Should I tried to use "&NRF_RADIO->EVENTS_CRCERROR" instead?

    I tried it but I have not seen the repro yet.

Children
  • Hi,

    The CRC will only be computed if you receive the whole packet first. So it may also be that the RADIO is not receiving the preamble for the scan request and therefore not checking the crc either.  Do you have a shielded room our enclosure you could test your device in to eliminate noise or interference from other devices?

  • Hi Vidar and Nordic Semi support, I could not reply to you sooner.
    I could not use a shielded box, but I got Nordic PPK2 and tested some more cases.
    I've got a new question. Sorry for my lengthy post, but any comments would be greatly appreciated.

    [Test purpose]
    To understand the relationship between the current waves of scan request and scan response and the softdevice procedure.

    [Environment]
    nRF52 DK (solder bridge SB9 has been cut)
    nRF5 SDK 17.1.0 ble_app_blinky (pca10040/S132) modified like these:
    to set TX power to 4dBm to differenciate TX and RX current waves.
    to turn on/off LED4 en BLE_GAP_EVT_SCAN_REQ_REPORT is received.
    to turn on/off LED3 when CRC error is received.
    Nordic PPK2 (digital port D0 is connected to P0.20 (LED4), D1 is to P0.19 (LED3))
    nRF Connect for Desktop - Power Profiler (Ampere Meter)
    nRF Connect for Mobile + Android Smart Phone (Clicking "SCAN" during the current measurement in order to enforce the active scan)

    [Result 1]
    This is nRF52832 current wave, including D0 (BLE_GAP_EVT_SCAN_REQ_REPORT) and D1 (CRC error).
    In case the smart phone is nearby (RSSI is high), some CRC errors were seen (e.g. 12 times in 30 sec).

    In case the smart phone is far (RSSI is low), more CRC errors were seen (e.g. 61 times in 30 sec).

    [Result 2]
    Looking into the above "far" current graphs, the following 4 patterns were seen.
    1. BLE_GAP_EVT_SCAN_REQ_REPORT is received. SCAN_RSP is sent, and then post procedure is done (~8mA current consumption continues).

    2. CRC error is received, then the post procedure is done (~8mA current consumption).

    3. No event is received. ~8mA current consumption is not seen. No packet was received during this advertisement.

    4. Like case 3, no event is received.  But ~8mA current consumption is seen.


    [Question]
    Pattern 1, 2, and 3 are understandable. But I cannot understand pattern 4. Why ~8mA consumes even though packet is not received regardless of CRC?

    Thank you.  Toru

  • Hi Toru,

    Do you have any application interrupts enabled when you run this test (apart from the SW interrupt used for monitoring the CRC error event? 

    Best regards,

    Vidar

  • Hi Vidar,

    Thank you for your comments.  No, the app is slightly modified ble_app_blinky only.  Do I miss anything in your question?

    Thank you,

    Toru  

  • Thanks Toru. Yes, that answered my question. Still, it is not clear to me why the CPU is seemingly running after the advertisement event in the case where you did not receive the scan request.

    Are the output pins shown in shown in your screenshots toggled in SW or in HW with the help of PPI? 

Related