Dear all,
I use nRF52840 custom board with nRF52 SDK and I want to advertise two more services:
- one custom service (0x1523)
- one battery service (0x180F)
and read them through my mobile with nRF Connect app.
I experiment with the ble_app_uart example (since I want to stream various data after connection with the mobile).
The problem is that the custom service, although it is advertised along with the battery service and the Nordic Uart Service (NUS),
it does not have the 128 bit UUID that I set to it but instead it gets the UUID of the NUS as you can see in the following image.
Obviously I am doing something wrong here but I can't figure out what it is...
Here are the changes that I have performed in main.c. First I added the custom service UUID in the list along with its type (128bit)
#define CUSTOM_UUID_BASE {0x23, 0xD1, 0xBC, 0xEA, 0x5F, 0x78, 0x23, 0x15, 0xEF, 0xD6, 0x31, 0xBE, 0x00, 0x00, 0x15, 0x16} #define CUSTOM_SERVICE_UUID 0x1523 static ble_uuid_t m_adv_uuids[] = { {BLE_UUID_NUS_SERVICE, NUS_SERVICE_UUID_TYPE}, {BLE_UUID_BATTERY_SERVICE, BLE_UUID_TYPE_BLE}, {CUSTOM_SERVICE_UUID, BLE_UUID_TYPE_VENDOR_BEGIN} };
and then I enabled init.config.ble_adv_extended_enabled flag in advertising_init()
static void advertising_init(void) { uint32_t err_code; ble_advertising_init_t init; memset(&init, 0, sizeof(init)); init.advdata.name_type = BLE_ADVDATA_FULL_NAME; init.advdata.include_appearance = true; init.advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE; //BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE; init.advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]); init.advdata.uuids_complete.p_uuids = m_adv_uuids; //init.srdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]); //init.srdata.uuids_complete.p_uuids = m_adv_uuids; init.config.ble_adv_extended_enabled = true; init.config.ble_adv_fast_enabled = true; init.config.ble_adv_fast_interval = APP_ADV_INTERVAL; init.config.ble_adv_fast_timeout = APP_ADV_DURATION; init.evt_handler = on_adv_evt; err_code = ble_advertising_init(&m_advertising, &init); APP_ERROR_CHECK(err_code); ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG); }