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

Set new channel map

Hi everyone!

Could anyone clarify a few questions regarding channel mapping?

1. Is that true if I want to use specific BLE channels I need to do it just once on a central device?
2. Is that true once channel map is set it will be used for all next connections until it's changed again?
3. Is that true it's not necessary to set channel map only when connection event happens? I can do it, say, when I initialize central device, because connection handler is only applicable for sd_ble_opt_get().
4. Is that true default values of channel map 0xff,0xff,0xff,0xff,0x1f mean that adaptive frequency hopping is used?
5. Is that true if I set, say, following map 0x00,0xff,0xff,0xff,0x1f this means channels from 0 to 7 will be used for connection and others except dvertising channels will be ignored by frequency hopping algorithm?
6. When does a central device provide information about channel map to a peripheral device? My understanding is it happens on connection? How to make sure reliably this was happened? When I read channel map upon connection by using sd_ble_opt_get() I always get default values 0xff,0xff,0xff,0xff,0x1f.
7. Finally, here is the code I use to set channel map on a central device side (I run it just one time):

ble_gap_opt_ch_map_t channel_map = {0};
channel_map.conn_handle = m_conn_handle; //I tried to use connection 
                                         //handle when I get it upon connection
                                         //also I left the field unflled. 
                                         //No difference, err_code is always 0.
channel_map.ch_map[0] = 0x00;
channel_map.ch_map[1] = 0xfe;
channel_map.ch_map[2] = 0xff;
channel_map.ch_map[3] = 0xff;
channel_map.ch_map[4] = 0x1f;
err_code =
sd_ble_opt_set(BLE_GAP_OPT_CH_MAP, (ble_opt_t *)&channel_map); //always returns 0

And here is the code I use to read channel map on peripheral device side (I run it every time when connection happened):

ble_opt_t opt;
memset(&opt, 0, sizeof(opt));
opt.gap_opt.ch_map.conn_handle = m_conn_handle;
err_code = sd_ble_opt_get(BLE_GAP_OPT_CH_MAP, &opt); //returns 0
LOG(
    "err_code = %x, map %x,%x,%x,%x,%x",
    err_code,
    opt.gap_opt.ch_map.ch_map[0],
    opt.gap_opt.ch_map.ch_map[1],
    opt.gap_opt.ch_map.ch_map[2],
    opt.gap_opt.ch_map.ch_map[3],
    opt.gap_opt.ch_map.ch_map[4]);

My expectation is once I set channel map on central device I see (in a few second) same channel map on peripheral device side.
Since my connections are pretty short 300-900 ms, I thought I would see updated channel map after a few connection later, but it never happens. What did I miss?

Thanks,
Dmitry.

  • Hi,

    1. Is that true if I want to use specific BLE channels I need to do it just once on a central device?

    Yes, from the documentation here, we have that "When setting the channel map, it applies to all current and future connections".

    2. Is that true once channel map is set it will be used for all next connections until it's changed again?

     Yes, see 1.

    3. Is that true it's not necessary to set channel map only when connection event happens? I can do it, say, when I initialize central device, because connection handler is only applicable for sd_ble_opt_get().

     Correct. You can set it as part of the initialization for the central device.

    4. Is that true default values of channel map 0xff,0xff,0xff,0xff,0x1f mean that adaptive frequency hopping is used?

     This channel map means that all data channels can be used. It will do frequency hopping, but it will by-default not be adaptive. To be adaptive, you would need to periodically update the channel map based on the measurements of the energy levels on the Bluetooth Low Energy channels. The Quality of service feature for channel monitoring in the SoftDevice can be used for this. See this link , you might find this repo useful.

    5. Is that true if I set, say, following map 0x00,0xff,0xff,0xff,0x1f this means channels from 0 to 7 will be used for connection

    Since you set ch_map[0] = 0x00; and ch_map[1] = 0xfe;, it will be 0 to 8. And based on my testing, it will be the other way around, 0 to 8 will not be used. Advertising channels are not used.

    6. When does a central device provide information about channel map to a peripheral device? My understanding is it happens on connection?

    Based on my testing, I see that the SoftDevice will shortly after the connection is established send a LL_CHANNEL_MAP_REQ packet with the updated channel map to the peripheral device.

    When I read channel map upon connection by using sd_ble_opt_get() I always get default values 0xff,0xff,0xff,0xff,0x1f.

     When I use the code you attached, and read the channel map some time after the BLE_GAP_EVT_CONNECTED I get this:

    <info> app: err_code = 0, map 0,FE,FF,FF,1F

    Try reading it after 1-2 seconds, and see if you get the expected result. If you have very long connection intervals, you might need to wait more than 1-2 seconds. If it does not work, I recommend using nRF Sniffer to analyze what is happening on-air. See this and this link.

  • Hi!

    Thank you for the clarification.

    I'm currently working on more priority task, so I'll back to this and check channel map settings later on. 

    Regards,

    Dmitry.

  • Hi there!

    This channel map means that all data channels can be used. It will do frequency hopping, but it will by-default not be adaptive. To be adaptive, you would need to periodically update the channel map based on the measurements of the energy levels on the Bluetooth Low Energy channels. The Quality of service feature for channel monitoring in the SoftDevice can be used for this. See this link , you might find this repo useful.

    So, according to this, can I understand it in this way, that SoftDevice itself only implements the frequency hopping function, but there are no default channel monitoring methods running in the background?

    Further speaking, all of the examples/templates in nRF5 SDK and SoftDevice do not perform channel monitoring. We should integrate the monitoring function into those examples/templates by ourselves. Is that correct?

    Really appreciate it if this could be helped ASAP.

    Best regards :-)

    Ethan

  • EthanJia said:
    but there are no default channel monitoring methods running in the background?

    Correct. 

    EthanJia said:
    We should integrate the monitoring function into those examples/templates by ourselves. Is that correct?

    Typically it's the BLE central that implements this. If you are creating a BLE central, then you might want to use the Quality of Service feature to set new channel maps.

  • Hi!

    Thanks! I got it. Appreciate it a lot.

    Best regards :-)

    Ethan

Related