Go Down

Topic: Problem in CODE for WiShield v1.0 (Read 2 times) previous topic - next topic

NI$HANT

Feb 16, 2012, 10:04 am Last Edit: Feb 16, 2012, 10:07 am by NI$HANT Reason: 1
This the Simple Server code:
Code: [Select]
/*
* 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:
Code: [Select]










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:
Code: [Select]
/*
* 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();
}
"Real Men can Accomplish  Anything"
-  Website  
- skype : nishants5  

????? ???? !

johnwasser

For some reason your compile is finding WiServer.h but not the library containing WiServer.cpp.

It's not clear if the library should be named WiShield or WiServer.  If the only include file is called WiServer it may be necessary to name the library WiServer.  Perhaps WiShield.h should be included before WiServer.h?  Very confusing.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

NI$HANT

Hi John , WiServer and WiShield are two separate libraries existing in the same repository and also both WiServer and WiShield cpp files are also there , Arduino 1.0 problem it seems
"Real Men can Accomplish  Anything"
-  Website  
- skype : nishants5  

????? ???? !

johnwasser

I think Arduino 1.0 finds the libraries to build by matching .h filenames to library folders.  I suspect the library folder is called "WiShield" and not "WiServer".  Perhaps if you added a "#include <WiShield.h>" before the "#include <WiServer.h>" it would build and link the full library.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

NI$HANT

Now im using the Arduino IDE version 0022 and now i get the following error's:

Code: [Select]
SimpleServer.cpp.o: In function `loop':
C:\Users\nishant\AppData\Local\Temp\build2704773252878641827.tmp/SimpleServer.cpp:74: undefined reference to `WiServer'
C:\Users\nishant\AppData\Local\Temp\build2704773252878641827.tmp/SimpleServer.cpp:74: undefined reference to `WiServer'
C:\Users\nishant\AppData\Local\Temp\build2704773252878641827.tmp/SimpleServer.cpp:74: undefined reference to `Server::server_task()'
SimpleServer.cpp.o: In function `setup':
C:\Users\nishant\AppData\Local\Temp\build2704773252878641827.tmp/SimpleServer.cpp:64: undefined reference to `WiServer'
C:\Users\nishant\AppData\Local\Temp\build2704773252878641827.tmp/SimpleServer.cpp:64: undefined reference to `WiServer'
C:\Users\nishant\AppData\Local\Temp\build2704773252878641827.tmp/SimpleServer.cpp:64: undefined reference to `Server::init(unsigned char (*)(char*))'
C:\Users\nishant\AppData\Local\Temp\build2704773252878641827.tmp/SimpleServer.cpp:68: undefined reference to `Server::enableVerboseMode(unsigned char)'
SimpleServer.cpp.o: In function `sendMyPage(char*)':
C:\Users\nishant\AppData\Local\Temp\build2704773252878641827.tmp/SimpleServer.cpp:50: undefined reference to `WiServer'
C:\Users\nishant\AppData\Local\Temp\build2704773252878641827.tmp/SimpleServer.cpp:50: undefined reference to `WiServer'
C:\Users\nishant\AppData\Local\Temp\build2704773252878641827.tmp/SimpleServer.cpp:51: undefined reference to `WiServer'
C:\Users\nishant\AppData\Local\Temp\build2704773252878641827.tmp/SimpleServer.cpp:51: undefined reference to `WiServer'
C:\Users\nishant\AppData\Local\Temp\build2704773252878641827.tmp/SimpleServer.cpp:52: undefined reference to `WiServer'
SimpleServer.cpp.o:C:\Users\nishant\AppData\Local\Temp\build2704773252878641827.tmp/SimpleServer.cpp:52: more undefined references to `WiServer' follow
"Real Men can Accomplish  Anything"
-  Website  
- skype : nishants5  

????? ???? !

Go Up