Access Point

From Klaus' wiki
Jump to: navigation, search

In order to set up the BeagleBone Black as an access point you need to go through a few steps.

I have done this with a TP-Link TL-WN722N adapter.
TP-Link TL-WN722N.png

Manual set up for testing

First is introduced a manual set up and test. After that comes the automation

Configure the Hostappd

First edit the /etc/hostapd/hostapd.conf file (as root)

### Wireless network name ###
### Set your bridge name ###
ssid=<The SSID the AP should Present it self with>
channel=<select af free channel e.g. 1, 6 or 11>
# # Static WPA2 key configuration
# #1=wpa1, 2=wpa2, 3=both
## Key management algorithms ##
## Set cipher suites (encryption algorithms) ##
## TKIP = Temporal Key Integrity Protocol
## CCMP = AES in Counter mode with CBC-MAC
wpa_pairwise=TKIP CCMP
## Shared Key Authentication ##
## Accept all MAC address ###
#enables/disables broadcasting the ssid
# Needed for Windows clients

Configure IP addresses

To set an ip address on the wlan0 interface perform these commands as root:

]$ ip link set wlan0 down
]$ ip addr flush dev wlan0
]$ ip link set wlan0 up
]$ ip addr add dev wlan0

Set up dnsmasqd

In /etc/dnsmasq.d/ create a file (e.g. WlanAp0) with this content:


Note: Do not add to the SoftAp0 file because it will be overwritten at boot.


]$ systemctl restart dnsmasq.service

Manually test

Next test i manually, in order to see if the access point software will run without errors.

root@beaglebone ]$ systemctl stop wpa_supplicant.service
root@beaglebone ]$ hostapd  /etc/hostapd/hostapd.conf

If you can get this connection up running with your Wifi-password and an IP address everything is fine. If not - debug.

Automating it all

In order to set up the wifi access point a boot a few things is needed to be done.

Rather than tracing the whole shabang of boot scripts and other relevant configuration files, I've made a couple of simple scripts that will bring up the WiFi access point at boot.

If this was for production I'd gone through all the scripts and configuration files to make it more correct. But this solution solves my needs for this project. I kill or stop what I don't need and starts what I need.

You'll need the configurations files from above, so keep them intact.

The start up script

In /root/bin/ put this:

/bin/systemctl stop wpa_supplicant.service
sleep 1
/sbin/ip link set wlan0 down
sleep 1
/sbin/ip addr flush dev wlan0
/sbin/ip link set wlan0 up
/sbin/ip addr add dev wlan0
/bin/systemctl restart hostapd

Note: If you want another IP address be sure to also modify the WifiAP0 file in /etc/dnsmasq.d to suit your needs.

NOTE: The sleep's are needed to make it work. I found out that when run from commandline it worked perfect, but not in the boot process. Adding logger statements to get something in the /var/log/messages log then it worked. So a small delay was apparently needed to let things settle.

The shut down script

In /root/bin/ put this:

/bin/systemctl stop hostapd
/sbin/ip link set wlan0 down
/sbin/ip addr flush dev wlan0
/sbin/ip link set wlan0 up
/bin/systemctl start wpa_supplicant.service

which, when run, should bring your BeagleBone back to "normal" conditions

FInally make the scripts executable:

]$ chmod u+x st*

init script

In /etc/init.d create af file (e.g. wifiAP) with this content:

#! /bin/sh

# Provides: WifiAccessPoint
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Enables or stop Wifi Access Point
# Description: Enables or stop Wifi Access Point
case "$1" in
    sleep 60

exit 0

The sleep 60 is just to allow the basic system to get up and stabilise - may be shortened.

Next execute these commands:

]$ chmod 755 /etc/init.d/wifiAP
]$ update-rc.d wifiAP defaults

References and Acknowledgements

I've been way around on the internet to get inspiration to this.

One page gave me the first steeps dantalion

But it was only when visiting the Foo, Bar, Foobar page it all fell into place.