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

How to correctly set channel map of next connection?

I'm using s130_nrf51_2.0.0-4.alpha as central and do some testing with channel map. I set the channel map before I'm trying to connect to a peripheral with:

  ble_opt_t opt;
  memset(&opt, 0, sizeof(opt));
  opt.gap_opt.ch_map.ch_map[0] = 0xFF;
  opt.gap_opt.ch_map.ch_map[1] = 0x0F;
  err_code = sd_ble_opt_set(BLE_GAP_OPT_CH_MAP, &opt);
  APP_ERROR_CHECK(err_code);

  // Initiate connection.
  err_code = sd_ble_gap_connect(peer_addr,
                                &m_scan_param,
                                &conn_params);

But when I check the current active channel map during the connection, I get the default channel map!

  ble_opt_t opt;
  memset(&opt, 0, sizeof(opt));
  opt.gap_opt.ch_map.conn_handle = m_conn_handle_central;
  sd_ble_opt_get(BLE_GAP_OPT_CH_MAP, &opt);
  APP_LOG("ChMap %02X %02X %02X %02X %02X\r\n",
    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]);

Output:

ChMap FF FF FF FF 1F

Parents Reply
  • When setting the channel map, it applies to all current and future connections, so you can set it whenever you want. The packet with the channel map will be sent to the peripheral 10 connection events after the connection request packet. This means that if you use a connection interval of 20ms, the channel map will not be updated before at least 200ms after the connection request packet. The reason for this is backwards compatibility with previous nordic devices.

Children
No Data
Related