STM32WB: Problem to connect to the board via BLE when adding a custom service
Hi,
using STM32WBRG, I was able to connect to the board via BLE: i installed the app "ST BLE Sensor" and then i was able to turn off/on the led. (Code generated by CubeMX). all works fine. In fact, I followed "STM32WB_workshop" proposed by ST.
In the next step, i tried to add my own service (without any characteristic). The purpose is to add successfully a custom service.
But, i can't connect my android app to the board. I install also LightBlue to see the different service and characteristic. But i didn't work. Not able to connect the the board. when i delete the service that i have added, all works fine. So, I am not able to added my own service.
Here is the service that i have added. Note that the uuid of this service is generated by "https ://www.uuidgenerator.net".
Please see the snippet code in file "custom_stm.c" where i developped the service:
#include "common_blesvc.h"
#include "custom_stm.h"
typedef struct{
uint16_t CustomSvcHdle; /**< Service handle */
}CustomContext_t;
#define UUID_128_SUPPORTED 1
#if (UUID_128_SUPPORTED == 1)
#define BM_UUID_LENGTH UUID_TYPE_128
#else
#define BM_UUID_LENGTH UUID_TYPE_16
#endif
#define BM_REQ_CHAR_SIZE (3)
PLACE_IN_SECTION("BLE_DRIVER_CONTEXT") static CustomContext_t CustomContext;
static SVCCTL_EvtAckStatus_t Custom_STM_Event_Handler(void *pckt);
#define COPY_UUID_128(uuid_struct, uuid_15, uuid_14, uuid_13, uuid_12, uuid_11, uuid_10, uuid_9, uuid_8, uuid_7, uuid_6, uuid_5, uuid_4, uuid_3, uuid_2, uuid_1, uuid_0) \
do {\
uuid_struct[0] = uuid_0; uuid_struct[1] = uuid_1; uuid_struct[2] = uuid_2; uuid_struct[3] = uuid_3; \
uuid_struct[4] = uuid_4; uuid_struct[5] = uuid_5; uuid_struct[6] = uuid_6; uuid_struct[7] = uuid_7; \
uuid_struct[8] = uuid_8; uuid_struct[9] = uuid_9; uuid_struct[10] = uuid_10; uuid_struct[11] = uuid_11; \
uuid_struct[12] = uuid_12; uuid_struct[13] = uuid_13; uuid_struct[14] = uuid_14; uuid_struct[15] = uuid_15; \
}while(0)
//The uuid generated by https ://www.uuidgenerator.net": 1885c1f8-6652-4f79-a5da-1db714f18194
//So The uuid of this service
#define COPY_CUSTOM_SERVICE_UUID(uuid_struct) COPY_UUID_128(uuid_struct,0x18,0x85,0xc1,0xf8,0x66,0x52,0x4f,0x79,0xa5,0xda,0x1d,0xb7,0x14,0xf1,0x81,0x49)
static SVCCTL_EvtAckStatus_t Custom_STM_Event_Handler(void *Event)
{
SVCCTL_EvtAckStatus_t return_value;
hci_event_pckt *event_pckt;
evt_blue_aci *blue_evt;
/* USER CODE BEGIN Custom_STM_Event_Handler_1 */
/* USER CODE END Custom_STM_Event_Handler_1 */
return_value = SVCCTL_EvtNotAck;
event_pckt = (hci_event_pckt *)(((hci_uart_pckt*)Event)->data);
switch(event_pckt->evt)
{
case EVT_VENDOR:
blue_evt = (evt_blue_aci*)event_pckt->data;
switch(blue_evt->ecode)
{
case EVT_BLUE_GATT_ATTRIBUTE_MODIFIED:
/* USER CODE BEGIN EVT_BLUE_GATT_ATTRIBUTE_MODIFIED */
/* USER CODE END EVT_BLUE_GATT_ATTRIBUTE_MODIFIED */
break;
case EVT_BLUE_GATT_READ_PERMIT_REQ :
/* USER CODE BEGIN EVT_BLUE_GATT_READ_PERMIT_REQ */
/* USER CODE END EVT_BLUE_GATT_READ_PERMIT_REQ */
break;
case EVT_BLUE_GATT_WRITE_PERMIT_REQ:
/* USER CODE BEGIN EVT_BLUE_GATT_WRITE_PERMIT_REQ */
/* USER CODE END EVT_BLUE_GATT_WRITE_PERMIT_REQ */
break;
default:
/* USER CODE BEGIN EVT_DEFAULT */
/* USER CODE END EVT_DEFAULT */
break;
}
/* USER CODE BEGIN EVT_VENDOR*/
/* USER CODE END EVT_VENDOR*/
break; /* EVT_VENDOR */
/* USER CODE BEGIN EVENT_PCKT_CASES*/
/* USER CODE END EVENT_PCKT_CASES*/
default:
break;
}
void SVCCTL_InitCustomSvc(void)
{
Char_UUID_t uuid;
/* USER CODE BEGIN SVCCTL_InitCustomSvc_1 */
/* USER CODE END SVCCTL_InitCustomSvc_1 */
/**
* Register the event handler to the BLE controller
*/
SVCCTL_RegisterSvcHandler(Custom_STM_Event_Handler);
/* USER CODE BEGIN SVCCTL_InitCustomSvc_2 */
COPY_CUSTOM_SERVICE_UUID(uuid.Char_UUID_128);
aci_gatt_add_service(UUID_TYPE_128,
(Service_UUID_t *) &uuid,
PRIMARY_SERVICE,
1,
&(CustomContext.CustomSvcHdle));
/* USER CODE END SVCCTL_InitCustomSvc_2 */
return;
}
Please what's missid, what shouldi do when adding a custom service.