I defined a timer and start the timer when application open gps, it can prevent the timeout of star search failure; When the gps search star successful, I will turn off the timer. However, when the program was running, I found that after the GPS positioning was successful, I called the function to stop the timer in advance, but the timer did not actually stop running. After the time was up, it still triggered the overdue function. Could you tell me what caused this?
static void APP_Ask_GPS_Data_timerout(struct k_timer *timer_id);
K_TIMER_DEFINE(app_wait_gps_timer, APP_Ask_GPS_Data_timerout, NULL);
void APP_Ask_GPS_Data_timerout(struct k_timer *timer)
{
u8_t str_gps[20] = {0};
u32_t tmp1;
double tmp2;
LOG_INF("[%s] begin\n", __func__);
app_gps_off = true;
APP_GPS_data_send(false);
}
void APP_Ask_GPS_Data(void)
{
static u8_t time_init = false;
if(!app_gps_on)
{
LOG_INF("[%s] begin\n", __func__);
app_gps_on = true;
k_timer_start(&app_wait_gps_timer, K_MSEC(3*60*1000), NULL);
}
}
..
case GPS_EVT_PVT_FIX:
LOG_INF("GPS_EVT_PVT_FIX");
sprintf(tmpbuf, "Longitude:%f, Latitude:%f\n", evt->pvt.longitude, evt->pvt.latitude);
LOG_INF("%s",tmpbuf);
memcpy(&gps_pvt_data, &(evt->pvt), sizeof(evt->pvt));
if(k_timer_remaining_get(&app_wait_gps_timer) > 0)
{
LOG_INF("[%s] stop gps wait timer\n", __func__);
k_timer_stop(&app_wait_gps_timer);
}
break;
..