Pages: [1] 2   Go Down
Author Topic: Problems with WiFly  (Read 2515 times)
0 Members and 1 Guest are viewing this topic.
Aalborg, Denmark
Offline Offline
Newbie
*
Karma: 0
Posts: 31
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 549
Posts: 46113
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

Aalborg, Denmark
Offline Offline
Newbie
*
Karma: 0
Posts: 31
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The shield:
http://www.sparkfun.com/products/9954

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);
  }
}
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 549
Posts: 46113
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I've tried the suggested replacement in error 2 but that's not working.
The suggested replacement was not:
Code:
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?
Logged

Aalborg, Denmark
Offline Offline
Newbie
*
Karma: 0
Posts: 31
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 549
Posts: 46113
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
if (!WiFly.join(ssid, passphrase)) {
Are ssid and passphrase defined in Credentials.h? What does that file look like?
Logged

Aalborg, Denmark
Offline Offline
Newbie
*
Karma: 0
Posts: 31
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 549
Posts: 46113
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So:
Code:
Serial.print(SpiSerial.read(), BYTE);
became:
Code:
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:
Code:
Serial.write((byte)SpiSerial.read());
Logged

Aalborg, Denmark
Offline Offline
Newbie
*
Karma: 0
Posts: 31
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 549
Posts: 46113
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

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:

https://github.com/jcrouchley/WiFly-Shield

Seems to be working well for me. Hopefully they will update the library with his updates soon. It also contains updated example code.
Logged

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

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:

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

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

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 549
Posts: 46113
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

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

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 549
Posts: 46113
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Quote
It seems like it would be tough to track down
Timing issues, if that IS what you are having, usually are.
Logged

Pages: [1] 2   Go Up
Jump to: