WiFly Shield
#21
Posted 26 November 2010 - 06:05 PM
This is a sample our web application user interface:
And here it is a picture of first prototype of our "wi-fi fence":
I don't think Google will try to buy our Company next week, but we're proud of it...
#22
Posted 26 November 2010 - 06:20 PM
#23
Posted 27 November 2010 - 08:53 AM
#24
Posted 28 November 2010 - 05:54 AM
#25
Posted 30 November 2010 - 02:24 AM
This is huge news for those of us chomping at the bit to use the WiFly. Any chance you could post the drivers to get us started?
I have the same request. If not full drivers, maybe some hints how you overcame the SPI issues that seem to plague me?
#26
Posted 01 December 2010 - 09:44 AM
We don't still know what and when we'll be able to publish since our prototype should be first discussed on a electronics italian magazine, but it should suffice to say that:
1)It is by far easier to pre-configure WiFly module using an ad-hoc connection as shown on module user manual (near the end). Once done this the firmware will have only to configure SPI-2-UART bridge.
2)We used following configuration for SPI-2-UART bridge:
_spi.Write(new byte[] { LCR, 0x80 });
_spi.Write(new byte[] { DLL, 0x60 });
_spi.Write(new byte[] { DLM, 0x00 });
_spi.Write(new byte[] { LCR, 0xBF });
_spi.Write(new byte[] { EFR, 0x10 });
_spi.Write(new byte[] { LCR, 0x03 });
_spi.Write(new byte[] { FCR, 0x06 });
_spi.Write(new byte[] { FCR, 0x01 });
3)Looking at original code posted, to let all work well it should suffice to use following read/write functions
public static void SpiUartWrite(string data_)
{
byte[] sendBuffer = new byte[data_.Length + 1];
sendBuffer[0] = THR;
for (int i = 0; i < data_.Length; ++i)
{
sendBuffer[i + 1] = (byte)data_[i];
}
_spi.Write(sendBuffer);
}
public static string SpiUartReadLine()
{
int i = 0;
string data = "";
while (i < 1000)
{
if ((SpiUartReadByte(LSR) & 0x01) == 0x01)
{
byte b = SpiUartReadByte(RHR);
data += (char)b;
}
else
{
i++;
}
}
return data;
}
4) Of course, use an external power supply for your Netduino. Our shield was completely off when powered via USB, so it was easy to understand that something was bad, but I am not sure the behavior is the same for everybody. It's curious that plugging the shield to an Arduino board powered via USB the shield works...
#27
Posted 01 December 2010 - 10:26 AM
We don't still know what and when we'll be able to publish since our prototype should be first discussed on a electronics italian magazine, but it should suffice to say that:
1)It is by far easier to pre-configure WiFly module using an ad-hoc connection as shown on module user manual (near the end). Once done this the firmware will have only to configure SPI-2-UART bridge.
2)We used following configuration for SPI-2-UART bridge [...]
3)Looking at original code posted, to let all work well it should suffice to use following read/write functions [...]
4) Of course, use an external power supply for your Netduino. Our shield was completely off when powered via USB, so it was easy to understand that something was bad, but I am not sure the behavior is the same for everybody. It's curious that plugging the shield to an Arduino board powered via USB the shield works...
One big issue that I faced with Wifly is the difficulty to programmatically switch back and forth between command mode and "direct" mode (where you can actually send and receive characters on the WiFI connection). Typing the "exit" and "$$$" sequences in TeraTerm work perfectly, but this doesn't work so well when I tried to do the same by program. Have you met this issue as well? If so what is the piece of code that does the trick?
Thanks
JP
#28
Posted 04 December 2010 - 06:59 PM
One big issue that I faced with Wifly is the difficulty to programmatically switch back and forth between command mode and "direct" mode (where you can actually send and receive characters on the WiFI connection). Typing the "exit" and "$$$" sequences in TeraTerm work perfectly, but this doesn't work so well when I tried to do the same by program. Have you met this issue as well? If so what is the piece of code that does the trick?
Thanks
JP
What I did was set it to Ad-Hoc using the hardware (3.3v on the P109), Use Putty to telent in via IP, configure it for my network using putty, Save the config, then reboot it into infrastructure.
Worked Great until I changed the IP. Now I can't telnet back into it using ad-hoc or infrastructure. The WiFly just terminated connection instantly.
#29
Posted 05 December 2010 - 07:57 AM
What I did was set it to Ad-Hoc using the hardware (3.3v on the P109), Use Putty to telent in via IP, configure it for my network using putty, Save the config, then reboot it into infrastructure.
Worked Great until I changed the IP. Now I can't telnet back into it using ad-hoc or infrastructure. The WiFly just terminated connection instantly.
It actually happened once to us, too.
We had to restore factory settings using P109 toggling (5 times, if I remember well).
Maybe it is a module firmware bug...
#30
Posted 05 December 2010 - 08:05 AM
It actually happened once to us, too.
We had to restore factory settings using P109 toggling (5 times, if I remember well).
Maybe it is a module firmware bug...
Perhaps. I don't think it matters to me. Mine won't even power on now. So frustrating. It was on my network in infrastructure. I tried to reset it via hardware (5 X P109), and it just fried out. No smell or anything, it just has no life.
#31
Posted 07 December 2010 - 11:08 AM
Power: Fine on my board as I use external power and was managing to read something back anyway.
SPI/Serial: Looks like I'm setting that up correctly as my init code matches Innovactive's.
Writing: The only difference is that I call _spi.Write twice but Innovactive just calls it once (which is much more elegant if nothing else!).
Quiche31: Maybe I have this problem too? I don't understand why I can't get it into command mode with the Netduino, but the Arduino running the Sparkfun demo code gets it right every time!
Has anyone managed to get commands into the module from the Netduino or is everyone just preconfiguring with a PC connection?
Innovactive: Can you post the body of your SpiUartReadByte method? Just want to check it matches mine!
Excellent work with the Silverlight GUI by the way. I'm a WPF developer for a living, so I like to see good looking WPF/Silverlight GUIs. I'd hoped to make a similar one for remote control of my little robot project.
Cheers,
Dan
#32
Posted 07 December 2010 - 11:16 AM
Quiche31: Maybe I have this problem too? I don't understand why I can't get it into command mode with the Netduino, but the Arduino running the Sparkfun demo code gets it right every time!
Genious/Dan,
I have the opposite problem it seems: after initial configuration (in command mode) I cannot programmatically switch to "direct" mode (or whatever this mode is called), in order for me to send/receive data broadband. Do you mean that you are in this "direct" mode and cannot switch back to command mode? If so that would be less of a problem, as you can at least operate as a web server!
JP
#33
Posted 07 December 2010 - 02:30 PM
I have been assuming up to now that it's because A: The serial commands I'm sending are garbled somehow or B: The unit fails to enter command mode.
Since I can't analyse the serial comms, there's not much more I can work out!
Dan
#34
Posted 13 December 2010 - 05:33 AM
To be honest, no clue what mode it's in - or even if there's data getting through! The code I've tried so far (see snippet in my first post) attempts to enter command mode to issue the appropriate commands to connect to my wireless, but nothing seems to happen.
I have been assuming up to now that it's because A: The serial commands I'm sending are garbled somehow or B: The unit fails to enter command mode.
Since I can't analyse the serial comms, there's not much more I can work out!
Dan
Dan,
I found an issue with your 'H' test character.
Unplug the wifly shield completely and run the code. You will still get the 'H' character read back. I think it's just reading back from the netduino's buffer, not from the WiFly's buffer.
The ONLY way I got this to work (and work magnificently, I might add), was to use the manual mode (3.3V to P109 on startup) to put it into ad-hoc. I then used my laptop to join the adhoc network and I was able to terminal into the IP (the default ip is in the manual), and use the terminal as a command-line interface. It was working brilliantly, until my Wifly just stopped responding altogether. Now, I have no lights, and the wifly doesn't power up. I believe this is my own fault as the 3.3 lead I used to set it into ad-hoc manually touched the metal shield on the actual module and I believe I burned up my WiFly.
#35
Posted 15 December 2010 - 06:42 AM
#36
Posted 16 December 2010 - 11:25 AM
In the end I got it booting into ad-hoc (by setting up ad-hoc with an Arduino program) and connected from the laptop. Was able to telnet in on port 80, enter command mode and send data as you'd expect.
Swapped the shield over to the netduino with a simple program to copy every received char to Debug.Write. Nothing happened.
Plugged back into Arduino and now the red comms light doesn't flash when the Arduino boots (so no comms at all from the SPI/Serial). Have I killed the WiFly..? probably. No clue how I managed it though, and the other lights still flash when it's powered.
Totally confused and quite miserable about the £60 I may have just flushed down the toilet!!
Dan
#37
Posted 16 December 2010 - 11:45 AM
Totally confused and quite miserable about the £60 I may have just flushed down the toilet!!
Dan
Not to be so despaired, Dan. I am making slow progress, but with some good, although not totally satisfactory, results. With my modified driver I have a web server to which I can connect to... There are two main caveats that I still need to solve before posting the driver:
1) It works with IE8, but not with Chrome8
2) After returning the http response, closing the connection produces a Wifly error; as a workaround, the driver sends a reboot command, forcing the connection to close; then only the browser receives the response
If this helps for the time being, here is the sequence of Wifly commands that "kind of" work for me (the swallowResponse() function is a debugging helper that does an active Thread.sleep(), whilst sending to Debug console the messages received from the Wifly):
static String payload = "<html><h1>Hello world</h1></html>\r\n"; static String contents = "HTTP/1.1 200 OK\r\n" + "Content-Length: "+payload.Length+"\r\n" + "Content-Type: text/html\r\n" + "\r\n" + payload; public static void RunWebServer(Cpu.Pin cs) { _spi = new SPI(new SPI.Configuration((Cpu.Pin)cs, false, 10, 10, false, true, 2000, SPI.SPI_module.SPI1)); WriteRegister(Register.LCR, 0x80); // 0x80 to program baudrate WriteRegister(Register.DLL, 0x60); //0x50 = 9600 with Xtal = 12.288MHz / 0x60 fro 14 MHz WriteRegister(Register.DLM, 0); WriteRegister(Register.LCR, 0xBF); // access EFR register WriteRegister(Register.EFR, 0x10); // enable enhanced registers WriteRegister(Register.LCR, 3); // 8 data bit, 1 stop bit, no parity WriteRegister(Register.FCR, 0x06); // reset TXFIFO, reset RXFIFO, non FIFO mode WriteRegister(Register.FCR, 0x01); // enable FIFO mode WriteRegister(Register.SPR, 0x55); if(ReadRegister(Register.SPR) != 0x55) throw new Exception("Failed to init SPI<->UART chip"); SendCommand(""); SendCommand("exit"); swallowResponse(100); SendString("$$$"); swallowResponse(100); SendCommand("reboot"); swallowResponse(4000); SendString("$$$"); swallowResponse(100); SendCommand("set w j 0"); swallowResponse(4000); SendCommand("exit"); swallowResponse(100); StringBuilder line = new StringBuilder(); Debug.Print("LISTENING...\n\n"); while (true) { if ((ReadRegister(Register.LSR) & 0x01) > 0) { char c = (char)ReadRegister(Register.RHR); if (c == '\n') { Debug.Print("line: " + line.ToString()); line.Clear(); if (line.ToString().Length == 0) { Thread.Sleep(500); SendString(contents); // always sends the same static html page for now Thread.Sleep(200); SendString("$$$"); swallowResponse(100); //SendCommand("close"); // this produces a Wifly error (seen in the swallowed response) //swallowResponse(100); SendCommand("reboot"); swallowResponse(2000); SendCommand("exit"); swallowResponse(100); } line.Clear(); } else if(c != '\r') line.Append("" + c); } } }
Apparently the WiFly sends a 7 bytes TCP packet (*HELLO*) right before my code sends back the response. This *HELLO* string is ignored by IE, but shown by Firefox and Chrome and makes teh response plain text instead of html. I have sent a request to RovingNetworks with the report of the two issues. Hopefully they will get back to me with the fixes, which I will naturally pass on
See screenshot:
JP
#38
Posted 16 December 2010 - 10:15 PM
I have sent a request to RovingNetworks with the report of the two issues. Hopefully they will get back to me with the fixes, which I will naturally pass on
Success!!!
These folks at RovingNetworks support are incredibly fast. It took less than 20' for them to get back to me on both problem. Here is their answer. Thanks Mike Conrad of RovingNetworks!
1. if you dont want the *HELLO* packet just turn it off. "set c r 0" (this is in the user guide !!!!! ) 2. you should be able to issue the close command. it does work just fine. you have to be in command mode, and you issue "close\r" command if you get "ERR?" maybe the connection is already closed by the CLIENT? 3. however, another nice way to automatically close the connection is to just use the IDLE timer. "set c i 2" for example, this will automatically close the connection if no data is send/received after 2 seconds. 4. if you have ability to use the GPIO pins, you can close the connection using PIO5 check the ALTERNATE functions in the user guide.
And here is the working code:
static String payload = "<html><h1>Hello world</h1></html>\n"; static String contents = "HTTP/1.1 200 OK\nContent-Length: "+payload.Length+"\nContent-Type: text/html\n\n" + payload; public static void RunWebServer(Cpu.Pin cs) { _spi = new SPI(new SPI.Configuration((Cpu.Pin)cs, false, 10, 10, false, true, 2000, SPI.SPI_module.SPI1)); WriteRegister(Register.LCR, 0x80); // 0x80 to program baudrate WriteRegister(Register.DLL, 0x60); //0x50 = 9600 with Xtal = 12.288MHz / 0x60 fro 14 MHz WriteRegister(Register.DLM, 0); WriteRegister(Register.LCR, 0xBF); // access EFR register WriteRegister(Register.EFR, 0x10); // enable enhanced registers WriteRegister(Register.LCR, 3); // 8 data bit, 1 stop bit, no parity WriteRegister(Register.FCR, 0x06); // reset TXFIFO, reset RXFIFO, non FIFO mode WriteRegister(Register.FCR, 0x01); // enable FIFO mode WriteRegister(Register.SPR, 0x55); if(ReadRegister(Register.SPR) != 0x55) throw new Exception("Failed to init SPI<->UART chip"); SendCommand(""); SendCommand("exit"); Thread.Sleep(100); SendString("$$$"); Thread.Sleep(100); SendCommand("reboot"); Thread.Sleep(4000); SendString("$$$"); Thread.Sleep(100); SendCommand("set w j 0"); Thread.Sleep(4000); SendCommand("set c i 2"); SendCommand("set c r 0"); SendCommand("exit"); Thread.Sleep(100); StringBuilder line = new StringBuilder(); while (true) { if ((ReadRegister(Register.LSR) & 0x01) > 0) { char c = (char)ReadRegister(Register.RHR); if (c == '\n') { Debug.Print("line: " + line.ToString()); line.Clear(); if (line.ToString().Length == 0) { Thread.Sleep(500); SendString(contents); // always sends the same static html page for now Thread.Sleep(200); SendString("$$$"); Thread.Sleep(100); SendCommand("set c i 2"); SendCommand("set c r 0"); SendCommand("exit"); swallowResponse(100); } } else if(c != '\r') line.Append("" + c); } } }
Now I will package a clean driver and post it here.
JP
#39
Posted 21 December 2010 - 06:31 AM
Was able to telnet in on port 80, enter command mode and send data as you'd expect.
A small update here - the default telnet port on my device turned out to be 2000.
#40
Posted 23 December 2010 - 09:56 AM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users