I'm reading a code that uses Arduino as a webclient and when he tries to catch the info from the site, he uses a callback with the following parameters:

static void response_callback (byte status, word off, word len)

Can anyone explain me how does each one of this parameters work exactly?

PS.: The example I got it from:

#include <EtherCard.h>

static byte mymac[] = {0x12,0x34,0x56,0x78,0x90,0xAB};
char website[] PROGMEM = "www.yourwebsite.com";

byte Ethernet::buffer[700];
static uint32_t timer = 0;

static void response_callback (byte status, word off, word len) {
  Serial.print((const char*) Ethernet::buffer + off + HTTP_HEADER_OFFSET);

void setup () {

  if (!ether.begin(sizeof Ethernet::buffer, mymac, 10))
    Serial.println("Failed to access Ethernet controller");
    Serial.println("Ethernet controller initialized");

  if (!ether.dhcpSetup())
    Serial.println("Failed to get configuration from DHCP");
    Serial.println("DHCP configuration done");

  if (!ether.dnsLookup(website))
    Serial.println("DNS failed");
    Serial.println("DNS resolution done"); 

  ether.printIp("SRV IP:\t", ether.hisip);

void loop() {

  if (millis() > timer) {
    timer = millis() + 5000;
    ether.browseUrl("/", "yourpage.php", website, response_callback);
  • Where do you get that callback signature? – fabrosell Mar 28 '16 at 14:13
  • Just added the example I got it from – Vinícius Affonso Mar 28 '16 at 14:31
  • The Arduino world indeed often lacks traditionally detailed API documentation. One fallback is to do a full-text search (with a GUI tool or grep -R ) of the library folders and installation for the function name, and find its actually source code to study. – Chris Stratton May 27 '16 at 19:03

Apparently, the callback is executed on every packet which arrives by the browseUrl call.

"off" and "len" are pointers to the Ethernet buffer holding the data. "Off" are the initial value (offset) and "len" (length) is the amount of data received.

"byte status", I am not sure what it means, but it's very likely will be some kind of error code. It's not being used in any sample I am seeing, so I am really wondering what it means...

Check this link for a fully working sample

Callback here are called browseUrlCallback1 and browseUrlCallback2.

Can't figure out a link with the detailed documentation. If someone has it, please post it.

  • Could it be this product: jeelabs.org/pub/docs/ethercard ? – ott-- Mar 28 '16 at 19:47
  • Yeah, but as all I have found, it lacks specific documentation about callback details. BrowseUrl is well documented as usual, but it just specifies how the callback method has to be defined, not what does each parameter mean. – fabrosell Mar 28 '16 at 19:56
  • 1
    Thats exactly my problem, I can't find its documentation anywhere! Btw, thx for the response! – Vinícius Affonso Mar 28 '16 at 21:35
  • It's all in the source. In the file tcpip.cpp in the ethercard-master.zip you find the function static uint8_t www_client_internal_result_cb. There you see how status is derived from the HTTP status code, like uint8_t f = strncmp("200",(char *)&(gPB[datapos+9]),3) != 0;. Why waste any other space in a docfile nobody likes to write or even read? – ott-- Mar 29 '16 at 0:00
  • They are not actually pointers. "off" is presumably an offset index while "len" is a count or size. – Chris Stratton May 27 '16 at 19:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.