mbed official WiflyInterface (interface for Roving Networks Wifly modules)

Dependents:   Wifly_HelloWorld Websocket_Wifly_HelloWorld RPC_Wifly_HelloWorld HTTPClient_Wifly_HelloWorld ... more

Issue: RN131C/RM New Batch not Compatible

Just got a new batch of board with more RN131C modules.

I'm finding that the status messages from the WiFly engine have changed and its breaking the mBed API.

For instance, the join command for DHCP needs an updated acknowledgement check:

if (state.dhcp) {
            if (!sendCommand("join\r", "OK", NULL, 10000))

The method used to look for "DHCP=ON" instead of "OK" but that text is no longer in the response. There are a few other places where the output is different as well so I'm not sure how far impacting these changes are...

It also looks like some of the command buffer is getting overwritten with response bytes sometimes (note the content of the very last "check:")

Its also worth noting that the initial response to "$$$" can vary depending on what mode the radio is in. These radios seem to be starting up in ADHOC mode until the first time that the mBed API configures the radio and calls "save". The response when in ADHOC mode has different text than what is shown below.

Here is the output in debug mode from the simple test program below:

Quote:

Starting...

Init Wifi...

Init = 0

Connect Wifi...

[Wifly : DBG]will send: $$$

[Wifly : DBG]check: wifly-GSX Ver 4.00.1, Apr 19 2013 11:48:28 on RN-131MAC Addr=00:06:66:31:d9:90*READY*

[Wifly : ERR]cannot enter in cmd mode

[Wifly : DBG]will send: set w j 0

[Wifly : DBG]check:

[Wifly : ERR]sendCommand: cannot set w j 0

[Wifly : DBG]will send: $$$

[Wifly : DBG]check: CMD

[Wifly : DBG]will send: set w j 0

[Wifly : DBG]check: AOK

[Wifly : DBG]will send: set u m 1

[Wifly : DBG]check: AOK

[Wifly : DBG]will send: set c t 30

[Wifly : DBG]check: AOK

[Wifly : DBG]will send: set c s 1024

[Wifly : DBG]check: AOK

[Wifly : DBG]will send: set s i 0x40

[Wifly : DBG]check: AOK

[Wifly : DBG]will send: set c r 0

[Wifly : DBG]check: AOK

[Wifly : DBG]will send: set i p 2

[Wifly : DBG]check: AOK

[Wifly : DBG]will send: set i f 0x7

[Wifly : DBG]check: AOK

[Wifly : DBG]will send: set d n rn.microchip.com

[Wifly : DBG]check: AOK

[Wifly : DBG]will send: set i d 1

[Wifly : DBG]check: AOK

[Wifly : DBG]will send: set w s Kimble24G

[Wifly : DBG]check: AOK

[Wifly : DBG]will send: set w a 3

[Wifly : DBG]check: AOK

[Wifly : DBG]will send: set w p XXXXX

[Wifly : DBG]check: AOK

[Wifly : DBG]will send: join

[Wifly : DBG]check: Auto-Assoc Kimble24G chan=1 mode=MIXED SCAN OK

[Wifly : DBG]will send: save

[Wifly : DBG]check: <4.00> Stor

[Wifly : DBG]will send: exit

[Wifly : DBG]check: ng Kimble24G now..Associated!DHCP: StartEXIT

[Wifly : INFO]

ssid: Kimble24G

phrase: XXXXX

security: WPA

Connect = 1

#include "mbed.h"
#include "WiflyInterface.h"
#include "PinDetect.h"

DigitalOut LedYellow(LED1);
DigitalOut LedGreen(LED2);
DigitalOut LedBlue(LED3);
DigitalOut LedRed(LED4);

DigitalOut Output1(p30);
DigitalOut Output2(p29);
PinDetect Input1(p8, PullDown);
PinDetect Input2(p7, PullDown);
DigitalIn Button1(p25);
DigitalIn Button2(p26);

char wifiNetwork[32] = "Kimble24G";
char wpaPassword[64] = "XXXXX";

Serial pc(USBTX, USBRX);
WiflyInterface wifly(p13, p14, p15, p5, wifiNetwork, wpaPassword, WPA);

int main() {
    wait(2);
    pc.printf("Starting...\n");
    int result;
    pc.printf("Init Wifi...\n");
    result = wifly.init();
    pc.printf("Init = %d\n", result);
    pc.printf("Connect Wifi...\n");
    result = wifly.connect();
    pc.printf("Connect = %d\n", result);
    //pc.printf("Connect Server...\n");
    //result = wifly.connect("192.168.1.8", 1235);
    //pc.printf("Connect = %d\n", result);
    while(1) {
        if(pc.readable()) {
            char c = pc.getc();
            pc.putc(c);
            wifly.putc(c);
        }
        LedGreen = 1;
        wait(0.2);
        LedGreen = 0;
        wait(0.2);
    }
}

Also, where the wifly.connect() command is commented out in the test code, that line causes a compile error; it doesn't like the parameters... apparently because a connect method with no parameters is wrapping the join operation. If I rename the connect method with no parameters to something like "joinnetwork" then the code will compile without error.