cancel
Showing results for 
Search instead for 
Did you mean: 

Checking received Value from st ble toolbox app

PMato.1
Associate II

Hello

I have watched the lab about stm32wb55 where the board receives any event from the smartphone app and toggles the onboard LD2. 

Now i want to make mine specific by checking for the received value and only toggle the LD2 if its a 1 and only turn it off if its a 0. 

i have tried using the code below but it is not working well can someone assist me

attribute_modified = (aci_gatt_attribute_modified_event_rp0*)blecore_evt->data;

if (attribute_modified->Attr_Handle == (CustomContext.CustomMycharwriteHdle + CHARACTERISTIC_VALUE_ATTRIBUTE_OFFSET))

{

return_value = SVCCTL_EvtAckFlowEnable;

/* USER CODE BEGIN CUSTOM_STM_Service_1_Char_1_ACI_GATT_ATTRIBUTE_MODIFIED_VSEVT_CODE */

 

uint8_t* receivedData = attribute_modified->Attr_Data;

// Check the received value and perform actions based on it

if(receivedData[0] == 1) {

// If the received data is 1, toggle the LED

HAL_GPIO_TogglePin(LD1_GPIO_Port, LD1_Pin);

} else if(receivedData[0] == 0) {

// If the received data is 0, turn off the LED

HAL_GPIO_WritePin(LD1_GPIO_Port, LD1_Pin, GPIO_PIN_RESET);

}

0 REPLIES 0