meta-somdevices: hostapd: Add hostapd script to restart wilc-sdio module after stoppi...
authorJosep Orga <jorga@somdevices.com>
Fri, 16 Apr 2021 11:30:33 +0000 (13:30 +0200)
committerJosep Orga <jorga@somdevices.com>
Fri, 16 Apr 2021 11:30:33 +0000 (13:30 +0200)
Signed-off-by: Josep Orga <jorga@somdevices.com>
recipes-connectivity/hostapd/hostapd/hostapd.sh [new file with mode: 0644]
recipes-connectivity/hostapd/hostapd_2.8.bbappend

diff --git a/recipes-connectivity/hostapd/hostapd/hostapd.sh b/recipes-connectivity/hostapd/hostapd/hostapd.sh
new file mode 100644 (file)
index 0000000..fd4b1ab
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+sleep 1
+if [ ! -d /sys/class/net/wlan0 ]; then
+    #If wlan0 device does not exist reset wilc-sdio module
+    /sbin/rmmod wilc-sdio
+    sleep 1
+    /sbin/modprobe wilc-sdio
+fi
\ No newline at end of file
index 5f639ed..c59b0e1 100644 (file)
@@ -1,7 +1,8 @@
 FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
 
-SUMMARY = "Change hostapd.conf file"
-DESCRIPTION = "Enable 80211n-mode and WPA2-PSK security and change SSID to hostname and password to hostname1234"
+SUMMARY = "Change hostapd.conf file and add hostapd script to restore wlan0"
+DESCRIPTION = "Enable 80211n-mode and WPA2-PSK security and change SSID to hostname and password to hostname1234. \
+And restore wlan0 with hostapd script restarting wilc-sdio module after stopping hostapd service."
 PR = "somdevices.0"
 MAINTAINER = "SomDevices <somdevices@somdevices.com>"
 
@@ -11,6 +12,9 @@ SYSTEMD_SERVICE_${PN} = " hostapd.service"
 SYSTEMD_AUTO_ENABLE_${PN} = "enable"
 HOSTAPD_AP = "somdevices"
 
+SRC_URI += " file://hostapd.sh \
+"
+
 do_install_append () {
        echo "#content hostapd.conf" > ${D}/etc/hostapd.conf
        echo "interface=wlan0" >> ${D}/etc/hostapd.conf
@@ -25,4 +29,8 @@ do_install_append () {
        echo "hw_mode=g" >> ${D}/etc/hostapd.conf
        echo "ieee80211n=1" >> ${D}/etc/hostapd.conf
        echo "wmm_enabled=1" >> ${D}/etc/hostapd.conf
+       #Insert hostapd script
+       install -d ${D}${sysconfdir}/network/if-post-down.d/
+       install -m 755 ${WORKDIR}/hostapd.sh ${D}${sysconfdir}/network/if-post-down.d/hostapd
+       sed -i "9i ExecStopPost=/etc/network/if-post-down.d/hostapd" ${D}${systemd_unitdir}/system/hostapd.service
 }