Project

General

Profile

What is the browseUrl callback for ?

Added by DaveOB over 4 years ago

I have been using an Arduino Mega 2560 for a few months, with an ethernet module and your ethercard library - Thank You for that - it is brilliant. :)

I am a DIY hobby coder, so no real experience, other than what I see and learn as I go along.

Problem I have now is I need to make a different project and there is something that I can not understand, and can not find any documentation on that I can understand.

I have code that includes :

#include 
char website[] PROGMEM = "";

void SendDataToServer(char* SendTxt) { 
 ether.persistTcpConnection(true); 
 ether.browseUrl(PSTR("/aaa/bbb/ccc.php?"), SendTxt, website, my_callback);
}

static void my_callback (byte status, word off, word len) {
 // called when the client request is complete
 delay(300);
 Ethernet::buffer[off+300] = 0;
}

so the text / string / data / whatever, to send to the ccc.php page is set in SendTxt, and then I call the SendDataToServer function.

This part I think I understand.

The ether.browseUrl ( function ? ) does the ‘work’ and puts the response received from the php script in the Ethernet::buffer, and calls the callback function : my_callback.

So if the php script outputs a page of text in response to the browse URL, that returned data is put in the Ethernet::buffer.

What I can’t find reference to, or a simple plain explanation for, is the 3 parameters in the my_callback function :

byte status
word off
word len

Once I have any idea of what these are, next question would be : what is the purpose of the line:

Ethernet::buffer[off+300] = 0;