à décrypter:
traite une chaîne de format et remplit un "buffer" situé je ne sais où, mais hors l'espace ram à utiliser dans Stash::prepare par le format $H !
n'est pas effac par tcpsend
// 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>
// ethernet interface mac address, must be unique on the LAN
byte mymac[] = { 0,1,2,3,4,5 };
char website[] PROGMEM = "wolpobox.logsm.net";
char target[100];
byte Ethernet::buffer[700];
uint32_t timer;
Stash stash;
int nb=0;
byte sd[2];
void setup () {
Serial.begin(9600);
Serial.println("\n[demo stah et prepare]");
if (ether.begin(sizeof Ethernet::buffer, mymac,10) == 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);
sd[0] = stash.create();
stash.println("bonjour monsieur le directeur! ");
stash.save();
sd[1] = stash.create();
stash.println("madmela drectrice ! ");
stash.save();
}
void loop () {
ether.packetLoop(ether.packetReceive());
if (millis() > timer) {
timer = millis() + 10000;
nb=nb+1;
// 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("$D PUT $H"),nb, sd[nb%2]);
stash.extract(0,stash.size(),&target);
Serial.println("------------------prepare:");
Serial.println((char*)target);
Serial.println("------------------:");
// send the packet - this also releases all stash buffers once done
ether.tcpSend();
}
}