本帖最后由 dong_abc 于 2015-6-3 12:30 编辑
:handshake :handshake
void gprs_init(void)
{
if((strstr(aUart5RxBuffer, "command ready") == NULL)
/*||(strstr(aUart5RxBuffer, "+SIM READY") == NULL)*/)
{
gprs_init_ok = 0;
}
else
{
gprs_init_ok = 1;
}
}
void ppp_config(void)
{
switch (ppp_config_step)
{
case 0:
free_rom_buf(aUart5RxBuffer,sizeof(aUart5RxBuffer));
gprs_puts("AT+GTSET=\"LPMMODE\",0\r\n");
gprs_tick = msTicks;
ppp_config_step = 1;
break;
case 1:
if((msTicks - gprs_tick) > 500)
{
if(strstr(aUart5RxBuffer, "OK") == NULL)
{
ppp_config_step = 0;
}
else
{
ppp_config_step = 2;
}
free_rom_buf(aUart5RxBuffer,sizeof(aUart5RxBuffer));
}
break;
//===================================================
case 2:
gprs_puts("AT+CPIN?\r\n");
ppp_config_step = 3;
gprs_tick = msTicks;
break;
case 3:
if((msTicks - gprs_tick) > 500)
{
if((strstr(aUart5RxBuffer, "OK") == NULL) || (strstr(aUart5RxBuffer, "+CPIN: READY") == NULL))
{
ppp_config_step = 2;
}
else
{
ppp_config_step = 4;
}
free_rom_buf(aUart5RxBuffer,strlen(aUart5RxBuffer));
}
break;
//======================================================
case 4:
gprs_puts("AT+CSQ\r\n");
ppp_config_step = 5;
gprs_tick = msTicks;
break;
case 5:
if((msTicks - gprs_tick) > 500)
{
if(strstr(aUart5RxBuffer, "OK") == NULL)
{
ppp_config_step = 4;
}
else
{
ppp_config_step = 6;
}
free_rom_buf(aUart5RxBuffer,strlen(aUart5RxBuffer));
}
break;
//=====================================================
case 6:
gprs_puts("AT+CREG?\r\n");
ppp_config_step = 7;
gprs_tick = msTicks;
break;
case 7:
if((msTicks - gprs_tick) > 500)
{
if(strstr(aUart5RxBuffer, "+CREG: 0,0") == NULL)
{
ppp_config_step = 8;
}
else
{
ppp_config_step = 6;
}
free_rom_buf(aUart5RxBuffer,strlen(aUart5RxBuffer));
}
break;
//=========================================================
case 8:
//gprs_puts("AT+MIPCALL=1,\"3GNET\"\r\n");
gprs_puts("AT+MIPCALL=1,\"xagfzqx.ydoa.snapn\"\r\n");
ppp_config_step = 9;
gprs_tick = msTicks;
break;
case 9:
if((msTicks - gprs_tick) > 3000)
{
if(strstr(aUart5RxBuffer, "+MIPCALL: 0") == NULL)
{
ppp_config_step = 0;
ppp_config_ok = 1;
}
else
{
ppp_config_step = 8;
}
free_rom_buf(aUart5RxBuffer,strlen(aUart5RxBuffer));
}
break;
default:
break;
}
}
void gprs_monit_routine(void)
{
if(!gprs_init_ok) { gprs_init(); }
if((gprs_init_ok)&&(!ppp_config_ok)) { ppp_config(); }
if((ppp_config_ok)&&(data_is_ok)&&(!http_send_cmplt)) { http_send_test(); }
}
|