Paso 18: Smart parking código
#include
#include
#include
#include
int = 67;
mac de bytes [] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
const char * servidor = "vittest.azure-mobile.net";
const char * table_name = "tabla_de_prueba";
const char * ams_key = "aDFcKPwvWLJnoXzYkJiupceKzDIsFG91";
Cliente EthernetClient;
buffer de Char [64];
void send_request(int qw)
{
Serial.println("\nconnecting...");
Si (client.connect (servidor, 80)) {}
Serial.Print ("enviando:");
Serial.Print(QW);
Serial.Print(".");
sprintf (buffer, "POST /tables/%s HTTP/1.1", table_name);
Client.println(buffer);
sprintf (buffer, "Host: %s", servidor);
Client.println(buffer);
sprintf (buffer, "X-ZUMO-aplicación: %s", ams_key);
Client.println(buffer);
Client.println ("Content-Type: aplicación/json");
sprintf (buffer, "{\"value\ ": %d}", qw);
Client.Print ("Content-Length:");
Client.println(strlen(buffer));
Client.println();
Client.println(buffer);
} else {}
Serial.println ("fallada la conexión");
}
}
void wait_response()
{
mientras (! {client.available())}
Si (! {client.connected())}
retorno;
}
}
}
void read_response()
{
impresión de bool = true;
mientras (client.available()) {}
char c = client.read();
Si (c == '\n')
imprimir = false;
Si (imprimir)
Serial.Print(c);
}
}
void end_request()
{
Client.STOP();
}
void setup()
{
Serial.Begin(9600);
mientras (!. Serie) {}
; Espere a que el puerto serial para conectar.
}
Delay(5);
Serial.println ("DS1621 Azure Demo");
Si (Ethernet.begin(mac) == 0) {}
Serial.println ("ethernet fallado");
para (;);
}
dar Ethernet escudo segundo a inicializar:
Delay(1000);
}
void loop()
{
int tC, tFrac;
flotador a val;
tFrac = tC % 100;
tC = tC 100;
send_request(We);
wait_response();
read_response();
end_request();
Delay(1000);
}