Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

WiFly Shield


  • Please log in to reply
64 replies to this topic

#21 Innovactive

Innovactive

    Member

  • Members
  • PipPip
  • 29 posts

Posted 26 November 2010 - 06:05 PM

As promised, here are a couple of pictures of our brand new prototype.

This is a sample our web application user interface:

Posted Image

And here it is a picture of first prototype of our "wi-fi fence":

Posted Image

I don't think Google will try to buy our Company next week, but we're proud of it... :D

#22 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 26 November 2010 - 06:20 PM

Wow, that looks really nice! Chris

#23 Mustang

Mustang

    Member

  • Members
  • PipPip
  • 26 posts
  • LocationDetroit, Michigan

Posted 27 November 2010 - 08:53 AM

That does look great. Do you have any problems with the range on the Sensors? Update on my issues.. I have lights. Thank you Chris, for your work on this matter. Ordering a Plus isn't an option for me, as this is a project funded by a third party. I need to get the WiFly operational as it is. Unfortunately, I am not real solid on my EE skills. I am more of a coder than an Electronics Engineer.

#24 James

James

    Advanced Member

  • Members
  • PipPipPip
  • 56 posts

Posted 28 November 2010 - 05:54 AM

Nice work to all at Innovactive! 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?

#25 Mustang

Mustang

    Member

  • Members
  • PipPip
  • 26 posts
  • LocationDetroit, Michigan

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 Innovactive

Innovactive

    Member

  • Members
  • PipPip
  • 29 posts

Posted 01 December 2010 - 09:44 AM

Hi.

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 Quiche31

Quiche31

    Advanced Member

  • Members
  • PipPipPip
  • 87 posts
  • LocationFrance

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 Mustang

Mustang

    Member

  • Members
  • PipPip
  • 26 posts
  • LocationDetroit, Michigan

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 Innovactive

Innovactive

    Member

  • Members
  • PipPip
  • 29 posts

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 Mustang

Mustang

    Member

  • Members
  • PipPip
  • 26 posts
  • LocationDetroit, Michigan

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 Genious

Genious

    Member

  • Members
  • PipPip
  • 10 posts

Posted 07 December 2010 - 11:08 AM

Hi all, thanks for the feedback on all this - I'll try and give it a go this week and see if I can get it up and running.

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 Quiche31

Quiche31

    Advanced Member

  • Members
  • PipPipPip
  • 87 posts
  • LocationFrance

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 Genious

Genious

    Member

  • Members
  • PipPip
  • 10 posts

Posted 07 December 2010 - 02:30 PM

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

#34 Mustang

Mustang

    Member

  • Members
  • PipPip
  • 26 posts
  • LocationDetroit, Michigan

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 James

James

    Advanced Member

  • Members
  • PipPipPip
  • 56 posts

Posted 15 December 2010 - 06:42 AM

Mustang - were there any tricks to connecting via terminal emulator? I can put the WiFly into adhoc mode and ping the default IP (169.254.1.1) as well as connect from my PC, but when I try to connect to that IP with TeraTerm 3.1 I get no connection. I tried ports 22 and 23 with no luck and used Telnet as the setting (not SSH). Any idea what I might be missing?

#36 Genious

Genious

    Member

  • Members
  • PipPip
  • 10 posts

Posted 16 December 2010 - 11:25 AM

Thanks for the info on the 'H', Mustang.

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 Quiche31

Quiche31

    Advanced Member

  • Members
  • PipPipPip
  • 87 posts
  • LocationFrance

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:
Posted Image
JP

#38 Quiche31

Quiche31

    Advanced Member

  • Members
  • PipPipPip
  • 87 posts
  • LocationFrance

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 James

James

    Advanced Member

  • Members
  • PipPipPip
  • 56 posts

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 ferry

ferry

    New Member

  • Members
  • Pip
  • 1 posts

Posted 23 December 2010 - 09:56 AM

I used the code from this thread. I keep getting unreadable string from WiFly like this: á/Ûí Íù-AøMåö‚‹áñק60íÑó'ìíUAâ¨9lMWVÒC•áÒ*sŒü +56=38!!228212 !;:!97875641772&&#"!&#(#"- ÿÿÿÿÿ Setup done +5"6*8'!221 !;:!97187563146773'&#"!%#"(!" !;99787:63116723&&#"!&# ÿÿÿÿ did anyone get this before?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.