This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Adding HID service to ANCS advertisement package

Hi.

We need volume control for apple device. I've added parts of the HID kbd example to ANCS example. However I have problems adding the service to advertisement. I've put the BLE_UUID_HUMAN_INTERFACE_DEVICE_SERVICE & BLE_UUID_TYPE_BLE to advdata.uuids_complete -struct. It already has the ANCS as solicited UUID. Problem is that the ble_advertising_init returns code 7 (invalid parameter) after call. Isn't it possible to advertise both solicited and complete services?

Advetising init code: uint32_t err_code; ble_advdata_t advdata;

static ble_uuid_t m_adv_uuids[1];  /**< Solicitated UUID:s. */
static ble_uuid_t m_main_uuids[1];  /**< Implemented UUID:s. */
m_adv_uuids[0].uuid = ANCS_UUID_SERVICE;
m_adv_uuids[0].type = m_ancs_c.service.service.uuid.type;
m_main_uuids[0].uuid = BLE_UUID_HUMAN_INTERFACE_DEVICE_SERVICE;
m_main_uuids[0].uuid = BLE_UUID_TYPE_BLE;
 // Build and set advertising data
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_main_uuids) / sizeof(m_main_uuids[0]);
advdata.uuids_complete.p_uuids   = m_main_uuids;
advdata.uuids_solicited.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
advdata.uuids_solicited.p_uuids  = m_adv_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);
Related