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?

  • Hi FA,

    Scanning with selective channel(s) is not supported yet. I will report internally to fix it in the documentation.

    Thanks for reporting.

    If you want to do scanning on single channel, you may want to have a look at this observer example. We do scanning manually on S110 softdevice using timeslot feature.

    ble_app_proximity - Observer.zip

  • Hi Hung, I tried to replace the scanning parts of my program with the one in main.c of the observer example. Again the example is SDK 6 I think and I'm using SDK 9, so a couple of errors came but I could get rid of those. However, I'm getting one error, which I don't know how to solve. It says ("SWI2_IRQHandler multiply defined by softdevice_handler.o and main.o). I had a similar error for SWI0_IRQHandler in main.c and app_timer.o. I changed all the SWI0 in main to SWI1. One error was gone, but there is no SWI2_IRQHandler defined in my main. So, where the error is coming from? Is it OK just to change the software interrupt numbers to get rid of duplicate definition error?

  • Hi FA,

    SWI2_IRQHandler is used in main.c under the name of SD_EVT_IRQHandler, check the macro define. The reason you got duplicate is that in your application you already have SWI2_IRQHandler in softdevice_handler.c. You would need to merge this 2 handlers into one.

    SWI1 is used for radio notification, if you don't use radio notification you can use it.

  • To troubleshoot step by step, I decided to make my program as close as possible to the GitHub example. I noticed that in that example, softdevice_handler.c is not included in the scan project. So, I removed that file from the project. The program now works with S110 provided in SDK 9, but it doesn't work with S130. 1- Is there any difference between S110 and S130 in using the time slot? 2- Even if I use S110 I should be able to scan with time slot and advertise just like any S110 device, right? I still have the problem of adding softwdevice_handler.c which is needed for the part of my program that is advertising, but I think I'll ask it in a separate post.

    1. No there should be no difference. But you would need to use the correct API headers matching with your Softdevice (S110 or S130). You mentioned it didn't work, could you be more specific ?

    2. Yes, the example on github created for S110.

    When you remove softdevice_handler.c, please make sure you have in your SWI2_IRQHandler that you fetch all the system event out, and handle them correctly. Including the pstorage event handle. My suggestion for you is to port the example on Github to SDK 9. After that you add your own application code in.

Related