generic webservice reply

I am trying to create a simple web enabled sketch reacting to GET commands.
I am using an ENC28J60 module witn ethernet connection.

I strugle with some basics,

// I have two issues I need help with:

  1. Create a web page to display variable value on request (marked as QUESTION 1)
  2. Initiate a web service call after detecting a status change ( marked as QUESTION 2)

// I took took inspiration from the following 3 examples
// base put together from winkleink.blogspot.com
// The BackSoon example provided with the EtherCard library
// Present a “Will be back soon web page”, as stand-in webserver.
// 2011-01-30 jc@wippler.nl http://opensource.org/licenses/mit-license.php

// Example from the Internet
// enc28j60_tutorial/_5_BasicServer.ino at master · lucadentella/enc28j60_tutorial · GitHub

#include <EtherCard.h>

// ethernet mac address - must be unique on your network
static byte mymac = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
// ethernet interface ip address
static byte myip = { 192,168,0,200 };
// gateway ip address
static byte gwip = { 192,168,0,1 };
// dns ip address
static byte dnsip = { 192,168,0,1 };

byte Ethernet::buffer[400]; // tcp/ip send and receive buffer
static uint32_t timer;

const char website PROGMEM = “www.vg.no”;

const int hallsensor1 = 1;

// Small web page to return so the request is completed !! “const” er lagt til av Steffen 13.07.2015 – fikk feilelding om at char maate vr
const char page PROGMEM =
“HTTP/1.0 503 Service Unavailable\r\n”
“Content-Type: text/html\r\n”
“Retry-After: 600\r\n”
“\r\n”
“”
“”
“Arduino 192.168.0.200”
“”
“”

Arduino 192.168.0.200


“”
“”
;

//**************** WEB client start
// called when the client request is complete
static void my_callback (byte status, word off, word len) {
Serial.println(">>>");
Ethernet::buffer[off+300] = 0;
Serial.print((const char*) Ethernet::buffer + off);
Serial.println("…");
}
//**************** WEB client end

void(* resetFunc) (void) = 0; //declare reset function @ address 0

void setup(){

Serial.begin(57600);
Serial.println("\n[test 0.1]");

// Set Pin1 to be an Input
pinMode(hallsensor1, INPUT);

//intializing of the EtherCard -
ether.begin(sizeof Ethernet::buffer, mymac);
// Set IP using Static
ether.staticSetup(myip, gwip , dnsip);
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(){

word len = ether.packetReceive();
word pos = ether.packetLoop(len);

// *********** Activate ---- IF action=activate:

if(strstr((char *)Ethernet::buffer + pos, “GET /?action=activate”) != 0) {
Serial.println(“Received activation command”);

// do something

//Return a page so the request is completed.
memcpy_P(ether.tcpOffset(), page, sizeof page);
ether.httpServerReply(sizeof page - 1);
}

// ************* RESET STATUS
if(strstr((char *)Ethernet::buffer + pos, “GET /?action=Reset”) != 0) {
Serial.println(“Received Reset command”);

// do something else

//QUESTION 1
//Return a DIFERENT page so the request is completed.
memcpy_P(ether.tcpOffset(), page, sizeof page);
ether.httpServerReply(sizeof page - 1);
// THIS REPLY SHOULD BE UPDATED WITH VARABLES, HOW IS THIS DONE???

// Check if all is NOT OK and inform server about status.
if ( digitalRead(hallsensor1) == 1 )
{
// Hallstatus OK
Serial.println(“HallStatus = 1”);

}
else
{
// Hallstatus NOT OK!!
Serial.println(“HallStatus = 0”);

//QUESTION 2
//call “home” to web service showing multiple variable/values.
// ???
// HOW to do this??
}
}
}