PT_THREAD(PT_GSM_Reset(struct pt *pt))
{
PT_BEGIN(pt);
while(1) {
//
gsm.online = 0;
//
GSM_Timer_Set((u16_t*)&gsm.wdt_timer, GSM_TIMEOUT_2S);
//
do{
Gsm_RX_Clr();
USART1_Sendstr((void*)&SET_ATE0);
GSM_Timer_Set((u16_t*)&gsm.timer, GSM_TIMEOUT_CMD);
PT_WAIT_UNTIL(pt, ((pt->res = Search_Template(OK)) != NOT_DATA_FIND) ||
GSM_Timer_Expired((u16_t*)&gsm.timer));
}while(GSM_Timer_Not_Expired((u16_t*)&gsm.wdt_timer) && (pt->res == NOT_DATA_FIND));
if((GSM_Timer_Expired((u16_t*)&gsm.wdt_timer) == 0) && (pt->res != NOT_DATA_FIND)) {
GSM_Switch_State(GSM_STATE_INIT);
PT_YIELD(pt);
}
#ifdef GSM_HW_RESET
GSM_Pwrkey_Init();
GSM_Pwrkey_ON();
GSM_Timer_Set((u16_t*)&gsm.timer, GSM_TIMEOUT_2S);
PT_WAIT_UNTIL(pt, GSM_Timer_Expired((u16_t*)&gsm.timer));
GSM_Pwrkey_OFF();
GSM_Timer_Set((u16_t*)&gsm.timer, GSM_TIMEOUT_2S);
PT_WAIT_UNTIL(pt, GSM_Timer_Expired((u16_t*)&gsm.timer));
#else
Gsm_RX_Clr();
USART1_Sendstr((void*)&SET_AT_RESET);
GSM_Timer_Set((u16_t*)&gsm.timer, GSM_TIMEOUT_2S);
PT_WAIT_UNTIL(pt, GSM_Timer_Expired((u16_t*)&gsm.timer));
#endif
}
PT_END(pt);
}