cancel
Showing results for 
Search instead for 
Did you mean: 

Where to add my char in STM32WB55 to the reading function to send DATA via BLE.

MKolo.2
Associate II

Where in the files or a function can I put a character to be read by Android(maybe humidity reading) when using BLE in STM32WB55. I can not find any help from your videos. Please if you reply send me the exact function and include character "thanks".This will help me build my ADC from there.Please do not send me links to videos,unless you have solved it and you have a link. Thanks you.

Regards,

M.E

1 REPLY 1
ALABR.1
ST Employee

Hello MKolo.2

I am assuming that your are running a custom BLE project on STM32WB55. You can set-up your custom services and characteristics using STM32_WPAN middleware in CubeMX. Lets' focus on a read characteristic with a notify read event (GATT side).

Step 1: Managed the read event

Under STM32_WPAN/App/custom_stm.c you will find the static SVCCTL_EvtAckStatus_t Custom_STM_Event_Handler(void *Event).

You need to identify where is you read characteristic event handler for exemple here we are using "FW" characteristic.

....
else if (read_req->Attribute_Handle == (CustomContext.CustomFwHdle + CHARACTERISTIC_VALUE_ATTRIBUTE_OFFSET))
          {
            return_value = SVCCTL_EvtAckFlowEnable;
            /*USER CODE BEGIN CUSTOM_STM_Service_3_Char_1_ACI_GATT_READ_PERMIT_REQ_VSEVT_CODE_1 */
            Notification.Custom_Evt_Opcode = CUSTOM_STM_FW_READ_EVT;						/* evt_Opcode = FW read event  */
            Custom_STM_App_Notification(&Notification);										/* Call Custom_STM_App_Notification to managed the command */
            /*USER CODE END CUSTOM_STM_Service_3_Char_1_ACI_GATT_READ_PERMIT_REQ_VSEVT_CODE_1*/
            aci_gatt_allow_read(read_req->Connection_Handle);
            /*USER CODE BEGIN CUSTOM_STM_Service_3_Char_1_ACI_GATT_READ_PERMIT_REQ_VSEVT_CODE_2 */
 
            /*USER CODE END CUSTOM_STM_Service_3_Char_1_ACI_GATT_READ_PERMIT_REQ_VSEVT_CODE_2*/
          } /* if (read_req->Attribute_Handle == (CustomContext.CustomFwHdle + CHARACTERISTIC_VALUE_ATTRIBUTE_OFFSET))*/
....

You need to call Custom_STM_App_Notification() with the correct event.

Step 2: Update and send your value

Under /STM32_WPAN/App_Customapp.c you will find void Custom_STM_App_Notification(Custom_STM_App_Notification_evt_t *pNotification). Find your read event, update your value and send it. Again with the "FW" read characterisitc:

case CUSTOM_STM_FW_READ_EVT:
      /* USER CODE BEGIN CUSTOM_STM_FW_READ_EVT */
		APP_DBG_MSG("\r\n\r** CUSTOM_STM_FW_READ_EVT \n");
		strcpy((char *)NotifyCharData, FW);
		Custom_STM_App_Update_Char(CUSTOM_STM_FW, (uint8_t *)NotifyCharData);
      /* USER CODE END CUSTOM_STM_FW_READ_EVT */
      break;

You have successfully managed to return the read characteristic to the client.

Hope this will help,

beST regards,

Axel L.