The wifi ad-hoc or accesspoint problem

I’m developing an application based the cobra2 card. The device acts like a server where users can connect with a mobile phone to access collected data and make settings. Wanting to support both Android and IOS phones I have run in to a few problems on the way that I would like to share.

We first started out using the built in RS21 module. As the RS21 cannot act as an access point we used an ad-hoc network for this. Working great on IOS. But android does not support ad-hoc networks. So we switched to the more advanced module RN171 module (discontinued at this point). This module can act as an access point. Worked fine until we found out that it can only do one socket connection at the time. This did not work to well with the jquery webpage that wants multiple sockets. We ended up solving this with a custom application on the phones that periodically polls the jquery webpages using only one socket. But we lost the snappy feeling of send/receive sockets doing this.

I know you can root some Android devices to get ad-hoc. But for a fairly large market product with “non forum” users, it’s just not gonna work

Rumors say that GHI might update the driver for RS21 to support access point mode and multiple sockets. But nothing official about when, or even if they will.

I imagine that having a gadgeteer device that acts as “server” for mobile phone clients (IOS Android etc) must be a common need?

1 Like

I 100% agree with you… This might be of interest to you.


From what I understand, this is a module that will connect to an excisting network. Still, an impressive piece of work they got going…

@ John Karbin - The IoT Labs IL-G-WF121 module can support Access Point mode. But we have not added it to the driver yet. Tell me a little more about your application and maybe our module will be able to handle your requirements.

1 Like

@ munderhill - Sounds very interesting!
The application in this case is used to measure the speed of objects passing a set of infrared ports. Users connect to a webserver running on the device, to view the measurements and make application settings. In the current form we can only support one viewer at the time, but we would like it to be open to many viewers. The webpage is currently a jquery page. Ideally a jquery page uses (more than one) sockets, to be able to push data to the clients. The reason we want the device to act as an accesspoint, is that it’s easy for users to find by looking for the configured SSID. And also that we can support many type of phones (Android and IOS at least).

@ John Karbin - So is the microcontroller running a web server and all you need is for clients to connect to the access point to serve up the page?

We’ll do some research and put together some code this weekend to enable the access point on our module.

@ munderhill - Yes. A webserver with multiple socket connections for each client. Can’t wait to hear the result from the tests. I think this is a key feature. The solution we had when using ad-hoc was very smooth with events from the application showing up on the phone instantly. To me this a key feature to many applications. Phone clients are everywhere, they just need a gadgeteer device to connect to :slight_smile:

@ munderhill - That’s exactly my same need. I’m run a webserver based on sockets

@ John Karbin, @ RobvanSchelven - Are these webservers of your own design or are you using open source software? If you are using open source software, let me know where to get the code so I can use the same in my test application.

@ munderhill - I build my own HTTP webserver, running in C#/NETMF. I choose to build a webserver because i wanted/needed to implement websockets

@ munderhill -

Is UDP included in your driver, and if, howmany concurrent sockets besides the TCP one. Can they be mixed, so let’s say 2 UDP and 5 TCP-Clients ?

You are using WF121 from blue giga, what host interface will be used and which IO are avail, like I2C, UART, SPI, etc ?

As far as I know, there is a PIC32 internal CPU on board are you using that for the web server or are you using the .NetMf one (which comes with a free undocumented feature, just one f… character … sloppy SQA if you ask me … but than again who is perfect … )

Maybe you have some specs for your WiFi board, they do probably differ from the BG ?

@ PiWi - The driver has some basic support for UDP, but development has been primarily on the TCP side to date. The IL-G-WF121 module uses a UART interface between it and the host MCU. None of the WF121 IO port are exposed, but I supppose you could solder directly to the board. :open_mouth:

@ munderhill - Same for me as for @ RobvanSchelven. Custom Http server with websockets.

@ John Karbin - Just a small update: I’ve got the access point working and multiple clients connecting to it. I modified some existing web server code to serve up a web page and all the clients can repeatedly poll the page (manually).

Here is the startup code (pretty sure I can simplify this too):

void ProgramStarted()
	_wifi = new GadgeteerWifi();
	_wifi.WifiStateChanged += new WifiBase.WifiStateChangedDelegate(OnWifiStateChanged);
	_ap = new AccessPoint(_wifi, new IpAddress(new byte[] { 192, 168, 1, 1 }));
	_webserver = new WebServer(_wifi);

void OnWifiStateChanged(object sender, WifiStateChangedEventArgs e)
	if (e.NewState == WifiStates.On)
		_ap.Start("IoTLabs", WifiSecurity.Open);

1 Like

@ munderhill - Is the name of the AP fixed or can that be changed by the user?
Does this device supports something like mDNS so that a user can access it by name instead of IP address?

@ Rob, the WF121 supports DNS, has to be implemented in the driver of course.

BGScript Functions:

call tcpip_dhcp_set_hostname(hostname_len, hostname_data)(result)

call tcpip_dns_configure(index, address)(result) // Index is 1 of 2 DNS servers

call tcpip_dns_gethostbyname(name_len, name_data)(result)

1 Like

@ RobvanSchelven - The SSID can be user specified. In my example it is “IoTLabs”

1 Like

@ munderhill - Greate!!! And nice looking api :slight_smile:
If you want to test it with websockets I can send you the code that we based our server on. And there seem to be alot of other examples and open source projects for websockets on codeplex and codshare etc.
And also dns… it would be perfect.

This is an interesting thread to me as it looks like you’ve got Access Point capability with the RS21 that GHI provides :slight_smile:

@ munderhil - is this AccessPoint class available yet as part of a GHI library or was it more experimental? In any case would I be able to get a binary with it so I can play with my Fez Spider and RS21 module?

Ideally I’d like to serve up a page from my Fez which would in turn show an enumeration of detected wireless networks that I can in turn join to. In my limited network knowledge it seems that I would have to turn my Spider into an access point.

Sorry if I’m out in left field with my questions :frowning:

Thank you for any help!

@ BigRunningBack - The code that I presented was for the IoT Labs WiFi module, not the GHI RS21 module. I do not think that you need to create an access point to list the available access points. The Spider could host a webserver and serve up a page that displays the list of access points that the WiFi module can “see”. Unless I am misunderstanding your requirements.