2022-07-18 09:46 PM
I am building ble application on stm32wb and below is the RTC configuration via cubemx.
I am trying to implement a scan timeout using the timeserver. Basically, I start a scan procedure and continue scanning until the time-out callback is invoked which terminates the scan procedure. However, for some reason, the timeout callback is never invoked. Below is my API usage.
/**
* @brief callback to timeout if dut wasn't found
*/
static void scan_timeout_cb(void) {
printf("ble: scan timed out\r\n");
// terminate the scan procedure
aci_gap_terminate_gap_proc(GAP_GENERAL_DISCOVERY_PROC);
}
static struct {
uint32_t process_id;
uint8_t id;
HW_TS_Mode_t mode;
HW_TS_pTimerCb_t cb;
bool created;
} scan_timer = { .process_id = 0, .mode = hw_ts_SingleShot, .cb = scan_timeout_cb, .created = false };
// create a timer
if (!scan_timer.created) {
HW_TS_ReturnStatus_t tmr_ret
= HW_TS_Create(scan_timer.process_id, &scan_timer.id, scan_timer.mode, scan_timer.cb);
if (tmr_ret != hw_ts_Successful) {
break;
}
}
scan_timer.created = true;
HW_TS_Start(scan_timer.id, 1);
I'd expect the "scan_timeout_cb" to be invoked immediately but that doesn't happen. Could someone please advise me on what I may be doing wrong?
Solved! Go to Solution.
2022-07-19 02:31 PM
Alright, I figured out why the callback wasn't being invoked. The HW_TS_RTC_Int_AppNot needs to be user-defined that invokes the registered callbacks when expired. @Piranha, I am still wondering what you found so absurd regarding my API usage and curious about my invention? Never mind:D
2022-07-19 01:20 AM
Maybe first learn how to use that time server API, not just invent something absurd?
2022-07-19 02:36 AM
I don't see what's done any differently in the link you have shared. He's used HW_TS_Create to create a repeating timer to invoke QueueStandbyMode on timeout. HW_TS_Create gives the timer id that can be used to reference the timer when starting or stopping it. Then he starts the timer using HW_TS_Start to invoke QueueStandbyMode once every 5 seconds. I am doing exactly the same except that I use a single shot timer. Could you please point out what's it that you see I am doing wrong?
Also, seems like someone else was having the same issue but the question was never answered.
2022-07-19 02:31 PM
Alright, I figured out why the callback wasn't being invoked. The HW_TS_RTC_Int_AppNot needs to be user-defined that invokes the registered callbacks when expired. @Piranha, I am still wondering what you found so absurd regarding my API usage and curious about my invention? Never mind:D
2022-07-20 02:32 PM
Initially it seemed to me that the first parameter of the HW_TS_Create() call should be some special CFG_TIM_PROC_ID_ISR, not a zero. Like some ID of a process, which services the timers. Now, searching for mode code, it seems that it's just a custom argument for arbitrary use. Sorry for causing an excessive stress! ;)