cancel
Showing results for 
Search instead for 
Did you mean: 

Button EXTI for STM32WBA55CG

Henry_BLE
Associate II

Hello everyone,

I'm very new to BLE in general. Here is the story, i'm aplplying this example STM32WBA Bluetooth® LE – Serial communication - stm32mcu
I want to create a button EXTI to send a BLE message and i should see the message on my phone via ST BLE Toolbox app. As my button is Pull-up configured, i have declared the EXTI as shown in main.c:

 
void HAL_GPIO_EXTI_Falling_Callback(uint16_t GPIO_Pin) {
if (GPIO_Pin == Button_2_Pin) {
const char *message2 = "Button 2.\r\n";
static uint32_t last_btn2_interrupt_time = 0;
uint32_t current_time = HAL_GetTick();
if (current_time - last_btn2_interrupt_time > 200) { // Button Debounce
last_btn2_interrupt_time = current_time;
tx_com((uint8_t *)message2, strlen(message2)); // USART debugging message
SendBLEMessage(message2); // Actual BLE message
}
}
}


This is SendBLEMessage defined in coc_peripheral_app.c:

 

 
void PeriphSendData( void )
{
tBleStatus status = BLE_STATUS_INVALID_PARAMS;

/*Data Packet to send to remote*/
status = aci_l2cap_coc_tx_data(BleCoCContextPeriph.Channel_Index_List,

2 + buffCocTxLen,/* 2 bytes of header */

(uint8_t *) &a_buffCocTx[0]);

if (status != BLE_STATUS_SUCCESS)
{
LOG_INFO_APP("==>> aci_l2cap_coc_tx_data : Fail, reason: 0x%02X\n", status);
}

return;
}



void SendBLEMessage(const char *msg)

{

uint8_t len = strlen(msg);



a_buffCocTx[0] = len;

a_buffCocTx[1] = 0;

memcpy(&a_buffCocTx[2], msg, len);

buffCocTxLen = len;





PeriphSendData(); // Send over BLE

}

This is aci_l2cap_coc_tx_data defined in ble_wrap.c:

/* ACI_L2CAP_COC_TX_DATA wrapper function */
tBleStatus aci_l2cap_coc_tx_data( uint8_t Channel_Index,

uint16_t Length,

const uint8_t* Data )

{

BLE_WRAP_ACI_L2CAP_COC_TX_DATA_PREPROC( );

tBleStatus status = ACI_L2CAP_COC_TX_DATA( Channel_Index,

Length,

Data );

BLE_WRAP_ACI_L2CAP_COC_TX_DATA_POSTPROC( );

return status;

}

 

When i pressed button 2, the code got stuck at BLE_WRAP_ACI_L2CAP_COC_TX_DATA_PREPROC( );

Could anyone give me advice how to solve this problem ? Thanks in advance.


Edited to apply source code formatting - please see How to insert source code for future reference.

0 REPLIES 0