This is fairly simply done! Here is what I just did to get the adhoc network scenario working:
1) Follow the WebServer sample sketch instructions to build the sample WebServer
2) Before building and uploading the sketch to the Arduino/WiShield make the following change to the WebServer sketch file (the one with the setup() and loop() functions in it) - to enable adhoc mode on the WiShield:
Change this line:
- Code: Select all
unsigned char wireless_mode = WIRELESS_MODE_INFRA;
To this:
- Code: Select all
unsigned char wireless_mode = WIRELESS_MODE_ADHOC;
3) Build the modified WebServer sample and upload to the Arduino/WiShield
4) Remember the IP address of the WiShield; you will need this later (by default it is 192.168.1.2)
Note: I never modify the sample scripts as I like to keep them pristine; I always copy them to a new location before modifying.
Now on the iPhone
1) Go to Settings -> Wi-Fi and choose the ASYNCLABS network. This network name comes from the following line in the sample sketch:
- Code: Select all
const prog_char ssid[] PROGMEM = {"ASYNCLABS"};
2) After you have selected the ASYNCLABS WiFi network touch the little white/blue arrow at the right of the ASYNCLABS entry in the Wi-Fi Networks page. This will allow you to configure the iPhone's usage of this adhoc WiFi network.
3) Select the Static button to allow you to set the IP address and Subnet mask
4) Change the IP address to: 192.168.1.1 and the Subnet Mask to: 255.255.255.0 - then back out of the net settings
5) Go to Safari and surf to 192.168.1.2 (or whatever address your WiShield is using) and see the WiShield sample WebServer page in all of its glory!
I noticed that the iPhone would stay connected to the ASYNCLABS adhoc network for random amounts of time and then default back to my home's "real" WiFi network. Not sure if this is a problem with the WiShield's adhoc mode or the iPhone. I suppose that once this is working you could do the same on your computer to see if it held onto ASYNCLABS any better...
These steps can be easily adapted to any of the other WiShield sample sketches. If you don't already have a WiFi network in place adhoc is a fine way to go; however if you do have a WiFi network in place I'd recommend not using adhoc and just put the Arduino/WiShield onto the network as any other device. This way you can access the Arduino/WiShield from any device on the network and not just those on the adhoc network.
Greg