61 lines
2.1 KiB
C++
61 lines
2.1 KiB
C++
#include <SD.h>
|
|
|
|
|
|
//librerias propias--------------------
|
|
#include <GloboSonda.h>
|
|
#define PIN_POWERKEY_SIM808 48
|
|
#define SERVIDOR_APN "lobster"
|
|
Sim808Manager sim808;
|
|
|
|
char buf[1024];
|
|
|
|
void setup() {
|
|
Serial.begin(9600);
|
|
Serial.println("Iniciando");
|
|
UtilesDebug=true;
|
|
//strcpy(buf,"GET /setcoord/lat=1/long=2/ HTTP/1.1\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7\r\nAccept-Encoding: gzip, deflate\r\nAccept-Language: es-ES,es;q=0.9\r\nConnection: keep-alive\r\nCookie: _pk_id.1.f9d1=3c5b9a711f0ca8c3.1668027224.\r\nHost: 192.168.2.60:6265\r\nUpgrade-Insecure-Requests: 1\r\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36\r\n\r\n" );
|
|
strcpy(buf,"GET /setcoord HTTP/1.0\r\nConnection: keep-alive\r\nHost:desa.narvaling.com:6265\r\n" );
|
|
Serial2.begin(9600);
|
|
|
|
if(!sim808.inicia(&Serial2, PIN_POWERKEY_SIM808,9600))
|
|
{
|
|
Serial.println("Sim808 join network error");
|
|
}
|
|
delay(3000);
|
|
|
|
//*********** Attempt DHCP *******************
|
|
/*
|
|
Serial.println(sim808.EnviaComando("AT+CGATT?"));
|
|
Serial.println(sim808.EnviaComando("AT+CGATT=1"));
|
|
Serial.println(sim808.EnviaComando("AT+SAPBR=3,1,\"APN\",\"internet.digimobil.es\""));
|
|
Serial.println(sim808.EnviaComando("AT+SAPBR=3,1,\"USER\",\"\""));
|
|
Serial.println(sim808.EnviaComando("AT+SAPBR=3,1,\"PWD\",\"\""));
|
|
Serial.println(sim808.EnviaComando("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\""));
|
|
Serial.println(sim808.EnviaComando("AT+SAPBR=1,1"));
|
|
Serial.println(sim808.EnviaComando("AT+SAPBR=2,1"));
|
|
while(true)
|
|
{
|
|
Serial.println(sim808.EnviaComando("AT+SAPBR=2,1"));
|
|
delay(5000);
|
|
}
|
|
*/
|
|
|
|
|
|
}
|
|
|
|
void loop(){
|
|
|
|
while(!sim808.IniciaNetwork(SERVIDOR_APN,0,0)) {
|
|
Serial.println("Sim808 join network error");
|
|
delay(2000);
|
|
}
|
|
Serial.println("Sim808 join network ok");
|
|
|
|
if(!sim808.httpGet("desa.narvaling.com:6265/setcoor/holaArdu"))
|
|
Serial.println("error en get http");
|
|
|
|
sim808.Desconecta();
|
|
|
|
delay(20000);
|
|
}
|