diff --git a/Makefile b/Makefile index 2ba09e93..be46007d 100644 --- a/Makefile +++ b/Makefile @@ -55,6 +55,7 @@ install: cp -f libdump978.so /usr/lib/libdump978.so cp -f dump1090/dump1090 /usr/bin/ cp -f image/hostapd_manager.sh /usr/sbin/ + cp -f image/hostapd_manager_quiet.sh /usr/sbin/ cp -f image/stratux-wifi.sh /usr/sbin/ clean: diff --git a/__root__stratux-pre-start.sh b/__root__stratux-pre-start.sh index cda14e54..259c2317 100755 --- a/__root__stratux-pre-start.sh +++ b/__root__stratux-pre-start.sh @@ -2,16 +2,39 @@ echo powersave >/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor +STX_LOG="/var/log/stratux.log" +function wLog () { + echo "$(date +"%Y/%m/%d %H:%m:%S") - $1" >> ${STX_LOG} +} + +wLog "Running Stratux Updater Script." + +SCRIPT_MASK="update*stratux*v*.sh" +TEMP_LOCATION="/boot/StratuxUpdates/$SCRIPT_MASK" +UPDATE_LOCATION="/root/$SCRIPT_MASK" + +if [ -e ${TEMP_LOCATION} ]; then + wLog "Found Update Script in $TEMP_LOCATION$SCRIPT_MASK" + TEMP_SCRIPT=`ls -1t ${TEMP_LOCATION} | head -1` + wLog "Moving Script $TEMP_SCRIPT" + cp -r ${TEMP_SCRIPT} /root/ + wLog "Changing permissions to chmod a+x $UPDATE_LOCATION" + chmod a+x ${UPDATE_LOCATION} + wLog "Removing Update file from $TEMP_LOCATION" + rm -rf ${TEMP_SCRIPT} +fi + # Check if we need to run an update. -if [ -e /root/update*stratux*v*.sh ] ; then - UPDATE_SCRIPT=`ls -1t /root/update*stratux*v*.sh | head -1` - if [ -n "$UPDATE_SCRIPT" ] ; then +if [ -e ${UPDATE_LOCATION} ]; then + UPDATE_SCRIPT=`ls -1t ${UPDATE_LOCATION} | head -1` + if [ -n ${UPDATE_SCRIPT} ] ; then # Execute the script, remove it, then reboot. - echo - echo "Running update script ${UPDATE_SCRIPT}..." + wLog "Running update script ${UPDATE_SCRIPT}..." bash ${UPDATE_SCRIPT} - rm -f $UPDATE_SCRIPT + wLog "Removing Update SH" + rm -f ${UPDATE_SCRIPT} + wLog "Finished... Rebooting... Bye" reboot fi fi - +wLog "Exited without updating anything..." diff --git a/image/hostapd_manager_quiet.sh b/image/hostapd_manager_quiet.sh new file mode 100644 index 00000000..3f0c9aa7 --- /dev/null +++ b/image/hostapd_manager_quiet.sh @@ -0,0 +1,244 @@ +#!/bin/bash + +###################################################################### +# STRATUX QUIET HOSTAPD MANAGE # +###################################################################### +# This script is almost identical to hostapd_manager.sh except all the +# screen outputs are supplressed except for error messages. +# +# Usage: +# hostapd_manager_quiet.sh -s Stratux-N12345 -p SquawkDirty! -c 5 +# Command above sets the SSID to "Stratux-N12345, secures the network with the passphrase "SquawkDirty!, and changes the network channel to "5" +# +# hostapd_manager_quiet.sh -o +# Command above opens the network(removes any passphrase) +# +# hostapd_manager_quiet.sh -e +# Command above secures the WiFi network using the default passphrase "SquawkDirtyToMe!" + +# Options: +# -s --Sets the SSID to ${BOLD}ssid${NORM}. -s stratux +# -c --Sets the channel to chan. -c 1 +# -o --Turns off encryption and sets network to open. Cannot be used with -e or -p. +# -e --Turns on encryption with passphrase SquawkDirtyToMe!. Cannot be used with -o or -p +# -p --Turns on encryption with your chosen passphrase pass. 8-63 Printable Characters(ascii 32-126). Cannot be used with -o or -e. -p password! +# +# Important: +# After each call of this script the wifi network will disconnect and restart all associated services to apply the changes + +#Set Script Name variable +SCRIPT=`basename ${BASH_SOURCE[0]}` + +#Initialize variables to default values. +OPT_S=false +OPT_C=false +OPT_E=false +OPT_O=false +OPT_P=false +OPT_Q=false +OPT_R=false +defaultPass="SquawkDirtyToMe!" + +#apply settings and restart all processes +function APPLYSETTINGSQUIET { + sleep 2 + TEMP=:$(/usr/bin/killall -9 hostapd hostapd-edimax > /dev/null 2>&1) + sleep 1 + TEMP=:$(/usr/sbin/service isc-dhcp-server stop > /dev/null 2>&1) + sleep 0.5 + TEMP=:$(ifdown wlan0) + sleep 0.5 + TEMP=:$(ifup wlan0) + sleep 0.5 +} + +function error_exit { + echo "$1" >&2 ## Send message to stderr. Exclude >&2 if you don't want it that way. + exit "${2:-1}" ## Return a code specified by $2 or 1 by default. +} + +if [ $(whoami) != 'root' ]; then + echo "${BOLD}${RED}This script must be executed as root, exiting...${WHITE}${NORMAL}" + echo "${BOLD}${RED}USAGE${WHITE}${NORMAL}" + error_exit "Not Root" +fi + +#Check the number of arguments. If none are passed, print help and exit. +NUMARGS=$# +if [ $NUMARGS -eq 0 ]; then + error_exit "No Args Passed" +fi + +### Start getopts code ### + +#Parse command line flags +#If an option should be followed by an argument, it should be followed by a ":". +#Notice there is no ":" after "eoqh". The leading ":" suppresses error messages from +#getopts. This is required to get my unrecognized option code to work. +options=':s:c:p:eoh' +while getopts $options option; do + case $option in + s) #set option "s" + if [[ -z "${OPTARG}" || "${OPTARG}" == *[[:space:]]* || "${OPTARG}" == -* ]]; then + error_exit "No SSID for -s, exiting..." + else + OPT_S=$OPTARG + fi + ;; + c) #set option "c" + if [[ -z "${OPTARG}" || "${OPTARG}" == *[[:space:]]* || "${OPTARG}" == -* ]]; then + error_exit "Channel option(-c) used without value, exiting... " + else + OPT_C=$OPTARG + if [[ "$OPT_C" =~ ^[0-9]+$ ]] && [ "$OPT_C" -ge 1 -a "$OPT_C" -le 13 ]; then + OPT_C=$OPTARG + else + error_exit "Channel is not within acceptable values, exiting..." + fi + fi + ;; + e) #set option "e" with default passphrase + if [[ -z "${OPTARG}" || "${OPTARG}" == *[[:space:]]* || "${OPTARG}" == -* ]]; then + OPT_E=$defaultPass + else + error_exit "Option -e does not require arguement.${WHITE}${NORMAL}" + fi + ;; + p) #set encryption with user specified passphrase + if [[ -z "${OPTARG}" || "${OPTARG}" =~ ^[[:space:]]*$ || "${OPTARG}" == -* ]]; then + error_exit "Encryption option(-p) used without passphrase!" + else + OPT_P=$OPTARG + fi + echo "$parm Encryption option -p used:" + if [ -z `echo $OPT_P | tr -d "[:print:]"` ] && [ ${#OPT_P} -ge 8 ] && [ ${#OPT_P} -le 63 ]; then + echo "${GREEN} WiFi will be encrypted using ${BOLD}${UNDR}$OPT_P${NORMAL}${GREEN} as the passphrase!${WHITE}${NORMAL}" + else + error_exit "Invalid PASSWORD: 8 - 63 printable characters, exiting..." + fi + ;; + o) #set option "o" + if [[ -z "${OPTARG}" || "${OPTARG}" == *[[:space:]]* || "${OPTARG}" == -* ]]; then + OPT_O=true + else + error_exit "${BOLD}${RED}$err Option -o does not require arguement. Exiting..." + fi + ;; + \?) # invalid option + error_exit "Invalid option -$OPTARG" + ;; + :) # Missing Arg + error_exit "Missing option for argument -$OPTARG" + ;; + *) # Invalid + error_exit "Unimplemented option -$OPTARG ${WHITE}${NORMAL}" + ;; + esac +done + +shift $((OPTIND-1)) #This tells getopts to move on to the next argument. + +### End getopts code ### + + +### Main loop to process files ### + +#This is where your main file processing will take place. This example is just +#printing the files and extensions to the terminal. You should place any other +#file processing tasks within the while-do loop. + +if [[ $OPT_O == true && ( $OPT_E != false || $OPT_P != false ) ]]; then + error_exit "Option -e , -p and -o cannot be used simultaneously" +fi + +if [ $OPT_P != false ] && [ $OPT_E != false ]; then + error_exit "Option -e and -p cannot be used simultaneously..." +fi + +# files to edit +HOSTAPD=('/etc/hostapd/hostapd.user') + +#### +#### File modification loop +#### +for i in "${HOSTAPD[@]}" +do + if [ -f ${i} ]; then + if [ $OPT_S != false ]; then + if grep -q "^ssid=" ${HOSTAPD[$x]}; then + sed -i "s/^ssid=.*/ssid=${OPT_S}/" ${i} + else + echo ${OPT_S} >> ${i} + fi + fi + + if [ $OPT_C != false ]; then + if grep -q "^channel=" ${i}; then + sed -i "s/^channel=.*/channel=${OPT_C}/" ${i} + else + echo ${OPT_C} >> ${i} + fi + fi + + if [ $OPT_E != false ]; then + if grep -q "^#auth_algs=" ${i}; then + sed -i "s/^#auth_algs=.*/auth_algs=1/" ${i} + sed -i "s/^#wpa=.*/wpa=3/" ${i} + sed -i "s/^#wpa_passphrase=.*/wpa_passphrase=$OPT_E/" ${i} + sed -i "s/^#wpa_key_mgmt=.*/wpa_key_mgmt=WPA-PSK/" ${i} + sed -i "s/^#wpa_pairwise=.*/wpa_pairwise=TKIP/" ${i} + sed -i "s/^#rsn_pairwise=.*/rsn_pairwise=CCMP/" ${i} + elif grep -q "^auth_algs=" ${i}; then + sed -i "s/^auth_algs=.*/auth_algs=1/" ${i} + sed -i "s/^wpa=.*/wpa=3/" ${i} + sed -i "s/^wpa_passphrase=.*/wpa_passphrase=$OPT_E/" ${i} + sed -i "s/^wpa_key_mgmt=.*/wpa_key_mgmt=WPA-PSK/" ${i} + sed -i "s/^wpa_pairwise=.*/wpa_pairwise=TKIP/" ${i} + sed -i "s/^rsn_pairwise=.*/rsn_pairwise=CCMP/" ${i} + else + echo "" >> ${i} + echo "auth_algs=1" >> ${i} + echo "wpa=3" >> ${i} + echo "wpa_passphrase=$OPT_E" >> ${i} + echo "wpa_key_mgmt=WPA-PSK" >> ${i} + echo "wpa_pairwise=TKIP" >> ${i} + echo "rsn_pairwise=CCMP" >> ${i} + fi + fi + if [ $OPT_O != false ]; then + if grep -q "^auth_algs=" ${i}; then + sed -i "s/^auth_algs=.*/#auth_algs=1/" ${i} + sed -i "s/^wpa=.*/#wpa=3/" ${i} + sed -i "s/^wpa_passphrase=.*/#wpa_passphrase=$defaultPass/" ${i} + sed -i "s/^wpa_key_mgmt=.*/#wpa_key_mgmt=WPA-PSK/" ${i} + sed -i "s/^wpa_pairwise=.*/#wpa_pairwise=TKIP/" ${i} + sed -i "s/^rsn_pairwise=.*/#rsn_pairwise=CCMP/" ${i} + elif grep -q "^#auth_algs=" ${i}; then + sed -i "s/^#auth_algs=.*/#auth_algs=1/" ${i} + sed -i "s/^#wpa=.*/#wpa=3/" ${i} + sed -i "s/^#wpa_passphrase=.*/#wpa_passphrase=$defaultPass/" ${i} + sed -i "s/^#wpa_key_mgmt=.*/#wpa_key_mgmt=WPA-PSK/" ${i} + sed -i "s/^#wpa_pairwise=.*/#wpa_pairwise=TKIP/" ${i} + sed -i "s/^#rsn_pairwise=.*/#rsn_pairwise=CCMP/" ${i} + else + echo "" >> ${i} + echo "#auth_algs=1" >> ${i} + echo "#wpa=3" >> ${i} + echo "#wpa_passphrase=$defaultPass" >> ${i} + echo "#wpa_key_mgmt=WPA-PSK" >> ${i} + echo "#wpa_pairwise=TKIP" >> ${i} + echo "#rsn_pairwise=CCMP" >> ${i} + fi + fi + else + error_exit "No ${i} file found..." + fi +done + +### End main loop ### + +### Apply Settings and restart all services + + APPLYSETTINGSQUIET + +exit 1 diff --git a/image/mkimg.sh b/image/mkimg.sh index 15b3c58f..b8ec6e33 100755 --- a/image/mkimg.sh +++ b/image/mkimg.sh @@ -43,6 +43,8 @@ cp -f hostapd-edimax.conf mnt/etc/hostapd/hostapd-edimax.conf #hostapd manager script cp -f hostapd_manager.sh mnt/usr/sbin/hostapd_manager.sh chmod 755 mnt/usr/sbin/hostapd_manager.sh +cp -f hostapd_manager_quiet.sh mnt/usr/sbin/hostapd_manager_quiet.sh +chmod 755 mnt/usr/sbin/hostapd_manager_quiet.sh #hostapd cp -f hostapd-edimax mnt/usr/sbin/hostapd-edimax chmod 755 mnt/usr/sbin/hostapd-edimax diff --git a/selfupdate/makeupdate.sh b/selfupdate/makeupdate.sh index 54ae511c..238cc66c 100755 --- a/selfupdate/makeupdate.sh +++ b/selfupdate/makeupdate.sh @@ -31,6 +31,7 @@ cp image/bashrc.txt work/bin/ cp image/modules.txt work/bin/ cp image/stxAliases.txt work/bin/ cp image/hostapd_manager.sh work/bin/ +cp image/hostapd_manager_quiet.sh work/bin/ cp image/sdr-tool.sh work/bin/ cp image/10-stratux.rules work/bin/ cp image/99-uavionix.rules work/bin/ diff --git a/selfupdate/update_footer.sh b/selfupdate/update_footer.sh index 2a2f2018..1f1f4ea8 100755 --- a/selfupdate/update_footer.sh +++ b/selfupdate/update_footer.sh @@ -28,6 +28,7 @@ cp -f stratux-wifi.sh /usr/sbin/ #WiFi Config Manager cp -f hostapd_manager.sh /usr/sbin/ +cp -f hostapd_manager_quiet.sh /usr/sbin/ #SDR Serial Script cp -f sdr-tool.sh /usr/sbin/ diff --git a/web/css/main.css b/web/css/main.css index 643dc24f..0d0110bc 100644 --- a/web/css/main.css +++ b/web/css/main.css @@ -4,6 +4,12 @@ .modal { } + +.grayout { + opacity: 0.4; /* Real browsers */ + filter: alpha(opacity = 60); /* MSIE */ +} + .vertical-alignment-helper { display:table; height: 100%; diff --git a/web/js/main.js b/web/js/main.js index 4a2226f9..bf62e8b0 100755 --- a/web/js/main.js +++ b/web/js/main.js @@ -1,29 +1,32 @@ // application constants -var URL_HOST_BASE = window.location.hostname; -var URL_SETTINGS_GET = "http://" + URL_HOST_BASE + "/getSettings"; -var URL_SETTINGS_SET = "http://" + URL_HOST_BASE + "/setSettings"; -var URL_GPS_WS = "ws://" + URL_HOST_BASE + "/situation"; -var URL_TOWERS_GET = "http://" + URL_HOST_BASE + "/getTowers"; -var URL_STATUS_GET = "http://" + URL_HOST_BASE + "/getStatus"; -var URL_SATELLITES_GET = "http://" + URL_HOST_BASE + "/getSatellites"; -var URL_STATUS_WS = "ws://" + URL_HOST_BASE + "/status"; -var URL_TRAFFIC_WS = "ws://" + URL_HOST_BASE + "/traffic"; -var URL_WEATHER_WS = "ws://" + URL_HOST_BASE + "/weather"; -var URL_DEVELOPER_GET = "ws://" + URL_HOST_BASE + "/developer"; -var URL_UPDATE_UPLOAD = "http://" + URL_HOST_BASE + "/updateUpload"; -var URL_REBOOT = "http://" + URL_HOST_BASE + "/reboot"; -var URL_SHUTDOWN = "http://" + URL_HOST_BASE + "/shutdown"; -var URL_RESTARTAPP = "http://" + URL_HOST_BASE + "/restart"; -var URL_DEV_TOGGLE_GET = "http://" + URL_HOST_BASE + "/develmodetoggle"; -var URL_AHRS_ORIENT = "http://" + URL_HOST_BASE + "/orientAHRS"; -var URL_AHRS_CAL = "http://" + URL_HOST_BASE + "/calibrateAHRS"; -var URL_AHRS_CAGE = "http://" + URL_HOST_BASE + "/cageAHRS"; -var URL_GMETER_RESET = "http://" + URL_HOST_BASE + "/resetGMeter"; -var URL_DELETELOGFILE = "http://" + URL_HOST_BASE + "/deletelogfile"; -var URL_DOWNLOADLOGFILE = "http://" + URL_HOST_BASE + "/downloadlog"; -var URL_DELETEAHRSLOGFILES = "http://" + URL_HOST_BASE + "/deleteahrslogfiles"; -var URL_DOWNLOADAHRSLOGFILES = "http://" + URL_HOST_BASE + "/downloadahrslogs"; -var URL_DOWNLOADDB = "http://" + URL_HOST_BASE + "/downloaddb"; +var URL_HOST_BASE = window.location.hostname + (window.location.port ? ':' + window.location.port : ''); +var URL_HOST_PROTOCOL = window.location.protocol + "//"; + +var URL_AHRS_CAGE = URL_HOST_PROTOCOL + URL_HOST_BASE + "/cageAHRS"; +var URL_AHRS_CAL = URL_HOST_PROTOCOL + URL_HOST_BASE + "/calibrateAHRS"; +var URL_AHRS_ORIENT = URL_HOST_PROTOCOL + URL_HOST_BASE + "/orientAHRS"; +var URL_DELETEAHRSLOGFILES = URL_HOST_PROTOCOL + URL_HOST_BASE + "/deleteahrslogfiles"; +var URL_DELETELOGFILE = URL_HOST_PROTOCOL + URL_HOST_BASE + "/deletelogfile"; +var URL_DEV_TOGGLE_GET = URL_HOST_PROTOCOL + URL_HOST_BASE + "/develmodetoggle"; +var URL_DOWNLOADAHRSLOGFILES = URL_HOST_PROTOCOL + URL_HOST_BASE + "/downloadahrslogs"; +var URL_DOWNLOADDB = URL_HOST_PROTOCOL + URL_HOST_BASE + "/downloaddb"; +var URL_DOWNLOADLOGFILE = URL_HOST_PROTOCOL + URL_HOST_BASE + "/downloadlog"; +var URL_GMETER_RESET = URL_HOST_PROTOCOL + URL_HOST_BASE + "/resetGMeter"; +var URL_REBOOT = URL_HOST_PROTOCOL + URL_HOST_BASE + "/reboot"; +var URL_RESTARTAPP = URL_HOST_PROTOCOL + URL_HOST_BASE + "/restart"; +var URL_SATELLITES_GET = URL_HOST_PROTOCOL + URL_HOST_BASE + "/getSatellites"; +var URL_SETTINGS_GET = URL_HOST_PROTOCOL + URL_HOST_BASE + "/getSettings"; +var URL_SETTINGS_SET = URL_HOST_PROTOCOL + URL_HOST_BASE + "/setSettings"; +var URL_SHUTDOWN = URL_HOST_PROTOCOL + URL_HOST_BASE + "/shutdown"; +var URL_STATUS_GET = URL_HOST_PROTOCOL + URL_HOST_BASE + "/getStatus"; +var URL_TOWERS_GET = URL_HOST_PROTOCOL + URL_HOST_BASE + "/getTowers"; +var URL_UPDATE_UPLOAD = URL_HOST_PROTOCOL + URL_HOST_BASE + "/updateUpload"; + +var URL_DEVELOPER_WS = "ws://" + URL_HOST_BASE + "/developer"; +var URL_GPS_WS = "ws://" + URL_HOST_BASE + "/situation"; +var URL_STATUS_WS = "ws://" + URL_HOST_BASE + "/status"; +var URL_TRAFFIC_WS = "ws://" + URL_HOST_BASE + "/traffic"; +var URL_WEATHER_WS = "ws://" + URL_HOST_BASE + "/weather"; // define the module with dependency on mobile-angular-ui //var app = angular.module('stratux', ['ngRoute', 'mobile-angular-ui', 'mobile-angular-ui.gestures', 'appControllers']); @@ -99,4 +102,4 @@ app.controller('MainCtrl', function ($scope, $http) { }, function(response) { //Second function handles error }); -}); \ No newline at end of file +}); diff --git a/web/plates/js/settings.js b/web/plates/js/settings.js old mode 100644 new mode 100755 index 396986c0..861cfd36 --- a/web/plates/js/settings.js +++ b/web/plates/js/settings.js @@ -1,4 +1,4 @@ -angular.module('appControllers').controller('SettingsCtrl', SettingsCtrl); // get the main module contollers set +angular.module('appControllers').controller('SettingsCtrl', SettingsCtrl); // get the main module controllers set SettingsCtrl.$inject = ['$rootScope', '$scope', '$state', '$location', '$window', '$http']; // Inject my dependencies // create our controller function with all necessary logic @@ -9,7 +9,7 @@ function SettingsCtrl($rootScope, $scope, $state, $location, $window, $http) { var toggles = ['UAT_Enabled', 'ES_Enabled', 'Ping_Enabled', 'GPS_Enabled', 'IMU_Sensor_Enabled', 'BMP_Sensor_Enabled', 'DisplayTrafficSource', 'DEBUG', 'ReplayLog', 'AHRSLog']; var settings = {}; - for (i = 0; i < toggles.length; i++) { + for (var i = 0; i < toggles.length; i++) { settings[toggles[i]] = undefined; } $scope.update_files = ''; @@ -40,6 +40,12 @@ function SettingsCtrl($rootScope, $scope, $state, $location, $window, $http) { $scope.OwnshipModeS = settings.OwnshipModeS; $scope.DeveloperMode = settings.DeveloperMode; $scope.GLimits = settings.GLimits; + $scope.StaticIps = settings.StaticIps; + + $scope.WiFiSSID = settings.WiFiSSID; + $scope.WiFiSecurityEnabled = settings.WiFiSecurityEnabled; + $scope.WiFiPasscode = settings.WiFiPasscode; + $scope.WiFiChannel = settings.WiFiChannel; } function getSettings() { @@ -73,6 +79,11 @@ function SettingsCtrl($rootScope, $scope, $state, $location, $window, $http) { getSettings(); + // Reset all settings from a button on the page + $scope.resetSettings = function () { + getSettings(); + }; + $scope.$watchGroup(toggles, function (newValues, oldValues, scope) { var newsettings = {}; var dirty = false; @@ -95,7 +106,7 @@ function SettingsCtrl($rootScope, $scope, $state, $location, $window, $http) { settings["PPM"] = 0; if (($scope.PPM !== undefined) && ($scope.PPM !== null) && ($scope.PPM !== settings["PPM"])) { settings["PPM"] = parseInt($scope.PPM); - newsettings = { + var newsettings = { "PPM": settings["PPM"] }; // console.log(angular.toJson(newsettings)); @@ -107,7 +118,7 @@ function SettingsCtrl($rootScope, $scope, $state, $location, $window, $http) { settings["Baud"] = 0; if (($scope.Baud !== undefined) && ($scope.Baud !== null) && ($scope.Baud !== settings["Baud"])) { settings["Baud"] = parseInt($scope.Baud); - newsettings = { + var newsettings = { "Baud": settings["Baud"] }; // console.log(angular.toJson(newsettings)); @@ -115,24 +126,24 @@ function SettingsCtrl($rootScope, $scope, $state, $location, $window, $http) { } }; - $scope.updatewatchlist = function () { - if ($scope.WatchList !== settings["WatchList"]) { - settings["WatchList"] = ""; - if ($scope.WatchList !== undefined) { - settings["WatchList"] = $scope.WatchList.toUpperCase(); - } - newsettings = { - "WatchList": settings["WatchList"] - }; - // console.log(angular.toJson(newsettings)); - setSettings(angular.toJson(newsettings)); - } - }; + $scope.updatewatchlist = function () { + if ($scope.WatchList !== settings["WatchList"]) { + settings["WatchList"] = ""; + if ($scope.WatchList !== undefined) { + settings["WatchList"] = $scope.WatchList.toUpperCase(); + } + var newsettings = { + "WatchList": settings["WatchList"] + }; + // console.log(angular.toJson(newsettings)); + setSettings(angular.toJson(newsettings)); + } + }; $scope.updatemodes = function () { if ($scope.OwnshipModeS !== settings["OwnshipModeS"]) { settings["OwnshipModeS"] = $scope.OwnshipModeS.toUpperCase(); - newsettings = { + var newsettings = { "OwnshipModeS": $scope.OwnshipModeS.toUpperCase() }; // console.log(angular.toJson(newsettings)); @@ -142,18 +153,18 @@ function SettingsCtrl($rootScope, $scope, $state, $location, $window, $http) { $scope.updatestaticips = function () { if ($scope.StaticIps !== settings.StaticIps) { - newsettings = { - "StaticIps": $scope.StaticIps === undefined ? "" : $scope.StaticIps.join(' ') + var newsettings = { + "StaticIps": $scope.StaticIps === undefined? "" : $scope.StaticIps.join(' ') }; // console.log(angular.toJson(newsettings)); setSettings(angular.toJson(newsettings)); } }; - $scope.updateGLimits = function () { + $scope.updateGLimits = function () { if ($scope.GLimits !== settings["GLimits"]) { settings["GLimits"] = $scope.GLimits; - newsettings = { + var newsettings = { "GLimits": settings["GLimits"] }; // console.log(angular.toJson(newsettings)); @@ -161,16 +172,16 @@ function SettingsCtrl($rootScope, $scope, $state, $location, $window, $http) { } }; - $scope.postShutdown = function () { - $window.location.href = "/"; - $location.path('/home'); - $http.post(URL_SHUTDOWN). - then(function (response) { - // do nothing - // $scope.$apply(); - }, function (response) { - // do nothing - }); + $scope.postShutdown = function () { + $window.location.href = "/"; + $location.path('/home'); + $http.post(URL_SHUTDOWN). + then(function (response) { + // do nothing + // $scope.$apply(); + }, function (response) { + // do nothing + }); }; $scope.postReboot = function () { @@ -189,10 +200,12 @@ function SettingsCtrl($rootScope, $scope, $state, $location, $window, $http) { $scope.update_files = files; $scope.$apply(); }; + $scope.resetUploadFile = function () { $scope.update_files = ''; $scope.$apply(); }; + $scope.uploadFile = function () { var fd = new FormData(); //Take the first selected file @@ -209,7 +222,7 @@ function SettingsCtrl($rootScope, $scope, $state, $location, $window, $http) { alert ("file does not appear to be an update"); return; } - + fd.append("update_file", file); $http.post(URL_UPDATE_UPLOAD, fd, { @@ -239,18 +252,61 @@ function SettingsCtrl($rootScope, $scope, $state, $location, $window, $http) { $scope.Ui.turnOff('modalCalibrateDone'); $scope.Ui.turnOn("modalCalibrateFailed"); }); - }; + }; - $scope.calibrateGyros = function() { - console.log("sending calibrate message."); - $http.post(URL_AHRS_CAL). - then(function(response) { - console.log("Sent calibrate message."); - }, function(response) { - console.log(response.data); - $scope.Calibration_Failure_Message = response.data; - $scope.Ui.turnOff("modalCalibrateGyros"); - $scope.Ui.turnOn("modalCalibrateGyrosFailed"); + $scope.calibrateGyros = function() { + console.log("sending calibrate message."); + $http.post(URL_AHRS_CAL).then(function (response) { + console.log("Sent calibrate message."); + }, function (response) { + console.log(response.data); + $scope.Calibration_Failure_Message = response.data; + $scope.Ui.turnOff("modalCalibrateGyros"); + $scope.Ui.turnOn("modalCalibrateGyrosFailed"); }); }; + + $scope.updateWiFi = function(action) { + $scope.WiFiErrors = { + 'WiFiSSID':'', + 'WiFiPasscode':'', + 'Errors':false + }; + + if (($scope.WiFiSSID === undefined) || ($scope.WiFiSSID === null) || ($scope.WiFiSSID.length === 0)) { + $scope.WiFiErrors.WiFiSSID = "Your Network Name(\"SSID\") Cannot be Blank."; + $scope.WiFiErrors.Errors = true; + } + + if ($scope.WiFiPasscode.length < 8) { + if ($scope.WiFiPasscode.length === 0) { + $scope.WiFiErrors.WiFiPasscode = "Your WiFi Password must be at least 8 characters long"; + } else { + $scope.WiFiErrors.WiFiPasscode = "Your WiFi Password, " + $scope.WiFiPasscode + ", must be at least 8 characters long"; + } + $scope.WiFiErrors.Errors = true; + } + + $scope.Ui.turnOff("modalSubmitWiFi"); + + if (!$scope.WiFiErrors.Errors) { + var newsettings = { + "WiFiSSID" : $scope.WiFiSSID, + "WiFiSecurityEnabled" : $scope.WiFiSecurityEnabled, + "WiFiPasscode" : $scope.WiFiPasscode, + "WiFiChannel" : $scope.WiFiChannel + }; + + console.log(angular.toJson(newsettings)); + alert("Developers,\nThis is the JSON string\n"+angular.toJson(newsettings)+"\npassed to\n"+URL_SETTINGS_SET+"\n"); + setSettings(angular.toJson(newsettings)); + $scope.Ui.turnOn("modalSuccessWiFi"); + + } else { + + $scope.Ui.turnOn("modalErrorWiFi"); + + //alert($scope.WiFiErrorMsg); + } + }; } diff --git a/web/plates/settings-help.html b/web/plates/settings-help.html old mode 100644 new mode 100755 index 923bc1fc..3ebbab77 --- a/web/plates/settings-help.html +++ b/web/plates/settings-help.html @@ -1,40 +1,78 @@
The Settings page provides both control and configuration of your Stratux device.
+The Settings page provides both control and configuration of your Stratux device.
-Use the toggles in the Hardware section to control which devices are active.
-NOTE: Only hardware toggled on here, will appear on the - Status page.
+Use the toggles in the Hardware section to control which devices are active.
+NOTE: Only hardware toggled on here, will appear on the + Status page.
-The Diagnostics section helps with debugging and communicating with the Stratux project contributors via GitHub and the reddit subgroup.
-u
while traffic received via 1090 will display e
.+ The WiFi section allows the user to change various WiFi Settings: +
The AHRS section allows for calibration and future configuration of the AHRS function. - Calibrate AHRS Sensors guides initial setup of the AHRS function, specifying the orientation of the sensors relative to the airplane. Additional calibration may be added later.
-The calibration process determines which sensor direction will be forward, which toward the left wing, and which toward the ground. You only have to do this once. The settings for this sensor will be saved for future flights.
-The direction of gravity is used to determine the forward and up orientations, and the left wing is determined based on this.
+The Diagnostics section helps with debugging and communicating with the Stratux project contributors + via GitHub and the reddit subgroup.
+u
+ while traffic received via 1090 will display e
.GLoad Limits allows the user to set which limits will show on the G Meter on the GPS/AHRS page. Enter a space-separated list of G limits, e.g. "-1.76 4.4".
+The AHRS section allows for calibration and future configuration of the AHRS function. + Calibrate AHRS Sensors guides initial setup of the AHRS function, + specifying the orientation of the sensors relative to the airplane. + Additional calibration may be added later.
+The calibration process determines which sensor direction will be forward. + You only have to do this once. The settings for this sensor will be saved for future flights.
+The direction of gravity is used to determine the forward orientation.
-The Configuration section lets you adjust the default operation of your Stratux device.
-KBOS EEN LAH LKP
. You may change this list at any time and the Weather page will start watching for the updated list immediately.
- ENTER
or RETURN
or GO
(or whatever your keyboard indicates).
- kal -g 48 -s GSM850
to scan for available channels in your area. Then use the command kal -g 48 -c channel#
to calculate the PPM.
- root
by issuing the command: sudo su -
. You will need to stop the Stratux software before running the calibration process. You can stop all of the Stratux processes with the command: pkill screen
.
- The System section lets you safely shutdown or reboot your Stratux device.
-GLoad Limits allows the user to set which limits will show on the G Meter on the GPS/AHRS page. + Enter a space-separated list of G limits, e.g. "-1.76 4.4".
+ +The Configuration section lets you adjust the default operation of your Stratux device.
+KBOS EEN LAH LKP
.
+ You may change this list at any time and the Weather page will start watching for the
+ updated list immediately.
+ ENTER
or RETURN
or GO
+ (or whatever your keyboard indicates).
+ kal -g 48 -s GSM850
to scan for available channels in your area.
+ Then use the command kal -g 48 -c channel#
to calculate the PPM.
+ root
+ by issuing the command: sudo su -
.
+ You will need to stop the Stratux software before running the calibration process.
+ You can stop all of the Stratux processes with the command: pkill screen
.
+ The System section lets you safely shutdown or reboot your Stratux device.
+stratux.conf:
-{{rawSettings}}+ + +
stratux.conf:
+{{rawSettings}}+
The sensor orientation is set. These settings will be saved for future flights. - Place the Stratux in its in-flight orientation and keep it stationary for 5 seconds - after you press the Done button.
+ Place the Stratux in its in-flight orientation and keep it stationary for 5 seconds + after you press the Done button.