cancel
Showing results for 
Search instead for 
Did you mean: 

How do I fix the failed attempt to add Characteristic to aci_gatt_add_char() in BlueNRG-2?

Jhe.657
Associate II

I used BCN002V1D development board.When I used the BLE Chat Demo project, I added Characteristic to the original service.There should have been no problem, but when it was run, it got an error code 0x47.

The requested operation violates The logic of The called layer/function or The format of The data to be processed during The operation.

#define BLE_STATUS_ERROR          ((tBleStatus)(0x47))

I think my format is referring to the other Demo project, should be no problem.I wonder if configuration is needed elsewhere?

Here is the code for the function that ran wrong. I added the italicized part.

uint8_t Add_Chat_Service(void) {

uint8_t ret;

/*

UUIDs:

D973F2E0-B19E-11E2-9E96-0800200C9A66

D973F2E1-B19E-11E2-9E96-0800200C9A66

D973F2E2-B19E-11E2-9E96-0800200C9A66

75a028a0-53c3-11ea-aaef-0800200c9a66

75a028a1-53c3-11ea-aaef-0800200c9a66

75a028a2-53c3-11ea-aaef-0800200c9a66

*/

const uint8_t uuid[16] = { 0x66, 0x9a, 0x0c, 0x20, 0x00, 0x08, 0x96, 0x9e, 0xe2, 0x11, 0x9e, 0xb1, 0xe0, 0xf2, 0x73, 0xd9 };

const uint8_t charUuidTX[16] = { 0x66, 0x9a, 0x0c, 0x20, 0x00, 0x08, 0x96, 0x9e, 0xe2, 0x11, 0x9e, 0xb1, 0xe1, 0xf2, 0x73, 0xd9 };

const uint8_t charUuidRX[16] = { 0x66, 0x9a, 0x0c, 0x20, 0x00, 0x08, 0x96, 0x9e, 0xe2, 0x11, 0x9e, 0xb1, 0xe2, 0xf2, 0x73, 0xd9 };

const uint8_t charUuidTX_t[16] = { 0x66, 0x9a, 0x0c, 0x20, 0x00, 0x08, 0xef, 0xaa, 0xea, 0x11, 0xc3, 0x53, 0xa1, 0x28, 0xa0, 0x75 };

Osal_MemCpy(&service_uuid.Service_UUID_128, uuid, 16);

ret = aci_gatt_add_service(UUID_TYPE_128, &service_uuid, PRIMARY_SERVICE, 6, &chatServHandle);

if (ret != BLE_STATUS_SUCCESS)

goto fail;

Osal_MemCpy(&char_uuid.Char_UUID_128, charUuidTX, 16);

ret = aci_gatt_add_char(chatServHandle, UUID_TYPE_128, &char_uuid, 20, CHAR_PROP_NOTIFY, ATTR_PERMISSION_NONE, 0, 16, 1, &TXCharHandle);

if (ret != BLE_STATUS_SUCCESS)

goto fail;

Osal_MemCpy(&char_uuid.Char_UUID_128, charUuidRX, 16);

ret = aci_gatt_add_char(chatServHandle, UUID_TYPE_128, &char_uuid, 20, CHAR_PROP_WRITE | CHAR_PROP_WRITE_WITHOUT_RESP, ATTR_PERMISSION_NONE, GATT_NOTIFY_ATTRIBUTE_WRITE, 16, 1, &RXCharHandle);

if (ret != BLE_STATUS_SUCCESS)

goto fail;

Osal_MemCpy(&char_uuid.Char_UUID_128, charUuidTX_t, 16);

ret = aci_gatt_add_char(chatServHandle, UUID_TYPE_128, &char_uuid, 3, CHAR_PROP_NOTIFY, ATTR_PERMISSION_NONE, 0, 16, 1, &TXCharHandle_t);

printf("debug3\r\n");

if (ret != BLE_STATUS_SUCCESS)

goto fail;

printf("Chat Service added.\nTX Char Handle %04X, RX Char Handle %04X\n", TXCharHandle, RXCharHandle);

return BLE_STATUS_SUCCESS;

fail: printf("Error while adding Chat service.\n");

return BLE_STATUS_ERROR;

}

The operation results are as follows:

BlueNRG-1 BLE Chat Server Application (version: 1.0.0)

aci_gatt_init() --> SUCCESS

aci_gap_init() --> SUCCESS

aci_gatt_update_char_value_ext() --> SUCCESS

debug3

Error while adding Chat service.

Error in Add_Chat_Service 0x47

CHAT_DeviceInit()--> Failed 0x47

If I remove the first code that added Characteristic, the code I added will work fine.But when I removed the second code that added Characteristic, the service wasn't created properly.

How to solve this problem?

4 REPLIES 4
Jhe.657
Associate II

I found the solution. Because I have no configuration BlueNRG_Stack_Init_params in Chat_config.h. Insufficient memory allocation.

RAdam.1
Associate III

Hi there - I have this same issue and changed the num services and num attributes to 2 and 20 (from 1 and 5) but it still runs out of memory when adding the 4th characteristic - did you change anything else? really appreciate your answer.

You must configuration the structure of the BlueNRG_Stack_Init_params in Chat_config.h. This structure involves the configuration of initialization parameters for the bluetooth protocol stack.This structure is called when initializing the bluetooth stack in the main function.The default memory allocation is not enough to cause this error. Configure the memory allocation parameter in the structure to be larger to ensure that it can accommodate the services and properties you need.

DKopp.2
Associate III

I have run into the same problem. I cannot find BlueNRG_Stack_Init_params. I'm using a X-NUCLEO-IDB05A2 evaluation kit with Nucleo-F303ZE STM evaluation board. Ive downloaded the software pack X-CUBE-BLE1 1.6.2.4. I dont have a config.h file where I have update parameters.

Any Help will be appreciated.