How to use Wifi RS21 to set up an ad-hoc network?

We will have a solution soon specifically to connect to phones and tablets using internal access point. Using adhoc is no good. We spent months on this to come up with best answer.

Details come in few weeks.

@ Gus - Just to make sure I understnad what youā€™re saying: youā€™ve had no luck setting up an adhoc network, so your looking at making the driver support a dhcp server and all the stuff needed to let other devices attach to the wifi module WITHOUT needing any other hardware? (that is, a point to point network or a built-in router). Right?

Also, any good examples of how to use BT with the provided drivers?

The problem is not on GHI side. It is the phones and tablets that do not work right with adhoc. Too many obstacles.

What we will offer is an alternative to allow you to connect to any tablet or phone with ease.

@ Gus, Good to know that GHI is working on this subject and to come up with a better solution.

@ jzeevi. Now you have it working on iPad/iPhone you have reached all you can do with adhoc as far as i know. To my experience it also works well with laptop using MS-Windows as long you use an IP address 169.255.x.x On some but not all android tablets/phones i could add a wifi network manually and then it also works fine. Other android devices still wont work.

@ RobvanSchelven - Robvan, I actually was only able to expose the connection - not actually make it. If you can point me (or educate me) on how to get the connection going that would be brilliant. My iPhone/iPad sees the connection, but I donā€™t know how to demonstrate that the RS21 module has actually connected with the device. Iā€™m absolutely certain I donā€™t know enough here and am hoping you can help me learn.

@ Gus - I understand the frustration and look forward to any easier solution.

@ jzeevi, make a simple web server like in the example from Gus at http://www.tinyclr.com/codeshare/entry/588. and try to access it with your browser.

@ RobvanSchelven - I would, but there are huge differences in what methods are available for Ethernet vs. Wifi that Iā€™m getting lost in trying to make the example work for wifi. Suggestions?

The differences are in how to setup the connectionā€¦ Once you have a connection, wifi or ethernet you can use the code below that works for bothā€¦
in your code, after your adhoc setup code call the method RunServer. (This was copied from the example i mentioned). Run the code, Connect your iPad/iPhone and use your browser to surf to 169.254.0.200

in the medthod ProcessClientGetReques(ā€¦) fill the variable outBuffer with some text. This should appear in your browser


internal static void RunServer()
        {
            HttpListener listener = new HttpListener("http");
            listener.Start();
 
            while (true)
            {
                HttpListenerResponse response = null;
                HttpListenerContext context = null;
 
                try
                {
                    context = listener.GetContext();
                    response = context.Response;
                    HttpListenerRequest request = context.Request;
                    switch (request.HttpMethod.ToUpper())
                    {
                        case "GET": ProcessClientGetRequest(context); break;
                    }
 
                    if (response != null)
                    {
                        response.Close();
                    }
                }
                catch
                {
                    if (context != null)
                    {
                        context.Close();
                    }
                }
            }
        }
 
        private static void ProcessClientGetRequest(HttpListenerContext context)
        {
            HttpListenerRequest request = context.Request;
            HttpListenerResponse response = context.Response;
 
            Debug.Print(request.RawUrl);
            response.OutputStream.Write(outBuffer, 0, outBuffer.Length);
        }

@ RobvanSchelven - Two questions:

  1. How is HttpListener defined? It shows up in the VC editor as unknown.
  2. after I do this:
 
           wifi.Interface.Open();
            wifi.Interface.NetworkInterface.EnableStaticIP("169.254.0.200", "255.255.0.0", "169.254.0.1");
            wifi.Interface.WirelessConnectivityChanged += new GHI.Premium.Net.WiFiRS9110.WirelessConnectivityChangedEventHandler(wifi_Changed);


what defines ā€œconnectedā€? (You said ā€œafter you get connectedā€¦ā€)

  1. using System.net
  2. with connected i meanā€¦ when you connect your tablet/phone to your adhoc deviceā€¦ your tablet will show its status as connected

Funny, Iā€™ve been trying to set up Ad hoc connection since yesterday. Eventually I gave up. At some point I was able to connect to my G120+RS21, and even got HttpRequests working for 8 minutes; but no matter what I tried, Iā€™ve always been ending with a scary flashing ā€œBuffer OVFLWā€ error.

Adhoc with RS21 is something definitely not suitable for industry applications. Too many bugs everywhere. Lets hope that new methog Gus was talking about will really be nice and easyā€¦

The more I learn, the more I realize Iā€™m missing key pieces of the VC# interface.

So, I have created a wifi setup that can be seen from an iPhone (didnā€™t see it on a tablet) in adhoc mode. Iā€™m giving up on that based on Gusā€™s input (and everyone elseā€™s as well)

Now, Iā€™m trying to figure out how to set up a small network that doesnā€™t require a router for me to connect toā€¦ Thatā€™s what Iā€™m hoping Gusā€™s solution makes easy.

So, how do I advance from a connection to using it? Do I put in a ā€œusing System.netā€? What action gets invoked when a request comes in?

I think youā€™ll need to wait for Gusā€™ answer here, but let me say this is advanced stuff, seems like you should leave the networking stuff alone for a bit and play with sensors or wired connections or somethingā€¦ you should try a simpler project first up

@ Brett - Iā€™ve gotten lots of the tiny stuff working - but my interest in this is motivated by a wifi/BT connection. Gus has been quite helpful and Iā€™m looking forward to what he has.

Iā€™m still looking for an explanation of how the wifi pieces all connect. I can see the network I create on my iPhone, but I donā€™t know how to attach the wifi connection to the networking subsystemā€¦ :slight_smile:

@ Simon, I have Adhoc + Spider + MF4.2 running fine with a custom http server based on sockets. There is a know issue with G120 related to network/socketsā€¦ GHI is working on that. Maybe that has effected your experiment :frowning:

@ RobvanSchelven - Care to share that? :slight_smile: (whatā€™s a GS120?)

G120 is the name of a product of GHI. See GHIā€™s main page. See http://www.tinyclr.com/forum/topic?id=10197&page=6 for a discussion on that issue.

Ah - thanks. I did a search from the catalog page and got no results. Maybe I was a level too deep. Thanksā€¦

Are you willing to share the code you wrote for the wifi network?

Hmmmā€¦ I might give EMX a try, then.

If only GHI had a public bug tracking systemā€¦

1 Like

Any update here? I would like to connect to the Cobra II WiFi directly with a laptop and an Android phone (Galaxy Nexus). I have the adhoc network listening but havenā€™t been able to send/receive data yet. Iā€™m going to try TCP networking between the two. Does anybody have any code handy? I can probably dig some up but I only have one day to get it working before I shelve the idea for now.

On the Android phone front, Adhoc networking is not supported so it sure would be nice if GHI figured something out. I got a GoPro Hero 3 Black for Christmas and it uses WiFi to communicate with my phone. I wonder how they are doing that?

Update - found some code over at CodeShare that Iā€™m going to try tomorrow. Wish me luckā€¦