I am writing a custom BLE service (inspired by NUS) and don't see service getting advertised in an iOS nRF Connect app.
I'm using nrf52840 DK. The code builds and programs fine without any errors. I haven't set up the characteristics yet but that shouldn't be needed for the advertisement.
I have also tried restarting the photo after closing the nRF Connect app in addition to toggling the Airplane mode to no luck!
The brief snippets are as follows:
void BLEController::Init() { InitBLEStack(); InitGAPParams(); // init nRF Queued Write Module nrf_ble_qwr_init_t qwrInit = {0}; qwrInit.error_handler = nrf_qwr_error_handler; ret_code_t err_code = nrf_ble_qwr_init(&m_qwr, &qwrInit); APP_ERROR_CHECK(err_code); // Init Custom Service mBleCustomSrv.Init(); AdvertisingInit(); InitConnectionParams(); StartAdvertising(); }
BLECustomService
// // custom_service.hpp // registering the ble_cus_on_ble_evt event handler as event observer using the NRF_SDH_BLE_OBSERVER() macro #define BLE_CUS_DEF(_name) \ static BLECustomServiceInfo _name; \ NRF_SDH_BLE_OBSERVER(_name ## _obs, \ BLE_HRS_BLE_OBSERVER_PRIO, \ ble_cus_on_ble_evt, &_name) // custom_service.cpp BLE_CUS_DEF(m_cust); void BLECustomService::InitService(BLECustomServiceInfo* customServiceInfo) { if (customServiceInfo == NULL) { return; } ble_uuid128_t baseUUID; ble_uuid_t bleUuid; // Initialize service structure customServiceInfo->connectionHandle = BLE_CONN_HANDLE_INVALID; memcpy(baseUUID.uuid128, CUSTOM_SERVICE_UUID_BASE, sizeof(CUSTOM_SERVICE_UUID_BASE)); // Adding proprietary Service to the SoftDevice uint32_t errorCode = sd_ble_uuid_vs_add(&baseUUID, &customServiceInfo->uuidType); if (errorCode != NRF_SUCCESS) { return; } //VERIFY_SUCCESS(errorCode); bleUuid.type = customServiceInfo->uuidType; bleUuid.uuid = CUSTOM_SERVICE_UUID; // Add the Custom Service errorCode = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &bleUuid, &customServiceInfo->serviceHandle); if (errorCode != NRF_SUCCESS) { return; } } void BLECustomService::Init() { InitService(&m_cust); }
I can add my project as well if that's needed. Please guide.