Pauly, please try the following - search "YPort" for the changes
I made. This is a completed sketch.
/*
* Web Server
*
* A simple web server example using the WiShield 1.0
*/
#include <WiShield.h>
#define WIRELESS_MODE_INFRA 1
#define WIRELESS_MODE_ADHOC 2
// Wireless configuration parameters ----------------------------------------
unsigned long local_ip = IP_ADDR(192,168,1,2);
const prog_char ssid[] PROGMEM = {"ASYNCLABS"}; // max 32 bytes
unsigned char security_type = 0; // 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2
// WPA/WPA2 passphrase
const prog_char security_passphrase[] PROGMEM = {"12345678"}; // max 64 characters
// WEP 128-bit keys
// sample HEX keys
prog_uchar wep_keys[] PROGMEM = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, // Key 0
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 1
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 2
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Key 3
};
// setup the wireless mode
// infrastructure - connect to AP
// adhoc - connect to another WiFi device
unsigned char wireless_mode = WIRELESS_MODE_INFRA;
unsigned char ssid_len;
unsigned char security_passphrase_len;
//---------------------------------------------------------------------------
// Webpages served by the webserver
//
// Due to the RAM limitation, the largest data packet that the application can
// transmit is limited to 446 bytes. Larger webpages can be broken down into
// smaller chunks and transmitted as shown in the code below to overcome this
// limitation
//YPort
const prog_char webpage[] PROGMEM = {"HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<center><p><h1>WiShield Temprature 0000 F!</h1></p></center>"};
unsigned int webpage_len;
void setup()
{
// Initialize the WiFi device
// Resets the WiFi device and sets up the interrupt
WiFi.init();
Serial.begin(9600);
}
#define APP_IDLE 0
#define APP_MORE_DATA 1
void loop()
{
char temp[5] = "78.9"; //Yport
char* data; // variable pointing to the data received from the client
unsigned int data_len; //length of data received from the client
unsigned char app_state = APP_IDLE;
webpage_len = strlen_P(webpage); // length of the webpage
WiFi.server_listen(80); // start server on port 80 (HTTP)
while(1) {
WiFi.driver_task(); // run WiFi driver task
WiFi.stack_task(); // run stack task
data = (char*)WiFi.data_available(&data_len);
if (data_len) {
// process data
Serial.println(data);
if (memcmp(data, "GET / ", 6) == 0) {
// copy data into TX buffer
memcpy_P(data, webpage, webpage_len);
memcpy(&data[80], temp, 4); // YPort
WiFi.send_data(webpage_len);
// indicate this was the last chunk for TX
WiFi.set_more_data(1);
}
else {
WiFi.send_data(0);
WiFi.set_more_data(1);
}
// we run the stack task again here to allow the stack
// to package the app data and set it up for TX when
// the driver task runs the next time
WiFi.stack_task();
}
}
}