Add WiFi "Smart Mode" option.

No default gateway. Allows iOS to choose internet source (cellular or WiFi).
pull/801/head
cyoung 2019-12-21 12:32:02 -05:00
rodzic eebe80d3c7
commit be93f4290c
8 zmienionych plików z 41 dodań i 5 usunięć

Wyświetl plik

@ -0,0 +1,13 @@
ddns-update-style none;
default-lease-time 86400; # 24 hours
max-lease-time 172800; # 48 hours
authoritative;
log-facility local7;
subnet 192.168.10.0 netmask 255.255.255.0 {
range 192.168.10.10 192.168.10.50;
option broadcast-address 192.168.10.255;
default-lease-time 12000;
max-lease-time 12000;
option domain-name "stratux.local";
option domain-name-servers 4.2.2.2;
}

Wyświetl plik

@ -296,8 +296,8 @@ func makeOwnshipReport() bool {
msg[0] = 0x0A // Message type "Ownship".
// Ownship Target Identify (see 3.5.1.2 of GDL-90 Specifications)
// First half of byte is 0 for 'No Traffic Alert'
// Second half of byte is 0 for 'ADS-B with ICAO'
// First half of byte is 0 for 'No Traffic Alert'
// Second half of byte is 0 for 'ADS-B with ICAO'
msg[1] = 0x00 // Alert status, address type.
code, _ := hex.DecodeString(globalSettings.OwnshipModeS)
@ -1125,6 +1125,7 @@ type settings struct {
WiFiChannel int
WiFiSecurityEnabled bool
WiFiPassphrase string
WiFiSmartEnabled bool // "Smart WiFi" - disables the default gateway for iOS.
}
type status struct {
@ -1309,6 +1310,13 @@ func saveWiFiUserSettings() {
fmt.Fprintf(writer, "wpa_passphrase=%s\n", globalSettings.WiFiPassphrase)
}
writer.Flush()
// "Smart WiFi". Just use one of two pre-made dhcpd config files.
dhcpd_config := "/etc/dhcp/dhcpd-not_smart.conf"
if globalSettings.WiFiSmartEnabled {
dhcpd_config = "/etc/dhcp/dhcpd-smart.conf"
}
os.Symlink(dhcpd_config, "/etc/dhcp/dhcpd.conf")
}
func openReplay(fn string, compressed bool) (WriteCloser, error) {

Wyświetl plik

@ -378,6 +378,9 @@ func handleSettingsSetRequest(w http.ResponseWriter, r *http.Request) {
case "WiFiPassphrase":
globalSettings.WiFiPassphrase = val.(string)
resetWiFi = true
case "WiFiSmartEnabled":
globalSettings.WiFiSmartEnabled = val.(bool)
resetWiFi = true
default:
log.Printf("handleSettingsSetRequest:json: unrecognized key:%s\n", key)
}

Wyświetl plik

@ -36,7 +36,8 @@ cp image/99-uavionix.rules work/bin/
cp image/motd work/bin/
cp image/stratux-wifi.sh work/bin/
cp image/rc.local work/bin/
cp image/dhcpd.conf work/bin/
cp image/dhcpd-not_smart.conf work/bin/
cp image/dhcpd-smart.conf work/bin/
cp image/interfaces work/bin/
cp image/logrotate.conf work/bin/
cp image/logrotate_d_stratux work/bin/

Wyświetl plik

@ -87,7 +87,9 @@ cp -f ahrs_approx /usr/bin/
chmod 755 /usr/bin/ahrs_approx
# DHCPD Config.
cp -f dhcpd.conf /etc/dhcp/dhcpd.conf
cp -f dhcpd-not_smart.conf /etc/dhcp/
cp -f dhcpd-smart.conf /etc/dhcp/
ln -s /etc/dhcp/dhcpd-not_smart.conf /etc/dhcp/dhcpd.conf
# Interfaces file.
cp -f interfaces /etc/network/interfaces

Wyświetl plik

@ -47,6 +47,7 @@ function SettingsCtrl($rootScope, $scope, $state, $location, $window, $http) {
$scope.WiFiPassphrase = settings.WiFiPassphrase;
$scope.WiFiSecurityEnabled = settings.WiFiSecurityEnabled;
$scope.WiFiChannel = settings.WiFiChannel;
$scope.WiFiSmartEnabled = settings.WiFiSmartEnabled;
$scope.Channels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
}
@ -287,7 +288,8 @@ function SettingsCtrl($rootScope, $scope, $state, $location, $window, $http) {
"WiFiSSID" : $scope.WiFiSSID,
"WiFiSecurityEnabled" : $scope.WiFiSecurityEnabled,
"WiFiPassphrase" : $scope.WiFiPassphrase,
"WiFiChannel" : parseInt($scope.WiFiChannel)
"WiFiChannel" : parseInt($scope.WiFiChannel),
"WiFiSmartEnabled": $scope.WiFiSmartEnabled
};
// console.log(angular.toJson(newsettings));

Wyświetl plik

@ -134,6 +134,12 @@
<select id="WiFiChannel" class="input-small col-sm-2 form-control-sm"
ng-model="WiFiChannel" ng-options="x for x in Channels"></select>
</div>
<div class="form-group reset-flow">
<label class="control-label col-xs-7">Smart WiFi</label>
<div class="col-xs-5">
<ui-switch ng-model="WiFiSmartEnabled" settings-change></ui-switch>
</div>
</div>
<div class="form-group reset-flow">
<button class="btn btn-primary btn-block" ng-click="updateWiFi()">Submit WiFi Changes</button>
</div>
@ -383,6 +389,7 @@
<p>WiFi Security: <b>{{WiFiSecurityEnabled}}</b></p>
<p>WiFi Passphrase: <b>{{WiFiPassphrase}}</b></p>
<p>WiFi Channel: <b>{{WiFiChannel}}</b></p>
<p>Smart mode: <b>{{WiFiSmartEnabled}}</b></p>
<p>Your Stratux's WiFi services are now restarting to apply the new settings. This could take up to 30 seconds.<br/>
You might have to reconnect to your new WiFi SSID. </p>
</div>