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

ble_ancs_c_t add to ble_advertising_init get error code 12

image description(/attachment/0495424521df76d5b8f8e66c969ed791)Hi, I add ANCS Service into my Heart rate ref ble_app_ancs_c example code. I use MCU nRF51 and SD130 in nRF5_SDK_11.0.0_89a8197.

When I add ANCS_UUID_SERVICE UUID into my advertising_init will get error code 12. If I don't add this UUID in advertising_init the nRF51 does work include ANCS fun.

The code:

static void advertising_init(void)
{
    uint32_t      err_code;
    ble_advdata_t advdata;
   
		static ble_uuid_t m_ancs_uuids[1];  /**< Universally unique service identifiers. */
    m_ancs_uuids[0].uuid = ANCS_UUID_SERVICE;
    m_ancs_uuids[0].type = m_ancs_c.service.service.uuid.type;
	
    // Build advertising data struct to pass into @ref ble_advertising_init.
    memset(&advdata, 0, sizeof(advdata));

    advdata.name_type                = BLE_ADVDATA_FULL_NAME;
    advdata.include_appearance       = true;
    advdata.flags                    = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
    advdata.uuids_complete.uuid_cnt  = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
    advdata.uuids_complete.p_uuids   = m_adv_uuids;
		advdata.uuids_solicited.uuid_cnt = sizeof(m_ancs_uuids) / sizeof(m_ancs_uuids[0]);
    advdata.uuids_solicited.p_uuids  = m_ancs_uuids;
		

    ble_adv_modes_config_t options = {0};
    options.ble_adv_whitelist_enabled = BLE_ADV_WHITELIST_ENABLED;
    options.ble_adv_fast_enabled      = BLE_ADV_FAST_ENABLED;
    options.ble_adv_fast_interval     = APP_ADV_FAST_INTERVAL;
    options.ble_adv_fast_timeout      = APP_ADV_FAST_TIMEOUT;
    options.ble_adv_slow_enabled      = BLE_ADV_SLOW_ENABLED;
    options.ble_adv_slow_interval     = APP_ADV_SLOW_INTERVAL;
    options.ble_adv_slow_timeout      = APP_ADV_SLOW_TIMEOUT;

    err_code = ble_advertising_init(&advdata, NULL, &options, on_adv_evt, NULL);
    APP_ERROR_CHECK(err_code);
}

So I want to ask Does the ANCS UUID in advertising is necessary or not?

Thanks

Parents
  • Hi Vincent,

    If you have a look at the error list, you can find error 12 means NRF_ERROR_DATA_SIZE.

    You may have put too many bytes in the advertising packet, the maximum size is 31 bytes. If there is not enough you can think of using scan response packet. You can have a look here to read more.

    ANCS UUID in the advertising packet/scan response packet is needed if you want your device to be re-connected automatically by the phone, natively.

  • I use Heart rate profile in nRF ToolBox. First time nRF ToolBox scan it has no Lock icon but after connect to nRF toolbox and Iphone (ANCS) Then start nRF toolbox App again it will show up. Does it happen because ancs service or not.

    The MCU does work fine now. I just wonder this lock icon. What the lock icon show the cause of ANCS service.

    Thanks

Reply Children
No Data
Related