Alert.png

Notice: This page contains information for the legacy Phidget21 Library.

Phidget21 is out of support. Bugfixes may be considered on a case by case basis.

Phidget21 does not support VINT Phidgets, or new USB Phidgets released after 2020. We maintain a selection of legacy devices for sale that are supported in Phidget21.

We recommend that new projects be developed against the Phidget22 Library.


Click on the 2phidget22.jpg button in the menu bar to go to the Phidget22 version of this page.

Alert.png

Ad-Hoc Networks on the SBC

From Phidgets Legacy Support
Revision as of 19:20, 16 October 2012 by Mwbenedi (talk | contribs)

If you ever wanted to communicate with your single board computer wirelessly and without using your home network, then you're probably going to be interested in setting up an Ad-Hoc network connection. And though we currently do not have a proper interface for doing this, the entire process is relatively simple.

In this example, I'm going to show you how to communicate between a computer running a Linux based operating system, such as a laptop or desktop, and the Phidgets Single Board Computer. The first thing you'll need to do is connect to your Single Board Computer via SSH. Remember that you'll need to enable the "SSH Server" on your SBC first.

You can do this by:

* logging into the SBC's web interface
* clicking on the "Network" tab
* clicking on the "Settings" tab
* selecting "enabled" under "SSH Server"
* clicking "Save Changes"

When that's done, you can use SSH to log in to your SBC by typing:

ssh root@phidgetsbc.local

Remember, if you changed the hostname of your SBC, you'll need to enter that hostname instead of "phidgetsbc". If you prefer, and if you know what it is, you can always type in the ip address instead.

Once you're logged in, the next step is to navigate to the root directory. If you're not sure how to navigate to the root directory, you can do that by typing:

cd /

Then, we need to create a file called "wireless". We can do this with a simple text editor such as pico.

pico wireless

When pico launches, you will need to copy the following lines of code.

#!/bin/sh
ifconfig wlan0 down
iwconfig wlan0 mode ad-hoc
iwconfig wlan0 essid 'test'
iwconfig wlan0 key 1234567890
ifconfig wlan0 up
ifconfig wlan0 192.168.100.2
iwconfig wlan0 channel 4

One the code is copied, you can press "ctrl+o" to save the file and "ctrl+x" to exit pico. You may notice that we're setting a lot of the specifics of our ad-hoc network in this file. If you ever want to change any of these settings, you will need to change this file.

When this is done, you will need to edit another file. This time, we're going to edit a file that runs every time the SBC boots up. Begin by navigating to the "etc" directory from root.

cd /etc

Then, start up pico again, but this time, by opening the file "rc.local".

pico rc.local

Finally, copy this line of code right before the "exit 0" line.

/wireless

After you're done that, simply save the file with "ctrl+o" and exit with "ctrl+x", like you did before. When the file has been saved, you exit out of SSH and reboot the robot.

We have now finished setting up the Ad-Hoc network on the SBC.

The next thing we're going to do is connect our Linux based computer to the SBC via our new Ad-Hoc network. If you're not using Linux, this process is a little bit different, but not by much.

The nice thing about using Linux is that it's exactly the same process as before. The only difference is how we set up the wireless file. For your Linux based computer, the wireless file will look like this:

#!/bin/sh
ifconfig wlan0 down
iwconfig wlan0 mode ad-hoc
iwconfig wlan0 essid 'test'
iwconfig wlan0 key 1234567890
ifconfig wlan0 up
ifconfig wlan0 192.168.100.1
iwconfig wlan0 channel 4

Notice that the only thing I have changed is the ip address.