teste de publish
Dependencies: DS1820 HighSpeedAnalogIn devices mbed
Diff: modem.cpp
- Revision:
- 31:a1ba855c6e8a
- Parent:
- 30:8a06a85d8807
- Child:
- 33:a60abda630f7
diff -r 8a06a85d8807 -r a1ba855c6e8a modem.cpp --- a/modem.cpp Fri May 25 23:46:10 2018 +0000 +++ b/modem.cpp Sat May 26 13:00:00 2018 +0000 @@ -54,7 +54,7 @@ uint16_t numeroByteSendoEnviado; sprintf(aux,"AT+CIPSEND=%u,%lu\r\n",sId,bufferLength); - if(modemCom::sendToModem(aux,1,&modemCom::status.PROMPT_ENVIO_COMMAND_MODE,NULL,300,10,1)) { + if(modemCom::sendToModem(aux,1,&modemCom::status.PROMPT_ENVIO_COMMAND_MODE,NULL,500,10,1)) { for(numeroByteSendoEnviado = 0; numeroByteSendoEnviado<bufferLength; numeroByteSendoEnviado++) { modem.printf("%c",buffer[numeroByteSendoEnviado]); if(debug){ @@ -72,7 +72,7 @@ void modemCom::leMAC(void) { char *ptr; - if(modemCom::sendToModem("AT+CIPSTAMAC?\r\n",1,&modemCom::status.modemResponse,NULL,250,20,1)){ + if(modemCom::sendToModem("AT+CIPSTAMAC?\r\n",1,&modemCom::status.modemResponse,NULL,500,20,1)){ //resposta: +CIPSTAMAC:"18:fe:34:f4:5f:c4" ptr = strtok(bufModem.getRowBuffer(),"\""); ptr = strtok(NULL,"\""); @@ -273,7 +273,7 @@ headerTam = strlen(header); sprintf(aux,"AT+CIPSEND=1,%u\r\n",headerTam); - if(modemCom::sendToModem(aux,1,&modemCom::status.PROMPT_ENVIO_COMMAND_MODE,NULL,250,10,1)) { + if(modemCom::sendToModem(aux,1,&modemCom::status.PROMPT_ENVIO_COMMAND_MODE,NULL,1000,10,1)) { if(!modemCom::sendToModem(header,1,&modemCom::status.SEND_OK,NULL,1000,1,1)) { sdCard::fechaArquivo(arquivo); modemCom::status.emComunicacao = false; @@ -304,7 +304,7 @@ } while((maxTentativas)&&(!passaParaProximaParte)) { sprintf(aux,"AT+CIPSEND=1,%u\r\n",numeroDeBytesPorEnvio); - if(modemCom::sendToModem(aux,1,&modemCom::status.PROMPT_ENVIO_COMMAND_MODE,NULL,250,20,1)) { + if(modemCom::sendToModem(aux,1,&modemCom::status.PROMPT_ENVIO_COMMAND_MODE,NULL,1000,20,1)) { if(maxTentativas!=maxRetentativasEnvioParteArquivo) { //Estou realizando reenvio desta parte logo preciso fazer fseek para a quantidade de bytes do envio anterior fseek(arquivo->fp,-numeroDeBytesPorEnvio,SEEK_CUR); @@ -356,7 +356,7 @@ maxTentativas = maxRetentativasEnvioParteArquivo; while((maxTentativas)&&(!passaParaProximaParte)) { sprintf(aux,"AT+CIPSEND=1,%u\r\n",restoDoEnvio+strlen("\r\n--xxBOUNDARYxx--\r\n\r\n")); //Para incluir "\n--xxBOUNDARYxx--\n\n" no fim da msg http - if(modemCom::sendToModem(aux,1,&modemCom::status.PROMPT_ENVIO_COMMAND_MODE,NULL,500,3,1)) { + if(modemCom::sendToModem(aux,1,&modemCom::status.PROMPT_ENVIO_COMMAND_MODE,NULL,1000,3,1)) { for(numeroByteSendoEnviado=0; numeroByteSendoEnviado<restoDoEnvio; numeroByteSendoEnviado++) { //Envio os bytes aqui! Menos o ultimo para ter o check; c = fgetc(arquivo->fp); @@ -388,7 +388,7 @@ } } else { maxTentativas--; - modemCom::sendToModem("AT\r\n",1,&modemCom::status.OK,NULL,1000,100,1); + modemCom::sendToModem("AT\r\n",1,&modemCom::status.OK,NULL,1000,20,1); } } @@ -488,7 +488,7 @@ if(debug){pc.printf("Lido %u como sendo o id em closeConnection.\r\n",id);} sprintf(command,"AT+CIPCLOSE=%u\r\n",id); - return modemCom::sendToModem(command,1,NULL,",CLOSED",500,3,1); + return modemCom::sendToModem(command,1,NULL,",CLOSED",1000,3,300); } char modemCom::cipSend(uint8_t idConnection,char *buffer,uint16_t len){ @@ -674,8 +674,8 @@ bool modemCom::leIP(void){ char *ptr; - sendToModem("AT+CIFSR\r\n",1,NULL,"+CIFSR:STAIP,",200,1,1); - if(debug){pc.printf("Lido de leIP <%s>.\r\n",modemCom::bufIn);} + sendToModem("AT+CIFSR\r\n",1,NULL,"+CIFSR:STAIP,",2000,1,1); + pc.printf("Lido de leIP <%s>.\r\n",modemCom::bufIn); ptr=strstr(modemCom::bufIn,"+CIFSR:STAIP,"); if(ptr) { ptr = strtok(ptr,"\""); @@ -690,7 +690,7 @@ char *ptr; int16_t RSSI = 255; - if(modemCom::sendToModem("AT+CWJAP?\r\n",1,&modemCom::status.OK,NULL,10000,1,1000)){ + if(modemCom::sendToModem("AT+CWJAP?\r\n",1,&modemCom::status.OK,NULL,10000,2,1000)){ ptr = strstr(modemCom::bufIn,(const char*)modemCom::status.ssid); if(ptr){ ptr = strtok(ptr,","); //Descarta SSID @@ -726,7 +726,7 @@ //modemCom::leParametrosConexaoSDCard(); //AT+CWJAP=\"\",\"\"\r\n sprintf(aux,"AT+CWJAP=\"%s\",\"%s\"\r\n",modemCom::status.ssid,modemCom::status.password); - if(modemCom::sendToModem(aux,1,&modemCom::status.OK,NULL,5000,1,1)) { + if(modemCom::sendToModem(aux,1,&modemCom::status.OK,NULL,5000,2,5000)) { if(debug){pc.printf("WiFi Conectado.\n");} return true; }else{ @@ -869,7 +869,7 @@ } if((connID==modemCom::status.connIDServerCommand)&& IPDNumBytes && modemCom::status.recebendoArquivoDoServer && (strstr(modemCom::bufIn,"CONNECT")==NULL) && (strstr(modemCom::bufIn,"*ServerCommand*")==NULL) ){ - if(debug){pc.printf("sendData recebidos %lu bytes\n",sdCard::nBytesArquivoRecebidos/2);} + pc.printf("sendData recebidos %lu bytes\n",sdCard::nBytesArquivoRecebidos/2); sdCard::insereDadosArquivoHex(&sdCard::tempFile,modemCom::bufIn,IPDNumBytes); //sdCard::insereDadosArquivo(&sdCard::tempFile,modemCom::bufIn,IPDNumBytes); sdCard::nBytesArquivoRecebidos+=IPDNumBytes; @@ -1034,7 +1034,7 @@ char aux[255]; modemCom::timeOutModem = 10; modemCom::status.emComunicacao = true; - if(modemCom::sendToModem("ATE0\r\n",1,&modemCom::status.OK,NULL,1000,10,1)) { + if(modemCom::sendToModem("ATE0\r\n",1,&modemCom::status.OK,NULL,1000,10,100)) { pc.printf("Recebeu o comando ATE0.\n"); } @@ -1044,49 +1044,49 @@ //Colocando aqui o conteudo de conectaWiFi //Mudando mode para AP e Station - if(modemCom::sendToModem("AT+CWMODE=3\r\n",1,&modemCom::status.OK,NULL,3000,1,1)) { + if(modemCom::sendToModem("AT+CWMODE=3\r\n",1,&modemCom::status.OK,NULL,3000,2,250)) { pc.printf("Modo AP+STATION aceito.\n"); } - if(modemCom::sendToModem("AT+CIPMUX=1\r\n",1,&modemCom::status.OK,NULL,250,4,1)) { + if(modemCom::sendToModem("AT+CIPMUX=1\r\n",1,&modemCom::status.OK,NULL,1000,4,250)) { pc.printf("Recebeu o comando AT+CIPMUX=1.\n"); } //AT+CIPSERVER=1,portaLidaDoSDCard sprintf(aux,"AT+CIPSERVER=1,%s\r\n",modemCom::status.port); - if(modemCom::sendToModem(aux,1,&modemCom::status.OK,NULL,250,4,1)) { + if(modemCom::sendToModem(aux,1,&modemCom::status.OK,NULL,1000,4,250)) { pc.printf("Recebeu o comando <%s>.\n",aux); } - if(modemCom::sendToModem("AT+CIPSTO=10\r\n",1,&modemCom::status.OK,NULL,250,4,1)) { + if(modemCom::sendToModem("AT+CIPSTO=10\r\n",1,&modemCom::status.OK,NULL,500,3,250)) { pc.printf("Recebeu o comando AT+CIPSTO=10.\n"); } sprintf(aux,"AT+CWSAP_CUR=\"DROME_WIFI_%s\",\"VseDROME\",5,3\r\n",modemCom::status.MAC); - if(modemCom::sendToModem(aux,1,&modemCom::status.OK,NULL,250,4,1)) { + if(modemCom::sendToModem(aux,1,&modemCom::status.OK,NULL,1000,2,300)) { pc.printf("Recebeu o comando %s.\n",aux); } - if(modemCom::sendToModem("AT+CIPAP_CUR=\"192.168.4.1\",\"192.168.4.1\",\"255.255.255.0\"\r\n",1,&modemCom::status.OK,NULL,500,4,1)) { + if(modemCom::sendToModem("AT+CIPAP_CUR=\"192.168.4.1\",\"192.168.4.1\",\"255.255.255.0\"\r\n",1,&modemCom::status.OK,NULL,500,4,300)) { pc.printf("Recebeu o comando AT+CIPAP_CUR=\"192.168.4.1\",\"192.168.4.1\",\"255.255.255.0\".\n"); } //Aqui decido se uso DHCP ou não. if(strstr(modemCom::status.gateway,"dhcp")||(strlen(modemCom::status.gateway)==0)){ //usando dhcp - if(modemCom::sendToModem("AT+CWDHCP_CUR=2,1\r\n",1,&modemCom::status.OK,NULL,250,4,1)) { + if(modemCom::sendToModem("AT+CWDHCP_CUR=2,1\r\n",1,&modemCom::status.OK,NULL,500,4,300)) { pc.printf("Recebeu o comando AT+CWDHCP_CUR=2,1.\n"); } }else{ - if(modemCom::sendToModem("AT+CWDHCP_CUR=2,0\r\n",1,&modemCom::status.OK,NULL,250,4,1)) { + if(modemCom::sendToModem("AT+CWDHCP_CUR=2,0\r\n",1,&modemCom::status.OK,NULL,500,4,300)) { pc.printf("Recebeu o comando AT+CWDHCP_CUR=2,0.\n"); } //AT+CIPSTA_DEF="192.168.6.100","192.168.6.1","255.255.255.0" sprintf(aux,"AT+CIPSTA_CUR=\"%s\",\"%s\",\"%s\"\r\n",modemCom::status.STAIP,modemCom::status.gateway,modemCom::status.subnetmask); - if(modemCom::sendToModem(aux,1,&modemCom::status.OK,NULL,250,4,1)) { + if(modemCom::sendToModem(aux,1,&modemCom::status.OK,NULL,500,4,300)) { pc.printf("Recebeu o comando <%s>.\n",aux); }