Hallo
Ich habe folgenden Code geschrieben /kopiert
Leider klappt der Eintrag in die Volkszähler DB nicht.... wer kann mir helfen?
#include <EtherCard.h>
// wenn ich diese Zeile in einen Browser eingebe, dann wird unter UUID 3673c950usw der Wert 11 eingetragen
// "http://192.168.2.101/middleware.php/data/3673c950-c1ef-11e6-b11a-0192d8f83db0.json?operation=add&value=11"
#define PATH "/middleware.php/data/3673c950-c1ef-11e6-b11a-0192d8f83db0"
// ethernet interface mac address, must be unique on the LAN
byte mymac[] = { 0x9e,0xb3,0x19,0xc7,0x1b,0x10 };
const char website[] PROGMEM = "192.168.2.101";
byte Ethernet::buffer[700];
uint32_t timer;
Stash stash;
void setup () {
Serial.begin(57600);
Serial.println("\n[webClient]");
if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
Serial.println( "Failed to access Ethernet controller");
if (!ether.dhcpSetup())
Serial.println("DHCP failed");
ether.printIp("IP: ", ether.myip);
ether.printIp("GW: ", ether.gwip);
ether.printIp("DNS: ", ether.dnsip);
if (!ether.dnsLookup(website))
Serial.println("DNS failed");
ether.printIp("SRV: ", ether.hisip);
}
void loop () {
ether.packetLoop(ether.packetReceive());
if (millis() > timer) {
timer = millis() + 10000;
byte sd = stash.create();
stash.print("operation=add&");
stash.print("value=");
stash.print("11");
stash.save();
// generate the header with payload - note that the stash size is used,
// and that a "stash descriptor" is passed in as argument using "$H"
Stash::prepare(PSTR("GET http://$F/$F.json HTTP/1.0" "\r\n"
"Host: $F" "\r\n"
"Content-Length: $D" "\r\n"
"Content-Type: application/x-www-form-urlencoded" "\r\n"
"\r\n"
"$H"),
website, PSTR(PATH), website, stash.size(), sd);
// send the packet - this also releases all stash buffers once done
ether.tcpSend();
}
}