Pages: 1 ... 3 4 [5]   Go Down
Author Topic: WiFlyHQ: A new library for the WiFly RN-XV  (Read 23986 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi sbright33,

How can I submit the command set wlan linkmon 5 to the WiFly RN-XV?

Andreas
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for that library - it's the only one I could get to work! I was able to create a sketch to tweet data from an EZ1 ultrasonic rangefinder, with an Uno. Works fine... for a while, but then stops tweeting after a while - seems to get 'stuck' trying to connect to the network. Any ideas, improvements etc welcome! Code is here: https://github.com/hackinstance/WiFly_twitter
Logged

Offline Offline
Edison Member
*
Karma: 6
Posts: leet
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Without looking at the library today, can't you just use print()?
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey!
great library thanks alot.
Im having an issue that u'll probably find easy to explain:
after couple of minutes running, I'm getting the message: "WiFly has crashed and will reboot..."

only restarting the arduino recover from this

how can i overcome this? is it familiar issue? can i recover the arduino from the software in this case?

TX!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi guys,
I get the following error message

Free memory: 1333
setPrompt failed
Failed to enter command mode
Failed to start wifly
Terminal ready

My configuration is Arduino UNO REV2, Arduino wireless SD Shield, RN-XV. I have bend out pin 1 and 2 (no Connection the uno) of the arduino wireless shield. Pin 1 and 2 are connected to pin 8 and 9 of the Arduino wireless shield because of SoftwareSerial(8,9). 

My approach is:
1. The jumper of the Arduino wireless shield is switch to USB
2. Upload the httpserver sketch to Arduino short flash of the middle LED RN-XV
3. Switch Jumper of the Arduino wireless shield to MICRO
4. The PWR LED on the Arduino wireless shield  is blinking red
5  The LED on the RN-XV flashes alternate

Any idea what is wrong with my configuration.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 37
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Do you have any idea how to set up a Java Type webserver page?
I want to beable to update the data "Live".
It doesnt need to be java (because i really have no clue about webpages, and i want to display a graph so i will be learning alot)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,
I need your help.
I have been trying for days to get the wifly rn-xv module to work.

I have tried several libraries, WiflyHQ being one of them.
I'm using arduino uno rev3, wifly rn-xv from Roving Networks on a Sparkfun xbee shield. (Cant remember exactly which one, but it looks like this: https://www.sparkfun.com/products/9588)
I have bent pins (of the shield) 1 and 2 away from the arduino and connected them with jumpers to pin 8 and 9 (also tried 9 and smiley-cool

But no matter what I do, I keep getting this result:

Starting
Free memory: 1303
setPrompt failed
Failed to enter command mode
Failed to start wifly
Terminal ready


I am able to start the module in ad-hoc mode. I have giving it a fixed ip (192.168.1.128)
I can telnet into it over port 2000.

What am I doing wrong?????

Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 37
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

First thing i did was check the BAUD Rate. so since you can telnet into it, set the baud rate to whatever it is in the library. that should clear the problem you are having.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 5
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is there a way to check if the server to which the Wifly has connected has dropped the (TCP) connection?

If I connect to a server and then close the socket (at the server side) then the Wifly still sees it as an active connection.

Code:
wifly.isConnected()
and
Code:
wifly.available()
only seem to update if I manually close the connection.
Logged

South Africa
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I was having problems with this library when running it on an uno with the rnxv module. I switched out the uno for a mega, and used only hardware serial connections and all seems to work fine.

Can anyone shed some insight on this?
Is there maybe clash between the softwareSerial and wiflyHQ library? (im running arduino 1.0)
I have ruled out hardware issues by trying on a few uno's with the same results.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 30
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I'm having trouble with trying to read the NTP time with the library, could someone please point out what I'm doing wrong?  I'm only getting the uptime, I'm not getting the NTP time.

Code:
  wifly.setTimeAddress("129.6.15.28");
  wifly.setTimePort(123);
  wifly.setTimezone(+5);
  wifly.setTimeEnable(1);
 
  delay(1000);
  char MyTime[20];
  wifly.getTime(MyTime, 20);
 
  Serial.println(MyTime);
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm having trouble with trying to read the NTP time with the library, could someone please point out what I'm doing wrong?  I'm only getting the uptime, I'm not getting the NTP time.
This is because, unless you save the configuration after setting Time Enable to 1, it will not automatically update.  Code was just added today to enable the "time" function, which updates the internal RTC: https://github.com/harlequin-tech/WiFlyHQ/pull/28

Edit: So the way to update the RTC clock would be:
Code:
  wifly.setTimeAddress("129.6.15.28");
  wifly.setTimePort(123);
  wifly.setTimezone(5);
  wifly.setTimeEnable(5);
  wifly.time();
« Last Edit: July 25, 2013, 10:33:19 am by gobbledygook » Logged

Palo Alto, CA
Offline Offline
Newbie
*
Karma: 0
Posts: 15
Open Source Electric Cars! eMotorWerks.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Guys - awesome lib - saved sooooooooo much time! Thanks!

One question (sorry if I missed it on the prev pages): is there a way to call wps_app with this library? If not, how would you do it?

Thanks!
valery
Logged


Palo Alto, CA
Offline Offline
Newbie
*
Karma: 0
Posts: 15
Open Source Electric Cars! eMotorWerks.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

another question - just tried to port some of my code using this lib to Arduino Due and found out it does not compile due to a few avr-specific includes and use of prog_xxx variable types. Has anyone solved this?
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I use Arduino Mega 2560 with Arduino Shield Xbee v1.1 and WiFi module Roving Networks RN XV 171B.
I'm using this code:

Code:
/*
 * WiFlyHQ Example httpserver.ino
 *
 * This sketch implements a simple Web server that waits for requests
 * and serves up a small form asking for a username, then when the
 * client posts that form the server sends a greeting page with the
 * user's name and an analog reading.
 *
 * This sketch is released to the public domain.
 *
 */

 /* Notes:
  * Uses chunked message bodies to work around a problem where
  * the WiFly will not handle the close() of a client initiated
  * TCP connection. It fails to send the FIN to the client.
  * (WiFly RN-XV Firmware version 2.32).
  */

/* Work around a bug with PROGMEM and PSTR where the compiler always
 * generates warnings.
 */
#undef PROGMEM
#define PROGMEM __attribute__(( section(".progmem.data") ))
#undef PSTR
#define PSTR(s) (__extension__({static prog_char __c[] PROGMEM = (s); &__c[0];}))

#include <WiFlyHQ.h>

#include <SoftwareSerial.h>
SoftwareSerial wifiSerial(8,9);

//#include <AltSoftSerial.h>
//AltSoftSerial wifiSerial(8,9);

WiFly wifly;

/* Change these to match your WiFi network */
const char mySSID[] = "<nome SSID>";
const char myPassword[] = "<password WIFI>";

void sendIndex();
void sendGreeting(char *name);
void send404();

char buf[80];

void setup()
{
    Serial.begin(9600);
    Serial.println(F("Starting"));
    Serial.print(F("Free memory: "));
    Serial.println(wifly.getFreeMemory(),DEC);

    wifiSerial.begin(9600);
    if (!wifly.begin(&wifiSerial, &Serial)) {
        Serial.println(F("Failed to start wifly"));
wifly.terminal();
    }

    /* Join wifi network if not already associated */
    if (!wifly.isAssociated()) {
/* Setup the WiFly to connect to a wifi network */
Serial.println(F("Joining network"));
wifly.setSSID(mySSID);
wifly.setPassphrase(myPassword);
wifly.enableDHCP();
wifly.save();

if (wifly.join()) {
    Serial.println(F("Joined wifi network"));
} else {
    Serial.println(F("Failed to join wifi network"));
    wifly.terminal();
}
    } else {
        Serial.println(F("Already joined network"));
    }

    wifly.setBroadcastInterval(0); // Turn off UPD broadcast

    //wifly.terminal();

    Serial.print(F("MAC: "));
    Serial.println(wifly.getMAC(buf, sizeof(buf)));
    Serial.print(F("IP: "));
    Serial.println(wifly.getIP(buf, sizeof(buf)));

    wifly.setDeviceID("Wifly-WebServer");

    if (wifly.isConnected()) {
        Serial.println(F("Old connection active. Closing"));
wifly.close();
    }

    wifly.setProtocol(WIFLY_PROTOCOL_TCP);
    if (wifly.getPort() != 80) {
        wifly.setPort(80);
/* local port does not take effect until the WiFly has rebooted (2.32) */
wifly.save();
Serial.println(F("Set port to 80, rebooting to make it work"));
wifly.reboot();
delay(3000);
    }
    Serial.println(F("Ready"));
}

void loop()
{
    if (wifly.available() > 0) {

        /* See if there is a request */
if (wifly.gets(buf, sizeof(buf))) {
    if (strncmp_P(buf, PSTR("GET / "), 6) == 0) {
/* GET request */
Serial.println(F("Got GET request"));
while (wifly.gets(buf, sizeof(buf)) > 0) {
    /* Skip rest of request */
}
sendIndex();
Serial.println(F("Sent index page"));
    } else if (strncmp_P(buf, PSTR("POST"), 4) == 0) {
        /* Form POST */
        char username[16];
        Serial.println(F("Got POST"));

/* Get posted field value */
if (wifly.match(F("user="))) {
    wifly.gets(username, sizeof(username));
    wifly.flushRx(); // discard rest of input
    sendGreeting(username);
    Serial.println(F("Sent greeting page"));
}
    } else {
        /* Unexpected request */
Serial.print(F("Unexpected: "));
Serial.println(buf);
wifly.flushRx(); // discard rest of input
Serial.println(F("Sending 404"));
send404();
    }
}
    }
}

/** Send an index HTML page with an input box for a username */
void sendIndex()
{
    /* Send the header direclty with print */
    wifly.println(F("HTTP/1.1 200 OK"));
    wifly.println(F("Content-Type: text/html"));
    wifly.println(F("Transfer-Encoding: chunked"));
    wifly.println();

    /* Send the body using the chunked protocol so the client knows when
     * the message is finished.
     * Note: we're not simply doing a close() because in version 2.32
     * firmware the close() does not work for client TCP streams.
     */
    wifly.sendChunkln(F("<html>"));
    wifly.sendChunkln(F("<title>WiFly HTTP Server Example</title>"));
    wifly.sendChunkln(F("<h1>"));
    wifly.sendChunkln(F("<p>Hello</p>"));
    wifly.sendChunkln(F("</h1>"));
    wifly.sendChunkln(F("<form name=\"input\" action=\"/\" method=\"post\">"));
    wifly.sendChunkln(F("Username:"));
    wifly.sendChunkln(F("<input type=\"text\" name=\"user\" />"));
    wifly.sendChunkln(F("<input type=\"submit\" value=\"Submit\" />"));
    wifly.sendChunkln(F("</form>"));
    wifly.sendChunkln(F("</html>"));
    wifly.sendChunkln();
}

/** Send an greeting HTML page with the user's name and an analog reading */
void sendGreeting(char *name)
{
    /* Send the header direclty with print */
    wifly.println(F("HTTP/1.1 200 OK"));
    wifly.println(F("Content-Type: text/html"));
    wifly.println(F("Transfer-Encoding: chunked"));
    wifly.println();

    /* Send the body using the chunked protocol so the client knows when
     * the message is finished.
     */
    wifly.sendChunkln(F("<html>"));
    wifly.sendChunkln(F("<title>WiFly HTTP Server Example</title>"));
    /* No newlines on the next parts */
    wifly.sendChunk(F("<h1><p>Hello "));
    wifly.sendChunk(name);
    /* Finish the paragraph and heading */
    wifly.sendChunkln(F("</p></h1>"));

    /* Include a reading from Analog pin 0 */
    snprintf_P(buf, sizeof(buf), PSTR("<p>Analog0=%d</p>"), analogRead(A0));
    wifly.sendChunkln(buf);

    wifly.sendChunkln(F("</html>"));
    wifly.sendChunkln();
}

/** Send a 404 error */
void send404()
{
    wifly.println(F("HTTP/1.1 404 Not Found"));
    wifly.println(F("Content-Type: text/html"));
    wifly.println(F("Transfer-Encoding: chunked"));
    wifly.println();
    wifly.sendChunkln(F("<html><head>"));
    wifly.sendChunkln(F("<title>404 Not Found</title>"));
    wifly.sendChunkln(F("</head><body>"));
    wifly.sendChunkln(F("<h1>Not Found</h1>"));
    wifly.sendChunkln(F("<hr>"));
    wifly.sendChunkln(F("</body></html>"));
    wifly.sendChunkln();
}

If i enter in Serial Monitor from Arduino IDE i saw the following messages:
Code:
Starting
Free memory: 6918
setPrompt failed
Failed to enter command mode
Failed to start wifly
Terminal ready

If instead access with a web browser to address IP of Arduino i saw that browser is always waiting a response from Arduino.

Is it correct this configuration?

I executed these steps:
- uploaded on microcontroller Arduino without Arduino Xbee v1.1 Shield this code:
Code:
void setup(){} void loop(){}
- pluged Arduino Xbee v1.1 Shield on microcontroller
- jumper in USB mode
- enter in command mode '$$$' on wifi module and configured wifi module with this command:
Code:
set w s <SSID Wifi>
set w p <password Wifi>
save
reboot
- uploaded on microcontroller Arduino without Arduino Xbee v1.1 Shield code that i paste at the start of my reply
- jumper in XBee mode
- pluged Arduino Xbee v1.1 Shield on microcontroller
- connected USB cable to Arduino microcontroller
Logged

Pages: 1 ... 3 4 [5]   Go Up
Jump to: