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

Scan in a Single Channel

Hi,

As mentioned in this post: devzone.nordicsemi.com/.../

the struct ble_gap_adv_params_t --> ble_gap_adv_ch_mask_t give the option to turn any advertising channel OFF. I tested this approach and could advertise on only one channel.

The problem that I found was in scanning for this packet. When I'm using 3 channels for advertising, the scanning program is ALWAYS able to pick the advertising packet. But when I'm using 1 channel for advertising it misses some. Is there any way to program the scanning so that it only looks on a single channel? Can this problem be due to values of scan interval and scan window (I'm setting them equal to continuously scan)?

In the description of ble_gap_adv_ch_mask_t (infocenter.nordicsemi.com/index.jsp it says "Channel mask for RF channels used in advertising and scanning". But I could only found a place in the ble_gap_adv_params_t to pass it, and ble_gap_scan_params_t doesn't have this field.

So how can we set this feature for scan mode?

  • 1- Yes, I'm changing the headers from S110 to S130 when changing the soft device. The program will scan on a single channel and after receiving an advertisement from a specific address, toggles an LED. Didn't work means that it will enter the program, but it fails to capture any advertisement, which means it's not scanning properly. 2- After removing softdevice_handler.c, I'm using exactly the same SWI2_IRQHandler that is used in the GitHub and I think I didn't notice any pstorage event. You suggested PORTING the example to SDK 9, can you give more information about it? Is there a way to do it automatically? I included all the example files in a SDK 9 project and tried to fix any errors that Keil was showing.

  • Hi FA,

    Removing softdevice_handler.c maybe not the best idea here. What you should do is to remove the SD_EVT_IRQHandler function. Then create a new function like this:

    void timeslot_sys_event_handler(uint32_t evt)
    {
    
     switch (evt)
        {
          case NRF_EVT_RADIO_SESSION_IDLE:
          case NRF_EVT_RADIO_BLOCKED:
            /* Request a new timeslot */
            ASSERT (btle_scan_enable_set (scan_enable) == BTLE_STATUS_CODE_SUCCESS);
            break;
    
          case NRF_EVT_RADIO_SESSION_CLOSED:
            break;
          
          case NRF_EVT_RADIO_SIGNAL_CALLBACK_INVALID_RETURN:
            ASSERT(false);
            break;
    
          case NRF_EVT_RADIO_CANCELED:
            ASSERT (btle_scan_enable_set (scan_enable) == BTLE_STATUS_CODE_SUCCESS);
            break;
    
          default:
            /* This should not happen */
            __LOG ("%s: Program failure, undefined event = %d", __FUNCTION__, evt);
            ASSERT(false);
        }
    }
    

    Then you can add a call timeslot_sys_event_handler(sys_evt); in sys_evt_dispatch() function so that it will be executed when there is a system event. This way you can merge 2 interrupt handler into one with no problem.

    I'm a little bit sort on time to be able to port ( modifying the code so that it would work on SDK 9.0) the github example code to SDK9.0. I could be able to do it some time next week, but I'm not sure.

  • I included the handler you posted. Off course there was no sys_evt_dispatch() in the Observer example, and I added it similar to the Timeslot Tutorial (devzone.nordicsemi.com/.../) with also the pstorage_sys_event_handler(sys_evt). Right now it works with S110 SDK 9 and the softdevice_handler.c included, but still not with S130. If it helps, the errors and warnings that I had to correct after using SDK 9 were all in nrf_adv_conn.c: 1- sd_ble_gatts_sys_attr_set and sd_ble_gap_sec_params_reply: missing 1 argument (passed NULL). 2- Used BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED for ble_adv_data.flags. 3- ble_gap_bond_params: one additional assignment.

  • Hi FA,

    Sorry for a late response. I have made an example to integrate the proximity example in SDK 9.0 with the observer. The example worked with both S110 and S130. It's attached in the answer above.

  • Hi Hung,

    Which particular channel is scanned in the observer code given by you?

Related