When trying to use the Sparkfun Wifly shield an Wifly Library I get these to errors when trying to compile the code (I'm trying with the Wifly_Autoconnect_Terminal example)
Error 1) 'class WiFlyDevice' has no member named 'join'
Error 2) As of Arduino 1.0, the 'BYTE' keyword is no longer supported. Please use Serial.write() instead.
I've tried the suggested replacement in error 2 but that's not working.
if (!WiFly.join(ssid, passphrase)) {
Serial.println("Association failed.");
while (1) {
// Hang on failure.
}
}
Serial.println("Associated!");
}
void loop() {
// Terminal routine
// Always display a response uninterrupted by typing
// but note that this makes the terminal unresponsive
// while a response is being received.
while(SpiSerial.available() > 0) {
Serial.print(SpiSerial.read(), BYTE);
}
if(Serial.available()) { // Outgoing data
SpiSerial.print(Serial.read(), BYTE);
}
}
I've downloaded the alpha 2 one, but when I open the readme.txt it says alpha 1 in the beginning so honestly I'm not sure.
The two errors are the same as in the first post.
if (!WiFly.join(ssid, passphrase)) {
Serial.println("Association failed.");
while (1) {
// Hang on failure.
}
}
Serial.println("Associated!");
}
void loop() {
// Terminal routine
// Always display a response uninterrupted by typing
// but note that this makes the terminal unresponsive
// while a response is being received.
while(SpiSerial.available() > 0) {
Serial.print(SpiSerial.write();
}
if(Serial.available()) { // Outgoing data
SpiSerial.print(Serial.write();
}
}
The credintials.h file: #ifndefCREDENTIALS_H #defineCREDENTIALS_H
I'm trying to figure out how why you changed SpiSerial.read(), BYTE) to SpiSerial.write(), when the error message said that Serial.print() no longer supported the BYTE argument, and should be replaced by Serial.write().
The code you posted initially, and the library you posted a link to, compile and link fine on Arduino 0022.
I had to change the sketch and 5 files in the library (SpiUart.cpp, Client.cpp, Client.h, SpiUart.h, and _Spi.h) to make the sketch and library compile and link on Arduino 1.0.
Since I do not have a WiFly shield to test the modified code on, I'm reluctant to post it.
I'll tell you what I changed, though. In _Spi.h, change WProgram.h to Arduino.h. In the other two header files, change all void write() function definitions to size_t write(). In the cpp files, change the implementations of the write() functions to have a return type of size_t and add a return statement to each function. In Client.cpp, that's just a matter of adding return in front of the single statement in the function body. In SpiUart.cpp, you need to add a return statement to return the number of characters actually written. That value is different in each of the three functions, but it should be fairly obvious what value to return in each case.
I had similar problems this weekend. It seems that the WiFly library is not updated for Arduino 1.0. This guy did a pull request of the library and has updated it to 1.0:
Seems to be working well for me. Hopefully they will update the library with his updates soon. It also contains updated example code.
So it turns out the WiFly library never "connects" for me, but here is what I have found:
If I go back from Arduino 1.0 to the previous version, the Sparkfun library works. So I tried to modify their library myself to get it to work with 1.0 and it does the same thing at this pull request I posted above. The funny thing I've noticed is that if I change this:
WiFlyClient client = server.available();
if (client > 0) {
Serial.println("Client");
// an http request ends with a blank line
boolean current_line_is_blank = true;
while (client.connected()) {
to this:
WiFlyClient client = server.available();
Serial.println(client);
if (client > 0) {
Serial.println("Client");
// an http request ends with a blank line
boolean current_line_is_blank = true;
while (client.connected()) {
It registers the connect properly.. Showing 0 over and over until I try to connect, I get a 1 and then it continues on as it should. If I remove that Serial.println, it stops working again.. Any ideas what would cause this strange behavior?
Does a delay(10) in place of the print cause the same "improvement"? This would indicate some kind of timing issue.
I am pretty sure I've done this and it did work.. I will verify it tonight at home. Is there some standard way to debug this type of issue? It seems like it would be tough to track down and I haven't change anything significant..
Another thing I would like to add, is that it does seem to be connecting when I don't have the println in there. The light on the wifly shield turns a solid green and if I telnet and type characters I see the red light flashing (Which I believe means it is receiving data over the connection).