Pages: [1]   Go Down
Author Topic: Arduino WiFi library and Copperhead v.2 wifi shield  (Read 731 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 40
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Greetings,

can someone help me understand why this WiFi library (comes with Arduino environment 1.03) does not work with the copperhead shield ? the shield works well with the Ada's WiShield library.

cheers,
Marian
Logged

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

Quote
can someone help me understand why this WiFi library (comes with Arduino environment 1.03) does not work with the copperhead shield ?
Because the library is written for a different chip from the one that the copperhead shield uses.

Quote
the shield works well with the Ada's WiShield library.
So, why aren't you using that library?
Logged

0
Offline Offline
Sr. Member
****
Karma: 7
Posts: 476
what?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thankfully i've only borrowed this idiot shield from my brother and not splashed out and bought it, has anyone actually got it to work?

I've cut my scetch down to the basics to try and debug it
Code:
#include <WiServer.h>

char buffer[5];

// Wireless configuration parameters ----------------------------------------
unsigned char local_ip[] = {192,168,2,10}; // 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 = {"Belkin"}; // max 32 bytes

void setup() {
  Serial.begin(9600);
  sprintf(buffer,"Local IP = %d,%d,%d,%d",local_ip[0],local_ip[1],local_ip[2],local_ip[3]);
  Serial.print(buffer);
  Serial.println();
  sprintf(buffer,"Gateway IP = %d,%d,%d,%d",gateway_ip[0],gateway_ip[1],gateway_ip[2],gateway_ip[3]);
  Serial.print(buffer);
  Serial.println();
}

void loop()
{

}

and this is what i get from the serial monitor

Code:
Local IP = 192,168,2,10
Gateway IP = 192,168,5,1

now if the gateway is defined as this
Code:
unsigned char gateway_ip[] = {192,168,2,1}; // router or gateway IP address
how the hell does it get this
Code:
Gateway IP = 192,168,5,1

I hate open source
Logged

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

Code:
  sprintf(buffer,"Gateway IP = %d,%d,%d,%d",gateway_ip[0],gateway_ip[1],gateway_ip[2],gateway_ip[3]);
Would you care to explain how all that stuff is supposed to fit in 5 bytes? That's how big your array is.

Quote
I hate open source
Well, I hate dumb coding.
Logged

0
Offline Offline
Sr. Member
****
Karma: 7
Posts: 476
what?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK, i guess you've answered my question

but i'll humour you,
Code:
gateway_ip[0]
gateway_ip[1]
gateway_ip[2]
gateway_ip[3]
is only 4 bytes

char buffer[5]; is all that is required
Logged

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

Quote
but i'll humour you,
Code:

gateway_ip[0]
gateway_ip[1]
gateway_ip[2]
gateway_ip[3]

is only 4 bytes

char buffer[5]; is all that is required
Wrong. You are using sprintf() to put "Gateway IP = " plus 3 commas plus 3 byte-sized values AS STRINGS plus the trailing NULL in the buffer. "Gate" and the trailing NULL fit in your 5 element buffer. None of the rest of the stuff fits.
Logged

Pages: [1]   Go Up
Jump to: