7 years, 11 months ago.

WiFly problem when receiving the ip

Hello, I tried the WiFly hello world program(http://mbed.org/users/samux/code/Wifly_HelloWorld/) , but in TeraTerm i receive only the text part of the pc.printf, not the ip returned by the .getIPAddress(). I've tried several things but none work (strcat-ing the returned result into a char buffer, printing with & in front of the parameter in printf, and so on) but none work. Has anyone else encountered this issue ? In the wifly user manual there is a specification that states that the wifly is configured by default for a 9600 baud rate, so i didn't change it, i'll try to do that also if everything else fails. In the teraterm i've set CR+LF on both send and receive.

Thank you in advance, Razvan

I have the same problem. I simplified to the Wifly_configure example, which communicates ok. I also updated both the WiflyInterface and the mbed lib in the _HelloWorld, and no change. It does return from the .init() but the .connect just spins. I also have a more complex piece of code that does not use the WiflyInterface, and I can connect to my network as expected.

posted by David Smart 19 Mar 2013

I saw on your profile David your code with the wifly+webserver, can i try it to see if the part that regards the connection init - join - check works for me ? I intend to use it to send some parameters via mail / websocket using the wifly .

posted by Razvan Coban 20 Mar 2013

Sure thing - and I hope it helps you out. Last night, I looked at the WiflyInterface logic, and tried to compare it to the old Wifly (that I'm using). They were very different. I tried replicating the sequence of commands using the configuration tool - just typing them in by hand, and then it works. Tried using the program again and it doesn't. This leads me to thinking a) I'm missing something, or b) there some race condition. I hope to get back to that in the next day or so to dig deeper.

posted by David Smart 21 Mar 2013

Hi All, sorry to hear that you have some problems with the wiflyinterface library.

Can you send me the debug log:

#if (1 && !defined(TARGET_LPC11U24))

in wiflyinterface/wifly/wifly.cpp

Cheers, Sam

posted by Samuel Mokrani 21 Mar 2013

Hi Sam, this is what i have after logging in teraterm:

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

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

[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: get ip a

[Wifly : DBG]user str:

[Wifly : DBG]user str:

[Wifly : DBG]result: 9

afafasfa -> this is what i had in the printf

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

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

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

Now i see that the target is the other LPC model ... i have the LPC1768 ... should i change it in the TARGET_ part ?

EDIT: I changed both targets to TARGET_LPC1768: and i receive this in the terminal:

IP Address is

posted by Razvan Coban 21 Mar 2013

Hi Razvan,

basically the wifly module is not responding. So i suggest you to check your wiring. You can start with the wifly_configure program to check that you can establish a connection with the wifly module.

You don't need to change the target.

Cheers, Sam

posted by Samuel Mokrani 21 Mar 2013

I remade the wiring, the only difference is that i use this https://www.sparkfun.com/products/9132 with the wifly because i couldn't find in Romania the board adaptor for the wifly (because of the non-standard pin distance) , so the only difference is that i placed jumper from mbed vout to the regulated board, not from the 3.3V ... the rest of the wiring is correct, with the configure wifly the $$$ command wouldn't respond at all, i configured the wifly via telnet by placing the adhoc pin from the wifly to 3.3V and created an ad-hoc network, and telnet-ed it so that i could enter in cmd mode, and from there i did set wlan 0 so that it wouldn't try to connect to it's default network, then i configured it with my ssid & pw.. . Thanks for your help, any advice is very valuable as i am trying to learn to work with the wifly module.

posted by Razvan Coban 21 Mar 2013

You can use the VU pin from the mbed to have a 5V output. Then check that the serial port is correctly connected (rx on tx and tx on rx). Then make sure that the serial port used in the wifly constructor is the one that you wired.

posted by Samuel Mokrani 21 Mar 2013

Hi Sam,

My log is a bit different in that I have a connection. When I manually type these commands, they work - including the set for the ssid. I haven't verified the connection status pin (I need to add a test for is_connected() in main).

WiflyInterface wifly(p28, p27, p23, p24, "myssid", "The$Pass$Phrase", WPA);

While I was picking this apart, I came up with a few questions -

  • I don't see the pass phrase being set - I just noticed that.
  • Curious - why not set dhcp to mode 3 (set i d 3)?
  • Curious - it is set to keep connection open on loss of AP (set i f 0x7), instead of closing on loss (set i f 0x6).
  • Why set dns to rn.microchip.com?

[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 myssid
[Wifly : DBG]check:
[Wifly : ERR]sendCommand: cannot set w s myssid
[Wifly : DBG]will send: exit
[Wifly : DBG]check: AOK<2.45> EXIT
posted by David Smart 21 Mar 2013

Quote:

I don't see the pass phrase being set - I just noticed that.

it is not set because the ssid command fails... i don't really know why

Quote:

Curious - why not set dhcp to mode 3 (set i d 3)?

in the reference manual, dhcp = 1 = DHCP ON. dhcp = 3 = DHCP cache mode.

Quote:

Curious - it is set to keep connection open on loss of AP (set i f 0x7), instead of closing on loss (set i f 0x6).

Good point!

Quote:

Why set dns to rn.microchip.com?

It is the default dns server used by roving network to update their firmware

Concerning the problem with the command "set w s myssid", can you try to put this command at the beginning of the program to see if it makes any difference?

posted by Samuel Mokrani 21 Mar 2013

So i did the following: - remade the wiring -> now i have TX and RX on 28 and 27, i get nothing in teraterm, i placed TX and RX on their opposites RX and TX I have a pull-up resistor between 5V and RX on the wifly regulated board (i saw that on their forum) WiflyInterface wifly(p28, p27, p25, p26, "Tenda_1D5DE0", "mypw", WPA);

i took a photo with the boards but i don't know how to post it here.

thanks anyway for your help, i'll keep searching

posted by Razvan Coban 21 Mar 2013

This is the new log: [Wifly : ERR]sendCommand: cannot set c t 20

[Wifly : DBG]will send: $$$

[Wifly : DBG]check:

[Wifly : ERR]cannot enter in cmd mode

[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

[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

[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

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

[Wifly : DBG]check: Auto-Assoc roving1 chan=0 mode=NONE FAILED

[Wifly : ERR]sendCommand: cannot set c t 20

[Wifly : DBG]will send: $$$

[Wifly : DBG]check:

[Wifly : ERR]cannot enter in cmd mode

[Wifly : DBG]check:

[Wifly : ERR]cannot enter in cmd mode

[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

[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

[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: Auto-Assoc roving1 chan=0 mode=NONE FAILED

what is this ? did the wifly reset itself to factory settings ?

posted by Razvan Coban 21 Mar 2013

PROBLEM SOLVED:

The whole problem was from the xbee regulated adapter. I forced jumpers to fit from the mbed to the wifly and it worked Now i get the following:

ssid: Tenda_1D5DE0 phrase: 22051990 security: WPA

IP Address is 192.168.0.110

Thank you all for trying to help me.

posted by Razvan Coban 21 Mar 2013

perfect!

posted by Samuel Mokrani 21 Mar 2013

Hi Sam,

Sorry, I blended my problem into another - and they were perhaps not so closely related...

I found the issue - the timeout was too short. The default of 500 msec I guess is more than generous for most commands, but I added some additional print commands to the Wifly::send(). Of course these prints can take a bit of time too...

What I found first was that the timeout was expiring. I then changed the timeout to a more generous 1000 msec and it works.

I then put a print of the time value here -

                    if (found != string::npos) {
                        wait(0.01);
printf("tm2: %06d flush()\r\n", tmr.read_ms());
                        //We flush the buffer
                        while (wifi.readable())
                            wifi.getc();
                        break;

And here's what I collected for time values from my Wifly (it has SW v2.45)

The left pair of columns are the time measurements in the order it runs them (I moved a copy of the set w s myssid to the top). And the right pair is the same data - just sorted by execution time.

msCommand orderTime SortedCommand
000225$$$000009exit
000572set w s myssid000009exit
000013set w j 0000013leave
000013set u m 1000013set c r 0
000014set c t 30000013set i d 1
000017set c s 1024000013set i p 2
000017set s i 0x40000013set u m 1
000013set c r 0000013set w a 3
000013set i p 2000013set w j 0
000016set i f 0x7000014set c t 30
000029set d n rn.microchip.com000016set i f 0x7
000013set i d 1000017set c s 1024
000572set w s myssid000017set s i 0x40
000013set w a 3000018exit
000585set w p The$Pass$Code000029set d n rn.microchip.com
000716join000054$$$
000075save000075save
000018exit000124$$$
000054$$$000225$$$
000009exit000572set w s myssid
000124$$$000572set w s myssid
000013leave000585set w p The$Pass$Phrase
000009exit000716join

So, I don't know about others Wifly's, but for me, 3 of the commands would not complete before the 500 msec default timeout.

I revised it to

#define DEFAULT_WAIT_RESP_TIMEOUT 1000

And the Wifly_HelloWorld now works as expected.

posted by David Smart 22 Mar 2013

1 Answer

7 years, 11 months ago.

The whole problem was from the xbee regulated adapter. I forced jumpers to fit from the mbed to the wifly and it worked

Accepted Answer