This the Simple Server code:
/*
* A simple sketch that uses WiServer to serve a web page
*/
#include <WiServer.h>
#define WIRELESS_MODE_INFRA 1
#define WIRELESS_MODE_ADHOC 2
// Wireless configuration parameters ----------------------------------------
unsigned char local_ip[] = {192,168,1,2}; // IP address of WiShield
unsigned char gateway_ip[] = {192,168,1,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 = {"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;
// End of wireless configuration parameters ----------------------------------------
// This is our page serving function that generates web pages
boolean sendMyPage(char * URL) {
// 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("<html>");
WiServer.print("Hello World!");
WiServer.print("</html>");
// URL was recognized
return true;
}
// URL not found
return false;
}
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);
}
void loop(){
// Run WiServer
WiServer.server_task();
delay(10);
}
These are the problems im facing:
SimpleServer.cpp.o: In function `loop':
C:\Users\nishant\AppData\Local\Temp\build6414769034696593230.tmp/SimpleServer.cpp:74: undefined reference to `WiServer'
C:\Users\nishant\AppData\Local\Temp\build6414769034696593230.tmp/SimpleServer.cpp:74: undefined reference to `WiServer'
C:\Users\nishant\AppData\Local\Temp\build6414769034696593230.tmp/SimpleServer.cpp:74: undefined reference to `Server::server_task()'
SimpleServer.cpp.o: In function `setup':
C:\Users\nishant\AppData\Local\Temp\build6414769034696593230.tmp/SimpleServer.cpp:64: undefined reference to `WiServer'
C:\Users\nishant\AppData\Local\Temp\build6414769034696593230.tmp/SimpleServer.cpp:64: undefined reference to `WiServer'
C:\Users\nishant\AppData\Local\Temp\build6414769034696593230.tmp/SimpleServer.cpp:64: undefined reference to `Server::init(unsigned char (*)(char*))'
C:\Users\nishant\AppData\Local\Temp\build6414769034696593230.tmp/SimpleServer.cpp:68: undefined reference to `Server::enableVerboseMode(unsigned char)'
SimpleServer.cpp.o: In function `sendMyPage(char*)':
C:\Users\nishant\AppData\Local\Temp\build6414769034696593230.tmp/SimpleServer.cpp:50: undefined reference to `WiServer'
C:\Users\nishant\AppData\Local\Temp\build6414769034696593230.tmp/SimpleServer.cpp:50: undefined reference to `WiServer'
C:\Users\nishant\AppData\Local\Temp\build6414769034696593230.tmp/SimpleServer.cpp:51: undefined reference to `WiServer'
C:\Users\nishant\AppData\Local\Temp\build6414769034696593230.tmp/SimpleServer.cpp:51: undefined reference to `WiServer'
C:\Users\nishant\AppData\Local\Temp\build6414769034696593230.tmp/SimpleServer.cpp:52: undefined reference to `WiServer'
SimpleServer.cpp.o:C:\Users\nishant\AppData\Local\Temp\build6414769034696593230.tmp/SimpleServer.cpp:52: more undefined references to `WiServer' follow
what possibly could be causing this, i have checked the functions in the WiServer.h things seem pretty much ok, have a copy of WiServer.h as an attachment.
However i got this working pretty much fine:
/*
* Web Server
*
* A simple web server example using the WiShield 1.0
*/
#include <WiShield.h>
#include "WiServer.h"
//#include "wiring.h"
//#include "Arduino.h"
//#include "Wiserver"
#define WIRELESS_MODE_INFRA 1
#define WIRELESS_MODE_ADHOC 2
// Wireless configuration parameters ----------------------------------------
unsigned char local_ip[] = {192,168,137,5}; // IP address of WiShield
unsigned char gateway_ip[] = {192,168,137,4}; // router or gateway IP address
unsigned char subnet_mask[] = {255,255,255,0}; // subnet mask for the local network
const prog_char ssid[] PROGMEM = {"WinacroWii"}; // 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_ADHOC;
unsigned char ssid_len;
unsigned char security_passphrase_len;
//---------------------------------------------------------------------------
void setup()
{
WiFi.init();
}
// This is the webpage that is served up by the webserver
const prog_char webpage[] PROGMEM = {"HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<center><h1>Hello World!! I am WiShield</h1><form method=\"get\" action=\"0\">Toggle LED:<input type=\"submit\" name=\"0\" value=\"LED1\"></input></form></center>"};
void loop()
{
WiFi.run();
}
WiServer.h (7.47 KB)