Introduction: Emergency Communication Using Wireless Ad-Hoc on Intel Edison
In the cases of Emergency situations like Earth quakes, military etc, if the other networks are down, but still would like to have some network for communication, then one can opt for wireless ad-hoc. You can send Edisons with Ad-hoc enabled on it to the air, so that they can connect with each other and form a network and give access to others to connect with other people in remote places. That's a big picture of this project, but we will be demonstrating on how to setup a wireless ad-hoc network on Edison and how to communicate with other Edisons on the network.
This project is supported by BAL-IoTLAB(www.iotlab.in)
Step 1: Configuring Edison
If you have already flashed Yocto on Edison then you can skip this step.
First you need to have Yocto OS on Intel-Edison(I havnt tried this on Ubilinux),
Here is how you can flash Edison with Yocto OS:
1. Download and Unzip Yocto Image file from : http://downloadmirror.intel.com/24389/eng/edison-...
2. Then download and double unzip dfutils from : http://downloadmirror.intel.com/24389/eng/edison-...
3. Now copy all the contents in the extracted folder of dfutils/win32-mingw32 to the extracted folder of yoctoImage/ and paste it.
4. Run flashall.bat and follow the instructions on the screen.
After you are done with flashing yocto on Edison, now
1. Connect to Edison via Serial terminal, by connecting the Serial on Edison to your PC.
2. Then start a Serial session using Putty(windows), or Screen(linux).
3. Now execute "vi /etc/opkg/base-feeds.conf"
4. then add :
src/gz all http://repo.opkg.net/edison/repo/all
src/gz edison http://repo.opkg.net/edison/repo/all
src/gz core2-32 http://repo.opkg.net/edison/repo/all
These lines into base-feeds.conf
5. Now execute "opkg update"
6. Then you can download most of the software like 'git', 'nano', 'tmux', 'upm', 'mraa' etc.
If you would like to resize the boot then continue with this
1. Run 'vi resizeBoot.sh'
2. Paste this into it:
# Reference: https://communities.intel.com/message/259323
cp -rp /boot/* /home/root/boot-backup/
mkfs.vfat -v -nboot -F16 /dev/mmcblk0p7
cp -rp /home/root/boot-backup/* /boot
rm -rf /home/root/boot-backup
df -h /boot
echo "/boot resized."
3. Then run 'sh resizeBoot.sh'
Step 2: Configure the Ip Address Range That You Would Like to Have on Edison
1. Execute this command 'vi /etc/hostapd/udhcpd-for-hostapd.conf'(If you dont find it, then download udhcpd-for-hostapd.conf)
2. Press 'i', so that you will enter insert mode in 'vi' text editor
3. Then you can edit the start and end ip addresses according to your requirement.
4. Now in order to save your changes, press 'esc', then enter ':wq', and press enter
Step 3: Start Ad-Hoc on Edison
1. Run 'vi adHocOnEdison.sh'
2. Paste this into it :
$rmt wpa_cli -iwlan0 disconnect
$rmt wpa_cli -iwlan0 remove_network all
$rmt wpa_cli -iwlan0 add_network
$rmt wpa_cli -iwlan0 set_network 0 frequency 2412
$rmt wpa_cli -iwlan0 set_network 0 mode 1
if [ ! -n "$rmt" ] ; then
$rmt wpa_cli -iwlan0 set_network 0 ssid \"Edison Ad-Hoc\"
$rmt wpa_cli -iwlan0 set_network 0 ssid '\"'Edison Ad-Hoc'\"'
$rmt wpa_cli -iwlan0 set_network 0 auth_alg OPEN
$rmt wpa_cli -iwlan0 set_network 0 key_mgmt NONE
$rmt wpa_cli -iwlan0 set_network 0 scan_ssid 1
$rmt wpa_cli -iwlan0 select_network 0
$rmt wpa_cli -iwlan0 enable_network 0
$rmt wpa_cli -iwlan0 status
2. Run 'sh adHocOnEdison.sh'
3. Running the above script will create an Ad-Hoc Network under the name 'Edison Ad-Hoc'.
4. Wait for 10 secs
5. Run 'iwconfig' and check mode=='ad-hoc' and cell has an Id
6. If the above step is valid then your ad-hoc is ready.
7. You can check your ad-hoc on your pc by looking at list of Wifi's available
Step 4: Start Dhcp Server on Edison
Follow this step only on the first device
1. If this is the first device or node on the network, then you must run 'ifconfig wlan0 192.168.42.20(or whatever is the start address that you assigned in the step 'Configure the Ip address range')'. If this is not the first device then ignore this step.
2. Now you must configure dhcp server on Edison, for which we will use the same server that Edison uses when creating Access-point. So run "udhcpd -f /etc/hostapd/udhcpd-for-hostapd.conf &", the '&' is used to run the server in the background.
3. Now run 'ps' and check if 'udhcpd -f /etc/hostapd/udhcpd-for-hostapd.conf' is running in the list.
4. if so then the dhcp server is up in Edison, so all the devices connecting to this ad-hoc will be assigned an ip address dynamically.
Step 5: Connect Other Edisons to This Ad-Hoc Network
1. From another Edison create 'vi adHocOnEdison.sh'(copy the code from previous step).
2. Just run 'sh adHocOnEdison.sh'
3. Run 'iwconfig' and check mode=='ad-hoc' and cell has an Id
4. Test the connection by typing 'ping 192.168.42.20'(or whatever is the start address that you assigned in the step 'Configure the Ip address range')'.
5. If the previous step is successful, then everything is fine.
6. If step 4 fails, then type 'route' and see if you can find this line :
192.168.42.0 * 255.255.255.0 U 0 0 0 wlan0
7. If not then Run 'route add -net 192.168.42.0 netmask 255.255.255.0 dev wlan0
8. Now try pinging and everything has to be fine.
9. Now optionally you may configure dhcp server on this Edison as well, for which we will use the same server that Edison uses when creating Access-point. So run "udhcpd -f /etc/hostapd/udhcpd-for-hostapd.conf &", the '&' is used to run the server in the background.
10. Now run 'ps' and check if 'udhcpd -f /etc/hostapd/udhcpd-for-hostapd.conf' is running in the list.
11. if so then the dhcp server is up in Edison, so all the devices connecting to this ad-hoc will be assigned an ip address dynamically.
Step 6: Test the Ad-Hoc Network by Removing the Edison That Was Used to Create the Network.
1. Add one more Edison to the network by following the step 'Connect Other Devices to this Ad-Hoc'.
2. Now remove the First Edison that was added in the network.
3. Check if the network still exists(Practically if everything is fine then the network must exist).
4. If so then carry on with 'ssh', 'scp', sending Udp/Tcp packets, server etc.
Step 7: Changing the Name of the Ad-Hoc Created
1. Edit adHocOnEdison.sh by running 'vi adHocOnEdison.sh' in the folder where adHocOnEdison.sh was downloaded.
2. Then replace 'Edison Ad-Hoc' with the name of the network that you desire.
Step 8: Udp Communication Over Ad-Hoc Network
1. Download 'udpServer.js' and run 'node udpServer.js' on one Edison, note down its host:port(ex 192.168.42.20:41234)
2. Now Download 'udpClient.js', alter the Host and Port address in it according to the host:port that you copied from step 1, and run 'node udpClient.js' on another Edison.
3. Now you can see the udpClient's packets being received on the Edison running UDPServer. You can use this message and build logic on top of it, or use it for voice communication.
We have a be nice policy.
Please be positive and constructive.