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

I’d like to use the Wifi RS21 to set up an ad-hoc network (that is, as an ad-hoc access point). All the examples I’ve been able to find, show how to use the wifi module to attach to an AP.

From looking at the methods provided, it seems that I can’t do the AP end of things…

Any input on how to make that work the way I’d like? Samples, etc are greatly appreciated… :slight_smile:

josef

You have not told us what device you are using?

In the Premium library, there is the WiFiRS9110.StartAdHocHost Method.

BTW, ad hoc networks do not have access points. Communications is done host to host.

**** Oooops was thinking about another type of ad hoc network ****

Joe mentioned that it is there in this old thread:

http://www.tinyclr.com/forum/topic?id=3892

To Mike: I thought I mentioned that I was using the Wifi RS21. Is that not the device? (Please be kind, as I’m just learning the lingo around here. :-))

To Architect: Interesting thread, thanks for the pointer, however (and forgive me if I missed something) when I instantiated the wifi module, I didn’t see anything like a function that would allow me to set up an ad hoc network…

@ jzeevi - What device (mainboard) do you connect the Wifi RS21 to?

FEZ Spider

Ok. As Mike mentioned the module driver has a method through its Interface property:

wifi_RS21.Interface.StartAdHocHost(...)

Have you tried that?

No, but I will and thanks. There are lots of little pieces that I’m still figuring out. One I do wish was better was docs explaining all the functions and variables in a module.

Great! I would like to encourage you to contribute as well. If you make something working and there is no existing examples for that you can share the whole projects on Codeshare or write articles and tutorials on wiki.

Looks like this one need some update since the module driver has changed a lot:

After Opening your WiFi module and calling StartAdHocHost(…) also set your device IP address…
for example…

 
 wifi.StartAdHocHost("YourSSID", SecurityMode.Open," ", 4);
 wifi.NetworkInterface.EnableStaticIP("169.254.0.200", "255.255.0.0", "169.254.0.1");

@ RobvanSchelven - Looks like you have a working example there. :wink:

Obviously, I’m still not quite tuned in. I created the wifi object and tried to start the adhoc network as follows:

wifi_RS21.Interface.StartAdHocHost(“MyNet”, GHI.Premium.Net.SecurityMode.Open, “”, 6);

to try to name my network MyNet as an open net with no key and on channel 6.

I got this:

A first chance exception of type ‘GHI.Premium.Net.NetworkInterfaceExtensionException’ occurred in GHI.Premium.Net.dll
An unhandled exception of type ‘GHI.Premium.Net.NetworkInterfaceExtensionException’ occurred in GHI.Premium.Net.dll

so I can only assume that it wants more from me, but I don’t know what…

Any clues?

josef

Ok I take it you fixed the exception.

Did you see @ RobvanSchelven post about setting up an IP?

Ah - it’s getting closer - one note: my object is named “wifi”, so (for clarity) the code is:

wifi.Interface.Open();
wifi.Interface.StartAdHocHost("MyNet", GHIPremium.Net.SecurityMode.Open, "", 6);
wifi.Interface.NetworkInterface.EnableStaticIP("169.254.0.200", "255.255.0.0", "169.254.0.1");

I added an event handler for WirelessConnectivityChanged as follows:

 wifi.Interface.WirelessConnectivityChanged += new GHI.Premium.Net.WiFiRS9110.WirelessConnectivityChangedEventHandler(wifi_Changed);

and it’s implemented as:

 void wifi_Changed(object sender, GHI.Premium.Net.WiFiRS9110.WirelessConnectivityEventArgs e)
        {
            debugLCD.Print("Something changed on the wifi!");
            debugLCD.Print("isConnected = " + e.IsConnected);
            debugLCD.Print("Info = " + e.NetworkInformation);
        }

Surprise, as soon as the code begins, I see that IsConnected = true. But, I can’t seem to find out what’s in “e” to see if anything there is useful.

First of all please use (you can edit your post above with pencil button) code button to surround your code with code tags or do it manually. That way it is nicely formatted and easier to read.

You can put a breakpoint inside your event handler. The while running under VS debugger you will be able to examine the object when it will hit the breakpoint.

Thanks for the hint on the code. Sorry to have not seen that earlier.

And, I’m still getting used to the VC interface (I’m a linux hack usually, so I’m more familiar with gdb. Fortunately this is quite analgous.

e.NetworkInformation is null, so that’s not terribly helpful. :frowning:

Maybe @ RobvanSchelven can provide more info.

GENERAL RANT ABOUT DOCUMENTATION:

it seems like help has become simply a restatement of data and often misses the information about hwo to use that data. When I worked in chip design, we spent enormous amount of time making sure that we carefully explained not only what the bits in a register meant, but how they interacted and how to use the block we were describing.

GENERAL RANT MODE OFF

Do not think I’m ungrateful. I am. Very! but I’m frustrated that I’m not easily able to find some of this information out myself. Given a reference manual/guide I would go pore over that - but I haven’t really found one.

Having said that, I’m having great fun with the spider board…

Yeah documentation is something that can be improved a lot, but it is getting there slowly.

And, life is getting more interesting.

With an iPhone, I can see the network I created.

With an adroid table, I can’t see it.

So - the next step is how to realize that someone is out there and wants to connect?

Any code out there?

I would enable static ip before starting the ad hoc network.

I did:


            wifi.Interface.Open();
            wifi.Interface.StartAdHocHost("CPAP", GHI.Premium.Net.SecurityMode.Open, "", 6);
            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);

I’m not sure I need to enable the event handler, but I did that to see if anything interesting happened. It gets called almost immediately…

any ideas or code you can point me at?