Problems with WiFly

Hi all

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.

Thanks for any help.

I've tried the suggested replacement in error 2 but that's not working.

Without seeing your code, and the EXACT error messages, all I can say is "Bummer".

Error 1) 'class WiFlyDevice' has no member named 'join'

So, quit trying to use it.

Some links, to the WiFi shield and library, would be useful, if you want us to help.

The shield:

The library:
http://forum.sparkfun.com/viewtopic.php?p=115626#p115626

The code:
/*

  • based on:
  • WiFly Autoconnect Example
  • Copyright (c) 2010 SparkFun Electronics. All right reserved.
  • Written by Chris Taylor
  • This code was written to demonstrate the WiFly Shield from SparkFun Electronics
  • This code will initialize and test the SC16IS750 UART-SPI bridge, and automatically
  • connect to a WiFi network using the parameters given in the global variables.
  • http://www.sparkfun.com
    */

#include "WiFly.h"

#include "Credentials.h"

void setup() {

Serial.begin(9600);
Serial.println("\n\r\n\rWiFly Shield Terminal Routine");

WiFly.begin();

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 tried the suggested replacement in error 2 but that's not working.

The suggested replacement was not:

SpiSerial.print(Serial.read(), BYTE);

On the library link page, there are two versions of the library listed Alpha 1 and Alpha 2. Which are you using?

The Alpha 2 version most definitely has 2 join methods. What exactly is the error message you are seeing?

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.

The two errors are the same as in the first post.

But, you said that you tried to fix one of them, and that the fix was not successful. Yet, the code you posted does not reflect that fact.

if (!WiFly.join(ssid, passphrase)) {

Are ssid and passphrase defined in Credentials.h? What does that file look like?

The code after I tryed to fix error 2:
/*

  • based on:
  • WiFly Autoconnect Example
  • Copyright (c) 2010 SparkFun Electronics. All right reserved.
  • Written by Chris Taylor
  • This code was written to demonstrate the WiFly Shield from SparkFun Electronics
  • This code will initialize and test the SC16IS750 UART-SPI bridge, and automatically
  • connect to a WiFi network using the parameters given in the global variables.
  • http://www.sparkfun.com
    */

#include "WiFly.h"

#include "Credentials.h"

void setup() {

Serial.begin(9600);
Serial.println("\n\r\n\rWiFly Shield Terminal Routine");

WiFly.begin();

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:
#ifndef CREDENTIALS_H
#define CREDENTIALS_H

// Wifi parameters
char passphrase[] = "81ccd015eb76424a2ed09770d8";
char ssid[] = "vinyl74dusin46tomme";

#endif

So:

Serial.print(SpiSerial.read(), BYTE);

became:

Serial.print(SpiSerial.write();

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 statement should have changed to:

Serial.write((byte)SpiSerial.read());

Do you by any chance have a working example of code that uses the sparkfun wifly shield and an Arduino Mega 2560?

Then I might be able to see some working code and adjust it to my needs.

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.

Hi,

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?

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.

PaulS:

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

Thanks.

Is there some standard way to debug this type of issue?

Pounding your head against the wall IS the standard way. You are doing it right.

It seems like it would be tough to track down

Timing issues, if that IS what you are having, usually are.

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