I have the following code:
// Simple demo for feeding some random data to Pachube.
// 2011-07-08 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php
#include <EtherCard.h>
// change these settings to match your own setup
#define FEED "98772"
#define APIKEY " " // empty due too online post
// ethernet interface mac address, must be unique on the LAN
byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
// Static IP configuration to use if no DHCP found
// Change these to match your site setup
static byte static_ip[] = { 192,168,1,110};
static byte static_gw[] = { 192,168,1,1};
char website[] PROGMEM = "api.cosm.com";
byte Ethernet::buffer[700];
uint32_t timer;
Stash stash;
void setup () {
Serial.begin(115200);
Serial.println("\n[webClient]");
if (ether.begin(sizeof Ethernet::buffer, mymac,10) == 0)
printf_P(PSTR( "Failed to access Ethernet controller\n\r"));
if (!ether.dhcpSetup())
{
printf_P(PSTR("DHCP failed, using static configuration\n\r"));
ether.staticSetup(static_ip, static_gw);
}
ether.printIp("IP: ", ether.myip);
ether.printIp("GW: ", ether.gwip);
ether.printIp("DNS: ", ether.dnsip);
if (!ether.dnsLookup(website))
printf_P(PSTR("DNS failed\n\r"));
ether.printIp("SRV: ", ether.hisip);
}
void loop () {
ether.packetLoop(ether.packetReceive());
if (millis() > timer) {
timer = millis() + 10000;
byte sd = stash.create();
stash.print("0,"); // 5 est le numero du datastream
stash.println(30);
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("PUT http://api.cosm.com/v2/feeds/98772.csv HTTP/1.0" "\r\n"
"Host: $F" "\r\n"
"X-PachubeApiKey: $F" "\r\n"
"Content-Length: $D" "\r\n"
"\r\n"
"$H"),
website, PSTR(FEED), website, PSTR(APIKEY), stash.size(), sd);
Serial.println("SEND");
// send the packet - this also releases all stash buffers once done
ether.tcpSend();
}
}
It prints out the following on my serialmonitor:
[webClient]
IP: 192.168.1.105
GW: 192.168.1.1
DNS: 192.168.1.1
SRV: 216.52.233.121
SEND
SEND
SEND
SEND
SEND
Yet there is no update on my feed from cosm.
https://cosm.com/feeds/98772 What am I doing wrong? Please if anyone can assist.