WiFi access point on MarS Board - FrankBau/meta-marsboard-bsp GitHub Wiki
Preface
If you have not uses WiFi on MarsBoard before, you might want to start with a WiFi client on MarS Board.
The goal is that the MarS Board shows its own wifi network and that other clients like smartphones, laptops etc.. can connect to the MarS Board. for testing, you may set up a Web Server (lighttpd). This scenario is perfect for wireless communication to a nearby MarS Board, e.g. mounted on a mobile robotic platform.
The MarS Board network as configured here will not be connected to the internet. In order to achieve internet access, you may use the wired network connector and configure the MarS Board as a wireless router (not shown here but there are many tutorial on the internet).
Setting up a Wireless Access Point
Add two more layers to conf/bblayers.conf if not yet present:
${BSPDIR}/sources/meta-openembedded/meta-networking \
${BSPDIR}/sources/meta-openembedded/meta-python \
add some packages to your image:
IMAGE_INSTALL_append += " hostapd dnsmasq"
build the image, install it on SD card and boot the target.
Preparation
There may be some services/daemons running that interfere with the access point setup.
Use ps -x
to check for:
connmand
connection manager daemon. see https://01.org/connman which may use the DNS server port 53. Stop connman with
/etc/init.d/connman stop
wpa_supplicant
se https://w1.fi/wpa_supplicant/. Kill it with
killall wpa_supplicant
Use fixed IP address
First, you should edit your network configuration file:
mv /etc/network/interfaces /etc/network/interfaces.orig
vi /etc/network/interfaces
new file content:
auto wlan0
iface wlan0 inet static
address 192.168.0.1
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
The network 192.168.0.0 was chosen from the private network pool such that it does not conflict with other nearby networks. You may need to change the .0.
part of the network according to your needs.
Finally, restart the networking services to make your changes effective and enable wifi:
ifdown wlan0
rfkill unblock wifi
ifup wlan0
hostapd (Wireless Access Point Daemon)
Save the original the hostapd conf file /etc/hostapd.conf and create a new, minimal conf file
mv /etc/hostapd.conf /etc/hostapd.conf.orig
vi /etc/hostapd.conf
with the following minimal content (for an unencrypted open network):
interface=wlan0
driver=nl80211
ssid=test
hw_mode=g
channel=1
later you may add some lines to force network authentication, consult the internet wisdom.
Start hostapd as a daemon:
/etc/init.d/hostapd restart
Now, you should see a new wireless network test
on any nearby wireless client like your laptop or smartphone. But, you cannot connect right now, as the new access point needs a little more configuration.
Further reading:
dnsmasq (DHCP and DNS server)
Edit /etc/dnsmasq.conf
(save the original file before overwriting it).
interface=wlan0
listen-address=127.0.0.1
bind-interfaces
bogus-priv
domain-needed
dhcp-range=192.168.0.50,192.168.0.150,12h
Restart dnsmasq
to make your changes effective (only need to stop it when it was running before or use restart).
/etc/init.d/dnsmasq stop
/etc/init.d/dnsmasq start
First connect
Tested using Android and Windows 10 clients. The lighttpd web server should be running and listen on port 80.
- search for the test network on your client.
- connect to it (The client may complain on missing internet connectivity)
- open a browser and enter the IP address you have chose above like http://192.168.0.1
- a webpage should be displayed (lighttpd default says "It works!").