9 years, 10 months ago.

Problems with WiFly "HelloWorld"

Hello!

I'm having some trouble gtting this example to work.

My WiFly modules are functional, as I can successfully connect them to directly to the pc and configure them, by re232 and by telnet. The modules also can correctly connect to my wifi.

I connected the pins to the mbed, just run the probram "as is" and id doesn't pass the line " while (!wifly.connect()); join the network".

I also tried to sand everything from the serial to the sifly, and it's correctly connected to the mbed.

Is there any known issue, since the modules appears to be fully functional?

Thanks in dvance.

Sergio.

Question relating to:

Hello World with a wifly module (RN 131 C/G - RN-XV)

Hi, Sergio can you post your code to try to help you? Greetings. (Puedes postear tu codigo para tratar de ayudarte?)

posted by Ney Palma 21 Jun 2014

I figured it out... The version I as using of the library, doesn't have the option to change the baud rate of the wifly module, somehow, my modules were configured for a much greater baud rate. After I manually configured the modules to 9600, the program worked fine.

posted by Sergio Vasconcelos 08 Jul 2014

2 Answers

9 years, 10 months ago.

Sergio, If you haven't, please work through the examples on the Cookbook - Wifly page. Especially the section just under "More details". It would be helpful to know how your module responds to the commands shown there.

Hello David, thanks for the answer.

Here is what I'm experiencing, if I configure the module manually through serial or telnet, I can afterwards put ir to comunicate with the "getc - putc" example, I typ in the mbed serial and see on the telnet terminal. I think the problem is when I run the other example, the one that configures the mbed and outputs the ip address, it never get to that part. As I said on the main question, the program (exactly as supplied, I didn't change a thing) doesn't pass this line -> "while (!wifly.connect());". I'm intriged and not sure how to debug this.

Thank you.

posted by Sergio Vasconcelos 23 Jun 2014

Hi Sergio, ok, then let's go a step further with the more details section of the cookbook page. If you can type on your terminal and interact with the module, then that connection must be good. The next thing to come to mind is the security setting of the access point you are joining. So, first, when you are in the terminal mode, if you type "scan", will it pause and then show you the available access points?

Does your access point of interest have a strong signal - compared to others that may be present?

Assuming it is there and with a good signal, then you want to check carefully the ssid and passphrase you use (note the '$' to substitute for ' ').

I don't like to recommend this, but you might also try reducing the security on your access point and setting the module correspondingly. Perhaps there is an incompatibility there.

Does your access point have any special settings - MAC address filtering for instance? double-check or turn that off.

If you get the access point security reduced to where the Wifly module can connect, then turn the security settings back on and work your way up.

posted by David Smart 23 Jun 2014
9 years, 10 months ago.

did you figure it out?

Hello,

First of all, I appreciate the help very much! :)

Now the problem... I probaby dindn't make myself clear with the previous explanations of my issue. The thing is, manually (as per manually I mean, connected directly to the WiFly module by serial or telnet) I can do aything. I can conect to my wifi with no problem at all. Now, when I conect the mbed to the configured module, I can write to the terminal through the getc-putc" example. The thing is, when I run the other example, where the mbed reconfigure and try to connect by itself, now there is my problem and only there.

Thanks. Sergio

posted by Sergio Vasconcelos 24 Jun 2014

Well, I'm starting to run out of ideas, but I'll take another spin here -

Wifly Configure

Serial pc(USBTX, USBRX);
Serial wifi(p9,p10);
 
 
int main() {
    
    pc.printf("Test Wifly!\r\n");
 
    while (1) 
    {
        while(pc.readable())
            wifi.putc(pc.getc());
        while(wifi.readable())
            pc.putc(wifi.getc());
    }
}

Comparing that to -

Wifly Hello World

WiflyInterface wifly(p9, p10, p25, p26, "mbed", "password", WPA);
 
int main() {
    wifly.init(); // use DHCP
    while (!wifly.connect()); // join the network
    printf("IP Address is %s\n\r", wifly.getIPAddress());
    wifly.disconnect();
}

Both use p9 and p10 for receive and transmit. The WiflyInterface also can use p25 and p26, and of course it has an ssid, passcode, and security.

p25 and p26 are probably not required - so you could unhook them to more closely simulate the Wifly Configure program.

The ssid and passcode have that requirement for a $ instead of a <space> character, and the security mode of your access point must match the parameter here.

And, there is some debug capability built in - Edit Wifly.cpp in your project, and look for this:

//Debug is disabled by default
#if (0 && !defined(TARGET_LPC11U24))

Change that 0 to a 1 and rebuild, program and run it. It should print out a lot of information to the USB terminal program. This may give us a hint where it hangs up.

Another popular library uses this construction:

//#define DEBUG "WiFi"      //Debug is disabled by default

So here just remove the comment leader.

posted by David Smart 25 Jun 2014

Hey there, thanks for the help!

Sorry for the delay, but I didn't got the chance to "play around" the mbed until today...

With the debug active, I receie this in the terminal over and over again.

[Wifly : DBG]will send: set c t 20 [Wifly : DBG]check:

[Wifly : ERR]sendCommand: cannot set c t 20 [Wifly : DBG]will send: $$$

[Wifly : DBG]check:

[Wifly : ERR]cannot enter in cmd mode

It seems it doesn't even enter the command mode...

BR, Sergio

posted by Sergio Vasconcelos 26 Jun 2014

Hey Sergio,

I looked at a couple of different Wifly libraries, and they all have "set c t 30", not "20". So, I wonder which library you are using, and if there is a newer and better one (hopefully with the changes needed to solve your problem).

posted by David Smart 29 Jun 2014

Well, you are right! I'm using an outdated library. I'll give it a shot with the newer library tonight and let you know the unroll of the situation! Thanks!

posted by Sergio Vasconcelos 30 Jun 2014

You dont need the libraries. I rather use the acces point configuration.

Connections: Actually you just need the 3.3v, GND, Tx and Rx pins :D https://mbed.org/media/uploads/WiredHome/wifly_smartboard.png

Burn this progrma into your mbed:

Mbed-Wifly-Config

#include "mbed.h"
Serial Pc(USBTX, USBRX);
Serial Wf(p28,p27);// wire connections: --- Wifly p3 to Mbed p28 ---  Wifly p2 to Mbed p27 
int main()         //                   --- Wifly p1 to Mbed Vout --- Wifly p10 to Mbed GND
{      
    Pc.printf("Configuracion, escribe: '$$$' ");
    while(1)
        {         
              while(Pc.readable())
                Wf.putc(Pc.getc());
              while(Wf.readable())
                Pc.putc(Wf.getc());         
        }                    
}

Use a terminal applications such as PuTTY and Tereterm (I preffer Teraterm for a windows user).

When you receive cmd after writing $$$ you should do this: (after any command you should receive "OK"

Wifly-Config-commands

set wlan join 7                    [enables Access Point mode]
set ip dhcp 4                      [enables DHCP server]
set ip address 169.254.1.1         [or choose any other IP address]
set ip gateway 169.254.1.1         [for iPhone to connect, gateway nees to be the same as the IP address]
set ip netmask 255.255.255.0       [note, only one zero at the end]
set apmode ssid WiFly              [or any other name you choose for you Wifi network]

save
reboot

Then you should be able to find your wifly in you wireless connections. After that, just connect your laptop or smartphone to the wifly connection and test it.(you should use a telnet comunication with the IP you configurated before "169.254.1.1" and the port 2000. Here is an example code:

Mbed-Wifly-Led

#include "mbed.h"
Serial Wf(p28,p27);
Serial Pc(USBTX, USBRX);
DigitalOut myled(LED1);
char K;
int main() {
    while(1) {
        K=Wf.getc();
        myled=0;
        if (K=='1'){ myled=1;wait(5);}
        Pc.printf("%c",K);
    }
}
posted by J Daniel Martinez C 30 Jun 2014

Hello,

Thanks for the help Daniel, but if you notice, on my explanations of the problem I told that I can already configure the module manually. Although, that's not my intent. I want the mbd to configure any WiFly module hookd when it starts.......

So, back to the problem, I'm now using the newer library, but still the same behaviour, it can't enter command mode.

[Wifly : DBG]will send: $$$

[Wifly : DBG]check:

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

[Wifly : ERR]cannot enter in cmd mode

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

B.r., Sergio

posted by Sergio Vasconcelos 30 Jun 2014

Hi,

I think the problm might be o the baud rate of the serial port..... How can I change it? Is it defined anywhere on the library or it's set by default?

Br, Sergio

posted by Sergio Vasconcelos 30 Jun 2014