How to update BLE characteristics via timer interrupt in STM32WB55 ?
Hello everyone,
I'm trying to use the timer interrupt callback to modify the GATT characteristics and send out a notification (see code excerpt below). This only works once and after sending the message the timer no longer triggers and I no longer see any advertisements from my board. If I send the data via the USB-COM port, it works using the timer interrupt. So there seems to be something wrong with the IPCC but I don't know what it is and how I can fix it/get around it. can someone help me ?
Many Greetings,
Andreas
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_RTC_Init();
MX_USB_Device_Init();
MX_TIM16_Init();
MX_RF_Init();
/* USER CODE BEGIN 2 */
static uint8_t cnt = 0;
const uint8_t max_cnt = 255;
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
// Check which version of the timer triggered this callback
if (htim == &htim16 )
{
if (cnt % (max_cnt - 1) == 0) cnt = 0;
uint8_t data[1];
memcpy(data, &cnt, sizeof(cnt));
cnt++;
// only one of the two is active at a time!
// This part for BLE, works just once!
// Custom_STM_App_Update_Char(CUSTOM_STM_TEMPERATUR, data);
// This USB-part works allways as desired
uint16_t data_len = (uint16_t) sizeof(data)/sizeof(uint8_t);
CDC_Transmit_FS((uint8_t*)data, data_len);
}
}
