From: Joseph Coffland Date: Thu, 8 Oct 2020 02:01:14 +0000 (-0700) Subject: Allow disabling the internal WiFi so a USB dongle can be used. X-Git-Url: https://git.buildbotics.com/?a=commitdiff_plain;h=94d7ba202a630aab036d7053d517c26dd24ff265;p=bbctrl-firmware Allow disabling the internal WiFi so a USB dongle can be used. --- diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bc0b97..405a65c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ Buildbotics CNC Controller Firmware Changelog - Clear planner coolant and spindle state on stop. - Fix web disconnect problem when downloading a bug report. - Fix for jogging on touch screens. + - Allow disabling the internal WiFi so a USB dongle can be used. ## v0.4.14 - Handle file uploads with '#' or '?' in the name. diff --git a/scripts/config-wifi b/scripts/config-wifi index 018c676..f76300c 100755 --- a/scripts/config-wifi +++ b/scripts/config-wifi @@ -6,19 +6,28 @@ SSID= PASS= CHANNEL=7 REBOOT=false +DISABLE_INTERNAL_WIFI=false WLAN0_CFG=/etc/network/interfaces.d/wlan0 HOSTAPD_CFG=/etc/hostapd/hostapd.conf DNSMASQ_CFG=/etc/dnsmasq.conf DHCPCD_CFG=/etc/dhcpcd.conf WPA_CFG=/etc/wpa_supplicant/wpa_supplicant.conf +MOD_DISABLE=/etc/modprobe.d/blacklist-internal-wifi.conf function query_config() { + if [ -e $MOD_DISABLE ]; then + INTERNAL=false + else + INTERNAL=true + fi + if [ -e $WLAN0_CFG ]; then SSID=$(grep wpa-ssid $WLAN0_CFG | sed 's/^[[:space:]]*wpa-ssid "\([^"]*\)"/\1/') - echo "{\"ssid\": \"$SSID\", \"mode\": \"client\"}" + echo -n "{\"ssid\": \"$SSID\", \"mode\": \"client\", " + echo "\"internal\": $INTERNAL}" else if [ -e $HOSTAPD_CFG -a -e /etc/default/hostapd ]; then @@ -27,7 +36,8 @@ function query_config() { sed 's/^channel=\(.*\)$/\1/') echo -n "{\"ssid\": \"$SSID\", " - echo "\"channel\": $CHANNEL, \"mode\": \"ap\"}" + echo -n "\"channel\": $CHANNEL, \"mode\": \"ap\" " + echo "\"internal\": $INTERNAL}" else echo "{\"mode\": \"disabled\"}" @@ -177,6 +187,7 @@ function usage() { echo echo " -a Configure access point." echo " -d Disable wifi." + echo " -x Disable internal wifi." echo " -r Reboot when done." echo " -s Set SSID." echo " -p Set password." @@ -191,6 +202,7 @@ while [ $# -ne 0 ]; do case "$1" in -a) AP=true ;; -d) DISABLE=true ;; + -x) DISABLE_INTERNAL_WIFI=true ;; -r) REBOOT=true; ;; -s) SSID="$2"; shift ;; -p) PASS="$2"; shift ;; @@ -253,6 +265,18 @@ else echo "Configuring Wifi" configure_wifi fi + + if $DISABLE_INTERNAL_WIFI; then + if [ ! -e $MOD_DISABLE ]; then + echo -e "blacklist brcmfmac\nblacklist brcmutil" > $MOD_DISABLE + REBOOT=true; + fi + else + if [ -e $MOD_DISABLE ]; then + rm $MOD_DISABLE + REBOOT=true; + fi + fi fi diff --git a/src/js/admin-network-view.js b/src/js/admin-network-view.js index 4bc71cb..bf029cf 100644 --- a/src/js/admin-network-view.js +++ b/src/js/admin-network-view.js @@ -48,6 +48,7 @@ module.exports = { password: '', password2: '', wifi_mode: 'client', + wifi_internal: true, wifi_ssid: '', wifi_ch: undefined, wifi_pass: '', @@ -67,9 +68,10 @@ module.exports = { }.bind(this)); api.get('wifi').done(function (config) { - this.wifi_mode = config.mode; - this.wifi_ssid = config.ssid; - this.wifi_ch = config.channel; + this.wifi_mode = config.mode; + this.wifi_internal = config.internal; + this.wifi_ssid = config.ssid; + this.wifi_ch = config.channel; }.bind(this)); }, @@ -162,10 +164,11 @@ module.exports = { this.rebooting = true; var config = { - mode: this.wifi_mode, - channel: this.wifi_ch, - ssid: this.wifi_ssid, - pass: this.wifi_pass + mode: this.wifi_mode, + internal: this.wifi_internal, + channel: this.wifi_ch, + ssid: this.wifi_ssid, + pass: this.wifi_pass } api.put('wifi', config).fail(function (error) { diff --git a/src/pug/templates/admin-network-view.pug b/src/pug/templates/admin-network-view.pug index eba3370..de1e966 100644 --- a/src/pug/templates/admin-network-view.pug +++ b/src/pug/templates/admin-network-view.pug @@ -81,6 +81,11 @@ script#admin-network-view-template(type="text/x-template") button.pure-button.pure-button-primary(@click="wifiConfirm = true", v-if="wifi_mode == 'disabled'") Set + .pure-control-group(v-if="wifi_mode != 'disabled'", + title="Use the intenral WiFi. Disable to use a USB WiFi dongle") + label(for="internal") Internal WiFi + input(type="checkbox", v-model="wifi_internal") + .pure-control-group(v-if="wifi_mode == 'ap'") label(for="wifi_ch") Channel select(name="wifi_ch", v-model="wifi_ch") diff --git a/src/py/bbctrl/Web.py b/src/py/bbctrl/Web.py index 9815c36..2674783 100644 --- a/src/py/bbctrl/Web.py +++ b/src/py/bbctrl/Web.py @@ -194,6 +194,9 @@ class WifiHandler(bbctrl.APIHandler): elif 'ssid' in self.json: cmd += ['-s', self.json['ssid']] + if 'internal' in self.json and not self.json['internal']: + cmd += ['-x'] + if mode == 'ap': cmd += ['-a'] if 'channel' in self.json: