Go Down

Topic: Arduino WiFi library and Copperhead v.2 wifi shield (Read 862 times) previous topic - next topic

MaLi

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

PaulS

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?

P18F4550

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: [Select]
#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: [Select]
Local IP = 192,168,2,10
Gateway IP = 192,168,5,1


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

I hate open source

PaulS

Code: [Select]
  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.

P18F4550

OK, i guess you've answered my question

but i'll humour you,
Code: [Select]
gateway_ip[0]
gateway_ip[1]
gateway_ip[2]
gateway_ip[3]

is only 4 bytes

char buffer[5]; is all that is required

PaulS

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.

Go Up