Go Down

Topic: Undefined reference to 'WiServer' (Read 78 times) previous topic - next topic

Sjaro

Hello,
I have some errors and i don't understand why:

...\AppData\Local\Temp\build211053159388385527.tmp/sketch_dec01a.cpp:352: undefined reference to `WiServer'

I have IDE 0023 and I added the WiShield librairy. I put it in 'libraries' directory of my arduino-0023

Thank you in advance

(Sorry for my english)

holmes4

You have not declared WiServer.

Mark

Sjaro

I do include WiServer like this: #include <WiServer.h> but he does not recognize WiServer

holmes4

I said declare NOT include You must do BOTH!

Mark

Sjaro

I am sorry but i do not really know how to declare my WiServer, yn my main code i have  this :



Code: [Select]

#include <WiServer.h>
...
void setup()
{
     WiServer.init (WebPage);//initialize server/send HTML
...


I initialize my WiServer but it is not declared by doing this. Do I have to change something outside my main code, in my librairies ?

Thank you for your patience :smiley-confuse:

johnwasser

Look for example sketches provided with the library:

         File->Examples->libraryname->examplename

Look for one likely to use the WiServer functions and see how they write the code.  It may have to be something like:
Code: [Select]

#include <WiServer.h>
WiServer myWiServer(arguments);
...
void setup()
{
     myWiServer.init(WebPage); //initialize server/send HTML
...
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Sjaro

Thank you for your reponse,
I tried to declare my WiServer like this at the beginning of my program WiServer MyWiServer(); and a new error occurs : error: 'WiServer' does not name a type

I looked for different simple exemple and tried them. The same error keep coming :

undefined reference to `WiServer'

That let me think that my librairy is not well installed and not recognize by my arduino 0023...

Here is the code I use


johnwasser

Looks like you had it right the first time.  Below is the "SimpleServer" example that comes with the WiServer library.  If that doesn't work there must be something wrong with your installation of the library.  Try deleting the libraries/WiServer folder and installing it again from GitHub.

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);
}
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Sjaro

I  tried to add WiServer.h librairie to Arduino 1.0 and i have the same error. I download another librairy this one : https://github.com/asynclabs/WiShield_user_contrib#sthash.83rox7zl.dpuf . I keep having error. I think I'll remake my code with arduino 1.06 and the new WiFi librairy.
Wish me luck :)

Go Up