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

No memory while initializing a custom characteristic

I have the following code for a custom service UUID and a custom 128 bit characteristic ID. I get a error of no memory available in our_char_init while adding the 128 bit characteristic UUID to the stack using sd_ble_uuid_vs_add. What is the issue? This is following the devzone.nordicsemi.com/.../ and the github.com/.../nrf5-ble-tutorial-characteristic Tutorials.

our_service.h

static uint32_t our_char_init(ble_os_t * p_our_service)
{
	uint32_t err_code;
	
	//Declare 16 bit service and 128 bit UUID
	ble_uuid128_t 	char_base_uuid = BLE_UUID_OUR_CHARACTERISTIC_BASE_UUID;
	ble_uuid_t			char_uuid;
	
	char_uuid.type  =	BLE_UUID_TYPE_VENDOR_BEGIN;
	char_uuid.uuid	= BLE_UUID_OUR_CHARACTERISTIC;
	
	//Adding the characteristic to BLE stack
	err_code = sd_ble_uuid_vs_add(&char_base_uuid, &char_uuid.type);
	APP_ERROR_CHECK(err_code);
	
	//Read/write properties to our characteristic
	ble_gatts_char_md_t char_md;
	memset(&char_md, 0, sizeof(char_md));
	
	//Attribute Metadata
	ble_gatts_attr_md_t attr_md;
	memset(&attr_md, 0, sizeof(attr_md));
	attr_md.vloc        = BLE_GATTS_VLOC_STACK;
	
	//Characteristic Value Attribute
	ble_gatts_attr_t    attr_char_value;
	memset(&attr_char_value, 0, sizeof(attr_char_value));    
	attr_char_value.p_uuid      = &char_uuid;
	attr_char_value.p_attr_md   = &attr_md;
	
	//Add Characteristic to Service
	err_code = sd_ble_gatts_characteristic_add(p_our_service->service_handle, &char_md, &attr_char_value, &p_our_service->char_handles);
	APP_ERROR_CHECK(err_code);
		
	return NRF_SUCCESS;
}



void our_service_init(ble_os_t * p_our_service)
{
	uint32_t 	err_code;
	
	//Declare 16 bit service and 128-bit UUID
	ble_uuid128_t our_service_base_uuid = BLE_UUID_OUR_BASE_UUID;
	ble_uuid_t 		service_uuid;
	
	service_uuid.uuid = BLE_UUID_OUR_SERVICE;
	
	//Adding the service to BLE stack
	err_code = sd_ble_uuid_vs_add(&our_service_base_uuid, &service_uuid.type);
	APP_ERROR_CHECK(err_code);
	
	//Initializing the connection handle
	p_our_service->conn_handle = BLE_CONN_HANDLE_INVALID;
	
	err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &service_uuid, &p_our_service->service_handle);
	APP_ERROR_CHECK(err_code);
	
	//Initialize the Characteristic under the Our Service
	our_char_init(p_our_service);
	
}

our_service.h

#define BLE_UUID_OUR_BASE_UUID 									{0x46, 0xf8, 0x22, 0x22, 0x22, 0x11, 0x66, 0x88, 0x97, 0x45, 0x9e, 0xf4, 0x90, 0x4b, 0x69, 0xfb} //128 bit base UUID
#define BLE_UUID_OUR_CHARACTERISTIC_BASE_UUID 	{0x22, 0x22, 0x22, 0x1b, 0x82, 0x81, 0x22, 0x22, 0x22, 0x4f, 0xcb, 0x69, 0xeb, 0x95, 0xce, 0x1e}

#define BLE_UUID_OUR_SERVICE 	 							0x904b 
#define BLE_UUID_OUR_CHARACTERISTIC 			 			0xeb95 

typedef struct
{
	uint16_t                    conn_handle;		//Connection Handle provided by connection handle
	uint16_t                    service_handle; //Provided by BLE stack
	ble_gatts_char_handles_t    char_handles;		//Handle for Characteristic
}ble_os_t;

void our_service_init(ble_os_t * p_our_service);
Related