static void bear_notify_cb(cbm_bearer_state_enum state, u8 ip_addr[4]) { LOG_DEBUG("bear_notify state: %s.", getStateDescription(state)); switch (state) { case CBM_ACTIVATED: LOG_DEBUG("local ip is %d.%d.%d.%d", ip_addr[0], ip_addr[1], ip_addr[2], ip_addr[3]); fsm_run(EVT_BEARER_HOLD); break; case CBM_DEACTIVATED: fsm_run(EVT_BEARER_DEACTIVATED); break; case CBM_GPRS_AUTO_DISC_TIMEOUT: LOG_ERROR("CBM_GPRS_AUTO_DISC_TIMEOUT happened!"); eat_reset_module(); break; case CBM_ACTIVATING: case CBM_DEACTIVATING: //no need to handle break; default: LOG_ERROR("BEAR_NOTIFY %d not handled", state); break; } }
static void eat_sms_send_cb(eat_bool result) { LOG_DEBUG("result=%d.", result); if(EAT_TRUE == ResetFlag) { ResetFlag = EAT_FALSE; eat_reset_module(); } }
void gpt_timer_callback() { static char gps_rx_count = 0; g_sending_time_cnt += 1;g_watchdog_cnt += 1;g_sleep_on_duration += 1;g_device_idle_duration += 1;gps_rx_count += 1;g_other_task_cnt+=1; if(f.g_device_in_sleep_F == 0) sending_interval = g_gprs_sending_time; else sending_interval = g_sleep_tracking_interval_in_secs; if(g_sending_time_cnt >= sending_interval) { g_sending_time_cnt = 0; f.g_make_data_F = 1; } if(g_sleep_on_duration >= 60) // If motion is not sensed from last 180 seconds then put the device in sleep. { g_sleep_on_duration = 0; f.g_enter_in_sleep_F = 1; } if(g_watchdog_cnt > 310) // Watchdog is running at 300 secs, if count goes more than 310 then restart the module. { eat_debug("WatchDog Reset\n"); eat_sleep(1000); eat_reset_module(); } if(g_device_idle_duration > 60) //If motion is not sensed from last 60 secs then put the device in idle mode. { g_device_idle_duration = 0; f.g_device_idle_F = 1; f.g_motion_sensed_F = 0; } if(gps_rx_count >= 2) { gps_rx_count = 0; if(f.g_gps_rx_F == 0 && f.g_device_in_sleep_F == 0) f.g_gps_rx_F = 1; } if(g_other_task_cnt > 30) { g_other_task_cnt = 0; f.g_other_routine_F = 1; } led_functionality(); }