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: Difference between revisions

From Phidgets Legacy Support
No edit summary
No edit summary
Line 13: Line 13:


<div class="source">
<div class="source">
<syntaxhighlight lang=java>
<syntaxhighlight lang=bash>
ssh root@phidgetsbc.local
ssh root@phidgetsbc.local
</syntaxhighlight>
</syntaxhighlight>
Line 22: Line 22:
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:
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:
<div class="source">
<div class="source">
<syntaxhighlight lang=java>
<syntaxhighlight lang=bash>
cd /
cd /
</syntaxhighlight>
</syntaxhighlight>
Line 29: Line 29:
Then, we need to create a file called "wireless". We can do this with a simple text editor such as pico.
Then, we need to create a file called "wireless". We can do this with a simple text editor such as pico.
<div class="source">
<div class="source">
<syntaxhighlight lang=java>
<syntaxhighlight lang=bash>
pico wireless
pico wireless
</syntaxhighlight>
</syntaxhighlight>
Line 36: Line 36:
When pico launches, you will need to copy the following lines of code.
When pico launches, you will need to copy the following lines of code.
<div class="source">
<div class="source">
<syntaxhighlight lang=java>
<syntaxhighlight lang=bash>
#!/bin/sh
#!/bin/sh
ifconfig wlan0 down
ifconfig wlan0 down
Line 52: Line 52:
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.
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.
<div class="source">
<div class="source">
<syntaxhighlight lang=java>
<syntaxhighlight lang=bash>
cd /etc
cd /etc
</syntaxhighlight>
</syntaxhighlight>
Line 59: Line 59:
Then, start up pico again, but this time, by opening the file "rc.local".
Then, start up pico again, but this time, by opening the file "rc.local".
<div class="source">
<div class="source">
<syntaxhighlight lang=java>
<syntaxhighlight lang=bash>
pico rc.local
pico rc.local
</syntaxhighlight>
</syntaxhighlight>
Line 66: Line 66:
Finally, copy this line of code right before the "exit 0" line.
Finally, copy this line of code right before the "exit 0" line.
<div class="source">
<div class="source">
<syntaxhighlight lang=java>
<syntaxhighlight lang=bash>
/wireless
/wireless
</syntaxhighlight>
</syntaxhighlight>
Line 79: Line 79:
The nice thing about using Linux is that it's exactly the same process as before. The only difference is only in how we set up the wireless file. For your Linux based computer, the wireless file will look like this instead:
The nice thing about using Linux is that it's exactly the same process as before. The only difference is only in how we set up the wireless file. For your Linux based computer, the wireless file will look like this instead:
<div class="source">
<div class="source">
<syntaxhighlight lang=java>
<syntaxhighlight lang=bash>
#!/bin/sh
#!/bin/sh
ifconfig wlan0 down
ifconfig wlan0 down
Line 95: Line 95:
When you're finished, you can reboot your computer, or alternatively, run the "wireless" script from the command line by navigating to the root directory and typing:
When you're finished, you can reboot your computer, or alternatively, run the "wireless" script from the command line by navigating to the root directory and typing:
<div class="source">
<div class="source">
<syntaxhighlight lang=java>
<syntaxhighlight lang=bash>
./wireless
./wireless
</syntaxhighlight>
</syntaxhighlight>

Revision as of 19:59, 16 October 2012

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. (Please remember that you will need two wireless adapters to set up your ad-hoc network. One adapter for your SBC and one adapter for your desktop or laptop.)

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.

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

#!/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. On the SBC, I used an ip address of "192.168.100.2".

When you're finished, you can reboot your computer, or alternatively, run the "wireless" script from the command line by navigating to the root directory and typing:

./wireless

After this is done, you should be able to connect to your SBC over the ad-hoc network.