Pages: [1]   Go Down
Author Topic: Problem in CODE for WiShield v1.0  (Read 2014 times)
0 Members and 1 Guest are viewing this topic.
ਪੰਜਾਬ
Offline Offline
Edison Member
*
Karma: 12
Posts: 1601
Another year! Alone! :(
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

This the Simple Server code:
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:
Code:









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:
/*
 * 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 - downloaded 27 times.)
« Last Edit: February 16, 2012, 04:07:08 am by NI$HANT » Logged

"Real Men can Accomplish  Anything"
-  Website  
- skype : nishants5  

ਫ਼ਤੇਹ ਕਰੂਂ !

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 208
Posts: 8854
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

ਪੰਜਾਬ
Offline Offline
Edison Member
*
Karma: 12
Posts: 1601
Another year! Alone! :(
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

"Real Men can Accomplish  Anything"
-  Website  
- skype : nishants5  

ਫ਼ਤੇਹ ਕਰੂਂ !

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 208
Posts: 8854
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

ਪੰਜਾਬ
Offline Offline
Edison Member
*
Karma: 12
Posts: 1601
Another year! Alone! :(
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
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
Logged

"Real Men can Accomplish  Anything"
-  Website  
- skype : nishants5  

ਫ਼ਤੇਹ ਕਰੂਂ !

ਪੰਜਾਬ
Offline Offline
Edison Member
*
Karma: 12
Posts: 1601
Another year! Alone! :(
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Got the code compiling with 0022 but with Arduino 1.0 still facing the following:
Code:

D:\Removable Disk\arduino-1.0\libraries\WiShield\WiServer.cpp:212: error: prototype for 'void Server::write(uint8_t)' does not match any in class 'Server'
D:\Removable Disk\arduino-1.0\libraries\WiShield\/WiServer.h:198: error: candidate is: virtual size_t Server::write(uint8_t)

never mind im using the 0022 to work with WiShield but to sharpen concepts it should be known that why this is causing problems in Arduino 1.0, Any one comes to know , Please make me understand as well!
Logged

"Real Men can Accomplish  Anything"
-  Website  
- skype : nishants5  

ਫ਼ਤੇਹ ਕਰੂਂ !

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 146
Posts: 6022
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have not looked at the shield code, but there were some changes made to the v1.0 ethernet shield write functions. The function that accepted a zero-terminated string was no longer in the library.
Instead of "Server.write(MyString)", try "Server.write(MyString, strlen(MyString))".
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Did anyone find a fix for the two errors NI$HANT reported? I'm getting the same errors when compiling the SimpleTweeter example. I tried SurferTim's suggestion but it just yielded more errors. I'm using Arduino 1.0.

Changing (in WiServer.cpp):
void Server::write(uint8_t b)
to
void Server::write(uint8_t b, strlen(uint8_t b))

Gave these errors:
C:\Desktop\arduino-1.0\libraries\WiShield\WiServer.cpp:212: error: 'strlen' is not a type
C:\Desktop\arduino-1.0\libraries\WiShield\WiServer.cpp:212: error: prototype for 'void Server::write(uint8_t, int (*)(uint8_t))' does not match any in class 'Server'
C:\Desktop\arduino-1.0\libraries\WiShield\/WiServer.h:198: error: candidate is: virtual size_t Server::write(uint8_t)
« Last Edit: March 07, 2012, 08:34:02 pm by fresheStF » Logged

ਪੰਜਾਬ
Offline Offline
Edison Member
*
Karma: 12
Posts: 1601
Another year! Alone! :(
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Got the code compiling with 0022 but with Arduino 1.0 still facing the following:
Code:

D:\Removable Disk\arduino-1.0\libraries\WiShield\WiServer.cpp:212: error: prototype for 'void Server::write(uint8_t)' does not match any in class 'Server'
D:\Removable Disk\arduino-1.0\libraries\WiShield\/WiServer.h:198: error: candidate is: virtual size_t Server::write(uint8_t)

never mind im using the 0022 to work with WiShield but to sharpen concepts it should be known that why this is causing problems in Arduino 1.0, Any one comes to know , Please make me understand as well!

If you refer to my above post as i quoted (look above for it in details) you will get to know that i solved the problem long time ago, please look above to solve these problems and use 0022 IDE not Arduino 1.0 it has some code problem's.

EDIT:

You just need 2 things to care here about:
1) Use 0022 Arduino IDE.
2) Replace the apps-config.h with the one i provided you in the attachment.

further you may contact me on nishant@winacro.com if you aren't able to make it work.

* apps-conf.h (1.77 KB - downloaded 13 times.)
« Last Edit: March 07, 2012, 11:50:24 pm by NI$HANT » Logged

"Real Men can Accomplish  Anything"
-  Website  
- skype : nishants5  

ਫ਼ਤੇਹ ਕਰੂਂ !

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The apps-conf.h file you attached isn't any different than the one I already have with the 1.0 version. I'm still getting the same two errors.
Logged

ਪੰਜਾਬ
Offline Offline
Edison Member
*
Karma: 12
Posts: 1601
Another year! Alone! :(
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The apps-conf.h file you attached isn't any different than the one I already have with the 1.0 version. I'm still getting the same two errors.

I'm assuming you checked the file i sent but didn't used the 0022 IDE

The apps-conf.h file is not related with 1.0 version its just this that the way Arduino 1.0 IDE deals with the WiShield library is different the 0022 IDE deals with the same. so please use 0022 IDE with this WiShield implication. first try with 0022 IDE then if things are fine then in that case put the same code in IDE 1.0 and try to sort out things there.
« Last Edit: March 08, 2012, 09:06:05 am by NI$HANT » Logged

"Real Men can Accomplish  Anything"
-  Website  
- skype : nishants5  

ਫ਼ਤੇਹ ਕਰੂਂ !

Seattle, WA
Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Got the code compiling with 0022 but with Arduino 1.0 still facing the following:
Code:

D:\Removable Disk\arduino-1.0\libraries\WiShield\WiServer.cpp:212: error: prototype for 'void Server::write(uint8_t)' does not match any in class 'Server'
D:\Removable Disk\arduino-1.0\libraries\WiShield\/WiServer.h:198: error: candidate is: virtual size_t Server::write(uint8_t)

never mind im using the 0022 to work with WiShield but to sharpen concepts it should be known that why this is causing problems in Arduino 1.0, Any one comes to know , Please make me understand as well!

I think you need to go into Server.cpp and change this:
Code:
void Server::write(uint8_t)
to this:
Code:
size_t Server::write(uint8_t)
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 614
Posts: 49343
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I think you need to go into Server.cpp and change this...to this...
You do, but you also need to add a return statement at the end of the function to return the number of bytes actually written.
Logged

Pages: [1]   Go Up
Jump to: