HI there! I am currently having some issues trying to add a custom 16 bit service to my nrf51822 project. Basically I am trying to make a dummy peripheral that I need for work until our customer will provide us with real hardware.
The issue that I am having is the fact that I can't seem to figure out how to make a custom service with a 16 bit UUID.
Usually I use this code (from one of the tutorials) to add a normal 128 bit service:
void our_service_init(ble_os_t * p_our_service)
{
uint32_t err_code; // Variable to hold return codes from library and softdevice functions
// OUR_JOB: Declare 16-bit service and 128-bit base UUIDs and add them to the BLE stack
ble_uuid_t service_uuid;
ble_uuid128_t base_uuid = BLE_UUID_OUR_BASE_UUID;
service_uuid.uuid = BLE_UUID_OUR_SERVICE;
err_code = sd_ble_uuid_vs_add(&base_uuid, &service_uuid.type);
APP_ERROR_CHECK(err_code);
// OUR_JOB: Add our service
err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &service_uuid, &p_our_service->service_handle);
APP_ERROR_CHECK(err_code);
add_characteristic_to_service(p_our_service, BLE_UUID_CHAR_ADDRESS, &p_our_service->address_characteristic_handle, 10);
//add_characteristic_to_service(p_our_service, BLE_UUID_CHAR_DATA, &p_our_service->data_characteristic_handle, 10);
}
I've tried simply defining the base and service UUIDs as:
#define BLE_UUID_OUR_BASE_UUID {0xFB, 0x34, 0x9B, 0x5F, 0x80, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0xF0, 0xFF, 0x00, 0x00} // 128-bit base UUID
#define BLE_UUID_OUR_SERVICE 0xFFF0 // 16 bit UUID for our service
As far as I know simply using this template: 0000xxxx-0000-1000-8000-00805F9B34FB will get you a valid 16 bit service. Which is what I am trying to do. But it seems that this doesn't work as the thing goes into a hard fault handler (it works with another valid 128 bit UUID). So there must be some other way of doing this, I just can't seem to find how.