I am new to aruino. I a trying to grasp the basics for using client application. My end goal is to create a super simple app that will light a LED when the wishield connects to a network. However so far I cannot get an example from the library to work. I researched the some examples and found a program that controls leds from a web page, I keep receiving the same errors when I try to compile the program.
errors
In file included from try2.cpp:8:
C:\Program Files (x86)\arduino-1.0\libraries\WiShield/WiServer.h:198: error: conflicting return type specified for 'virtual void Server::write(uint8_t)'
C:\Program Files (x86)\arduino-1.0\hardware\arduino\cores\arduino/Print.h:48: error: overriding 'virtual size_t Print::write(uint8_t)'
I have found other post that stated solutions that required modifying included files in the wishield library. I have tried to follow these solutions with no luck. Being new i suspect that I am missing something. Could someone help me please??
Here is the programs code.
#include <WiShield.h>
#include <WiServer.h>
#define WIRELESS_MODE_INFRA 1
#define WIRELESS_MODE_ADHOC 2
// Wireless configuration parameters ----------------------------------------
unsigned char local_ip[] = {192,168,2,150}; // IP address of WiShield
unsigned char gateway_ip[] = {192,168,2,1}; // router or gateway IP address
unsigned char subnet_mask[] = {255,255,255,0}; // subnet mask for the local network
const prog_char ssid[] PROGMEM = {"jon_repeater"}; // max 32 bytes
unsigned char security_type = 3; // 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2
// WPA/WPA2 passphrase
const prog_char security_passphrase[] PROGMEM = {"jvjerp2009"}; // 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;
//---------------------------------------------------------------------------
int redState = 0;
int whiteState = 0;
int greenState = 0;
int redPin = 5;
int whitePin = 6;
int greenPin = 7;
// This is our page serving function that generates web pages
boolean sendMyPage(char* URL) {
if (strcmp(URL, "/red") == 0) redState = !redState;
if (strcmp(URL, "/white") == 0) whiteState = !whiteState;
if (strcmp(URL, "/green") == 0) greenState = !greenState;
digitalWrite(redPin, redState);
digitalWrite(whitePin, whiteState);
digitalWrite(greenPin, greenState);
// Check if the requested URL matches "/"
// if (strcmp(URL, "/") == 0) {
// Use WiServer’s print and println functions to write out the page content
WiServer.print("");
WiServer.print("Light Control
");
printLightStatus("red", redState);
printLightStatus("white", whiteState);
printLightStatus("green", greenState);
WiServer.print("The page you requested was: ");
WiServer.print(URL);
WiServer.print("
The arduino has been running for: ");
WiServer.print(millis());
WiServer.print(" milliseconds
");
WiServer.print("");
// URL was recognized
return true;
//}
// URL not found
return false;
}
void printLightStatus( String lightName, int lightState) {
WiServer.print(lightName);
WiServer.print(" Light is ");
if(lightState ==0) {
WiServer.print(" off <a href=/");
WiServer.print(lightName);
WiServer.print(">Turn On
");
} else {
WiServer.print(" on <a href=/");
WiServer.print(lightName);
WiServer.print(">Turn off
");
}
}
void setup() {
// Initialize WiServer and have it use the sendMyPage function to serve pages
WiServer.init(sendMyPage);
// Enable Serial output and ask WiServer to generate log messages (optional)
Serial.begin(57600);
WiServer.enableVerboseMode(true);
pinMode(redPin, OUTPUT);
pinMode(whitePin, OUTPUT);
pinMode(greenPin, OUTPUT);
}
void loop(){
// Run WiServer
WiServer.server_task();
delay(10);
}