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

sd_ble_cfg_set returns NRF_ERROR_INVALID_PARAM for DEFAULT tag?

I just spent 2 hours chasing BLE bug after upgrading from s132 v3 => v4.0.2

I added a call

// Configure the maximum ATT MTU.
memset(&ble_cfg, 0x00, sizeof(ble_cfg));
ble_cfg.conn_cfg.conn_cfg_tag                 = BLE_CONN_CFG_TAG_DEFAULT;
ble_cfg.conn_cfg.params.gatt_conn_cfg.att_mtu = NRF_BLE_GATT_MAX_MTU_SIZE;
err_code = sd_ble_cfg_set(BLE_CONN_CFG_GATT, &ble_cfg, ram_start);
APP_ERROR_CHECK(err_code);

and the device started to go to reset loop. After lots of googling and not finding anything I tried to change tag to something else (though I want this to be the default config so I shouldn't), and lo and behold, the APP_ERROR_CHECK started passing! So if I give conn_cfg_tag > 0, everything is fine, but if I give BLE_CONN_CFG_TAG_DEFAULT, the call fails with INVALID_PARAM.

  1. Why on earth?
  2. Where is this documented?
  3. Is this fixed in some later SD?, is there later v4 than 4.0.2?
  • Hi,

    If you are going to use conn_cfg_tag you have to set it to something else than BLE_CONN_CFG_TAG_DEFAULT (0). It is documented in the `ble_conn_cfg_t``structure:

    uint8_t conn_cfg_tag; /**< The application chosen tag it can use with the @ref sd_ble_gap_adv_start() and @ref sd_ble_gap_connect()
                               calls to select this configuration when creating a connection.
                               Must be different for all connection configurations added and not @ref BLE_CONN_CFG_TAG_DEFAULT. */
    

    After that you will have to call ble_advertising_conn_cfg_tag_set(..., your_tag) to make sure that you use the correct configuration when connecting to devices in the future. Also remember to use the correct tag in sd_ble_gap_connect().

Related