├── Autohotspot ├── ChangeLog-Autohotspot-Setup.txt ├── ChangeLog-Autohotspot.txt ├── ReadMe.txt ├── autohotspot-setup.sh └── config │ ├── Checklist.md5 │ ├── autohotspot-Net.service │ ├── autohotspot-direct │ ├── autohotspot-direct.service │ ├── autohotspotN │ ├── dhcpcd-SHS.conf │ ├── dhcpcd-SHSN.conf │ ├── dhcpcd-autohs.conf │ ├── dhcpcd-remove.conf │ ├── dnsmasqAHS.conf │ ├── dnsmasqAHSN.conf │ ├── dnsmasqSHS.conf │ ├── hostapd │ ├── hostapd.conf │ ├── hs-iptables.service │ ├── hs-nftables.service │ ├── interfaces │ └── iptables-hs.txt ├── HotSpotorSwitchBack.sh ├── LICENSE ├── Quality.py ├── README.md ├── bstars.py ├── camera_pi.py ├── constellations.py ├── default_database.npz ├── encoder.py ├── encodertoSkySafari.service ├── images ├── hand_1.2.1.jpg ├── newcaseback.jpg ├── newcaseside.jpg ├── solve1.jpg └── solve2.jpg ├── restartsky.sh ├── skyConfig.json ├── skysolve.py ├── skysolve.service ├── skysolveSetup.sh ├── skysolve_setup.odt ├── skysolve_setup.pdf ├── skysove startup.pdf ├── skysove starup.odt ├── starTransDb.py ├── startEncoder.sh ├── startSkysolve.sh ├── static ├── demo │ ├── aquarius.jpg │ ├── bigdipper.jpg │ ├── coronaB.jpg │ └── orionsShield.jpg ├── js │ ├── bootstrap.min.js │ ├── jquery_3.5.1.min.js │ ├── popper.min.js │ └── skySolve.js ├── radec.txt └── styles │ └── bootstrap.min.css ├── templates ├── starHistory.html └── template.html └── tetra3.py /Autohotspot/ChangeLog-Autohotspot-Setup.txt: -------------------------------------------------------------------------------- 1 | Change log for autohotspot-setup.sh 2 | 3 | 0.72 4 | Updated improved handeling of Windows special characters for updating the SSID and Password 5 | Fixed issue where not all added comment lines were removed from dhcpcd.conf file on uninstall 6 | 7 | 0.71 First release 19 Apr 2020 8 | -------------------------------------------------------------------------------- /Autohotspot/ChangeLog-Autohotspot.txt: -------------------------------------------------------------------------------- 1 | Change log for autohotspot and autohotspotN scripts 2 | 3 | version 0.961-N/HS-I & version 0.961-N/HS 4 | -Added improved handeling of windows end of line special characters in wpa_supplicant.conf from users who create the file on windows 5 | -Modify ssid handeling for checking. If the ssid contained bash command character treat them as a string and not a command. 6 | Thanks to neaxi for these updates 7 | 8 | 9 | version 0.96-N/HS-I & version 0.96-N/HS 10 | 11 | -Added error checking for status "Invalid exchange (-52) 12 | -If the wpa_supplicant.conf file was created in windows then it can contain Cr characters. These caused the ssid not to match so the hotspot was generated. 13 | SSID matching now filters the Cr. 14 | -Script output of local SSID's and BSS's in list to be read easier. 15 | -From Raspbian Buster hostapd is masked by default. If the Autohotspot setup has been done before the first system update, hostapd can get remasked. As this may happen in future updates the Autohotspot/N scripts check for Masked & enabled hostapd and dnsmasq services and disables/stops them before the script chooses network or hotspot. 16 | 17 | up to version 0.95 18 | -Various updates from initial release on Raspbian Jessie 19 | -------------------------------------------------------------------------------- /Autohotspot/ReadMe.txt: -------------------------------------------------------------------------------- 1 | RaspberryConnect.com 2 | This installer script, the autohotspot and autohotspotN scripts can be shared and modified but all references to RaspberryConnect.com must be kept in place. 3 | 4 | AutoHotspot Setups: 5 | This script is for installing a Raspberry Pi WiFi setup where the Pi will connect to a previously configured Wifi network when the Pi is in range of the router or Automatically setup a Raspberry Pi Hotspot/access point when a known wifi network is not in range. 6 | This can also be run manually or with a timer to switch without a reboot. 7 | 8 | This is available in two setups: 9 | 1: Internet access available for connected devices when a Ethernet cable is connected for the Raspberry Pi's 3A,3B,3B+ & 4. For Rapberry Pi's A,B, B+,& 2 if an usb Wifi adapter is used. 10 | 2: No internet access for connected devices. Designed for the Raspberry Pi Zero W or other Raspberry PI's where only a direct connection to the PI from a phone, tablet or Laptop is required. 11 | 12 | There is also setup for permanent hotspot with internet access for connected devices. 13 | 14 | For more information and for the manual setup's see: 15 | https://www.raspberryconnect.com/projects/65-raspberrypi-hotspot-accesspoints/157-raspberry-pi-auto-wifi-hotspot-switch-internet 16 | https://www.raspberryconnect.com/projects/65-raspberrypi-hotspot-accesspoints/158-raspberry-pi-auto-wifi-hotspot-switch-direct-connection 17 | https://www.raspberryconnect.com/projects/65-raspberrypi-hotspot-accesspoints/168-raspberry-pi-hotspot-access-point-dhcpcd-method 18 | 19 | This script will install any of these three setups or allow you to change between setup types. 20 | In addition the Hotspot SSID and Password can be changed, new WiFi networks can be added to the Raspberry PI while in Hotspot Mode. The Pi can be forced between Network mode and Hotspot mode without a reboot. Also there is an uninstaller. 21 | 22 | To use the installer: 23 | 24 | Download the AutoHotspot-Setup.tar.xz archive from 25 | curl "https://www.raspberryconnect.com/images/hsinstaller/AutoHotspot-Setup.tar.gz" -o AutoHotspot-Setup.tar.gz 26 | 27 | Unarchive the file to the curent folder using the command 28 | tar -xzvf AutoHotspot-Setup.tar.xz 29 | If you are using the Desktop then right click on the AutoHotspot-Setup.tar.xz and select Extract Here 30 | 31 | open a terminal screen and navigate to the Autohotspot folder. If this is in your home directory then use 32 | cd Autohotspot 33 | if this is your desktop then use 34 | cd ./Desktop/Autohotspot 35 | Run the script with the command 36 | sudo ./autohotspot-setup.sh 37 | This script will fail if sudo is not used. 38 | 39 | You will presented with a menu with these options 40 | 41 | 1 = Install Autohotspot with Internet for Connected Devices 42 | 2 = Install Autohotspot with No Internet for connected devices 43 | 3 = Install a Permanent Hotspot with Internet for connected devices 44 | 4 = Uninstall Autohotspot or Permanent Hotspot 45 | 5 = Add or Change a WiFi network (SSID) 46 | 6 = Autohotspot: Force to a Hotspot or Force to Network if SSID in Range 47 | 7 = Change the Hotspots SSID and Password 48 | 8 = Exit 49 | 50 | Option 1: Install Autohotspot with Internet for Connected Devices 51 | Once installed and after a reboot the Raspberry Pi will connect to a router that has previously been connected to and is listed in /etc/wpa_supplicant/wpa_supplicant.conf. If no router is in range then it will generate a WiFi hotspot. 52 | This will have an SSID of RPiHotspot and password of 1234567890 53 | Use option 7 to change the password and also the SSID if required 54 | If an ethernet cable is connected to the Pi with access to the internet then it will allow devices connected to the hotspot access to the internet or local network. 55 | Once a connection to the hotspot has been made you can access the Raspberry Pi via ssh & VNC with 56 | ssh pi@192.168.50.5 57 | vnc: 192.168.50.5::5900 58 | for webservers use http://192.168.50.5/ 59 | 60 | Option 2: Install Autohotspot with No Internet for connected devices 61 | This option is similar to option 1 but connected devices have no internet connection if an ethernet cable is connected. 62 | This has been designed so you can access only the Pi from a Laptop, tablet or phone. 63 | The hotspot SSID will be RPiHotspot with a password of 1234567890 64 | Once a connection to the hotspot has been made you can access the Raspberry Pi via ssh & VNC with 65 | ssh pi@10.0.0.5 66 | vnc: 10.0.0.5::5900 67 | for webservers use http://10.0.0.5/ 68 | 69 | Otion 3: Install a Permanent Hotspot with Internet for connected devices 70 | This is for a permanent WiFi hotspot with internet access for connected devices. 71 | The Raspberry Pi will only have network or internet access when an ethernet cable is connected. 72 | Once a connection to the hotspot has been made you can access the Raspberry Pi via ssh & VNC with 73 | ssh pi@192.168.50.10 74 | vnc: 192.168.50.10::5900 75 | for webservers use http://192.168.50.10/ 76 | 77 | Additional setup is required if you wanted to use a second WiFi device to connect to the internet rather than a ethernet conection. This will be a future option. 78 | 79 | Option 4: Uninstall Autohotspot or Permanent Hotspot 80 | This will disable the setup of any of the three setups and return the Raspberry Pi to default Wifi settings. 81 | Hostapd & dnsmasq will not be uninstalled just disabled. 82 | 83 | Option 5: Add or Change a WiFi network (SSID) 84 | If you are using either of the autohotspot setups in hotspot modes and wish to connect to a local WiFi network. You will be unable to scan for any networks as the desktop wifi option will be disabled, shown as red crosses. You can manually add the details to /etc/wpa_supplicant/wpa_supplicant.conf if you know them. 85 | This option will allow you to scan for local WiFi networks and update the Pi. If you then reboot or use the Force... option ,see below. 86 | This option only works for WiFi networks where only a password is required. If a username is required this will not work. (Future update) 87 | 88 | Option 6: Autohotspot: Force to a Hotspot or Force to Network if SSID in Range 89 | This option is only for the Autohotspot setups. 90 | If you are at home and connected to your home network but would like to use the hotspot. This option will force the pi to hotspot mode and will ignore your home network untill the next reboot. If you use this option again while in hotspot mode it will attempt to connect to a known network. This will go back to the hotspot if no valid WiFi network is found or there is a connection issue. 91 | 92 | Option 7: Change the Hotspots SSID and Password 93 | By default the hotspot ssid is RPiHotSpot with a password of 1234567890. Use this option to change either or both SSID and Password. 94 | You will be prompted to change both but if you make no entry and press enter the existing setting will be kept. 95 | The password must be at least 8 characters. 96 | 97 | Option 8: Exit 98 | Exit the script. 99 | 100 | 101 | NFtables Warning. 102 | This setup uses iptables for routing the Hotspots to the internet, options 1 & 3. From Raspbian 10 Buster, IPtables are depreciated in place of NFtables. By default NFtables will handle IPtable rules. 103 | If you know you are using NFtables for a Firewall or other routing rules then don't use the internet routed hotspots and only use option 2, Autohotspot without internet. Otherwise there will be a conflict with your routing tables. 104 | NFtables will be implemented shortly in the next main update of the installer and scripts. 105 | Raspbian Stretch (9) & Jessie (8) only use IPtables. 106 | You will be warned when you initially run the installer script if NFtables are active. 107 | 108 | /etc/network/interfaces file: 109 | many older hotspot and network setup guides online add entries to the /etc/network/interfaces file. This file is depreciated in Raspbian and any entry in this file is not compatible with these setups. This installer backup and remove any entries found in this file. They will be restored if the uninstall option is used. 110 | 111 | RaspberryConnect.com 112 | -------------------------------------------------------------------------------- /Autohotspot/autohotspot-setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #RaspberryConnect.com 3 | #This installer can be shared but all references to RaspberryConnect.com in this file 4 | #and other files used by the installer should remain in place. 5 | 6 | #Installer version 0.72 (17 Oct 2020) 7 | #Installer for AutoHotspot, AutohotspotN scripts and Static Hotspot setup. 8 | #Autohotspot: a script that allows the Raspberry Pi to switch between Network Wifi and 9 | #a hotspot either at bootup or with a timer without a reboot. 10 | 11 | #This installer script will alter network settings and may overwrite existing settings if allowed. 12 | #/etc/hostapd/hostapd.conf (backup old), /etc/dnsmasq.conf (backup old), modifies /etc/dhcpcd.conf (modifies) 13 | #/etc/sysctl.conf (modifies), /etc/network/interfaces (backup old & removes any network entries) 14 | #Currently iptables are used, you will receive a warning if nftables active active. 15 | #If you are using nftables please only use option 2, Autohotspot-Non Internet script until a future update. 16 | 17 | #Force Hotspot or Network Wifi option will only work if either autohotspot is installed and active. 18 | 19 | 20 | #Check for Raspbian and version. 21 | osver=($(cat /etc/issue)) 22 | cpath="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" 23 | opt="X" 24 | vhostapd="N" vdnsmasq="N" autoH="N" 25 | autoserv="N" iptble="N" nftble="N" 26 | 27 | if [ "${osver[0]}" != 'Raspbian' ]; then 28 | echo "This AutoHotspot installer is only for the OS Raspbian on the Raspberry Pi" 29 | exit 1 30 | elif [ "${osver[2]}" -ge 10 ]; then 31 | echo 'Raspbian Version' "${osver[2]}" 32 | elif [ "${osver[2]}" -lt 8 ];then 33 | echo "The version of Raspbian is too old for the Autohotspot script" 34 | echo "Version 8 'Jessie' is the minimum requirement" 35 | fi 36 | 37 | check_installed() 38 | { 39 | #check if required software is already installed 40 | if dpkg -s "hostapd" | grep 'Status: install ok installed' >/dev/null 2>&1; then 41 | vhostapd="Y" 42 | fi 43 | if dpkg -s "dnsmasq" | grep 'Status: install ok installed' >/dev/null 2>&1; then 44 | vdnsmasq="Y" 45 | fi 46 | #Does an Autohotspot files exist 47 | if ls /usr/bin/ | grep "autohotspot*" >/dev/null 2>&1 ; then 48 | autoH="Y" 49 | fi 50 | if ls /etc/systemd/system/ | grep "autohotspot.service" >/dev/null 2>&1 ; then 51 | autoserv="Y" 52 | fi 53 | if dpkg -s "iptables" >/dev/null 2>&1 ; then 54 | iptble="Y" 55 | fi 56 | if dpkg -s "nftables" >/dev/null 2>&1 ; then 57 | nftble="Y" 58 | fi 59 | } 60 | 61 | check_reqfiles() 62 | { 63 | fstatus=0 64 | cd "${cpath}/config/" 65 | if test -f "Checklist.md5" ;then 66 | if ! md5sum -c --quiet Checklist.md5 ;then 67 | echo "one or more of the required files in the config folder are missing or have been altered" 68 | echo "please download the installer again from RaspberryConnect.com" 69 | exit 70 | fi 71 | else 72 | echo "The file Checklist.md5 is missing from Config folder" 73 | echo "Please download the installer again" 74 | echo "from RaspberryConnect.com" 75 | exit 76 | fi 77 | 78 | } 79 | 80 | check_wificountry() 81 | { 82 | #echo "Checking WiFi country" 83 | wpa=($(cat "/etc/wpa_supplicant/wpa_supplicant.conf" | grep "country=")) 84 | if [ -z ${wpa: -2} ] || [[ ${wpa: -2} == *"="* ]];then 85 | echo "The WiFi country has not been set. This is required for the hotspot setup." 86 | echo "Please update Raspbian with the wifi country using the command 'sudo raspi-config' and choose the localisation menu" 87 | echo "From the desktop this can be done in the menu Preferences - Raspberry Pi Configuration - Localisation" 88 | echo "Once done please try again." 89 | echo "" 90 | echo "press a key to continue" 91 | read 92 | fi 93 | } 94 | 95 | 96 | 97 | hostapd_config() 98 | { 99 | echo "hostapd Config" 100 | echo "Hostapd Status is " $vhostapd 101 | if [ "$vhostapd" = "N" ]; then 102 | echo "Hostapd not installed- now installing" 103 | apt -q install hostapd 104 | echo "Recheck install Status" 105 | check_installed 106 | if [ "$vhostapd" = "N" ]; then 107 | echo "" 108 | echo "" 109 | echo "Hostapd failed to install. Check there is internet access" 110 | echo "and try again" 111 | echo "Press a key to continue" 112 | read 113 | menu 114 | fi 115 | fi 116 | echo "Hostapd is installed" 117 | if ! grep -F "RaspberryConnect.com" "/etc/hostapd/hostapd.conf" ;then 118 | #not a autohotspot file, create backup 119 | mv "/etc/hostapd/hostapd.conf" "/etc/hostapd/hostapd-RCbackup.conf" 120 | fi 121 | cp "$cpath/config/hostapd.conf" /etc/hostapd/hostapd.conf 122 | if [ "${osver[2]}" -lt 10 ]; then 123 | cp "$cpath/config/hostapd" /etc/default/hostapd 124 | fi 125 | if [ "$opt" = "AHN" ] || [ "$opt" = "AHD" ]; then 126 | #For Autohotspots 127 | echo "Unmask & Disable Hostapd" 128 | if systemctl -all list-unit-files hostapd.service | grep "hostapd.service masked" ;then 129 | systemctl unmask hostapd.service >/dev/null 2>&1 130 | fi 131 | if systemctl -all list-unit-files hostapd.service | grep "hostapd.service enabled" ;then 132 | systemctl disable hostapd.service >/dev/null 2>&1 133 | fi 134 | elif [ "$opt" = "SHS" ]; then 135 | #for Static Hotspot 136 | echo "Unmask and enable hostapd" 137 | if systemctl -all list-unit-files hostapd.service | grep "hostapd.service masked" ;then 138 | systemctl unmask hostapd >/dev/null 2>&1 139 | fi 140 | if systemctl -all list-unit-files hostapd.service | grep "hostapd.service disabled" ;then 141 | systemctl enable hostapd >/dev/null 2>&1 142 | fi 143 | elif [ "$opt" = "REM" ]; then 144 | if [ -f "/etc/hostapd/hostapd-RCbackup.conf" ] ; then 145 | mv "/etc/hostapd/hostapd-RCbackup.conf" "/etc/hostapd/hostapd.conf" 146 | fi 147 | fi 148 | #check country code for hostapd.conf 149 | wpa=($(cat "/etc/wpa_supplicant/wpa_supplicant.conf" | grep "country=")) 150 | hapd=($(cat "/etc/hostapd/hostapd.conf" | grep "country_code=")) 151 | if [[ ! ${wpa: -2} == ${hapd: -2} ]] ; then 152 | echo "Changing Hostapd Wifi country to " ${wpa: -2} 153 | sed -i -e "/country_code=/c\country_code=${wpa: -2}" /etc/hostapd/hostapd.conf 154 | fi 155 | } 156 | 157 | dnsmasq_config() 158 | { 159 | echo "Dnsmasq Config" 160 | if [ "$vdnsmasq" = "N" ]; then 161 | apt -q install dnsmasq 162 | check_installed 163 | if [ "$vdnsmasq" = "N" ]; then 164 | echo "" 165 | echo "" 166 | echo "dnsmasq failed to install. Check there is internet access" 167 | echo "and try again" 168 | echo "Press a key to continue" 169 | read 170 | menu 171 | fi 172 | fi 173 | if [ -f "/etc/dnsmasq.conf" ] ; then 174 | if ! grep -F "RaspberryConnect.com" "/etc/dnsmasq.conf" ;then 175 | #not a autohotspot file, create backup 176 | mv "/etc/dnsmasq.conf" "/etc/dnsmasq-RCbackup.conf" 177 | fi 178 | fi 179 | if [ "$opt" = "AHN" ] ; then 180 | echo "${cpath}/config/dnsmasqAHSN.conf" 181 | cp "${cpath}/config/dnsmasqAHSN.conf" "/etc/dnsmasq.conf" 182 | elif [ "$opt" = "AHD" ];then 183 | cp "${cpath}/config/dnsmasqAHS.conf" "/etc/dnsmasq.conf" 184 | elif [ "$opt" = "SHS" ] ;then 185 | cp "${cpath}/config/dnsmasqSHS.conf" "/etc/dnsmasq.conf" 186 | fi 187 | if [ "$opt" = "AHN" ] || [ "$opt" = "AHD" ]; then 188 | #For Autohotspots 189 | echo "Unmask & Disable Dnsmasq" 190 | if systemctl -all list-unit-files dnsmasq.service | grep "dnsmasq.service masked" ;then 191 | systemctl unmask dnsmasq >/dev/null 2>&1 192 | fi 193 | if systemctl -all list-unit-files dnsmasq.service | grep "dnsmasq.service enabled" ;then 194 | systemctl disable dnsmasq >/dev/null 2>&1 195 | fi 196 | elif [ "$opt" = "SHS" ]; then 197 | #for Static Hotspot 198 | echo "Unmask & Enable Dnsmasq" 199 | if systemctl -all list-unit-files dnsmasq.service | grep "dnsmasq.service masked" ;then 200 | systemctl unmask dnsmasq >/dev/null 2>&1 201 | fi 202 | if systemctl -all list-unit-files dnsmasq.service | grep "dnsmasq.service disabled" ;then 203 | systemctl enable dnsmasq >/dev/null 2>&1 204 | fi 205 | fi 206 | if [ "$opt" = "REM" ]; then 207 | if [ -f "/etc/dnsmasq-RCbackup.conf" ] ; then 208 | mv "/etc/dnsmasq-RCbackup.conf" "/etc/dnsmasq.conf" 209 | fi 210 | fi 211 | 212 | } 213 | dhcpcd_config() 214 | { 215 | #Make backup if not done 216 | if [ ! "/etc/dhcpcd-RCbackup.conf" ] ;then 217 | mv "/etc/dhcpcd.conf" "/etc/dhcpcd-RCbackup.conf" 218 | fi 219 | if [ "$opt" = "AHN" ] || [ "$opt" = "AHD" ] ;then 220 | #use backup for Auto scripts to retain any custon Network Config like static ip's 221 | if [ ! "/etc/dhcpcd-RCbackup.conf" ] ;then 222 | cp "/etc/dhcpcd-RCbackup.conf" "/etc/dhcpcd.conf" 223 | fi 224 | grep -vxf "${cpath}/config/dhcpcd-remove.conf" "/etc/dhcpcd.conf" > "${cpath}/config/Ndhcpcd.conf" 225 | cat "${cpath}/config/dhcpcd-autohs.conf" >> "${cpath}/config/Ndhcpcd.conf" 226 | mv "${cpath}/config/Ndhcpcd.conf" "/etc/dhcpcd.conf" 227 | elif [ "$opt" = "SHS" ]; then 228 | #use clean dhcpcd.conf for static hotspot, backup will be restored on removal /etc/dhcpcd-RCbackup.conf 229 | mv "${cpath}/config/dhcpcd-default.conf" "/etc/dhcpcd.conf" 230 | grep -vxf "${cpath}/config/dhcpcd-remove.conf" "/etc/dhcpcd.conf" > "${cpath}/config/Ndhcpcd.conf" 231 | cat "${cpath}/config/dhcpcd-SHSN.conf" >> "${cpath}/config/Ndhcpcd.conf" 232 | mv "${cpath}/config/Ndhcpcd.conf" "/etc/dhcpcd.conf" 233 | fi 234 | } 235 | 236 | sysctl() 237 | { 238 | if [ "$opt" = "AHN" ] || [ "$opt" = "SHS" ] ;then 239 | sed -i -e "/#net.ipv4.ip_forward=1/c\net.ipv4.ip_forward=1" /etc/sysctl.conf 240 | elif [ "$opt" = "AHD" ] || [ "$opt" = "REM" ] ;then 241 | sed -i -e "/net.ipv4.ip_forward=1/c\#net.ipv4.ip_forward=1" /etc/sysctl.conf 242 | fi 243 | } 244 | 245 | auto_service() 246 | { 247 | if [ "$opt" = "AHN" ] ;then 248 | cp "${cpath}/config/autohotspot-Net.service" "/etc/systemd/system/autohotspot.service" 249 | systemctl daemon-reload 250 | systemctl enable autohotspot 251 | elif [ "$opt" = "AHD" ] ;then 252 | cp "${cpath}/config/autohotspot-direct.service" "/etc/systemd/system/autohotspot.service" 253 | systemctl daemon-reload 254 | systemctl enable autohotspot 255 | fi 256 | if [ "$opt" = "REM" ] || [ "$opt" = "SHS" ]; then 257 | if systemctl -all list-unit-files autohotspot.service | grep "autohotspot.service enabled" ;then 258 | systemctl disable autohotspot.service 259 | fi 260 | if [ -f "/etc/systemd/system/autohotspot.service" ]; then 261 | rm /etc/systemd/system/autohotspot.service 262 | fi 263 | fi 264 | 265 | } 266 | hs_routing() 267 | { 268 | if [ "$opt" = "SHS" ] ;then 269 | if [ "$iptble" = "Y" ] ; then 270 | if [ ! -f "/etc/systemd/system/hs-iptables.service" ];then 271 | cp "${cpath}/config/hs-iptables.service" "/etc/systemd/system/hs-iptables.service" 272 | fi 273 | if systemctl -all list-unit-files hs-iptables.service | grep "hs-iptables.service enabled" ;then 274 | systemctl daemon-reload 275 | fi 276 | if systemctl -all list-unit-files hs-iptables.service | grep "hs-iptables.service disabled" ;then 277 | systemctl enable hs-iptables.service 278 | fi 279 | if [ ! -f "/etc/iptables-hs" ] ;then 280 | cp "${cpath}/config/iptables-hs.txt" "/etc/iptables-hs" 281 | chmod +x "/etc/iptables-hs" 282 | fi 283 | 284 | elif [ "$nftble" = "Y" ] ; then 285 | echo "future feature" 286 | 287 | fi 288 | elif [ "$opt" = "REM" ] || [ "$opt" = "AHN" ] || [ "$opt" = "AHD" ] ; then 289 | if systemctl is-active hs-iptables | grep -w "active" ;then 290 | systemctl disable hs-iptables.service 291 | fi 292 | if test -f "/etc/systemd/system/hs-iptables.service" ; then 293 | rm /etc/systemd/system/hs-iptables.service 294 | fi 295 | if test -f "/etc/iptables-hs" ; then 296 | rm /etc/iptables-hs 297 | fi 298 | fi 299 | } 300 | 301 | auto_script() 302 | { 303 | if [ "$opt" = "AHN" ] ;then 304 | cp "${cpath}/config/autohotspotN" "/usr/bin/autohotspotN" 305 | chmod +x /usr/bin/autohotspotN 306 | elif [ "$opt" = "AHD" ] ;then 307 | cp "${cpath}/config/autohotspot-direct" "/usr/bin/autohotspot" 308 | chmod +x /usr/bin/autohotspot 309 | elif [ "$opt" = "REM" ] || [ "$opt" = "SHS" ] ;then 310 | if [ -f "/usr/bin/autohotspotN" ]; then 311 | rm /usr/bin/autohotspotN 312 | fi 313 | if [ -f "/usr/bin/autohotspot" ]; then 314 | rm /usr/bin/autohotspot 315 | fi 316 | fi 317 | } 318 | 319 | interface() 320 | { 321 | #if interfaces file contains network settings 322 | #backup and remove. 323 | if grep -vxf "${cpath}/config/interfaces" "/etc/network/interfaces" ;then 324 | mv "/etc/network/interfaces" "/etc/network/RCbackup-interfaces" 325 | cp "${cpath}/config/interfaces" "/etc/network/interfaces" 326 | fi 327 | if [ "$opt" = "REM" ] ;then 328 | if [ -f "/etc/network/RCbackup-interfaces" ] ;then 329 | mv "/etc/network/RCbackup-interfaces" "/etc/network/interfaces" 330 | fi 331 | fi 332 | } 333 | 334 | remove() 335 | { 336 | if systemctl -all list-unit-files hostapd.service | grep "hostapd.service enabled" ;then 337 | systemctl disable hostapd >/dev/null 2>&1 338 | fi 339 | if systemctl -all list-unit-files dnsmasq.service | grep "dnsmasq.service enabled" ;then 340 | systemctl disable dnsmasq >/dev/null 2>&1 341 | fi 342 | auto_script #Remove Autohotspot Scripts 343 | #Reset DHCPCD.conf 344 | if [ -f "/etc/dhcpcd-RCbackup.conf" ] ;then #restore backup 345 | mv "/etc/dhcpcd-RCbackup.conf" "/etc/dhcpcd.conf" 346 | else #or remove edits if no backup 347 | echo "Removing config from dhcpcd.conf" 348 | grep -vxf "${cpath}/config/dhcpcd-remove.conf" "/etc/dhcpcd.conf" > "${cpath}/config/Ndhcpcd.conf" 349 | mv "${cpath}/config/Ndhcpcd.conf" "/etc/dhcpcd.conf" 350 | fi 351 | hs_routing #remove routing for Static HS 352 | sysctl #remove port forwarding 353 | interface #restore backup of interfaces fle 354 | auto_service #remove autohotspot.service 355 | } 356 | 357 | Hotspotssid() 358 | { 359 | #Change the Default Hotspot SSID and Password 360 | if [ ! -f "/etc/hostapd/hostapd.conf" ] ;then 361 | echo "A hotspot is not installed. No Password to change" 362 | echo "press enter to continue" 363 | read 364 | menu 365 | fi 366 | HSssid=($(cat "/etc/hostapd/hostapd.conf" | grep '^ssid=')) 367 | HSpass=($(cat "/etc/hostapd/hostapd.conf" | grep '^wpa_passphrase=')) 368 | echo "Change the Hotspot's SSID and Password. press enter to keep existing settings" 369 | echo "The current SSID is:" "${HSssid:5}" 370 | echo "The current SSID Password is:" "${HSpass:15}" 371 | echo "Enter the new Hotspots SSID:" 372 | read ssname 373 | echo "Enter the hotspots new password. Minimum 8 characters" 374 | read sspwd 375 | if [ ! -z $ssname ] ;then 376 | echo "Changing Hotspot SSID to:" "$ssname" 377 | sed -i -e "/^ssid=/c\ssid=$ssname" /etc/hostapd/hostapd.conf 378 | else 379 | echo "The Hotspot SSID is" ${HSssid: 5} 380 | fi 381 | if [ ! -z $sspwd ] && [ ${#sspwd} -ge 8 ] ;then 382 | echo "Changing Hotspot Password to:" "$sspwd" 383 | sed -i -e "/^wpa_passphrase=/c\wpa_passphrase=$sspwd" /etc/hostapd/hostapd.conf 384 | else 385 | echo "The Hotspot Password is:" ${HSpass: 15} 386 | fi 387 | echo "" 388 | echo "The new setup will be available next time the hotspot is started" 389 | echo "Press a key to continue" 390 | read 391 | menu 392 | } 393 | 394 | setupssid() 395 | { 396 | echo "Searching for local WiFi connection" 397 | echo "Connect to a new WiFi network or change the password for an existing one in range" 398 | echo "For Wifi networks where only a password is required." 399 | echo "This will not work where a username and password is required" 400 | ct=0; j=0 ; lp=0 401 | wfselect=() 402 | 403 | until [ $lp -eq 1 ] #wait for wifi if busy, usb wifi is slower. 404 | do 405 | IFS=$'\n:$\t' localwifi=($((iw dev wlan0 scan ap-force | egrep "SSID:") 2>&1)) >/dev/null 2>&1 406 | #if wifi device errors recheck 407 | if (($j >= 5)); then #if busy 5 times exit to menu 408 | echo "WiFi Device Unavailable, cannot scan for wifi devices at this time" 409 | echo "press a key to continue" 410 | menu 411 | break 412 | elif echo "${localwifi[1]}" | grep "No such device (-19)" >/dev/null 2>&1; then 413 | echo "No Device found,trying again" 414 | j=$((j + 1)) 415 | sleep 2 416 | elif echo "${localwifi[1]}" | grep "Network is down (-100)" >/dev/null 2>&1 ; then 417 | echo "Network Not available, trying again" 418 | j=$((j + 1)) 419 | sleep 2 420 | elif echo "${localwifi[1]}" | grep "Read-only file system (-30)" >/dev/null 2>&1 ; then 421 | echo "Temporary Read only file system, trying again" 422 | j=$((j + 1)) 423 | sleep 2 424 | elif echo "${localwifi[1]}" | grep "Invalid exchange (-52)" >/dev/null 2>&1 ; then 425 | echo "Temporary unavailable, trying again" 426 | j=$((j + 1)) 427 | sleep 2 428 | elif echo "${localwifi[1]}" | grep -v "Device or resource busy (-16)" >/dev/null 2>&1 ; then 429 | lp=1 430 | else #see if device not busy in 2 seconds 431 | echo "WiFi Device unavailable checking again" 432 | j=$((j + 1)) 433 | sleep 2 434 | fi 435 | done 436 | 437 | #Wifi Connections found - continue 438 | for x in "${localwifi[@]}" 439 | do 440 | if [ $x != "SSID" ]; then 441 | ct=$((ct + 1)) 442 | echo "$ct ${x/ /}" 443 | wfselect+=("${x/ /}") 444 | fi 445 | done 446 | ct=$((ct + 1)) 447 | echo "$ct To Cancel" 448 | wfselect+=("Cancel") 449 | if [ "${#wfselect[@]}" -eq 1 ] ;then 450 | echo "Unable to detect local WiFi devices. Maybe there is a temporary issue with your WiFi" 451 | echo "Try again in a minute" 452 | echo "press a enter to continue" 453 | read 454 | menu 455 | fi 456 | 457 | read wf 458 | if [[ $wf =~ ^[0-9]+$ ]]; then 459 | if [ $wf -ge 0 ] && [ $wf -le $ct ]; then 460 | updatessid "${wfselect[$wf-1]}" 461 | else 462 | echo -e "\nNot a Valid entry" 463 | setupssid 464 | fi 465 | else 466 | echo -e "\nNot a Valid entry" 467 | setupssid 468 | fi 469 | } 470 | 471 | updatessid() 472 | { 473 | #check for blank in return 474 | echo "$1" 475 | echo "" 476 | if [ "$1" = "Cancel" ] || [ "$1" = "" ] ; then 477 | menu 478 | exit 479 | fi 480 | 481 | IFS="," wpassid=$(awk '/ssid="/{ print $0 }' /etc/wpa_supplicant/wpa_supplicant.conf | awk -F'ssid=' '{ print $2 }' | sed 's/\r//g'| awk 'BEGIN{ORS=","} {print}' | sed 's/\"/''/g' | sed 's/,$//') 482 | ssids=($wpassid) 483 | if [[ ! " ${ssids[@]} " =~ " $1 " ]]; then 484 | echo "Add New Wifi Network" 485 | echo "Selection SSID: $1" 486 | echo "" 487 | echo "Enter password for Wifi" 488 | read ssidpw 489 | echo -e "\nnetwork={\n\tssid=\x22$1\x22\n\tpsk=\x22$ssidpw\x22\n\tkey_mgmt=WPA-PSK\n}" >> /etc/wpa_supplicant/wpa_supplicant.conf 490 | else 491 | f=0 492 | echo "Change Password for Selected Wifi" 493 | while IFS= read -r ln || [[ -n "$ln" ]] <&3; do 494 | if [[ "$ln" == *"psk="* ]] && [ $f -eq 1 ] ;then 495 | break 496 | elif [[ "$ln" == *"$1"* ]] ; then 497 | f=1 498 | fi 499 | done < /etc/wpa_supplicant/wpa_supplicant.conf 500 | echo "Change Wifi Network Password" 501 | echo "Selected SSID: $1" 502 | echo "" 503 | echo "Enter password for Wifi" 504 | read chgpw 505 | newpsk=$'\tpsk=\x22'$chgpw$'\x22\n' 506 | echo "The entry will be" $newpsk 507 | echo "To be Replaced $ln" 508 | sed -i '/'"$ln"'/c\'"$newpsk" /etc/wpa_supplicant/wpa_supplicant.conf 509 | f=0 510 | fi 511 | } 512 | 513 | forceswitch() 514 | { 515 | if [ ! -f "/etc/systemd/system/autohotspot.service" ] ;then 516 | echo "No Autohotspot script installed, unable to continue" 517 | echo "press enter to continue" 518 | read 519 | menu 520 | fi 521 | Aserv=($(cat /etc/systemd/system/autohotspot.service | grep "ExecStart=")) 522 | wi=($(cat ${Aserv: 10} | grep wifidev=)) 523 | eth=($(cat ${Aserv: 10} | grep ethdev=)) 524 | 525 | wifidev=${wi[0]: 9:-1} #wifi device name from active autohotspot/N script 526 | ethdev=${eth[0]: 8:-1} #Ethernet port to use with IP tables 527 | 528 | createAdHocNetwork_N() #for Internet routed Hotspot 529 | { 530 | #receive IP as $1 531 | echo "Creating Hotspot with Internet" 532 | ip link set dev "$wifidev" down 533 | ip a add $1 brd + dev "$wifidev" 534 | ip link set dev "$wifidev" up 535 | dhcpcd -k "$wifidev" >/dev/null 2>&1 536 | iptables -t nat -A POSTROUTING -o "$ethdev" -j MASQUERADE 537 | iptables -A FORWARD -i "$ethdev" -o "$wifidev" -m state --state RELATED,ESTABLISHED -j ACCEPT 538 | iptables -A FORWARD -i "$wifidev" -o "$ethdev" -j ACCEPT 539 | systemctl start dnsmasq 540 | systemctl start hostapd 541 | echo 1 > /proc/sys/net/ipv4/ip_forward 542 | } 543 | 544 | createAdHocNetwork_D() #For non Internet Routed Hotspot 545 | { 546 | echo "Creating Hotspot direct - no Internet" 547 | ip link set dev "$wifidev" down 548 | ip a add $1 brd + dev "$wifidev" 549 | ip link set dev "$wifidev" up 550 | dhcpcd -k "$wifidev" >/dev/null 2>&1 551 | systemctl start dnsmasq 552 | systemctl start hostapd 553 | } 554 | 555 | get_HS_IP() #get ip address from current active hotspot script 556 | { 557 | #add check that the service is enabled, otherwise exit 558 | Aserv=($(cat /etc/systemd/system/autohotspot.service | grep "ExecStart=")) #which hotspot is active? 559 | if [ ${Aserv: -4} = "spot" ];then #Direct 560 | ipline=($(cat /usr/bin/autohotspot | grep "ip a add")) 561 | createAdHocNetwork_D "${ipline[3]}" 562 | elif [ ${Aserv: -4} = "potN" ];then #Internet 563 | ipline=($(cat /usr/bin/autohotspotN | grep "ip a add")) 564 | createAdHocNetwork_N "${ipline[3]}" 565 | else 566 | echo "The Autohotspot is disabled or not installed" 567 | echo "unable to force a switch." 568 | echo "Press enter to continue" 569 | read 570 | menu 571 | fi 572 | } 573 | 574 | #Create Hotspot or connect to valid wifi networks 575 | echo 0 > /proc/sys/net/ipv4/ip_forward #deactivate ip forwarding 576 | 577 | if systemctl status hostapd | grep "(running)" >/dev/null 2>&1 578 | then 579 | echo "Hotspot already active" 580 | echo "Switching to Network Wifi if it is available" 581 | echo "this takes about 20 seconds to complete checks" 582 | systemctl restart autohotspot.service 583 | menu 584 | elif { wpa_cli status | grep "$wifidev"; } >/dev/null 2>&1 585 | then 586 | echo "Cleaning wifi files and Activating Hotspot" 587 | wpa_cli terminate >/dev/null 2>&1 588 | ip addr flush "$wifidev" 589 | ip link set dev "$wifidev" down 590 | rm -r /var/run/wpa_supplicant >/dev/null 2>&1 591 | get_HS_IP 592 | else #Neither the Hotspot or Network is active 593 | get_HS_IP 594 | fi 595 | } 596 | 597 | display_HS_IP() #get ip address from current active hotspot script 598 | { 599 | Aserv=($(cat /etc/systemd/system/autohotspot.service 2>/dev/null| grep "ExecStart=")) #which hotspot is active? 600 | if [ ${Aserv: -4} = "spot" ] >/dev/null 2>&1 ;then #Direct 601 | ipline=($(cat /usr/bin/autohotspot | grep "ip a add")) 602 | echo "Hotspot IP Address for SSH and VNC: ${ipline[3]: :-3}" 603 | elif [ ${Aserv: -4} = "potN" ] >/dev/null 2>&1 ;then #Internet 604 | ipline=($(cat /usr/bin/autohotspotN | grep "ip a add")) 605 | echo "Hotspot IP Address for SSH and VNC: ${ipline[3]: :-3}" 606 | else #Static Hotspot default IP 607 | echo "Hotspot IP Address for ssh and VNC: 192.168.50.10" 608 | fi 609 | } 610 | 611 | go() 612 | { 613 | opt="$1" 614 | #echo "Selected" "$opt" 615 | #echo "Action options" 616 | if [ "$opt" = "REM" ] ;then 617 | remove 618 | echo "Please reboot to complete the uninstall" 619 | elif [ "$opt" = "SSI" ] ;then 620 | setupssid 621 | echo "the new ssid will be used next time the autohotspot script is " 622 | echo "run at boot or manually otherwise use the Force to.... option" 623 | echo "if the hotspot is active" 624 | elif [ "$opt" = "FOR" ] ;then 625 | forceswitch 626 | elif [ "$opt" = "HSS" ] ;then 627 | Hotspotssid 628 | else 629 | hostapd_config 630 | dnsmasq_config 631 | interface 632 | sysctl 633 | dhcpcd_config 634 | auto_service 635 | hs_routing 636 | auto_script 637 | echo "" 638 | echo "The hotspot setup will be available after a reboot" 639 | HSssid=($(cat "/etc/hostapd/hostapd.conf" | grep '^ssid=')) 640 | HSpass=($(cat "/etc/hostapd/hostapd.conf" | grep '^wpa_passphrase=')) 641 | echo "The Hotspots WiFi SSID name is: ${HSssid: 5}" 642 | echo "The WiFi password is: ${HSpass: 15}" 643 | display_HS_IP 644 | fi 645 | if [ "$1" ]; then 646 | echo completed. 647 | else 648 | echo -n "Press any key to continue" 649 | read 650 | fi 651 | 652 | 653 | } 654 | 655 | menu() 656 | { 657 | #selection menu 658 | clear 659 | until [ "$select" = "8" ]; do 660 | echo "Raspberryconnect.com Autohotspot installation and setup" 661 | echo "For installation or switching between hotspot types" 662 | echo " or uninstall the hotspot back to standard Pi wifi" 663 | echo "" 664 | echo "Autohotspot Net = connects to a known wifi network in range," 665 | echo "otherwise creates a Raspberry Pi Hotspot with internet if an" 666 | echo "Ethernet cable is connected, Wlan0, Eth0. Pi's 3,3+,4" 667 | echo "" 668 | echo "Autohotspot NO Net = as above but connected devices to the hotspot" 669 | echo "will NOT get internet if an Ethernet cable is connected. Rpi Zero W" 670 | echo "" 671 | echo "Permanent Hotspot = permanent hotspot with net access for connected devices" 672 | echo "" 673 | echo " 1 = Install Autohotspot with Internet for Connected Devices" 674 | echo " 2 = Install Autohotspot with No Internet for connected devices" 675 | echo " 3 = Install a Permanent Hotspot with Internet for connected devices" 676 | echo " 4 = Uninstall Autohotspot or Permanent Hotspot" 677 | echo " 5 = Add or Change a WiFi network (SSID)" 678 | echo " 6 = Autohotspot: Force to a Hotspot or Force to Network if SSID in Range" 679 | echo " 7 = Change the Hotspots SSID and Password" 680 | echo " 8 = Exit" 681 | echo "" 682 | echo -n "Select an Option:" 683 | read select 684 | case $select in 685 | 1) clear ; go "AHN" ;; #Autohospot Internet 686 | 2) clear ; go "AHD" ;; #Autohotspot Direct 687 | 3) clear ; go "SHS" ;; #Static Hotspot 688 | 4) clear ; go "REM" ;; #Remove Autohotspot or Static Hotspot 689 | 5) clear ; go "SSI" ;; #Change/Add Wifi Network 690 | 6) clear ; go "FOR" ;; #Force Hotspot <> Force Network 691 | 7) clear ; go "HSS" ;; #Change Hotspot SSID and Password 692 | 8) clear ; exit ;; 693 | *) clear; echo "Please select again";; 694 | esac 695 | done 696 | } 697 | 698 | check_installed #check system and status 699 | if [ $nftble = "Y" ]; then 700 | echo "The Internet Hotspots scripts use iptables. nftables is enabled on this system." 701 | echo "It is not recommended you use iptables and nftables together." 702 | echo "A nftables version will be available in the next update" 703 | echo "" 704 | echo "You can use the 'Autohotspot with NO Internet...' version of the script. Option 2 in the menus" 705 | if [ "$1" ]; then 706 | echo completed. 707 | else 708 | echo -n "Press a key to continue" 709 | read 710 | fi 711 | 712 | fi 713 | check_reqfiles 714 | check_installed 715 | check_wificountry 716 | 717 | if [ "$1" ] ; then 718 | case $1 in 719 | 1) clear ; go "AHN" ;; #Autohospot Internet 720 | 2) clear ; go "AHD" ;; #Autohotspot Direct 721 | 3) clear ; go "SHS" ;; #Static Hotspot 722 | 4) clear ; go "REM" ;; #Remove Autohotspot or Static Hotspot 723 | 5) clear ; go "SSI" ;; #Change/Add Wifi Network 724 | 6) clear ; go "FOR" ;; #Force Hotspot <> Force Network 725 | 7) clear ; go "HSS" ;; #Change Hotspot SSID and Password 726 | 8) clear ; exit ;; 727 | esac 728 | else 729 | 730 | menu #show menu 731 | fi 732 | -------------------------------------------------------------------------------- /Autohotspot/config/Checklist.md5: -------------------------------------------------------------------------------- 1 | ee2893699997ce0dd935945e8f7473e9 autohotspot-direct 2 | b87b8b6fa19445d0e65045d8e271f456 autohotspot-direct.service 3 | 7a7163a55ec1293ec8a0f2f5e4cb8e20 autohotspotN 4 | bb7fd111c1baa11fdee18699041a2516 autohotspot-Net.service 5 | 557bfbf9d19f7d4a8d8fd19e40a435c5 dhcpcd-autohs.conf 6 | ace02c8a941b75e2c922791e4a30b32c dhcpcd-remove.conf 7 | 26e78fb29affea8022a9c989f6475ca7 dhcpcd-SHS.conf 8 | 41ace870877f786773244a178f26cefe dhcpcd-SHSN.conf 9 | 8789bd5d1674e65d18c21c3bcffdfb0a dnsmasqAHS.conf 10 | 807885886aa6a40f30d4c9d480b80c84 dnsmasqAHSN.conf 11 | 25e3152c11d0860428bcb51b25e33441 dnsmasqSHS.conf 12 | 7f79d770c0c851b731a9f26e3487b199 hostapd 13 | 46634b98cc27980c4130b9fa9d568de9 hostapd.conf 14 | d0f09b7f89ef821edaef58e7b91b313a hs-iptables.service 15 | 65de69ce894bce4e0705143fc2cfb8d3 hs-nftables.service 16 | c82e7473bb1490cf4702aaf7b669bb33 interfaces 17 | fbb31822a27f4acca55acdb8f52d538c iptables-hs.txt 18 | -------------------------------------------------------------------------------- /Autohotspot/config/autohotspot-Net.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Automatically generates a Hotspot when a valid SSID is not in range 3 | After=multi-user.target 4 | [Service] 5 | Type=oneshot 6 | RemainAfterExit=yes 7 | ExecStart=/usr/bin/autohotspotN 8 | [Install] 9 | WantedBy=multi-user.target 10 | -------------------------------------------------------------------------------- /Autohotspot/config/autohotspot-direct: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #version 0.961-N/HS 3 | 4 | #You may share this script on the condition a reference to RaspberryConnect.com 5 | #must be included in copies or derivatives of this script. 6 | 7 | #A script to switch between a wifi network and a non internet routed Hotspot 8 | #Works at startup or with a seperate timer or manually without a reboot 9 | #Other setup required find out more at 10 | #http://www.raspberryconnect.com 11 | 12 | wifidev="wlan0" #device name to use. Default is wlan0. 13 | #use the command: iw dev ,to see wifi interface name 14 | 15 | IFSdef=$IFS 16 | cnt=0 17 | #These four lines capture the wifi networks the RPi is setup to use 18 | wpassid=$(awk '/ssid="/{ print $0 }' /etc/wpa_supplicant/wpa_supplicant.conf | awk -F'ssid=' '{ print $2 }' | sed 's/\r//g'| awk 'BEGIN{ORS=","} {print}' | sed 's/\"/''/g' | sed 's/,$//') 19 | IFS="," 20 | ssids=($wpassid) 21 | IFS=$IFSdef #reset back to defaults 22 | 23 | 24 | #Note:If you only want to check for certain SSIDs 25 | #Remove the # in in front of ssids=('mySSID1'.... below and put a # infront of all four lines above 26 | # separated by a space, eg ('mySSID1' 'mySSID2') 27 | #ssids=('mySSID1' 'mySSID2' 'mySSID3') 28 | 29 | #Enter the Routers Mac Addresses for hidden SSIDs, seperated by spaces ie 30 | #( '11:22:33:44:55:66' 'aa:bb:cc:dd:ee:ff' ) 31 | mac=() 32 | 33 | ssidsmac=("${ssids[@]}" "${mac[@]}") #combines ssid and MAC for checking 34 | 35 | createAdHocNetwork() 36 | { 37 | echo "Creating Hotspot" 38 | ip link set dev "$wifidev" down 39 | ip a add 10.0.0.5/24 brd + dev "$wifidev" 40 | ip link set dev "$wifidev" up 41 | dhcpcd -k "$wifidev" >/dev/null 2>&1 42 | systemctl start dnsmasq 43 | systemctl start hostapd 44 | } 45 | 46 | KillHotspot() 47 | { 48 | echo "Shutting Down Hotspot" 49 | ip link set dev "$wifidev" down 50 | systemctl stop hostapd 51 | systemctl stop dnsmasq 52 | ip addr flush dev "$wifidev" 53 | ip link set dev "$wifidev" up 54 | dhcpcd -n "$wifidev" >/dev/null 2>&1 55 | } 56 | 57 | ChkWifiUp() 58 | { 59 | echo "Checking WiFi connection ok" 60 | sleep 20 #give time for connection to be completed to router 61 | if ! wpa_cli -i "$wifidev" status | grep 'ip_address' >/dev/null 2>&1 62 | then #Failed to connect to wifi (check your wifi settings, password etc) 63 | echo 'Wifi failed to connect, falling back to Hotspot.' 64 | wpa_cli terminate "$wifidev" >/dev/null 2>&1 65 | createAdHocNetwork 66 | fi 67 | } 68 | 69 | 70 | chksys() 71 | { 72 | #After some system updates hostapd gets masked using Raspbian Buster, and above. This checks and fixes 73 | #the issue and also checks dnsmasq is ok so the hotspot can be generated. 74 | #Check Hostapd is unmasked and disabled 75 | if systemctl -all list-unit-files hostapd.service | grep "hostapd.service masked" >/dev/null 2>&1 ;then 76 | systemctl unmask hostapd.service >/dev/null 2>&1 77 | fi 78 | if systemctl -all list-unit-files hostapd.service | grep "hostapd.service enabled" >/dev/null 2>&1 ;then 79 | systemctl disable hostapd.service >/dev/null 2>&1 80 | systemctl stop hostapd >/dev/null 2>&1 81 | fi 82 | #Check dnsmasq is disabled 83 | if systemctl -all list-unit-files dnsmasq.service | grep "dnsmasq.service masked" >/dev/null 2>&1 ;then 84 | systemctl unmask dnsmasq >/dev/null 2>&1 85 | fi 86 | if systemctl -all list-unit-files dnsmasq.service | grep "dnsmasq.service enabled" >/dev/null 2>&1 ;then 87 | systemctl disable dnsmasq >/dev/null 2>&1 88 | systemctl stop dnsmasq >/dev/null 2>&1 89 | fi 90 | } 91 | 92 | 93 | FindSSID() 94 | { 95 | #Check to see what SSID's and MAC addresses are in range 96 | ssidChk=('NoSSid') 97 | i=0; j=0 98 | until [ $i -eq 1 ] #wait for wifi if busy, usb wifi is slower. 99 | do 100 | ssidreply=$((iw dev "$wifidev" scan ap-force | egrep "^BSS|SSID:") 2>&1) >/dev/null 2>&1 101 | #echo "SSid's in range: " $ssidreply 102 | printf '%s\n' "${ssidreply[@]}" 103 | echo "Device Available Check try " $j 104 | if (($j >= 10)); then #if busy 10 times goto hotspot 105 | echo "Device busy or unavailable 10 times, going to Hotspot" 106 | ssidreply="" 107 | i=1 108 | elif echo "$ssidreply" | grep "No such device (-19)" >/dev/null 2>&1; then 109 | echo "No Device Reported, try " $j 110 | NoDevice 111 | elif echo "$ssidreply" | grep "Network is down (-100)" >/dev/null 2>&1 ; then 112 | echo "Network Not available, trying again" $j 113 | j=$((j + 1)) 114 | sleep 2 115 | elif echo "$ssidreply" | grep "Read-only file system (-30)" >/dev/null 2>&1 ; then 116 | echo "Temporary Read only file system, trying again" 117 | j=$((j + 1)) 118 | sleep 2 119 | elif echo "$ssidreply" | grep "Invalid exchange (-52)" >/dev/null 2>&1 ; then 120 | echo "Temporary unavailable, trying again" 121 | j=$((j + 1)) 122 | sleep 2 123 | elif echo "$ssidreply" | grep -v "resource busy (-16)" >/dev/null 2>&1 ; then 124 | echo "Device Available, checking SSid Results" 125 | i=1 126 | else #see if device not busy in 2 seconds 127 | echo "Device unavailable checking again, try " $j 128 | j=$((j + 1)) 129 | sleep 2 130 | fi 131 | done 132 | 133 | for ssid in "${ssidsmac[@]}" 134 | do 135 | if (echo "$ssidreply" | grep -F -- "$ssid") >/dev/null 2>&1 136 | then 137 | #Valid SSid found, passing to script 138 | echo "Valid SSID Detected, assesing Wifi status" 139 | ssidChk=$ssid 140 | return 0 141 | else 142 | #No Network found, NoSSid issued" 143 | echo "No SSid found, assessing WiFi status" 144 | ssidChk='NoSSid' 145 | fi 146 | done 147 | } 148 | 149 | NoDevice() 150 | { 151 | #if no wifi device,ie usb wifi removed, activate wifi so when it is 152 | #reconnected wifi to a router will be available 153 | echo "No wifi device connected" 154 | wpa_supplicant -B -i "$wifidev" -c /etc/wpa_supplicant/wpa_supplicant.conf >/dev/null 2>&1 155 | exit 1 156 | } 157 | 158 | chksys 159 | FindSSID 160 | 161 | #Create Hotspot or connect to valid wifi networks 162 | if [ "$ssidChk" != "NoSSid" ] 163 | then 164 | if systemctl status hostapd | grep "(running)" >/dev/null 2>&1 165 | then #hotspot running and ssid in range 166 | KillHotspot 167 | echo "Hotspot Deactivated, Bringing Wifi Up" 168 | wpa_supplicant -B -i "$wifidev" -c /etc/wpa_supplicant/wpa_supplicant.conf >/dev/null 2>&1 169 | ChkWifiUp 170 | elif { wpa_cli -i "$wifidev" status | grep 'ip_address'; } >/dev/null 2>&1 171 | then #Already connected 172 | echo "Wifi already connected to a network" 173 | else #ssid exists and no hotspot running connect to wifi network 174 | echo "Connecting to the WiFi Network" 175 | wpa_supplicant -B -i "$wifidev" -c /etc/wpa_supplicant/wpa_supplicant.conf >/dev/null 2>&1 176 | ChkWifiUp 177 | fi 178 | else #ssid or MAC address not in range 179 | if systemctl status hostapd | grep "(running)" >/dev/null 2>&1 180 | then 181 | echo "Hostspot already active" 182 | elif { wpa_cli status | grep "$wifidev"; } >/dev/null 2>&1 183 | then 184 | echo "Cleaning wifi files and Activating Hotspot" 185 | wpa_cli terminate >/dev/null 2>&1 186 | ip addr flush "$wifidev" 187 | ip link set dev "$wifidev" down 188 | rm -r /var/run/wpa_supplicant >/dev/null 2>&1 189 | createAdHocNetwork 190 | else #"No SSID, activating Hotspot" 191 | createAdHocNetwork 192 | fi 193 | fi 194 | -------------------------------------------------------------------------------- /Autohotspot/config/autohotspot-direct.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Automatically generates a Hotspot when a valid SSID is not in range 3 | After=multi-user.target 4 | [Service] 5 | Type=oneshot 6 | RemainAfterExit=yes 7 | ExecStart=/usr/bin/autohotspot 8 | [Install] 9 | WantedBy=multi-user.target 10 | -------------------------------------------------------------------------------- /Autohotspot/config/autohotspotN: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #version 0.961-N/HS-I 3 | 4 | #You may share this script on the condition a reference to RaspberryConnect.com 5 | #must be included in copies or derivatives of this script. 6 | 7 | #Network Wifi & Hotspot with Internet 8 | #A script to switch between a wifi network and an Internet routed Hotspot 9 | #A Raspberry Pi with a network port required for Internet in hotspot mode. 10 | #Works at startup or with a seperate timer or manually without a reboot 11 | #Other setup required find out more at 12 | #http://www.raspberryconnect.com 13 | 14 | wifidev="wlan0" #device name to use. Default is wlan0. 15 | ethdev="eth0" #Ethernet port to use with IP tables 16 | #use the command: iw dev ,to see wifi interface name 17 | 18 | IFSdef=$IFS 19 | cnt=0 20 | #These four lines capture the wifi networks the RPi is setup to use 21 | wpassid=$(awk '/ssid="/{ print $0 }' /etc/wpa_supplicant/wpa_supplicant.conf | awk -F'ssid=' '{ print $2 }' | sed 's/\r//g'| awk 'BEGIN{ORS=","} {print}' | sed 's/\"/''/g' | sed 's/,$//') 22 | IFS="," 23 | ssids=($wpassid) 24 | IFS=$IFSdef #reset back to defaults 25 | 26 | 27 | #Note:If you only want to check for certain SSIDs 28 | #Remove the # in in front of ssids=('mySSID1'.... below and put a # infront of all four lines above 29 | # separated by a space, eg ('mySSID1' 'mySSID2') 30 | #ssids=('mySSID1' 'mySSID2' 'mySSID3') 31 | 32 | #Enter the Routers Mac Addresses for hidden SSIDs, seperated by spaces ie 33 | #( '11:22:33:44:55:66' 'aa:bb:cc:dd:ee:ff' ) 34 | mac=() 35 | 36 | ssidsmac=("${ssids[@]}" "${mac[@]}") #combines ssid and MAC for checking 37 | 38 | createAdHocNetwork() 39 | { 40 | echo "Creating Hotspot" 41 | ip link set dev "$wifidev" down 42 | ip a add 192.168.50.5/24 brd + dev "$wifidev" 43 | ip link set dev "$wifidev" up 44 | dhcpcd -k "$wifidev" >/dev/null 2>&1 45 | iptables -t nat -A POSTROUTING -o "$ethdev" -j MASQUERADE 46 | iptables -A FORWARD -i "$ethdev" -o "$wifidev" -m state --state RELATED,ESTABLISHED -j ACCEPT 47 | iptables -A FORWARD -i "$wifidev" -o "$ethdev" -j ACCEPT 48 | systemctl start dnsmasq 49 | systemctl start hostapd 50 | echo 1 > /proc/sys/net/ipv4/ip_forward 51 | } 52 | 53 | KillHotspot() 54 | { 55 | echo "Shutting Down Hotspot" 56 | ip link set dev "$wifidev" down 57 | systemctl stop hostapd 58 | systemctl stop dnsmasq 59 | iptables -D FORWARD -i "$ethdev" -o "$wifidev" -m state --state RELATED,ESTABLISHED -j ACCEPT 60 | iptables -D FORWARD -i "$wifidev" -o "$ethdev" -j ACCEPT 61 | echo 0 > /proc/sys/net/ipv4/ip_forward 62 | ip addr flush dev "$wifidev" 63 | ip link set dev "$wifidev" up 64 | dhcpcd -n "$wifidev" >/dev/null 2>&1 65 | } 66 | 67 | ChkWifiUp() 68 | { 69 | echo "Checking WiFi connection ok" 70 | sleep 20 #give time for connection to be completed to router 71 | if ! wpa_cli -i "$wifidev" status | grep 'ip_address' >/dev/null 2>&1 72 | then #Failed to connect to wifi (check your wifi settings, password etc) 73 | echo 'Wifi failed to connect, falling back to Hotspot.' 74 | wpa_cli terminate "$wifidev" >/dev/null 2>&1 75 | createAdHocNetwork 76 | fi 77 | } 78 | 79 | chksys() 80 | { 81 | #After some system updates hostapd gets masked using Raspbian Buster, and above. This checks and fixes 82 | #the issue and also checks dnsmasq is ok so the hotspot can be generated. 83 | #Check Hostapd is unmasked and disabled 84 | if systemctl -all list-unit-files hostapd.service | grep "hostapd.service masked" >/dev/null 2>&1 ;then 85 | systemctl unmask hostapd.service >/dev/null 2>&1 86 | fi 87 | if systemctl -all list-unit-files hostapd.service | grep "hostapd.service enabled" >/dev/null 2>&1 ;then 88 | systemctl disable hostapd.service >/dev/null 2>&1 89 | systemctl stop hostapd >/dev/null 2>&1 90 | fi 91 | #Check dnsmasq is disabled 92 | if systemctl -all list-unit-files dnsmasq.service | grep "dnsmasq.service masked" >/dev/null 2>&1 ;then 93 | systemctl unmask dnsmasq >/dev/null 2>&1 94 | fi 95 | if systemctl -all list-unit-files dnsmasq.service | grep "dnsmasq.service enabled" >/dev/null 2>&1 ;then 96 | systemctl disable dnsmasq >/dev/null 2>&1 97 | systemctl stop dnsmasq >/dev/null 2>&1 98 | fi 99 | } 100 | 101 | 102 | FindSSID() 103 | { 104 | #Check to see what SSID's and MAC addresses are in range 105 | ssidChk=('NoSSid') 106 | i=0; j=0 107 | # Set the pin for input 108 | gpio mode 7 in 109 | 110 | # Set the variable through command substitution 111 | b=$(gpio read 7) 112 | 113 | # Echo the value to the console 114 | echo "switch position is " "$b" 115 | if [ "$b" == "0" ] 116 | then 117 | echo " switch was set to field." 118 | return #force hot spot to be created if switch is set to field position. 119 | else 120 | echo "switch was set to home" 121 | fi 122 | until [ $i -eq 1 ] #wait for wifi if busy, usb wifi is slower. 123 | do 124 | 125 | ssidreply=$((iw dev "$wifidev" scan ap-force | egrep "^BSS|SSID:") 2>&1) >/dev/null 2>&1 126 | #echo "SSid's in range: " $ssidreply 127 | printf '%s\n' "${ssidreply[@]}" 128 | echo "Device Available Check try " $j 129 | if (($j >= 10)); then #if busy 10 times goto hotspot 130 | echo "Device busy or unavailable 10 times, going to Hotspot" 131 | ssidreply="" 132 | i=1 133 | elif echo "$ssidreply" | grep "No such device (-19)" >/dev/null 2>&1; then 134 | echo "No Device Reported, try " $j 135 | NoDevice 136 | elif echo "$ssidreply" | grep "Network is down (-100)" >/dev/null 2>&1 ; then 137 | echo "Network Not available, trying again" $j 138 | j=$((j + 1)) 139 | sleep 2 140 | elif echo "$ssidreply" | grep "Read-only file system (-30)" >/dev/null 2>&1 ; then 141 | echo "Temporary Read only file system, trying again" 142 | j=$((j + 1)) 143 | sleep 2 144 | elif echo "$ssidreply" | grep "Invalid exchange (-52)" >/dev/null 2>&1 ; then 145 | echo "Temporary unavailable, trying again" 146 | j=$((j + 1)) 147 | sleep 2 148 | elif echo "$ssidreply" | grep -v "resource busy (-16)" >/dev/null 2>&1 ; then 149 | echo "Device Available, checking SSid Results" 150 | i=1 151 | else #see if device not busy in 2 seconds 152 | echo "Device unavailable checking again, try " $j 153 | j=$((j + 1)) 154 | sleep 2 155 | fi 156 | done 157 | 158 | for ssid in "${ssidsmac[@]}" 159 | do 160 | if (echo "$ssidreply" | grep -F -- "$ssid") >/dev/null 2>&1 161 | then 162 | #Valid SSid found, passing to script 163 | echo "Valid SSID Detected, assesing Wifi status" 164 | ssidChk=$ssid 165 | return 0 166 | else 167 | #No Network found, NoSSid issued" 168 | echo "No SSid found, assessing WiFi status" 169 | ssidChk='NoSSid' 170 | fi 171 | done 172 | } 173 | 174 | NoDevice() 175 | { 176 | #if no wifi device,ie usb wifi removed, activate wifi so when it is 177 | #reconnected wifi to a router will be available 178 | echo "No wifi device connected" 179 | wpa_supplicant -B -i "$wifidev" -c /etc/wpa_supplicant/wpa_supplicant.conf >/dev/null 2>&1 180 | exit 1 181 | } 182 | 183 | chksys 184 | FindSSID 185 | 186 | #Create Hotspot or connect to valid wifi networks 187 | if [ "$ssidChk" != "NoSSid" ] 188 | then 189 | echo 0 > /proc/sys/net/ipv4/ip_forward #deactivate ip forwarding 190 | if systemctl status hostapd | grep "(running)" >/dev/null 2>&1 191 | then #hotspot running and ssid in range 192 | KillHotspot 193 | echo "Hotspot Deactivated, Bringing Wifi Up" 194 | wpa_supplicant -B -i "$wifidev" -c /etc/wpa_supplicant/wpa_supplicant.conf >/dev/null 2>&1 195 | ChkWifiUp 196 | elif { wpa_cli -i "$wifidev" status | grep 'ip_address'; } >/dev/null 2>&1 197 | then #Already connected 198 | echo "Wifi already connected to a network" 199 | else #ssid exists and no hotspot running connect to wifi network 200 | echo "Connecting to the WiFi Network" 201 | wpa_supplicant -B -i "$wifidev" -c /etc/wpa_supplicant/wpa_supplicant.conf >/dev/null 2>&1 202 | ChkWifiUp 203 | fi 204 | else #ssid or MAC address not in range 205 | if systemctl status hostapd | grep "(running)" >/dev/null 2>&1 206 | then 207 | echo "Hostspot already active" 208 | elif { wpa_cli status | grep "$wifidev"; } >/dev/null 2>&1 209 | then 210 | echo "Cleaning wifi files and Activating Hotspot" 211 | wpa_cli terminate >/dev/null 2>&1 212 | ip addr flush "$wifidev" 213 | ip link set dev "$wifidev" down 214 | rm -r /var/run/wpa_supplicant >/dev/null 2>&1 215 | createAdHocNetwork 216 | else #"No SSID, activating Hotspot" 217 | createAdHocNetwork 218 | fi 219 | fi 220 | -------------------------------------------------------------------------------- /Autohotspot/config/dhcpcd-SHS.conf: -------------------------------------------------------------------------------- 1 | #RaspberryConnect.com 2 | #Static Hotspot without Net 3 | nohook wpa_supplicant 4 | interface wlan0 5 | static ip_address=192.168.50.10/24 6 | static routers=192.168.50.1 7 | -------------------------------------------------------------------------------- /Autohotspot/config/dhcpcd-SHSN.conf: -------------------------------------------------------------------------------- 1 | #RaspberryConnect.com 2 | #Static Hotspot with Net 3 | nohook wpa_supplicant 4 | interface wlan0 5 | static ip_address=192.168.50.10/24 6 | static routers=192.168.50.1 7 | static domain_name_servers=8.8.8.8 -------------------------------------------------------------------------------- /Autohotspot/config/dhcpcd-autohs.conf: -------------------------------------------------------------------------------- 1 | #RaspberryConnect.com 2 | #Autohotspots 3 | nohook wpa_supplicant -------------------------------------------------------------------------------- /Autohotspot/config/dhcpcd-remove.conf: -------------------------------------------------------------------------------- 1 | #RaspberryConnect.com 2 | #Autohotspots 3 | nohook wpa_supplicant 4 | #Static Hotspot without Net 5 | interface wlan0 6 | static ip_address=192.168.50.10/24 7 | static routers=192.168.50.1 8 | #Static Hotspot with Net 9 | static domain_name_servers=8.8.8.8 10 | -------------------------------------------------------------------------------- /Autohotspot/config/dnsmasqAHS.conf: -------------------------------------------------------------------------------- 1 | #RaspberryConnect.com 2 | #AutoHotspot Config 3 | interface=wlan0 4 | no-resolv 5 | bind-interfaces 6 | dhcp-range=10.0.0.50,10.0.0.100,12h 7 | 8 | -------------------------------------------------------------------------------- /Autohotspot/config/dnsmasqAHSN.conf: -------------------------------------------------------------------------------- 1 | #RaspberryConnect.com Autohotspot 2 | #AutoHotspotN config 3 | interface=wlan0 4 | bind-dynamic 5 | server=8.8.8.8 6 | domain-needed 7 | bogus-priv 8 | dhcp-range=192.168.50.150,192.168.50.200,72h 9 | 10 | -------------------------------------------------------------------------------- /Autohotspot/config/dnsmasqSHS.conf: -------------------------------------------------------------------------------- 1 | #RaspberryConnect.com 2 | #RPiHotspot config - Internet 3 | interface=wlan0 4 | bind-dynamic 5 | domain-needed 6 | bogus-priv 7 | server=8.8.8.8 8 | dhcp-range=192.168.50.150,192.168.50.200,255.255.255.0,12h 9 | -------------------------------------------------------------------------------- /Autohotspot/config/hostapd: -------------------------------------------------------------------------------- 1 | # Defaults for hostapd initscript 2 | # 3 | # WARNING: The DAEMON_CONF setting has been deprecated and will be removed 4 | # in future package releases. 5 | # 6 | # See /usr/share/doc/hostapd/README.Debian for information about alternative 7 | # methods of managing hostapd. 8 | # 9 | # Uncomment and set DAEMON_CONF to the absolute path of a hostapd configuration 10 | # file and hostapd will be started during system boot. An example configuration 11 | # file can be found at /usr/share/doc/hostapd/examples/hostapd.conf.gz 12 | # 13 | DAEMON_CONF="/etc/hostapd/hostapd.config" 14 | 15 | # Additional daemon options to be appended to hostapd command:- 16 | # -d show more debug messages (-dd for even more) 17 | # -K include key data in debug messages 18 | # -t include timestamps in some debug messages 19 | # 20 | # Note that -B (daemon mode) and -P (pidfile) options are automatically 21 | # configured by the init.d script and must not be added to DAEMON_OPTS. 22 | # 23 | #DAEMON_OPTS="" 24 | -------------------------------------------------------------------------------- /Autohotspot/config/hostapd.conf: -------------------------------------------------------------------------------- 1 | #RaspberryConnect.com - Autohotspot 2 | #2.4GHz setup wifi 80211 b,g,n 3 | interface=wlan0 4 | driver=nl80211 5 | ssid=RPiHotspot 6 | hw_mode=g 7 | channel=8 8 | wmm_enabled=0 9 | macaddr_acl=0 10 | auth_algs=1 11 | ignore_broadcast_ssid=0 12 | wpa=2 13 | wpa_passphrase=1234567890 14 | wpa_key_mgmt=WPA-PSK 15 | wpa_pairwise=CCMP TKIP 16 | rsn_pairwise=CCMP 17 | 18 | #80211n - Change GB to your WiFi country code 19 | country_code=GB 20 | ieee80211n=1 21 | ieee80211d=1 22 | 23 | -------------------------------------------------------------------------------- /Autohotspot/config/hs-iptables.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Activate IPtables for Hotspot 3 | After=network-pre.target 4 | Before=network-online.target 5 | 6 | [Service] 7 | Type=simple 8 | ExecStart=/etc/iptables-hs 9 | 10 | [Install] 11 | WantedBy=multi-user.target 12 | -------------------------------------------------------------------------------- /Autohotspot/config/hs-nftables.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Activate NFtables for Hotspot 3 | After=network-pre.target 4 | Before=network-online.target 5 | 6 | [Service] 7 | Type=simple 8 | ExecStart=/etc/nftables-hs 9 | 10 | [Install] 11 | WantedBy=multi-user.target 12 | -------------------------------------------------------------------------------- /Autohotspot/config/interfaces: -------------------------------------------------------------------------------- 1 | # interfaces(5) file used by ifup(8) and ifdown(8) 2 | 3 | # Please note that this file is written to be used with dhcpcd 4 | # For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf' 5 | 6 | # Include files from /etc/network/interfaces.d: 7 | source-directory /etc/network/interfaces.d 8 | -------------------------------------------------------------------------------- /Autohotspot/config/iptables-hs.txt: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE 3 | iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT 4 | iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT 5 | 6 | -------------------------------------------------------------------------------- /HotSpotorSwitchBack.sh: -------------------------------------------------------------------------------- 1 | sudo /home/pi/Autohotspot/autohotspot-setup.sh 6 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /Quality.py: -------------------------------------------------------------------------------- 1 | """ 2 | Finds the brightness and magnitude of solved images stored in cap.jpeg alaong with the solved data in cap.wcs 3 | 4 | Note: Requires PIL (pip install Pillow) 5 | """ 6 | from cmath import nan 7 | from logging import exception 8 | from operator import truediv 9 | from termios import IXANY 10 | from PIL import Image, ImageDraw, ImageEnhance, ImageFont 11 | import os 12 | from pathlib import Path 13 | import subprocess 14 | import tetra3 15 | import sys 16 | import json as json 17 | import pprint 18 | import bstars 19 | import math 20 | import re 21 | import constellations 22 | import numpy as np 23 | import matplotlib.pyplot as plt 24 | from scipy import stats, spatial 25 | from scipy.optimize import curve_fit 26 | import fitsio 27 | from fitsio import FITS,FITSHDR 28 | 29 | sys.path.append('..') 30 | brightNamesStars = None 31 | kdtree = None 32 | hiptree = None 33 | hiptable = None 34 | # find star magnitude and name of stars in image. Uses astrometry's corr.cap file 35 | def findClosestPoint(x1,y1,starx, stary): 36 | bestdel = 10000 37 | bestNdx = -1 38 | for ndx, x in enumerate(starx): 39 | dx = 20 * (x - x1) 40 | dy = stary[ndx] - y1 41 | delta = math.sqrt(dx * dx + dy * dy) 42 | if delta < bestdel: 43 | bestdel = delta 44 | bestNdx = ndx 45 | return bestNdx 46 | 47 | # get star magnitudes from the caps.cor file then find it's name from the bright stars file 48 | # return the stars info and the labeled image 49 | def findStarMags(fn, sourceOfImage= None): 50 | global brightNamesStars, kdtree 51 | 52 | 53 | def getStarName(ra,dec,tree): 54 | delta,index = tree.query([ra,dec],1) 55 | if delta < .1: 56 | star = brightNamesStars[index] 57 | if star[1] != b'': 58 | return star[1] 59 | elif star[0] == b'': 60 | return 'B%d'%(index) 61 | else: 62 | return star[0].decode('utf-8') 63 | 64 | 65 | if not brightNamesStars: 66 | brightNamesStars = bstars.bstars 67 | kdtree = spatial.KDTree([[r[2],r[3]] for r in brightNamesStars]) 68 | 69 | if not os.path.exists(fn) or not os.path.exists('./static/cap.corr'): 70 | return None,"no solved file found" 71 | with Image.open(fn) as img: 72 | # image brightness enhancer 73 | enhancer = ImageEnhance.Brightness(img) 74 | factor = 3 # gives original image 75 | im_output = enhancer.enhance(factor) 76 | 77 | fitsTable,header= fitsio.read('./static/cap.corr',header=True) 78 | magstring = 'MAG_VT' 79 | for hh in header: 80 | if 'TTYPE' in hh: 81 | 82 | if magstring == header[hh]: 83 | break 84 | elif 'j_mag' == header[hh]: 85 | magstring = 'j_mag' 86 | break 87 | 88 | astars = [] 89 | for s in fitsTable: 90 | astar = {} 91 | astar['RA'] = s['index_ra'] 92 | astar['DEC'] = s['index_dec'] 93 | 94 | if s[magstring]>5.9: 95 | name = 'M%4.3lf'%(s[magstring]) 96 | else: 97 | name = getStarName(astar['RA'],astar['DEC'],kdtree) 98 | #print(name, 'ra:', s['index_ra'],s['index_dec'], magstring, s[magstring]) 99 | if name is None: 100 | continue 101 | 102 | astar['name'] = name 103 | astar['x'] = s['index_x'] 104 | astar['y'] = s['index_y'] 105 | astar['MAG'] = s[magstring] 106 | astar['FLUX'] = s['FLUX'] 107 | astar['Background'] = s['BACKGROUND'] 108 | 109 | # print('RA: %6.3lf Dec:%6.3lf x:%6.3lf y:%6.3lf Mag:%4.1lf Flux:%d Background:%d'%\ 110 | # (s['index_ra'],s['index_dec'],\ 111 | # s['index_x'], s['index_y'],\ 112 | # s['MAG_VT'],\ 113 | # s['FLUX'],s['BACKGROUND'])) 114 | 115 | astars.append(astar) 116 | 117 | 118 | unicode_font = ImageFont.truetype("DejaVuSans.ttf", 15) 119 | draw = ImageDraw.Draw(im_output) 120 | 121 | stars = [] 122 | for star in astars: 123 | x = star['x'] 124 | y = star['y'] 125 | magR = 4 * (6 - star['MAG']) 126 | if star['MAG'] < 5: 127 | draw.ellipse((star['x']-magR, star['y']-magR, star['x']+magR, star['y']+magR),\ 128 | outline='blue', width=3) 129 | 130 | #print('corrStar',corrStar) 131 | name = star['name'] 132 | if name is None: 133 | name = 'M%5.2lf'%(star['MAG']) 134 | consts = '' 135 | # find the constelation from the star name 136 | for c in constellations.constellationNames: 137 | 138 | if c.casefold() in name.casefold(): 139 | consts = c 140 | break 141 | draw.text((x+10,y-10),name,font = unicode_font) 142 | #if star['MAG'] > 7.5: 143 | #draw.ellipse((star['x']-20, star['y']-20, star['x']+20, star['y']+20),\ 144 | #outline='yellow') 145 | mag = star['MAG'] 146 | flux = star['FLUX'] 147 | if star['MAG'] < 5: 148 | txt = 'Mag:%4.1lf FL:%3.0lf BG:%d'%(mag, flux, star['Background']) 149 | draw.text((x-40,y+20), txt,font = unicode_font) 150 | 151 | 152 | if sourceOfImage is not None: 153 | fn = sourceOfImage 154 | stars.append({'name': name, 'mag': float(mag), 'flux':float(flux), 155 | 'constellation': consts,'fileName':fn, 156 | 'Background':float(star['Background']),'xy':[star['x'],star['y']] }) 157 | 158 | return stars, im_output ,img.width, img.height 159 | 160 | 161 | def selectStarsBetweenFluxValues(stars, minflux,maxflux): 162 | useThese = [] 163 | # find the brightest mag that has a flux less than maxflux 164 | for s in sorted(stars, key = lambda st: st['mag'], reverse=True): 165 | flx = s['flux'] 166 | if flx > maxflux or flx < minflux: 167 | continue 168 | m = s['mag'] 169 | if m < 8: 170 | useThese.append([m,flx, s['xy'], s['name']]) 171 | return useThese 172 | 173 | #make the actual mag versus plotStarMagsflux curves (expected and actual) 174 | # given a list of stars and a matplotlib axes 175 | def plotMagcurve(useThese, ax, leg = True): 176 | #input stars are sorted by assending magnitude. Darkest first 177 | mag1 = [row[0] for row in useThese] 178 | flux1 = [row[1] for row in useThese] 179 | 180 | #remove any stars whose perfect flux would be greater than 240 181 | flux = [] 182 | mag = [] 183 | for ndx, f in enumerate(flux1[1:]): 184 | 185 | #I2/I1 = 10 ^ (m1-m2)/2.5 186 | ilast = flux1[0] * 10 ** ((mag1[ndx] - mag1[0])/2.512) 187 | if ilast > 240: 188 | continue 189 | flux.append( flux1[ndx]) 190 | mag.append( mag1[ndx]) 191 | 192 | avgflux = sum(flux)/len(flux) 193 | fig = plt.gcf() 194 | minMag = min(mag) 195 | maxMag = max(mag) 196 | fig.set_facecolor('#404040') 197 | 198 | for ndx, m in enumerate(mag): 199 | ax.scatter(m,flux[ndx]) 200 | if flux[ndx] > avgflux: 201 | ax.text(m-.01*m,flux[ndx],useThese[ndx][3], dict(ha='right', va='center', fontsize=8, color='k')) 202 | #print(s, '%5.3lf'%(stars[s][0]), stars[s][1:]) 203 | 204 | ax.grid(color='darkred', linestyle=':') 205 | 206 | def func(x,a,b,c): 207 | return a * (x ** 2.512) + b * x + c 208 | 209 | #make best fit curve 210 | params, _ = curve_fit(func, mag, flux) 211 | a, b, c = params[0], params[1], params[2] 212 | xes = np.arange( minMag,maxMag, .2) 213 | yfit1 = [a*pow(x,2.512)+b*x+c for x in xes] 214 | 215 | #pick a point that the median of the magnitude 216 | x0 = (maxMag + minMag)/2 217 | 218 | fluxMid = a * pow(x0,2.512)+b * x0 + c 219 | #find the closest real star to this point 220 | ndx = findClosestPoint(x0,fluxMid,mag,flux) 221 | 222 | # now use one of the measured stars as a reference 223 | x0 = mag[ndx] 224 | fluxMid = a * (x0 ** 2.512) + b * x0 + c 225 | while fluxMid < 0: 226 | ndx += 1 227 | x0 = mag[ndx] 228 | fluxMid = a * (x0 ** 2.512) + b * x0 + c 229 | #make the pefect curve 230 | cnt = len(yfit1) 231 | 232 | x = [] 233 | y = [] 234 | 235 | 236 | ax.scatter(x0,fluxMid, color='white') 237 | for m in np.arange(minMag,maxMag, .2): 238 | x.append(m) 239 | fluxPerfect = fluxMid/ (2.512 ** (m-x0)) 240 | y.append(fluxPerfect) 241 | 242 | 243 | ax.xaxis.label.set_color('silver') 244 | ax.yaxis.label.set_color('silver') 245 | ax.tick_params(colors='silver', which='both') 246 | ax.set_facecolor('#a0a0a0') 247 | 248 | ax.set_xlabel('Magnitude') 249 | ax.set_ylabel('Flux') 250 | params, _ = curve_fit(func, x, y) 251 | a1, b1, c1 = params[0], params[1], params[2] 252 | 253 | if leg: 254 | label = 'Per a:%4.1lf b:%4.1lf c:%4.1lf'%(a1,b1,c1) 255 | else: 256 | label = '' 257 | 258 | qualMetric = math.sqrt(((a1 -a) ** 2 + (b1 -b) ** 2 )/2.) 259 | ylim = ax.get_ylim() 260 | xlim = ax.get_xlim() 261 | 262 | ax.plot(x,y,':',label = label) 263 | ax.plot(xes,yfit1, label='act a:%4.1lf b:%4.1lf c:%4.1lf'%(a,b,c)) 264 | legend = ax.legend(facecolor='k', framealpha = 0) 265 | #ax.setp(legend.get_texts(), color='grey') 266 | 267 | 268 | #compute the diff from perfect to actual 269 | 270 | for s in useThese: 271 | idealFlux = (fluxMid)/pow(2.512, s[0] - x0) 272 | delta = s[1]/idealFlux 273 | s[2].append(delta) 274 | 275 | #Show position of reference star 276 | #return reference star and stars with their intensity delta compared with reference 277 | return {'ref':useThese[ndx][2],'stars':useThese, 'QualityMetric':qualMetric} 278 | 279 | # select stars to be plotted in the flux/mag curves 280 | # min will be less than 1. because they have been reverse gamma corrected. 281 | def plotStarMags(stars, maxflux = 200, minflux = .01): 282 | 283 | starsAvg = {} 284 | if len(stars) < 6: 285 | raise ValueError('not enough stars found') 286 | 287 | rawFlux = [] 288 | degamad = [] 289 | backgrounds = [] 290 | # remove supposed gama correction 291 | 292 | for s in stars: 293 | f = s['flux']/255 294 | rawFlux.append(f) 295 | degamad.append (s.copy()) 296 | backgrounds.append(s['Background']) 297 | flx = 255 * (f ** 2.2) 298 | degamad[-1]['flux'] = flx 299 | 300 | 301 | 302 | xys = [] 303 | numberofstars = 0 304 | while True: 305 | useThese = selectStarsBetweenFluxValues(degamad, minflux,maxflux) 306 | numberofstars = len(useThese) 307 | if numberofstars < 5: 308 | maxflux = maxflux + 50 309 | if maxflux > 250: 310 | raise ValueError('not enough stars found') 311 | else: 312 | break 313 | #show histogram of fluxes 314 | starFlux = [v[1]for v in useThese] 315 | 316 | ax = plt.gca() 317 | hist = ax.inset_axes([.65,.6,.3,.15]) 318 | n, bins, patches = hist.hist(starFlux, 25, facecolor='b') 319 | hist.set_facecolor('#808080') 320 | hist.set_title('flux') 321 | 322 | histBackground = ax.inset_axes([.65, .35, .3, .1]) 323 | n,bins,patches = histBackground.hist(backgrounds, 10, facecolor='b') 324 | histBackground.set_facecolor('#808080') 325 | histBackground.set_title("background") 326 | result = plotMagcurve(useThese, ax) 327 | plt.title("Quality:%6.1lf File: %s"%(result['QualityMetric'],stars[0]['fileName'].split('/')[0]),\ 328 | color = 'w') 329 | return result 330 | 331 | 332 | def makeStarStats(star): 333 | 334 | return {'name':star['name'],'mag':star['mag'], 'brightness': star['flux'],\ 335 | 'fileName': star['fileName'],'background':star['Background']} 336 | 337 | def linkCss(): 338 | return ''\ 360 | 361 | 362 | if __name__ == '__main__': 363 | 364 | path = '/home/pi/work/skysolve/static/' #only used for debugging. 365 | results, im, width, height = findStarMags(path + 'cap.jpeg') 366 | 367 | try: 368 | plt.clf() 369 | results = plotStarMags(results,maxflux = 150) 370 | draw = ImageDraw.Draw(im, 'RGBA') 371 | except TypeError as e: 372 | print(e) 373 | quit() 374 | 375 | 376 | x = results['ref'][0] 377 | y = results['ref'][1] 378 | draw.ellipse((x - 20, y-20,x+20,y+20), outline="yellow") 379 | for s in results['stars']: 380 | x = s[2][0] 381 | y = s[2][1] 382 | 383 | if (s[2][2]< 1.25 and s[2][2] >= 1) or (s[2][2] < 1 and s[2][2] > .75): 384 | continue 385 | if s[2][2] > 1: 386 | delet = s[2][2] 387 | color = (10,255,0,40) 388 | else: 389 | color = (255,0,0,40) 390 | delet = 1/s[2][2] 391 | 392 | rad = 6 + 2 * (delet) 393 | draw.ellipse((x-rad,y-rad,x+rad,y+rad), fill = color) 394 | 395 | im.show("stars") 396 | #dplotRatios(results) 397 | plt.show() 398 | 399 | 400 | """ 401 | 402 | magnitude m | 0 1 2 3 4 5 6 7 8 9 10 403 | ---------------------------------------------------------------- 404 | relative | 1 2.5 6.3 16 40 100 250 630 1600 4000 10,000 405 | brightness | 406 | ratios | 407 | (Note that the lower row of numbers is just (2.512)^m.) 408 | 409 | 410 | 411 | (m1 -m2) = 2.5 * LOG(I2/I1) 412 | 2.5log(k) = (m1-m2) 413 | log(k) = (m1-m2)/2.5 414 | k = 10 ^ (m1-m2)/2.5 415 | I2/I1 = 10 ^ (m1-m2)/2.5 416 | """ 417 | 418 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # skysolve version 1 2 | ![screen](images/hand_1.2.1.jpg) 3 | Version 1 skysolve 4 | See video for a quick introduction. https://youtu.be/IewMli4AJLw 5 | stl files for the case and mount can be found on Thingiverse at https://www.thingiverse.com/thing:4920959 and https://www.thingiverse.com/thing:5594916 6 | 7 | ## skysolve case version 2 8 | This case was designed to be used with the inno-maker CAM-IMX296Mono-GS camera at https://www.inno-maker.com/product/cam-mipi296raw-trigger. This camera is more sensitive to light than the RPI HQ camera used in the skysolve version 1. The stl files can be found at https://www.thingiverse.com/thing:6731268 9 | ![newcaseside](https://github.com/user-attachments/assets/3f1a01fc-cba6-46cf-b290-c1bba2e66c6d) 10 | 11 | 12 | ## Description. 13 | Uses RaspberryPi and plate solving to take images of the night sky and identify the location of the image. 14 | It uses a Raspberry PI 4B (4gb) with the RPI High Quality camera and can send the solved position of were the camera is looking to a computer running SkySafari. When mounted to a telescope and aligned to where the scope is pointing it can then be used to guide the manual pushing of the telesopce to the desired target without using any encoders on the telescope. It communicates with SkySafari over WIFI so that no hard wired connections are needed to the computer running SkySafari. It continually takes images and solves them about every 1 to 10 seconds so that Skysafari can always show where the scope is pointing. 15 | 16 | Below is a screen shot of the application's browser interface showing an image of Ursa Major in the lower left. THe status field displays the names of stars it found in the image. 17 | 18 | ![screen](images/solve1.jpg) 19 | 20 | This nex image shows a diagram of the constelation found in the image. 21 | 22 | ![screen2](images/solve2.jpg) 23 | 24 | ### WIFI Connection options 25 | 26 | The RPI and the skysolve application can talk to both another computer as a web server and to a computer running SkySafari. Both need to be on the same WIFI network as the RPI. When connected the user can control the skysolve application using it's web page accessed by another computer's web browser. 27 | 28 | There are two options for the network. It can be your local WIFI network or the RPI can be the Hot Spot for it's own network that the other computers can connect to, This is handy for when the Telescope is out of range of your local WIFI. To begin with the setup process will be done with the RPI connected to your local WIFI. 29 | 30 | After setup if the RPI is booted out of range from the WIFI it knows then it will create it's own network that other computers can log into. It's IP address will be 192.168.50.5. This will usually be the case when out on the observing field. There is also an option to force the RPI to be it's own network (Hot Spot, Access point) even when already connected to the local WIFI. 31 | 32 | ## Field/Home Switch 33 | This is optional. The software on startup will sense the state of this switch. If in the Field position is will create a WIfII hot spot even if within range of a known WIFI router. In the Home position it will nuot create the hot spot if it can see the known router but will if it does not see it. 34 | 35 | The switch should be connected to the ground GPIO pin and and to GPIO pin 7. Pin 7 is the 4th pin on the left row of pins when looking at the pi with the USB at the bottom. 36 | 37 | If the switch is not attached the default is the home position where it will look for a known WIFI. 38 | 39 | 40 | There is a setup script meant to automate the many setup steps involved with configuring a Raspberry 4 running Raspbian, 41 | so that it can run this image capture and plate solving astro application I wrote called skysolve. 42 | 43 | ## First Usage 44 | 45 | After a correct install you can use a Web browser to connect to the skysolve app. The first thing you will want to do is align the camera to the telescope view. The application starts in align mode where camera will start taking images and posting them on the web screen. It will not try to solve the image in this mode so that it can loop through taking pictures faster. You can change camera perameters to adjust exposure and size of image file. I find that an exposuer of .9 seconds, ISO 800, and a frame size of 800 x 600 are good staring points. 46 | 47 | ### Demo Mode 48 | 49 | To get a feel how the program works without using it on a telescope you can use the demo mode where it will use several included sky images that can be solved. Press the Demo button and it will load those images into a list where you can select each one to be solved every time you press the "Solve This" button. It will also send the solved position to SkySafari if it is connected. To see the solution press the "results cfg" button then the "show solution" button. To see what stars it found press the "show stars" button. 50 | If the "show stars button is dimmed out" you can enable it by pressing the "Solver Params" button and the checking the "show found stars" check box. 51 | 52 | 53 | ## Install 54 | 55 | When you are ready, you can follow these steps to install it on the Raspberry pi: 56 | 57 | >[!NOTE] 58 | >Do not change the default username on the pi from pi to anything else. There is code that depends upon there being a using named lower case "pi".` 59 | 60 | >[!IMPORTANT] 61 | >There are two versions of the code. 62 | >1. ***Legacy*** - Works only on RPI models 4 and earlier and only with 32 bit legacy app. 63 | >2. ***New camera library*** - To work with the newer and 64 bit RPI operating systems and all RPI models. 64 | There is a significant advantage to the latest New camera library version because it provides faster solves and operation. 65 | 66 | ### Process to use the ***New camera library*** version 67 | 1. First you need to get the Raspberry Pi software installed on an SD card. The easiest way to do this is to use the RaspberryPi imager 68 | from [Raspberry Pi org](https://www.raspberrypi.org/software/). Select the RPI model you have and then select the most recent 64 bit version of the operating system. Usually the first in the list. 69 | 70 | Download this software onto a computer that can write SD cards. I use a Windows laptop. 71 | 2. Follow steps 2 thru 5 in the ***Legacy*** version below. 72 | 73 | 3. Using either you command line connection to the RPI or VNC Make a direcotry for skysolve then download the skysolve app from GIT Repo to your RPI and Open a Terminal Window. You could type or copy and paste the following commands into Terminal to accomplish this goal. 74 | ```bash 75 | sudo mkdir skysolve 76 | sudo chmod 777 skysolve 77 | cd skysolve 78 | sudo wget https://github.com/githubdoe/skysolve/archive/newCamLib.tar.gz 79 | sudo tar -xzvf newCamLib.tar.gz --strip-components=1 80 | ``` 81 | 4. Continue at step 7 of the ***Legacy*** instructions. 82 | 83 | 84 | ### Process to use the older RPI ***legacy*** system (for new installations use the previous instructions instead.) 85 | 1. First you need to get the Raspberry Pi software installed on an SD card. The easiest way to do this is to use the RaspberryPi imager 86 | from [Raspberry Pi org](https://www.raspberrypi.org/software/). Note that the software to download is not the most recent version but an older 32 bit version. 87 | It can be found under Raspberry Pi OS (other) then Raspberry Pi OS (Legacy) 88 | 89 | Download this software onto a computer that can write SD cards. I use a Windows laptop. 90 | 91 | 2. Set the advance menu options in Raspberry pi imager. 92 | 93 | You need to use those advanced options to setup network parameters so that when you boot the pi it will show up on your network and you can talk to it with another computer instead of using an external display and keyboard. 94 | 95 | * Set Hostname you want for the PI. I used SKYPI. 96 | * Enable SSH and set password 97 | * Enable "configure WIFI" and Set SSID and password of your local WIFI router you want the pi to connect to during setup. 98 | * Setup local. This is important because it is used by the WIFI to select the right frequencies. 99 | 100 | 101 | 3. Burn the image to the SD using the Raspberry Pi imager. 102 | 103 | 104 | 4. Insert the SD Card into the PI after it boots in a minute or so you need to find it on your WIFI network. Your router should have assigned it an 105 | IP address. [Here are some ways of finding it.](https://www.raspberrypi.org/documentation/remote-access/ip-address.md) 106 | 107 | 5. Connecto your computer to the PI. [(See how)](https://www.raspberrypi.org/documentation/remote-access/) 108 | I use VNC viewer from RealVNC on a windows PC. So download RealVNC to your PC. Follow the instructions for connecting to a VNC server like the RPI. 109 | First we need to enable VNC on the PI. We will do that from the command line on the RPI. 110 | On windows machine start a command promt. Type ssh pi@IPXXX (Replace IPXxx with either the hostname you set for the pi or by its IP address.) 111 | * Enter your password for the PI that you set in step 2.2. 112 | * Once logged into the RPI then type sudo raspi-config. 113 | * Select 3. Interface Options then P3 VNC and enable it. Then select yes and then OK. Now VNC should be enabled. 114 | * Chose display options and select resolution to be 1280 x 720 115 | * Optionally enable the Raspberrypi camera now. From Interface Options select the enable camera option. 116 | * UPDATE: November 2023: 117 | There is another step needed to be done while still in the raspi-config. That is to set all localization options to your local. 118 | 119 | Then reboot. 120 | Back on the windows PC start the VNC viewer and connect to the IP address of the Raspberry PI. 121 | 122 | 123 | 124 | 125 | 6. Using either you command line connection to the RPI or VNC Make a direcotry for skysolve then download the skysolve app from GIT Repo to your RPI and Open a Terminal Window. You could type the following commands into Terminal to accomplish this goal. 126 | ```bash 127 | sudo mkdir skysolve 128 | cd skysolve 129 | sudo wget https://github.com/githubdoe/skysolve/archive/main.tar.gz 130 | sudo tar -xzvf main.tar.gz --strip-components=1 131 | ``` 132 | 133 | 134 | 7. Run the setup script 135 | 136 | ``` 137 | sudo ./skysolveSetup.sh 138 | ``` 139 | 140 | Here is a list of what the script does (If you want to disable or modify any of these, please edit before running the script): 141 | 142 | 143 | 144 | - Uninstalls unattended-upgrades since they can slow down imaging and cause issues with updates. 145 | 146 | - Updates/Upgrades the RPI 147 | 148 | - Sets the user account to auto-login 149 | 150 | - Sets the HDMI to force-hotplug so that it doesn't turn off HDMI when it doesn't immediately detect a display (Helps to solve issues) 151 | 152 | - Sets the HDMI group and HDMI mode for a certain display resolution (Please see the comments in the scripts for details and the file /boot/config.txt on the SD card for options.) 153 | 154 | - Disables the screen lock and screen saver to prevent them from causing issues when connecting via VNC 155 | 156 | - Disables the CUPS modules for parallel printers since none are attached and it slows down boot (Raspberry Pi script only) 157 | 158 | 159 | - Makes a folder called utilties on the Desktop 160 | 161 | - Creates a shortcut/launcher for the UDev Script in utilities on the Desktop 162 | 163 | 164 | - Creates a hotspot Wifi profile for the observing field 165 | 166 | 167 | - Installs Astrometry.net and the Index Files 168 | 169 | - Sets up samba and caja filesharing so you can share any folder by right clicking 170 | 171 | 8. After the script finishes type sudo reboot to complete the setup. 172 | ## Testing the install 173 | When the RPI reboots it should be running the skysolve application. 174 | ### Testing skysolve 175 | On any PC or tablet on the same network as the RPI start up an internet browser and enter the address of the RPI followed by :5000. 176 | for example 192.168.1.170:5000 for an RPI at IP address of 192.168.1.170. 177 | ### Testing SkySafari connection 178 | * On your device running Skysafari start SkySafari and setup the Telescope control to use the IP address of the RPI and to use port 5005. 179 | * Try to connect to the Telescope. If it connects then the RPI is running and will give a default position set by the setup. 180 | * Set the telescope type to StellarCat ServoCat and mount type to ALT=AZ. Push-TO. Set the Connect Via WIFI and do not select Auto-Detect SkyFi. 181 | 182 | 10. Setup the PI camera and plate solving parameters. 183 | 1. On a pc or tablet on the same network as the pi using a network browser like Chrome connect to :5000 where is the ip address of the Raspberry pi. 184 | This should bring up the skysolve web page. Click on the help button on that page for info how to setup the camera and solve parameters. 185 | 186 | -------------------------------------------------------------------------------- /camera_pi.py: -------------------------------------------------------------------------------- 1 | #pi camera to be used with web based GUI plate solver 2 | import io 3 | import time 4 | from tkinter import EXCEPTION 5 | import picamera 6 | 7 | from fractions import Fraction 8 | import threading 9 | try: 10 | from greenlet import getcurrent as get_ident 11 | except ImportError: 12 | try: 13 | from thread import get_ident 14 | except ImportError: 15 | from _thread import get_ident 16 | 17 | class imageEvent(object): 18 | """An Event-like class that signals all active clients when a new frame is 19 | available. 20 | """ 21 | def __init__(self): 22 | self.events = {} 23 | 24 | def wait(self, tt = 60.): 25 | """Invoked from each client's thread to wait for the next frame.""" 26 | ident = get_ident() 27 | if ident not in self.events: 28 | # this is a new client 29 | # add an entry for it in the self.events dict 30 | # each entry has two elements, a threading.Event() and a timestamp 31 | self.events[ident] = [threading.Event(), time.time()] 32 | return self.events[ident][0].wait(timeout = tt) 33 | 34 | def set(self): 35 | """Invoked by the camera thread when a new frame is available.""" 36 | now = time.time() 37 | remove = None 38 | for ident, event in self.events.items(): 39 | if not event[0].isSet(): 40 | # if this client's event is not set, then set it 41 | # also update the last set timestamp to now 42 | event[0].set() 43 | event[1] = now 44 | else: 45 | # if the client's event is already set, it means the client 46 | # did not process a previous frame 47 | # if the event stays set for more than 5 seconds, then assume 48 | # the client is gone and remove it 49 | if now - event[1] > 5: 50 | remove = ident 51 | if remove: 52 | del self.events[remove] 53 | 54 | def clear(self): 55 | """Invoked from each client's thread after a frame was processed.""" 56 | self.events[get_ident()][0].clear() 57 | 58 | """ my new py camera class 59 | does not derive from a base class 60 | needs init to start frame thread 61 | needs __del__ method to kill that thread maybe in a close function 62 | 63 | Don't think any static methods are needed. 64 | 65 | thread camera gain init function and call in init 66 | 67 | 68 | """ 69 | 70 | class skyCamera(): 71 | camera = None 72 | event = imageEvent() 73 | thread = None # background thread that reads frames from camera 74 | gainThread = None 75 | frame = None # current frame is stored here by background thread 76 | shutter = 1000000 77 | ISO=800 78 | resolution= (2000,1500) 79 | abortMode = False 80 | runMode = True 81 | cameraStopped = True 82 | format = 'jpeg' 83 | def __init__(self, skystatus, shutter=1000000, ISO=800, resolution=(2000,1500), format = 'jpeg'): 84 | print("skystatus", skystatus) 85 | self.skyStatus = skystatus 86 | self.camera = picamera.PiCamera() 87 | self.camera.resolution = (2000,1500) 88 | self.camera.framerate = Fraction(1,6) 89 | self.shutter=shutter 90 | self.ISO=ISO 91 | self.resolution=resolution 92 | self.format = format 93 | self.setupGain() 94 | self.count = 0 95 | self.thread = threading.Thread(target=self._thread) 96 | self.thread.start() 97 | 98 | 99 | 100 | def __del__(self): 101 | if self.camera: 102 | self.camera.close() 103 | 104 | def pause(self): 105 | self.runMode = False 106 | 107 | def resume(self): 108 | self.runMode = True 109 | 110 | def setISO(self, iso): 111 | self.ISO = iso 112 | self.setupGain() 113 | 114 | def status(self): 115 | return [self.ISO, self.camera.shutter_speed, self.resolution] 116 | 117 | def setResolution(self, size): 118 | self.resolution = size 119 | self.runMode = False 120 | print ("waiting for camera to stop to set resolution",flush=True) 121 | while not self.cameraStopped: 122 | time.sleep(.2) 123 | res = tuple(map(int, size.split('x'))) 124 | print ("setting resolution", res, self.camera.resolution, flush=True) 125 | self.camera.resolution = res 126 | self.runMode = True 127 | 128 | def setFormat(self,type): 129 | self.format = type 130 | self.runMode = False 131 | while not self.cameraStopped: 132 | time.sleep(.2) 133 | self.runMode = True 134 | 135 | def setShutter(self, value): 136 | self.camera.shutter_speed = value 137 | self.shutter = value 138 | self.setupGain() 139 | print ("new shutter speed", value, flush=True) 140 | 141 | def setupGain(self): 142 | #make sure previous instance gain thread is not already running 143 | if self.gainThread: 144 | self.gainThread.join() 145 | self.gainThread = threading.Thread(target=self.setGainThread) 146 | self.gainThread.start() 147 | 148 | def setGainThread(self): 149 | if self.camera: 150 | self.runMode = False 151 | 152 | print ("cam setup called",flush=True) 153 | selfrunMode = False 154 | self.skyStatus(4," stopping camera to apply changes") 155 | while not self.cameraStopped: 156 | pass 157 | 158 | self.camera.resolution = self.resolution 159 | print ('camera framesize at init', self.resolution, flush=True) 160 | self.camera.iso = self.ISO 161 | self.camera.exposure_mode = 'auto' 162 | self.camera.framerate = Fraction(1,6) 163 | 164 | self.camera.shutter_speed = self.shutter 165 | time.sleep(10) 166 | self.camera.exposure_mode = 'off' 167 | self.runMode = True 168 | self.abortMOde = False 169 | 170 | def get_frame(self): 171 | """Return the current camera frame.""" 172 | # wait for a signal from the camera thread 173 | if not self.event.wait(tt=40.): 174 | print("camera image event wait timed out", flush=True) 175 | return None 176 | self.event.clear() 177 | return self.frame 178 | 179 | # the thread that gets images 180 | def _thread(self): 181 | """Camera background thread.""" 182 | while not self.runMode: 183 | time.sleep(.5) 184 | while True: 185 | try: 186 | self.count = 0 187 | print('camera thread. LOOP started', flush = True) 188 | frames_iterator = self.getImage() 189 | for frame in frames_iterator: 190 | self.frame = frame 191 | self.event.set() # send signal to clients 192 | time.sleep(0) 193 | except picamera.PiCameraError as e: 194 | print("camera thread caught e",e, flush=True) 195 | 196 | self.thread = None 197 | # import picamera.array 198 | 199 | # with picamera.PiCamera() as camera: 200 | # with picamera.array.PiBayerArray(camera) as output: 201 | # camera.capture(output, 'jpeg', bayer=True) 202 | def getImage(self): 203 | 204 | stream = io.BytesIO() 205 | print ("abortMOde", self.abortMode) 206 | while not self.abortMode: 207 | while not self.runMode: 208 | if self.abortMode: 209 | break 210 | pass 211 | if self.abortMode: 212 | break 213 | print ("picamera started", flush=True) 214 | self.skyStatus(0," camera started") 215 | try: 216 | for _ in self.camera.capture_continuous(stream, self.format, 217 | use_video_port=False): 218 | 219 | # return current frame 220 | stream.seek(0) 221 | yield stream.read() 222 | if not self.runMode: 223 | self.cameraStopped = True 224 | print ("camera stopped",flush=True) 225 | break 226 | self.cameraStopped = False 227 | 228 | # reset stream for next frame 229 | stream.seek(0) 230 | stream.truncate() 231 | except picamera.PiCameraRuntimeError as e: 232 | print("Getimage caught e", e,flush=True) 233 | raise e 234 | -------------------------------------------------------------------------------- /constellations.py: -------------------------------------------------------------------------------- 1 | constellationNames = [ 2 | "And", 3 | "Ant", 4 | "Aps", 5 | "Aqr", 6 | "Aql", 7 | "Ara", 8 | "Ari", 9 | "Aur", 10 | "Boo", 11 | "Cae", 12 | "Cam", 13 | "Cnc", 14 | "CVn", 15 | "CMa", 16 | "CMi", 17 | "Cap", 18 | "Car", 19 | "Cas", 20 | "Cen", 21 | "Cep", 22 | "Cet", 23 | "Cha", 24 | "Cir", 25 | "Col", 26 | "Com", 27 | "CrA", 28 | "CrB", 29 | "Crv", 30 | "Crt", 31 | "Cru", 32 | "Cyg", 33 | "Del", 34 | "Dor", 35 | "Dra", 36 | "Equ", 37 | "Eri", 38 | "For", 39 | "Gem", 40 | "Gru", 41 | "Her", 42 | "Hor", 43 | "Hya", 44 | "Hyi", 45 | "Ind", 46 | "Lac", 47 | "Leo", 48 | "LMi", 49 | "Lep", 50 | "Lib", 51 | "Lup", 52 | "Lyn", 53 | "Lyr", 54 | "Men", 55 | "Mic", 56 | "Mon", 57 | "Mus", 58 | "Nor", 59 | "Oct", 60 | "Oph", 61 | "Ori", 62 | "Pav", 63 | "Peg", 64 | "Per", 65 | "Phe", 66 | "Pic", 67 | "Psc", 68 | "PsA", 69 | "Pup", 70 | "Pyx", 71 | "Ret", 72 | "Sge", 73 | "Sgr", 74 | "Sco", 75 | "Scl", 76 | "Sct", 77 | "Ser", 78 | "Sex", 79 | "Tau", 80 | "Tel", 81 | "Tri", 82 | "TrA", 83 | "Tuc", 84 | "UMa", 85 | "UMi", 86 | "Vel", 87 | "Vir", 88 | "Vol", 89 | "Vul" 90 | ] 91 | -------------------------------------------------------------------------------- /default_database.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githubdoe/skysolve/76e5408ff74ae933bf8f469773319c8c6395b5ec/default_database.npz -------------------------------------------------------------------------------- /encoder.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Based on PSWAI but modified to work with Raspberry PI and immatate SERVO CAT telescope 4 | # PSWAI: A Plate Solved Where Am I application. 5 | # Copyright (C) 2018 arhcf (user arhcf at github 2018) 6 | # This file is part of the pswai project. 7 | # 8 | # This program is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation, either version 3 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program. If not, see . 20 | # 21 | # mimicks a SERVO CAT telescope controler for skysafari. 22 | # will return RA and dec in degrees if given a 'Q' command. 23 | # returns version if given a 'v' 24 | # takes a sky pic and solves and updates ra and dec to solved coords if given a 'g' (goto command) 25 | # Telescope is hard coded to 5005. IP address is the default address of the RPI on WLAN0 if only one net device. 26 | # you may need to modify the radecFile path to where your plate solve file is. 27 | # you may need to modify the command path to the platesolve script 28 | 29 | # Usage: 30 | # encoder.py [track] 31 | # track: Causes RA to be modified with time from last plate solve. Used for scopes that do not track 32 | # if not set then RA will be a the last value of the plate solve with no adjustment. 33 | 34 | 35 | import sys 36 | import os 37 | import socket 38 | import time 39 | import subprocess 40 | from threading import * 41 | 42 | port = 5005 #port for skysafari 43 | 44 | radecFile = './static/radec.txt' 45 | track = 0 #default is not to modify RA with time from last solve 46 | 47 | # radec.txt file has one line of ra in deg and dec in dec 48 | # lx200 protocol expects the ra to be in hours in decimal notation. 49 | 50 | # reads ra,dec from file and converts it into floatpoint HA and Deg 51 | def radec(): 52 | global track 53 | ra = 2 54 | dec = -19 55 | if not os.access(radecFile, os.R_OK): 56 | return (ra,dec) 57 | try: 58 | fileo=open(radecFile, 'r') 59 | except: 60 | print ('no radec file found') 61 | return (0,0) 62 | 63 | ln = fileo.readline().split() 64 | print ("line read", ln) 65 | if (len(ln) < 3 ): 66 | return (0,0) 67 | print ('radec is', ln, fileo.name) 68 | #if ln[3] !='rotation': 69 | #return (10,10) 70 | 71 | try: 72 | mytime=ln[0] 73 | myra=float(ln[1]) 74 | mydec=float(ln[2]) 75 | except (ValueError, IndexError): 76 | print ("Value error, continuing ....", ln) 77 | return (0,0) 78 | 79 | myra = myra / 15. #convert ra in deg back to hours 80 | 81 | lta = time.strftime("%H:%M:%S").split(':') 82 | tha = (float(lta[0])+float(lta[1])/60+float(lta[2])/3600) 83 | if track: 84 | myra = myra - tha 85 | 86 | if (myra >180): 87 | myra -= 360 88 | 89 | fileo.close() 90 | print (myra,mydec) 91 | return myra,mydec 92 | 93 | 94 | 95 | radec() 96 | serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 97 | 98 | 99 | argsnum = len(sys.argv) 100 | argi = 1 101 | while (argi < argsnum) : 102 | 103 | if ( sys.argv[argi] == "track") : 104 | print ("track enabled") 105 | track = 1 106 | else : 107 | print ("Bad option: %s" % (sys.argv[argi])) 108 | print ("Usage: encoder.py [track] [indi]") 109 | sys.exit(1) 110 | argi = argi +1 111 | 112 | 113 | serversocket.bind(('', port)) 114 | #snapthread = Thread(target=snap) 115 | serversocket.listen(5) 116 | print ('server started and listening') 117 | gotoactive = False 118 | while True: 119 | clientsocket, address = serversocket.accept() 120 | rbuf=clientsocket.recv(20).decode(); 121 | if rbuf: 122 | print ("recx:",rbuf,":",hex(ord(rbuf[0]))) 123 | if rbuf[0] == ':': 124 | print ("recx:",rbuf,":",hex(ord(rbuf[0]))) 125 | if rbuf[1:4] == 'GR#': 126 | print ('gr#') 127 | clientsocket.send(b'00:22:00#') 128 | elif rbuf[1:4] == 'RM#': 129 | print ('rm#') 130 | clientsocket.send(b'00:22:00#') 131 | elif rbuf[1:4] == 'GD#': 132 | clientsocket.send(b'00:22:00#') 133 | 134 | elif rbuf[0] == 'v': 135 | print ("recx:",rbuf,":",hex(ord(rbuf[0]))) 136 | clientsocket.send(b"70.A\0"); 137 | elif(rbuf[0] == 'Q' or ord(rbuf[0]) == 0x0d) : # send ra/dec 138 | ra,dec = radec() 139 | out = (b" %06.3lf %06.3f\0"%(ra,dec)) 140 | print ('xxx',out) 141 | clientsocket.send(out) 142 | elif(rbuf[0] == 'H') : # send encoder resolution 143 | sbuf=b"8192-8192\r" 144 | clientsocket.send(sbuf) 145 | elif(rbuf[0] == 'g'): 146 | ra,dec = radec() 147 | ra = 316. 148 | out = (b"%06.3lf %06.3f"%(ra,dec)) 149 | r = float(rbuf[1:7]) 150 | d = float(rbuf[8:15]) 151 | print (r,d) 152 | print (rbuf) 153 | clientsocket.send(out) 154 | 155 | 156 | else: print ("recx:",rbuf,":",hex(ord(rbuf[0]))) 157 | 158 | serversocket.close() 159 | -------------------------------------------------------------------------------- /encodertoSkySafari.service: -------------------------------------------------------------------------------- 1 | 2 | [Unit] 3 | Description=name-of-your-service Service 4 | After=network-online.target 5 | 6 | [Service] 7 | Type=idle 8 | User=pi 9 | ExecStart=/home/pi/skysolve/startEncoder.sh 10 | Restart=always 11 | 12 | [Install] 13 | WantedBy=network-online.target 14 | -------------------------------------------------------------------------------- /images/hand_1.2.1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githubdoe/skysolve/76e5408ff74ae933bf8f469773319c8c6395b5ec/images/hand_1.2.1.jpg -------------------------------------------------------------------------------- /images/newcaseback.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githubdoe/skysolve/76e5408ff74ae933bf8f469773319c8c6395b5ec/images/newcaseback.jpg -------------------------------------------------------------------------------- /images/newcaseside.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githubdoe/skysolve/76e5408ff74ae933bf8f469773319c8c6395b5ec/images/newcaseside.jpg -------------------------------------------------------------------------------- /images/solve1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githubdoe/skysolve/76e5408ff74ae933bf8f469773319c8c6395b5ec/images/solve1.jpg -------------------------------------------------------------------------------- /images/solve2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githubdoe/skysolve/76e5408ff74ae933bf8f469773319c8c6395b5ec/images/solve2.jpg -------------------------------------------------------------------------------- /restartsky.sh: -------------------------------------------------------------------------------- 1 | sleep 5 2 | sudo systemctl restart skysolve.service 3 | -------------------------------------------------------------------------------- /skyConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "camera": { 3 | "shutter": ".9", 4 | "ISO": "800", 5 | "frame": "800x600", 6 | "format": "jpeg" 7 | }, 8 | "solver": { 9 | "currentProfile": "25FL", 10 | "startupSolveing": false 11 | }, 12 | "observing": { 13 | "saveImages": "on", 14 | "showSolution": false, 15 | "savePosition": true, 16 | "verbose": true, 17 | "obsDelta": 0.5 18 | }, 19 | "solverProfiles": { 20 | "default": { 21 | "name": "default", 22 | "solver_type": "solverAstromet", 23 | "maxTime": 30.0, 24 | "solveSigma": 9, 25 | "solveDepth": 10, 26 | "UselastDelta": false, 27 | "FieldWidthMode": "FieldWidthModeOther", 28 | "FieldWidthModeaPP": "checked", 29 | "FieldWidthModeField": "", 30 | "FieldWidthModeOther": "", 31 | "aPPLoValue": "64", 32 | "aPPHiValue": "65", 33 | "fieldLoValue": "10", 34 | "fieldHiValue": "25", 35 | "searchRadius": 10.0, 36 | "solveVerbose": true, 37 | "showStars": false, 38 | "plots": true, 39 | "additionalParms": "" 40 | }, 41 | "25FL": { 42 | "name": "25FL", 43 | "solver_type": "solverAstromet", 44 | "maxTime": 10.0, 45 | "solveSigma": 5, 46 | "solveDepth": 20, 47 | "UselastDelta": false, 48 | "FieldWidthMode": "FieldWidthModeaPP", 49 | "FieldWidthModeaPP": "checked", 50 | "FieldWidthModeField": "", 51 | "FieldWidthModeOther": "", 52 | "aPPLoValue": "25", 53 | "aPPHiValue": "66", 54 | "fieldLoValue": "13", 55 | "fieldHiValue": "16", 56 | "searchRadius": 10.0, 57 | "solveVerbose": false, 58 | "showStars": false, 59 | "plots": false, 60 | "additionalParms": "--tag-all", 61 | "verbose": true 62 | }, 63 | "16FL": { 64 | "name": "16FL", 65 | "solver_type": "solverAstromet", 66 | "maxTime": 300.0, 67 | "solveSigma": 6, 68 | "solveDepth": 20, 69 | "UselastDelta": false, 70 | "FieldWidthMode": "FieldWidthModeaPP", 71 | "FieldWidthModeaPP": "checked", 72 | "FieldWidthModeField": "", 73 | "FieldWidthModeOther": "", 74 | "aPPLoValue": "40", 75 | "aPPHiValue": "45", 76 | "fieldLoValue": "", 77 | "fieldHiValue": "", 78 | "searchRadius": 0.0, 79 | "solveVerbose": true, 80 | "showStars": false, 81 | "plots": true, 82 | "additionalParms": "--guess-scale" 83 | }, 84 | "Tetra3": { 85 | "name": "Tetra3", 86 | "solver_type": "solverTetra3", 87 | "maxTime": 10.0, 88 | "solveSigma": 9, 89 | "solveDepth": 20, 90 | "UselastDelta": false, 91 | "FieldWidthMode": "FieldWidthModeOther", 92 | "FieldWidthModeaPP": "", 93 | "FieldWidthModeField": "", 94 | "FieldWidthModeOther": "", 95 | "aPPLoValue": "", 96 | "aPPHiValue": "", 97 | "fieldLoValue": "14", 98 | "fieldHiValue": "15", 99 | "searchRadius": 0.0, 100 | "solveVerbose": false, 101 | "showStars": false, 102 | "plots": true, 103 | "additionalParms": "", 104 | "verbose": true 105 | }, 106 | "OrionShield": { 107 | "name": "OrionShield", 108 | "solver_type": "solverAstromet", 109 | "maxTime": 30.0, 110 | "solveSigma": 9, 111 | "solveDepth": 20, 112 | "UselastDelta": false, 113 | "FieldWidthMode": "FieldWidthModeaPP", 114 | "FieldWidthModeaPP": "checked", 115 | "FieldWidthModeField": "", 116 | "FieldWidthModeOther": "", 117 | "aPPLoValue": "27", 118 | "aPPHiValue": "", 119 | "fieldLoValue": "0", 120 | "fieldHiValue": "0", 121 | "searchRadius": 10.0, 122 | "solveVerbose": true, 123 | "showStars": false, 124 | "plots": true, 125 | "additionalParms": "--guess-scale" 126 | }, 127 | "aquarius": { 128 | "name": "aquarius", 129 | "solver_type": "solverAstromet", 130 | "maxTime": 10.0, 131 | "solveSigma": 9, 132 | "solveDepth": 10, 133 | "UselastDelta": false, 134 | "FieldWidthMode": "FieldWidthModeField", 135 | "FieldWidthModeaPP": "checked", 136 | "FieldWidthModeField": "", 137 | "FieldWidthModeOther": "", 138 | "aPPLoValue": "40", 139 | "aPPHiValue": "42", 140 | "fieldLoValue": "14", 141 | "fieldHiValue": "15", 142 | "searchRadius": 10.0, 143 | "solveVerbose": false, 144 | "showStars": false, 145 | "plots": true, 146 | "additionalParms": "", 147 | "verbose": true 148 | }, 149 | "bigdipper": { 150 | "name": "bigdipper", 151 | "solver_type": "solverAstromet", 152 | "maxTime": 10.0, 153 | "solveSigma": 9, 154 | "solveDepth": 10, 155 | "UselastDelta": false, 156 | "FieldWidthMode": "FieldWidthModeField", 157 | "FieldWidthModeaPP": "checked", 158 | "FieldWidthModeField": "", 159 | "FieldWidthModeOther": "", 160 | "aPPLoValue": "40", 161 | "aPPHiValue": "41", 162 | "fieldLoValue": "22", 163 | "fieldHiValue": "23", 164 | "searchRadius": 10.0, 165 | "solveVerbose": false, 166 | "showStars": false, 167 | "plots": true, 168 | "additionalParms": "", 169 | "verbose": true 170 | }, 171 | "coronaB": { 172 | "name": "coronaB", 173 | "solver_type": "solverAstromet", 174 | "maxTime": 10.0, 175 | "solveSigma": 9, 176 | "solveDepth": 9, 177 | "UselastDelta": false, 178 | "FieldWidthMode": "FieldWidthModeField", 179 | "FieldWidthModeaPP": "checked", 180 | "FieldWidthModeField": "", 181 | "FieldWidthModeOther": "", 182 | "aPPLoValue": "30", 183 | "aPPHiValue": "80", 184 | "fieldLoValue": "22", 185 | "fieldHiValue": "23", 186 | "searchRadius": 10.0, 187 | "solveVerbose": false, 188 | "showStars": false, 189 | "plots": true, 190 | "additionalParms": "", 191 | "verbose": true 192 | } 193 | } 194 | } -------------------------------------------------------------------------------- /skysolve.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=sky solve 3 | After=network-online.target 4 | 5 | [Service] 6 | Type=idle 7 | User=pi 8 | ExecStart=/home/pi/skysolve/startSkysolve.sh 9 | Restart=always 10 | 11 | [Install] 12 | WantedBy=multi-user.target 13 | -------------------------------------------------------------------------------- /skysolveSetup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Installs files needed for skySolve program Script based in part on 4 | # AstroRaspbianPi Raspberry Pi Raspbian KStars/INDI Configuration Script 5 | # Copyright (C) 2018 Robert Lancaster 6 | # This script is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public 8 | # License as published by the Free Software Foundation; either 9 | # version 2 of the License, or (at your option) any later version. 10 | 11 | if [ "$(whoami)" != "root" ]; then 12 | echo "Please run this script with sudo due to the fact that it must do a number of sudo tasks. Exiting now." 13 | exit 1 14 | elif [ -z "$BASH_VERSION" ]; then 15 | echo "Please run this script in a BASH shell because it is a script written using BASH commands. Exiting now." 16 | exit 1 17 | else 18 | echo "You are running BASH $BASH_VERSION as the root user." 19 | fi 20 | 21 | DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) 22 | 23 | function display 24 | { 25 | echo "" 26 | echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" 27 | echo "~ $*" 28 | echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" 29 | echo "" 30 | 31 | # This will display the message in the title bar (Note that the PS1 variable needs to be changed too--see below) 32 | echo -en "\033]0;SkySolve-$*\a" 33 | } 34 | 35 | 36 | function checkForConnection 37 | { 38 | testCommand=$(curl -Is $2 | head -n 1) 39 | echo "testCommand results $testCommand" 40 | if [[ "${testCommand}" == *"200"* || "${testCommand}" == *"301"* ]] 41 | then 42 | echo "$1 was found. The script can proceed." 43 | else 44 | echo "$1, ($2), a required connection, was not found, aborting script." 45 | echo "If you would like the script to run anyway, please comment out the line that tests this connection in this script." 46 | exit 47 | fi 48 | } 49 | 50 | display "Welcome to the SKySolve Configuration Script." 51 | 52 | display "This will update, install and configure your Raspberry Pi 4 to work with SkySolve. Be sure to read the script first to see what it does and to customize it." 53 | 54 | read -p "Are you ready to proceed (y/n)? " proceed 55 | 56 | if [ "$proceed" != "y" ] 57 | then 58 | exit 59 | fi 60 | 61 | 62 | export USERHOME=$(sudo -u $SUDO_USER -H bash -c 'echo $HOME') 63 | 64 | 65 | # This changes the UserPrompt for the Setup Script (Necessary to make the messages display in the title bar) 66 | PS1='SkySolve Setup~$ ' 67 | 68 | read -p "Do you want to update the PI operating system (Recommended) (y/n)? " proceed 69 | 70 | if [ "$proceed" == "y" ] 71 | then 72 | 73 | ######################################################### 74 | ############# Updates 75 | 76 | # This would update the Raspberry Pi kernel. For now it is disabled because there is debate about whether to do it or not. To enable it, take away the # sign. 77 | #display "Updating Kernel" 78 | #sudo rpi-update 79 | 80 | # Updates the Raspberry Pi to the latest packages. 81 | display "Updating installed packages" 82 | sudo apt update 83 | sudo apt -y upgrade 84 | sudo apt -y dist-upgrade 85 | 86 | #update GPIO module 87 | wget https://project-downloads.drogon.net/wiringpi-latest.deb 88 | sudo dpkg -i wiringpi-latest.deb 89 | fi 90 | 91 | ######################################################### 92 | ############# Configuration for Ease of Use/Access 93 | 94 | # This makes sure there is a config folder owned by the user, since many things depend on it. 95 | mkdir -p $USERHOME/.config 96 | sudo chown $SUDO_USER:$SUDO_USER $USERHOME/.config 97 | 98 | # This will set up the Pi so that double clicking on desktop icons brings up the program right away 99 | # The default behavior is to ask what you want to do with the executable file. 100 | display "Setting desktop icons to open programs when you click them." 101 | if [ -f $USERHOME/.config/pcmanfm-qt/lxqt/settings.conf ] 102 | then 103 | sed -i "s/QuickExec=false/QuickExec=true/g" $USERHOME/.config/pcmanfm-qt/lxqt/settings.conf 104 | fi 105 | if [ -f $USERHOME/.config/pcmanfm-qt/default/settings.conf ] 106 | then 107 | sed -i "s/QuickExec=false/QuickExec=true/g" $USERHOME/.config/pcmanfm-qt/default/settings.conf 108 | fi 109 | if [ -f $USERHOME/.config/libfm/libfm.conf ] 110 | then 111 | if [ -z "$(grep 'quick_exec' $USERHOME/.config/libfm/libfm.conf)" ] 112 | then 113 | sed -i "/\[config\]/ a quick_exec=1" $USERHOME/.config/libfm/libfm.conf 114 | else 115 | sed -i "s/quick_exec=0/quick_exec=1/g" $USERHOME/.config/libfm/libfm.conf 116 | fi 117 | fi 118 | if [ -f /etc/xdg/libfm/libfm.conf ] 119 | then 120 | if [ -z "$(grep 'quick_exec' /etc/xdg/libfm/libfm.conf)" ] 121 | then 122 | sed -i "/\[config\]/ a quick_exec=1" /etc/xdg/libfm/libfm.conf 123 | else 124 | sed -i "s/quick_exec=0/quick_exec=1/g" /etc/xdg/libfm/libfm.conf 125 | fi 126 | fi 127 | 128 | # This will set your account to autologin. If you don't want this. then put a # on each line to comment it out. 129 | display "Setting account: "$SUDO_USER" to auto login." 130 | if [ -n "$(grep '#autologin-user' '/etc/lightdm/lightdm.conf')" ] 131 | then 132 | sed -i "s/#autologin-user=/autologin-user=$SUDO_USER/g" /etc/lightdm/lightdm.conf 133 | sed -i "s/#autologin-user-timeout=0/autologin-user-timeout=0/g" /etc/lightdm/lightdm.conf 134 | fi 135 | 136 | display "Setting HDMI settings in /boot/config.txt." 137 | 138 | # This pretends an HDMI display is connected at all times, otherwise, the pi might shut off HDMI 139 | # So that when you go to plug in an HDMI connector to diagnose a problem, it doesn't work 140 | # This makes the HDMI output always available 141 | if [ -n "$(grep '#hdmi_force_hotplug=1' '/boot/config.txt')" ] 142 | then 143 | sed -i "s/#hdmi_force_hotplug=1/hdmi_force_hotplug=1/g" /boot/config.txt 144 | fi 145 | 146 | # This sets the group for the HDMI mode. Please see the config file for details about all the different modes 147 | # There are many options. I selected group 1 mode 46 because that matches my laptop's resolution. 148 | # You might want a different mode and group if you want a certain resolution in VNC 149 | if [ -n "$(grep '#hdmi_group=1' '/boot/config.txt')" ] 150 | then 151 | sed -i "s/#hdmi_group=1/hdmi_group=2/g" /boot/config.txt 152 | fi 153 | 154 | # This sets the HDMI mode. Please see the config file for details about all the different modes 155 | # There are many options. I selected group 1 mode 46 because that matches my laptop's resolution. 156 | # You might want a different mode and group if you want a certain resolution in VNC 157 | if [ -n "$(grep '#hdmi_mode=1' '/boot/config.txt')" ] 158 | then 159 | sed -i "s/#hdmi_mode=1/hdmi_mode=46/g" /boot/config.txt 160 | fi 161 | 162 | # This comments out a line in Raspbian's config file that seems to prevent the desired screen resolution in VNC 163 | # The logic here is that if the line does exist, and if the line is not commented out, comment it out. 164 | if [ -n "$(grep '^dtoverlay=vc4-kms-v3d' '/boot/config.txt')" ] 165 | then 166 | sed -i "s/dtoverlay=vc4-kms-v3d/#dtoverlay=vc4-kms-v3d/g" /boot/config.txt 167 | fi 168 | if [ -n "$(grep '^dtoverlay=vc4-fkms-v3d' '/boot/config.txt')" ] 169 | then 170 | sed -i "s/dtoverlay=vc4-fkms-v3d/#dtoverlay=vc4-fkms-v3d/g" /boot/config.txt 171 | fi 172 | 173 | 174 | # This will prevent the raspberry pi from turning on the lock-screen / screensaver which can be problematic when using VNC 175 | if [ -z "$(grep 'xserver-command=X -s 0 dpms' '/etc/lightdm/lightdm.conf')" ] 176 | then 177 | sed -i "/\[Seat:\*\]/ a xserver-command=X -s 0 dpms" /etc/lightdm/lightdm.conf 178 | fi 179 | display "setup networking hotpot" 180 | # This will install the autohotspot files so that the pi can connect to local wifi or be a hotspot. 181 | ./Autohotspot/autohotspot-setup.sh 1 182 | 183 | display "Making Utilities Folder with script shortcuts for the Desktop" 184 | 185 | # This will make a folder on the desktop for the launchers if it doesn't exist already 186 | if [ ! -d "$USERHOME/Desktop/utilities" ] 187 | then 188 | mkdir -p $USERHOME/Desktop/utilities 189 | sudo chown $SUDO_USER:$SUDO_USER $USERHOME/Desktop/utilities 190 | fi 191 | 192 | 193 | 194 | 195 | # This will create a shortcut on the desktop in the utilities folder for Installing Astrometry Index Files. 196 | ################## 197 | sudo cat > $USERHOME/Desktop/utilities/InstallAstrometryIndexFiles.desktop <<- EOF 198 | #!/usr/bin/env xdg-open 199 | [Desktop Entry] 200 | Version=1.0 201 | Type=Application 202 | Terminal=true 203 | Icon[en_US]=mate-preferences-desktop-display 204 | Exec=sudo $(echo $DIR)/astrometryIndexInstaller.sh 205 | Name[en_US]=Install Astrometry Index Files 206 | Name=Install Astrometry Index Files 207 | Icon=$(echo $DIR)/icons/mate-preferences-desktop-display.svg 208 | EOF 209 | ################## 210 | sudo chmod +x $USERHOME/Desktop/utilities/InstallAstrometryIndexFiles.desktop 211 | sudo chown $SUDO_USER:$SUDO_USER $USERHOME/Desktop/utilities/InstallAstrometryIndexFiles.desktop 212 | 213 | # This will create a shortcut on the desktop folder for Updating the System. 214 | ################## 215 | sudo cat > $USERHOME/Desktop/utilities/systemUpdater.desktop <<- EOF 216 | #!/usr/bin/env xdg-open 217 | [Desktop Entry] 218 | Version=1.0 219 | Type=Application 220 | Terminal=true 221 | Icon[en_US]=system-software-update 222 | Exec=sudo $(echo $DIR)/systemUpdater.sh 223 | Name[en_US]=Software Update 224 | Name=Software Update 225 | Icon=$(echo $DIR)/icons/system-software-update.svg 226 | EOF 227 | ################## 228 | sudo chmod +x $USERHOME/Desktop/utilities/systemUpdater.desktop 229 | sudo chown $SUDO_USER:$SUDO_USER $USERHOME/Desktop/utilities/systemUpdater.desktop 230 | 231 | read -p "Install samba file sharing(y/n)? " proceed 232 | 233 | if [ "$proceed" == "y" ] 234 | then 235 | 236 | 237 | ######################################################### 238 | ############# File Sharing Configuration 239 | 240 | display "Setting up File Sharing" 241 | 242 | # Installs samba so that you can share files to your other computer(s). 243 | sudo apt -y install samba samba-common-bin 244 | sudo touch /etc/libuser.conf 245 | 246 | if [ ! -f /etc/samba/smb.conf ] 247 | then 248 | sudo mkdir -p /etc/samba/ 249 | ################## 250 | sudo cat > /etc/samba/smb.conf <<- EOF 251 | [global] 252 | workgroup = ASTROGROUP 253 | server string = Samba Server 254 | server role = standalone server 255 | log file = /var/log/samba/log.%m 256 | max log size = 50 257 | dns proxy = no 258 | [homes] 259 | comment = Home Directories 260 | browseable = no 261 | read only = no 262 | writable = yes 263 | valid users = $SUDO_USER 264 | EOF 265 | ################## 266 | fi 267 | 268 | # Adds yourself to the user group of who can use samba, but checks first if you are already in the list 269 | if [ -z "$(sudo pdbedit -L | grep $SUDO_USER)" ] 270 | then 271 | sudo smbpasswd -a $SUDO_USER 272 | sudo adduser $SUDO_USER sambashare 273 | fi 274 | fi 275 | 276 | 277 | # Installs the Astrometry.net package for supporting offline plate solves. 278 | display "Installing Astrometry.net" 279 | sudo apt -y install astrometry.net 280 | 281 | 282 | 283 | 284 | 285 | ######################################################### 286 | 287 | #!/bin/bash 288 | 289 | # AstroPi3 Astrometry Index File Installer 290 | # Copyright (C) 2018 Robert Lancaster 291 | # This script is free software; you can redistribute it and/or 292 | # modify it under the terms of the GNU General Public 293 | # License as published by the Free Software Foundation; either 294 | # version 2 of the License, or (at your option) any later version. 295 | 296 | read -p "do you want to install astrometry index files? (do at least once)" answer 297 | if [ "$answer" == "y" ] 298 | then 299 | echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" 300 | echo "Welcome to the Astrometry Index Installer Script" 301 | echo "This script will ask you which Index files you want to download and then will install them to /usr/share/astrometry" 302 | echo "Note that you need to install at least the index files that cover 10% to 100% of your FOV." 303 | echo "Please make sure you know your FOV before Proceeeding." 304 | echo "For the usual lenses (up to 25mm) on the PI quality cam the field will be 10 degs or more" 305 | echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" 306 | echo "To download and install the correct files, you need to decide which packages you want." 307 | echo "Note that for large file sizes, the index files are in a big set." 308 | echo "If you type the word 'large', you will get index files 4208-4219 which covers 30 arcmin to 2000 arcmin." 309 | echo "For smaller fields, the file sizes become much bigger, so they are in separate packages." 310 | echo "You just need to type the file number to download and install that package" 311 | echo "You can select more than one packages by typing each number after the other separated by spaces or commas" 312 | echo "Here is a list of all the available index file sets and their FOV's in Arc minutes" 313 | echo "File FOV" 314 | echo "4207 22 - 30" 315 | echo "4206 16 - 22" 316 | echo "4205 11 - 16" 317 | echo "4204 8 - 11" 318 | echo "4203 5.6 - 8.0" 319 | echo "4202 4.0 - 5.6" 320 | echo "4201 2.8 - 4.0" 321 | echo "4200 2.0 - 2.8" 322 | echo "RPI25FL for RPI HiQuality Camera with 25 FL Lens" 323 | echo "" 324 | read -p "Which file set would you like to download? Remember, type either 'large' or the file number(s) above: (large recommended)" indexFile 325 | 326 | if [ "$indexFile" = "RPI25FL" ] 327 | then 328 | wget http://data.astrometry.net/debian/astrometry-data-4208-4219_0.45_all.deb 329 | wget -P /usr/share/astrometry/ http://data.astrometry.net/4100/index-4112.fits 330 | wget -P /usr/share/astrometry/ http://data.astrometry.net/4100/index-4113.fits 331 | wget -P /usr/share/astrometry/ http://data.astrometry.net/4100/index-4114.fits 332 | wget -P /usr/share/astrometry/ http://data.astrometry.net/4100/index-4115.fits 333 | wget -P /usr/share/astrometry/ http://data.astrometry.net/4100/index-4116.fits 334 | wget -P /usr/share/astrometry/ http://data.astrometry.net/4100/index-4117.fits 335 | wget -P /usr/share/astrometry/ http://data.astrometry.net/4100/index-4118.fits 336 | fi 337 | if [[ $indexFile = *"large"* ]] 338 | then 339 | wget http://data.astrometry.net/debian/astrometry-data-4208-4219_0.45_all.deb 340 | fi 341 | 342 | if [[ $indexFile = *"4207"* ]] 343 | then 344 | wget http://data.astrometry.net/debian/astrometry-data-4207_0.45_all.deb 345 | fi 346 | 347 | if [[ $indexFile = *"4206"* ]] 348 | then 349 | wget http://data.astrometry.net/debian/astrometry-data-4206_0.45_all.deb 350 | fi 351 | 352 | if [[ $indexFile = *"4205"* ]] 353 | then 354 | wget http://data.astrometry.net/debian/astrometry-data-4205_0.45_all.deb 355 | fi 356 | 357 | if [[ $indexFile = *"4204"* ]] 358 | then 359 | wget http://data.astrometry.net/debian/astrometry-data-4204_0.45_all.deb 360 | fi 361 | 362 | if [[ $indexFile = *"4203"* ]] 363 | then 364 | wget http://data.astrometry.net/debian/astrometry-data-4203_0.45_all.deb 365 | fi 366 | 367 | if [[ $indexFile = *"4202"* ]] 368 | then 369 | wget http://data.astrometry.net/debian/astrometry-data-4202_0.45_all.deb 370 | fi 371 | 372 | if [[ $indexFile = *"4201"* ]] 373 | then 374 | wget http://data.astrometry.net/debian/astrometry-data-4201-1_0.45_all.deb 375 | wget http://data.astrometry.net/debian/astrometry-data-4201-2_0.45_all.deb 376 | wget http://data.astrometry.net/debian/astrometry-data-4201-3_0.45_all.deb 377 | wget http://data.astrometry.net/debian/astrometry-data-4201-4_0.45_all.deb 378 | fi 379 | 380 | if [[ $indexFile = *"4200"* ]] 381 | then 382 | wget http://data.astrometry.net/debian/astrometry-data-4200-1_0.45_all.deb 383 | wget http://data.astrometry.net/debian/astrometry-data-4200-2_0.45_all.deb 384 | wget http://data.astrometry.net/debian/astrometry-data-4200-3_0.45_all.deb 385 | wget http://data.astrometry.net/debian/astrometry-data-4200-4_0.45_all.deb 386 | fi 387 | 388 | sudo dpkg -i astrometry-data-*.deb 389 | sudo rm *.deb 390 | fi 391 | 392 | 393 | #setup auto run of encoder and skysolve at boot. 394 | 395 | echo "setup encoder service" 396 | sudo cp /home/pi/skysolve/encodertoSkySafari.service /etc/systemd/system/encodertoSkySafari.service 397 | sudo systemctl enable encodertoSkySafari.service 398 | 399 | echo "setup skySolve service" 400 | sudo cp /home/pi/skysolve/skysolve.service /etc/systemd/system/skysolve.service 401 | sudo systemctl enable skysolve.service 402 | 403 | 404 | #install python scipy 405 | sudo pip3 install scipy 406 | sudo apt install python3-matplotlib 407 | sudo pip3 install fitsio 408 | echo "This next step may take 10 to 15 minutes." 409 | #sudo pip3 install -U numpy 410 | echo "Your requested installations are complete." 411 | display "Script Execution Complete. Your Raspberry should now be ready to use for SkySolve. You should restart your Pi." 412 | -------------------------------------------------------------------------------- /skysolve_setup.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githubdoe/skysolve/76e5408ff74ae933bf8f469773319c8c6395b5ec/skysolve_setup.odt -------------------------------------------------------------------------------- /skysolve_setup.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githubdoe/skysolve/76e5408ff74ae933bf8f469773319c8c6395b5ec/skysolve_setup.pdf -------------------------------------------------------------------------------- /skysove startup.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githubdoe/skysolve/76e5408ff74ae933bf8f469773319c8c6395b5ec/skysove startup.pdf -------------------------------------------------------------------------------- /skysove starup.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githubdoe/skysolve/76e5408ff74ae933bf8f469773319c8c6395b5ec/skysove starup.odt -------------------------------------------------------------------------------- /starTransDb.py: -------------------------------------------------------------------------------- 1 | from re import X 2 | from tinydb import TinyDB, Query 3 | import os 4 | import pprint 5 | import Quality 6 | from scipy import stats 7 | dbName = 'transparent.json' 8 | def getTransperancyData(path): 9 | global dbName 10 | return TinyDB(os.path.join(path,dbName)) 11 | 12 | 13 | #solving /home/pi/work/skysolve/static/history/08_14_22_22_24_16.jpeg 14 | from PIL import Image, ImageDraw, ImageEnhance, ImageFont 15 | from matplotlib import pyplot as plt 16 | from scipy.optimize import curve_fit 17 | from datetime import datetime, timedelta 18 | import numpy as np 19 | import math 20 | if __name__ == '__main__': 21 | mag = np.arange(1,7, .1) 22 | flux = list(map(lambda mag: 40 +255/(mag ** 2.512),mag)) 23 | gamaflux = list(map(lambda f: 255*((f/255) ** .4545)-67, flux)) 24 | plt.plot(mag,flux, label = "linear sensor") 25 | plt.plot(mag,gamaflux, label = 'gamma 2.2') 26 | plt.legend() 27 | plt.xlabel('Magnitude') 28 | plt.ylabel('flux') 29 | plt.show() 30 | quit() 31 | 32 | # def makecurve( a,b,c, mag): 33 | # flux = [] 34 | # for m in mag: 35 | # flux.append( a * m ** 2.512 + b * m + c) 36 | # return flux 37 | 38 | # def gam(x): 39 | # return 255 * ((x/255) ** (1./2.2)) 40 | 41 | # def dgeam(x): 42 | # return 255 * ((x/255.) ** (2.2)) 43 | 44 | # mag = np.arange(0, 7, .2) 45 | # yg = makecurve(2.5,-50,350, mag) 46 | 47 | 48 | 49 | # #plt.plot(x,yg) 50 | # plt.plot(mag,yg) 51 | 52 | # plt.grid() 53 | # plt.show() 54 | 55 | 56 | 57 | path = '/home/pi/work/skysolve/static/' #only used for debugging. 58 | db = getTransperancyData(path) 59 | print("db",db) 60 | q = Query() 61 | 62 | samples = db.search(q.sample.matches('.*')) 63 | rows =2 64 | cols = 4 65 | last = len(samples) 66 | plt.clf() 67 | group =0 68 | unicode_font = ImageFont.truetype("DejaVuSans.ttf", 15) 69 | while group < len(samples): 70 | plt.clf() 71 | plt.gcf().set_size_inches(20, 10, forward=True) 72 | plt.gcf().set_dpi(200) 73 | plt.rcParams['figure.constrained_layout.use'] = True 74 | for ndx, s in enumerate(samples[group: group + 2 * rows]): 75 | col = ndx % 2 76 | row = int(ndx / 2) 77 | fn = os.path.join('static','history', samples[ndx + group]['sample'])+'.jpeg' 78 | with Image.open(fn) as img: 79 | # image brightness enhancer 80 | enhancer = ImageEnhance.Brightness(img) 81 | factor = 8 # gives original image 82 | im_output = enhancer.enhance(factor) 83 | 84 | 85 | print(group + ndx,samples[group + ndx]['sample']) 86 | stars = db.search(q.fileName == samples[group + ndx]['sample']) 87 | 88 | if len(stars) > 3: 89 | try: 90 | plt.subplot(rows,cols, 2 * ndx+ 1 ) 91 | results = Quality.plotStarMags(stars, maxflux =200, minflux = .01) 92 | 93 | except ValueError as e: 94 | continue 95 | 96 | draw = ImageDraw.Draw(im_output, 'RGBA') 97 | x = results['ref'][0] 98 | y = results['ref'][1] 99 | draw.ellipse((x - 20, y-20,x+20,y+20), outline="yellow") 100 | for s in results['stars']: 101 | x = s[2][0] 102 | y = s[2][1] 103 | if s[2][2] < 5 : 104 | draw.text([x,y], s[3], font = unicode_font) 105 | 106 | if (s[2][2]< 1.25 and s[2][2] >= 1) or (s[2][2] < 1 and s[2][2] > .75): 107 | continue 108 | if s[2][2] > 1: 109 | delet = s[2][2] 110 | color = (10,255,0,80) 111 | 112 | else: 113 | color = (255,0,0,80) 114 | delet = 1/s[2][2] 115 | 116 | 117 | rad = 6 + 2 * math.log2(delet) 118 | draw.ellipse((x-rad,y-rad,x+rad,y+rad), fill = color) 119 | 120 | plt.subplot(rows, cols, 2 * ndx + 2) 121 | plt.imshow(im_output) 122 | plt.title(stars[0]['fileName']) 123 | 124 | filename = 'qualityPlot'+datetime.now().strftime("%m_%d_%y_%H_%M_%S.png") 125 | plt.savefig(os.path.join('static','plots', filename ),facecolor='#606060', dpi=200) 126 | #plt.show() 127 | group += 4 128 | 129 | 130 | 131 | 132 | # a = list(db.search(q.name.matches('.*'))) 133 | # st = sorted(a, key = lambda s: s['mag']) 134 | # starsAvg = {} 135 | # for s in st: 136 | # m = s['mag'] 137 | # if m > 7.5: 138 | # continue 139 | # flux = s['flux'] 140 | # name = s['name'] 141 | # if name not in starsAvg: 142 | # starsAvg[name] = {'mag':m,'flux':[flux]} 143 | # else: 144 | # starsAvg[name]['flux'].append(flux) 145 | # mag = [] 146 | # flux = [] 147 | # for s in starsAvg: 148 | # starsAvg[s]['avg'] = sum(starsAvg[s]['flux'])/len(starsAvg[s]['flux']) 149 | # mag.append(starsAvg[s]['mag']) 150 | # flux.append(starsAvg[s]['avg']) 151 | 152 | 153 | # plt.scatter(mag,flux) 154 | # def func(x,a,b,c): 155 | # return a * x ** 2.512 + b * x + c 156 | # params, _ = curve_fit(func, mag, flux) 157 | # a, b, c = params[0], params[1], params[2] 158 | # xes = np.arange( min(mag),max(mag), .2) 159 | # yfit1 = [a*pow(float(x),2.512)+b*float(x)+c for x in xes] 160 | 161 | # plt.plot(xes,yfit1, label='a:%4.2lf b:%4.2lf c:%4.2lf'%(a,b,c)) 162 | 163 | # x = [] 164 | # y = [] 165 | 166 | # x0 = mag[50] 167 | # flux0 = flux[50] 168 | 169 | # for m in np.arange(1,7, .2): 170 | # x.append(m) 171 | # y.append(flux0/ pow(2.512, m-x0)) 172 | # ax = plt.gca() 173 | # ax.set_facecolor('#202020') 174 | # plt.plot(x,y,':',label='Perfect') 175 | # plt.legend() 176 | # plt.show() 177 | 178 | 179 | quit() 180 | 181 | starnames = set({}) 182 | maxavg = 0 183 | filename = '' 184 | star = None 185 | for s in a: 186 | if s['avg'] > maxavg: 187 | maxavg = s['avg'] 188 | filename = s['fileName'] 189 | star = s 190 | 191 | 192 | for star in a: 193 | starName = star['name'] 194 | starnames.add(starName) 195 | print(len(a), len(starnames)) 196 | stats = [] 197 | for star in starnames: 198 | starSamples = db.search(images.name == star) 199 | stat = {'name': star, 'mag': starSamples[0]['mag'],'samples':[]} 200 | 201 | for sample in starSamples: 202 | stat['samples'].append(round(sample['flux'])) 203 | stats.append(stat) 204 | 205 | so = sorted(stats, key = lambda s: s['mag']) 206 | for star in so: 207 | print('\n',star['name'], star['mag'], end=' ') 208 | for s in sorted(star['samples']): 209 | print(s,end=' ') 210 | 211 | 212 | 213 | 214 | -------------------------------------------------------------------------------- /startEncoder.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cd /home/pi/skysolve 3 | sudo python3 encoder.py -------------------------------------------------------------------------------- /startSkysolve.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cd /home/pi/skysolve 3 | sudo python3 skysolve.py -------------------------------------------------------------------------------- /static/demo/aquarius.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githubdoe/skysolve/76e5408ff74ae933bf8f469773319c8c6395b5ec/static/demo/aquarius.jpg -------------------------------------------------------------------------------- /static/demo/bigdipper.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githubdoe/skysolve/76e5408ff74ae933bf8f469773319c8c6395b5ec/static/demo/bigdipper.jpg -------------------------------------------------------------------------------- /static/demo/coronaB.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githubdoe/skysolve/76e5408ff74ae933bf8f469773319c8c6395b5ec/static/demo/coronaB.jpg -------------------------------------------------------------------------------- /static/demo/orionsShield.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githubdoe/skysolve/76e5408ff74ae933bf8f469773319c8c6395b5ec/static/demo/orionsShield.jpg -------------------------------------------------------------------------------- /static/js/popper.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) Federico Zivolo 2020 3 | Distributed under the MIT License (license terms are at http://opensource.org/licenses/MIT). 4 | */(function(e,t){'object'==typeof exports&&'undefined'!=typeof module?module.exports=t():'function'==typeof define&&define.amd?define(t):e.Popper=t()})(this,function(){'use strict';function e(e){return e&&'[object Function]'==={}.toString.call(e)}function t(e,t){if(1!==e.nodeType)return[];var o=e.ownerDocument.defaultView,n=o.getComputedStyle(e,null);return t?n[t]:n}function o(e){return'HTML'===e.nodeName?e:e.parentNode||e.host}function n(e){if(!e)return document.body;switch(e.nodeName){case'HTML':case'BODY':return e.ownerDocument.body;case'#document':return e.body;}var i=t(e),r=i.overflow,p=i.overflowX,s=i.overflowY;return /(auto|scroll|overlay)/.test(r+s+p)?e:n(o(e))}function i(e){return e&&e.referenceNode?e.referenceNode:e}function r(e){return 11===e?re:10===e?pe:re||pe}function p(e){if(!e)return document.documentElement;for(var o=r(10)?document.body:null,n=e.offsetParent||null;n===o&&e.nextElementSibling;)n=(e=e.nextElementSibling).offsetParent;var i=n&&n.nodeName;return i&&'BODY'!==i&&'HTML'!==i?-1!==['TH','TD','TABLE'].indexOf(n.nodeName)&&'static'===t(n,'position')?p(n):n:e?e.ownerDocument.documentElement:document.documentElement}function s(e){var t=e.nodeName;return'BODY'!==t&&('HTML'===t||p(e.firstElementChild)===e)}function d(e){return null===e.parentNode?e:d(e.parentNode)}function a(e,t){if(!e||!e.nodeType||!t||!t.nodeType)return document.documentElement;var o=e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING,n=o?e:t,i=o?t:e,r=document.createRange();r.setStart(n,0),r.setEnd(i,0);var l=r.commonAncestorContainer;if(e!==l&&t!==l||n.contains(i))return s(l)?l:p(l);var f=d(e);return f.host?a(f.host,t):a(e,d(t).host)}function l(e){var t=1=o.clientWidth&&n>=o.clientHeight}),l=0a[e]&&!t.escapeWithReference&&(n=Q(f[o],a[e]-('right'===e?f.width:f.height))),ae({},o,n)}};return l.forEach(function(e){var t=-1===['left','top'].indexOf(e)?'secondary':'primary';f=le({},f,m[t](e))}),e.offsets.popper=f,e},priority:['left','right','top','bottom'],padding:5,boundariesElement:'scrollParent'},keepTogether:{order:400,enabled:!0,fn:function(e){var t=e.offsets,o=t.popper,n=t.reference,i=e.placement.split('-')[0],r=Z,p=-1!==['top','bottom'].indexOf(i),s=p?'right':'bottom',d=p?'left':'top',a=p?'width':'height';return o[s]r(n[s])&&(e.offsets.popper[d]=r(n[s])),e}},arrow:{order:500,enabled:!0,fn:function(e,o){var n;if(!K(e.instance.modifiers,'arrow','keepTogether'))return e;var i=o.element;if('string'==typeof i){if(i=e.instance.popper.querySelector(i),!i)return e;}else if(!e.instance.popper.contains(i))return console.warn('WARNING: `arrow.element` must be child of its popper element!'),e;var r=e.placement.split('-')[0],p=e.offsets,s=p.popper,d=p.reference,a=-1!==['left','right'].indexOf(r),l=a?'height':'width',f=a?'Top':'Left',m=f.toLowerCase(),h=a?'left':'top',c=a?'bottom':'right',u=S(i)[l];d[c]-us[c]&&(e.offsets.popper[m]+=d[m]+u-s[c]),e.offsets.popper=g(e.offsets.popper);var b=d[m]+d[l]/2-u/2,w=t(e.instance.popper),y=parseFloat(w['margin'+f]),E=parseFloat(w['border'+f+'Width']),v=b-e.offsets.popper[m]-y-E;return v=ee(Q(s[l]-u,v),0),e.arrowElement=i,e.offsets.arrow=(n={},ae(n,m,$(v)),ae(n,h,''),n),e},element:'[x-arrow]'},flip:{order:600,enabled:!0,fn:function(e,t){if(W(e.instance.modifiers,'inner'))return e;if(e.flipped&&e.placement===e.originalPlacement)return e;var o=v(e.instance.popper,e.instance.reference,t.padding,t.boundariesElement,e.positionFixed),n=e.placement.split('-')[0],i=T(n),r=e.placement.split('-')[1]||'',p=[];switch(t.behavior){case ce.FLIP:p=[n,i];break;case ce.CLOCKWISE:p=G(n);break;case ce.COUNTERCLOCKWISE:p=G(n,!0);break;default:p=t.behavior;}return p.forEach(function(s,d){if(n!==s||p.length===d+1)return e;n=e.placement.split('-')[0],i=T(n);var a=e.offsets.popper,l=e.offsets.reference,f=Z,m='left'===n&&f(a.right)>f(l.left)||'right'===n&&f(a.left)f(l.top)||'bottom'===n&&f(a.top)f(o.right),g=f(a.top)f(o.bottom),b='left'===n&&h||'right'===n&&c||'top'===n&&g||'bottom'===n&&u,w=-1!==['top','bottom'].indexOf(n),y=!!t.flipVariations&&(w&&'start'===r&&h||w&&'end'===r&&c||!w&&'start'===r&&g||!w&&'end'===r&&u),E=!!t.flipVariationsByContent&&(w&&'start'===r&&c||w&&'end'===r&&h||!w&&'start'===r&&u||!w&&'end'===r&&g),v=y||E;(m||b||v)&&(e.flipped=!0,(m||b)&&(n=p[d+1]),v&&(r=z(r)),e.placement=n+(r?'-'+r:''),e.offsets.popper=le({},e.offsets.popper,C(e.instance.popper,e.offsets.reference,e.placement)),e=P(e.instance.modifiers,e,'flip'))}),e},behavior:'flip',padding:5,boundariesElement:'viewport',flipVariations:!1,flipVariationsByContent:!1},inner:{order:700,enabled:!1,fn:function(e){var t=e.placement,o=t.split('-')[0],n=e.offsets,i=n.popper,r=n.reference,p=-1!==['left','right'].indexOf(o),s=-1===['top','left'].indexOf(o);return i[p?'left':'top']=r[o]-(s?i[p?'width':'height']:0),e.placement=T(t),e.offsets.popper=g(i),e}},hide:{order:800,enabled:!0,fn:function(e){if(!K(e.instance.modifiers,'hide','preventOverflow'))return e;var t=e.offsets.reference,o=D(e.instance.modifiers,function(e){return'preventOverflow'===e.name}).boundaries;if(t.bottomo.right||t.top>o.bottom||t.rightwindow.devicePixelRatio||!fe),c='bottom'===o?'top':'bottom',g='right'===n?'left':'right',b=B('transform');if(d='bottom'==c?'HTML'===l.nodeName?-l.clientHeight+h.bottom:-f.height+h.bottom:h.top,s='right'==g?'HTML'===l.nodeName?-l.clientWidth+h.right:-f.width+h.right:h.left,a&&b)m[b]='translate3d('+s+'px, '+d+'px, 0)',m[c]=0,m[g]=0,m.willChange='transform';else{var w='bottom'==c?-1:1,y='right'==g?-1:1;m[c]=d*w,m[g]=s*y,m.willChange=c+', '+g}var E={"x-placement":e.placement};return e.attributes=le({},E,e.attributes),e.styles=le({},m,e.styles),e.arrowStyles=le({},e.offsets.arrow,e.arrowStyles),e},gpuAcceleration:!0,x:'bottom',y:'right'},applyStyle:{order:900,enabled:!0,fn:function(e){return V(e.instance.popper,e.styles),j(e.instance.popper,e.attributes),e.arrowElement&&Object.keys(e.arrowStyles).length&&V(e.arrowElement,e.arrowStyles),e},onLoad:function(e,t,o,n,i){var r=L(i,t,e,o.positionFixed),p=O(o.placement,r,t,e,o.modifiers.flip.boundariesElement,o.modifiers.flip.padding);return t.setAttribute('x-placement',p),V(t,{position:o.positionFixed?'fixed':'absolute'}),o},gpuAcceleration:void 0}}},ge}); 5 | //# sourceMappingURL=popper.min.js.map -------------------------------------------------------------------------------- /static/js/skySolve.js: -------------------------------------------------------------------------------- 1 | // 2 | 3 | 4 | 5 | sks = {} 6 | sks.consts = { 7 | 8 | yes: 0, 9 | no: 1, 10 | 11 | shutter: function() { 12 | var x = $('#shutterSelect'); 13 | return x; 14 | 15 | }, 16 | ISO: function() { 17 | var x = $('#ISOSelect'); 18 | return x; 19 | }, 20 | frame: function() { 21 | var x = $('#frameSelect'); 22 | return x; 23 | }, 24 | format: function() { 25 | var x = $('#formatSelect'); 26 | return x; 27 | }, 28 | saveObs: function() { 29 | var x = $('#saveObs'); 30 | return x; 31 | }, 32 | 33 | solverTetra3: function() { 34 | var x = $('#solverTetra3'); 35 | return x; 36 | }, 37 | 38 | solverAstromet: function() { 39 | var x = $('#solverAstromet'); 40 | return x; 41 | }, 42 | 43 | fieldWidthModeaPP: function() { 44 | var x = $('#FieldWidthModeaPP'); 45 | return x; 46 | }, 47 | FieldWidthaPPLow: function() { 48 | 49 | var x = $('#FieldWidthaPPLow'); 50 | console.log("low app field", x) 51 | return x; 52 | }, 53 | FieldWidthaPPHi: function() { 54 | var x = $('#FieldWidthaPPHi'); 55 | return x; 56 | }, 57 | 58 | fieldLoValue: function() { 59 | var x = $('#fieldLoValue'); 60 | return x; 61 | }, 62 | fieldHiValue: function() { 63 | var x = $('#fieldHiValue'); 64 | return x; 65 | }, 66 | FieldWidthModeOther: function() { 67 | var x = $('#FieldWidthModeOther'); 68 | return x; 69 | }, 70 | CPUtimeout: function() { 71 | var x = $('#CPUtimeout'); 72 | return x; 73 | }, 74 | additionalParms: function() { 75 | var x = $('#additionalParms'); 76 | return x; 77 | }, 78 | SolveDepth: function() { 79 | var x = $('#SolveDepth'); 80 | console.log("depth part", x) 81 | return x; 82 | }, 83 | SolveSigma: function() { 84 | var x = $('#SolveSigma'); 85 | return x; 86 | }, 87 | searchRadius: function() { 88 | var x = $('#searchRadius'); 89 | return x; 90 | }, 91 | 92 | 93 | verbose: function() { 94 | var x = $('#idverbose'); 95 | return x; 96 | }, 97 | 98 | showStars: function() { 99 | var x = $('#showStars'); 100 | return x; 101 | }, 102 | 103 | demoMode: false, 104 | showHistory: 0, 105 | showSolution: 0, 106 | profiles : {"a": 1, "b":2}, 107 | currentProfile: '' 108 | }; 109 | 110 | 111 | function setSolverParams( cur){ 112 | sks.consts.currentProfile = cur; 113 | console.log('cur profile',cur) 114 | // console.log('profiles', sks.consts.profiles) 115 | console.log("const.profiles",cur, JSON.stringify(sks.consts.profiles[cur])); 116 | sks.consts.showStars()[0].checked =sks.consts.profiles[cur]["showStars"]; 117 | sks.consts.SolveDepth().val(sks.consts.profiles[cur]['solveDepth']) 118 | sks.consts.SolveSigma().val(sks.consts.profiles[cur]['solveSigma']) 119 | sks.consts.FieldWidthaPPLow().val(sks.consts.profiles[cur]['aPPLoValue']) 120 | sks.consts.FieldWidthaPPHi().val(sks.consts.profiles[cur]['aPPHiValue']) 121 | sks.consts.CPUtimeout().val(sks.consts.profiles[cur]['maxTime']) 122 | sks.consts.searchRadius().val(sks.consts.profiles[cur]['searchRadius']) 123 | sks.consts.additionalParms().val(sks.consts.profiles[cur]['additionalParms']) 124 | sks.consts.fieldHiValue().val(sks.consts.profiles[cur]['fieldHiValue']) 125 | sks.consts.fieldLoValue().val(sks.consts.profiles[cur]['fieldLoValue']) 126 | var mode = sks.consts.profiles[sks.consts.currentProfile]['FieldWidthMode'] 127 | var type = sks.consts.profiles[sks.consts.currentProfile]['solver_type']; 128 | var yyy = $('#' + mode) 129 | yyy.prop('checked', true); 130 | var stype = $('#' + type); 131 | stype.prop('checked', true); 132 | } 133 | 134 | function setProfiles(profiles){ 135 | console.log("profile",profiles) 136 | var x = JSON.parse(profiles) 137 | sks.consts.profiles = x; 138 | 139 | } 140 | function setIniShutter( shutVal){ 141 | console.log("shutter value", shutVal) 142 | sks.consts.shutter().val(shutVal); 143 | var shutr = document.getElementById('setShutter'); 144 | shutr.value = shutVal; 145 | } 146 | function setIniISO( ISOVal){ 147 | console.log("ISO val", ISOVal) 148 | sks.consts.ISO().val(ISOVal); 149 | var iso2 = document.getElementById('setISO'); 150 | iso2.value = ISOVal; 151 | } 152 | function setIniFrame( frameVal){ 153 | sks.consts.frame().val(frameVal); 154 | } 155 | function setIniFormat(formatVal){ 156 | sks.consts.format().val(formatVal); 157 | } 158 | 159 | 160 | $(document).ready(function(){ 161 | 162 | $('#solverParamsForm').submit(function(){ 163 | 164 | $.ajax({ 165 | url: $('#solverParamsForm').attr('action'), 166 | type: 'POST', 167 | data : $('#solverParamsForm').serialize(), 168 | success: function(data){ 169 | console.log('form submitted.', data); 170 | setProfiles(data) 171 | } 172 | }); 173 | return false; 174 | }); 175 | 176 | var checkBox = document.getElementById("autoStatusCB"); 177 | console.log("checkBox", checkBox) 178 | if (checkBox.checked == true) { 179 | setTimeout(updateStatusField, 1000); 180 | } 181 | 182 | var cb = document.getElementById('showStars') 183 | var btn = document.getElementById('ShowStars') 184 | if (cb.checked == false){ 185 | btn.disabled = true 186 | } 187 | // event hookups/subscribes 188 | sks.consts.shutter().change( 189 | function() { 190 | let x = sks.consts.shutter().val(); 191 | $.post("/setShutter/" + x, data = { 192 | suggest: x 193 | }, function(result) {}); 194 | var numberVal = document.getElementById('setShutter'); 195 | numberVal.value = x; 196 | }); 197 | 198 | sks.consts.ISO().change( 199 | function() { 200 | 201 | let x = sks.consts.ISO().val(); 202 | console.log("ISO is being set", x); 203 | $.post("/setISO/" + x, data = { 204 | suggest: x 205 | }, function(result) {}); 206 | 207 | var numberVal = document.getElementById('setISO'); 208 | numberVal.value = x; 209 | }); 210 | 211 | sks.consts.frame().change( 212 | function() { 213 | console.log("frame size change"); 214 | let x = sks.consts.frame().val(); 215 | $.post("/setFrame/" + x, data = { 216 | suggest: x 217 | }, function(result) {}); 218 | }); 219 | 220 | sks.consts.format().change( 221 | function() { 222 | let x = sks.consts.format().val(); 223 | $.post("/setFormat/" + x, data = { 224 | suggest: x 225 | }, function(result) {}); 226 | }); 227 | 228 | sks.consts.saveObs().change( 229 | function() { 230 | let x = sks.consts.saveObs().val(); 231 | $.post("/saveObs/" + x, data = { 232 | suggest:x 233 | }, function(result) {}); 234 | }); 235 | 236 | function ajax_get_Status(cmdroute) { 237 | $.ajax({ 238 | url: cmdroute, 239 | method: 'POST', 240 | success: function(result) { 241 | document.getElementById("statusField").innerHTML = result; 242 | } 243 | }); 244 | } 245 | $('#solveProfile').change( 246 | function() { 247 | console.log("this", this.value) 248 | sks.consts.currentProfile = this.value; 249 | setSolverParams(this.value); 250 | } 251 | ) 252 | $('#addToProfiles').click( 253 | function() { 254 | console.log("new profile add clicked") 255 | // get reference to select element 256 | var sel = document.getElementById('solveProfile'); 257 | 258 | // create new option element 259 | var opt = document.createElement('option'); 260 | // create text node to add to option element (opt) 261 | var newName = $('#newProfilename').val() 262 | console.log("new name", newName) 263 | opt.appendChild( document.createTextNode(newName) ); 264 | 265 | // set value property of opt 266 | opt.value = newName; 267 | 268 | // add opt to end of select box (sel) 269 | sel.appendChild(opt); 270 | $('#solveProfile').val(newName); 271 | 272 | console.log("new profile",$('#solverParamsForm').serialize() ) 273 | 274 | $.ajax({ 275 | url: $('#solverParamsForm').attr('action'), 276 | type: 'POST', 277 | data : $('#solverParamsForm').serialize(), 278 | success: function(data){ 279 | console.log('form submitted.', data); 280 | setProfiles(data) 281 | } 282 | }) 283 | 284 | } 285 | ) 286 | $('#solverTetra3').click( 287 | function(){ 288 | var tetra = $('#solverAstromet').val() 289 | 290 | $('#solveProfile').val('Tetra3'); 291 | 292 | var ele = document.getElementById('astrometryForm'); 293 | ele.style.display = "none"; 294 | setSolverParams('Tetra3'); 295 | } 296 | ) 297 | 298 | $('#solverAstromet').click( 299 | function(){ 300 | var ele = document.getElementById('astrometryForm'); 301 | ele.style.display = "inline"; 302 | 303 | } 304 | ) 305 | $('#deleteProfile').click( 306 | function(){ 307 | var sel = $('#solveProfile').val() 308 | console.log("deleting ", sel) 309 | $.post("/deleteProfile/" + sel, data = { 310 | suggest: sel 311 | }, function(data) { 312 | setProfiles(data) 313 | var x = document.getElementById("solveProfile"); 314 | console.log("seletor", x); 315 | console.log("select this", x.selectedIndex) 316 | x.remove(x.selectedIndex); 317 | console.log('selections',x) 318 | }); 319 | 320 | } 321 | ) 322 | 323 | $('#starHistory').click( 324 | function() { 325 | ajax_get_Status('/qualityHistoryStars') 326 | } 327 | ) 328 | 329 | 330 | $('#stepNext').click( 331 | function() { 332 | ajax_get_Status('/nextImage') 333 | 334 | }) 335 | 336 | $('#stepPrev').click( 337 | function() { 338 | ajax_get_Status('/prevImage') 339 | 340 | }) 341 | 342 | $('#reboot').click( 343 | function(){ 344 | ajax_get_Status('/reboot') 345 | } 346 | ) 347 | $('#shutdown').click( 348 | function(){ 349 | ajax_get_Status('/shutdown') 350 | } 351 | ) 352 | 353 | $('#restartc').click( 354 | function(){ 355 | ajax_get_Status('/restartc') 356 | } 357 | ) 358 | $('#idPause').click ( 359 | function() { 360 | ajax_get_Status('/pause') 361 | }) 362 | $('#idAlign').click ( 363 | function() { 364 | ajax_get_Status('/Align') 365 | }) 366 | $('#idSolve').click ( 367 | function() { 368 | ajax_get_Status('/Solve') 369 | }) 370 | $('#idSaveCurrent').click ( 371 | function(){ 372 | ajax_get_Status('/saveCurrent') 373 | } 374 | ) 375 | $('#skyImage').click( 376 | function(){ 377 | console.log("skyimage was clicked"); 378 | var verb = document.getElementById('idverbose').checked; 379 | 380 | if ( !verb || sks.consts.currentProfile === 'Tetra3') 381 | return 382 | 383 | var src = document.getElementById("solu"); 384 | var d = new Date(); 385 | var n = d.getTime(); 386 | var fn = "/static/cap-ngc.png"; 387 | var x = fn.concat( "?dummy=",n,"?"); 388 | src.src = x 389 | src.style.display = "inline"; 390 | } 391 | ) 392 | $('#solu').click( 393 | function(){ 394 | var x = document.getElementById("solu"); 395 | x.style.display = "none"; 396 | 397 | } 398 | ) 399 | function ajax_get_Obs(cmdroute) { 400 | $.ajax({ 401 | url: cmdroute, 402 | method: 'POST', 403 | success: function(result) { 404 | console.log("result",result); 405 | var txt = document.getElementById("currentObs"); 406 | txt.value = result 407 | } 408 | }); 409 | } 410 | 411 | 412 | 413 | function showReplaybuttons(show){ 414 | var x = document.getElementById("stepNext"); 415 | var y = document.getElementById("stepPrev"); 416 | var z = document.getElementById("solveThis"); 417 | 418 | if (show) { 419 | x.style.display = "inline"; 420 | y.style.display = "inline"; 421 | z.style.display = "inline"; 422 | 423 | } else { 424 | x.style.display = "none"; 425 | y.style.display = "none"; 426 | z.style.display = "none"; 427 | 428 | } 429 | } 430 | 431 | 432 | $('#startObs').click( 433 | function() { 434 | console.log("start obs"); 435 | ajax_get_Obs('/startObs') 436 | }) 437 | 438 | $('#nextObs').click( 439 | function() { 440 | ajax_get_Obs('/nextObs') 441 | }) 442 | 443 | $('#prevObs').click( 444 | function() { 445 | ajax_get_Obs('/prevObs') 446 | }) 447 | 448 | 449 | 450 | $('#clearObsLog').click( 451 | function() { 452 | ajax_get_Status('/clearObsLog') 453 | }) 454 | 455 | 456 | $('#solveThis').click( 457 | function() { 458 | console.log("imageStep pressed") 459 | ajax_get_Status('/solveThis') 460 | }) 461 | $('#clearImages').click( 462 | function(){ 463 | ajax_get_Status('/clearImages') 464 | } 465 | ) 466 | 467 | $('#demoMode').click( 468 | function(){ 469 | if (sks.consts.demoMode) { 470 | showReplaybuttons(false); 471 | sks.consts.demoMode = false; 472 | 473 | } 474 | else { 475 | ajax_get_Status('/demoMode'); 476 | showReplaybuttons(true); 477 | sks.consts.demoMode=true; 478 | brightNormal() 479 | 480 | } 481 | } 482 | ) 483 | 484 | $('#testMode').click( 485 | function() { 486 | 487 | if (!sks.consts.demoMode) 488 | ajax_get_Status('/testMode'); 489 | 490 | var x = document.getElementById("stepNext"); 491 | if (x.style.display === "none") { 492 | showReplaybuttons(true); 493 | } 494 | else { 495 | showReplaybuttons(false); 496 | } 497 | }) 498 | $('#idAlign').click ( 499 | function(){ 500 | sks.consts.demoMode=false; 501 | showReplaybuttons(false); 502 | 503 | }) 504 | $("#showMore").click( 505 | function(){ 506 | console.log("show more"); 507 | var results = document.getElementById("resultsCfg"); 508 | var demo = document.getElementById("demoMode"); 509 | var test = document.getElementById("testMode"); 510 | if(results.style.display == "inline"){ 511 | results.style.display = "none"; 512 | demo.style.display = "none"; 513 | test.style.display = "none"; 514 | } 515 | else { 516 | results.style.display = "inline"; 517 | demo.style.display = "inline"; 518 | test.style.display = "inline"; 519 | } 520 | }) 521 | $('#showStars').click( 522 | 523 | function() { 524 | var cb = document.getElementById('showStars') 525 | var btn = document.getElementById('ShowStars') 526 | 527 | if (cb.checked == false) { 528 | btn.disabled = true 529 | 530 | } 531 | else { 532 | btn.disabled = false 533 | 534 | } 535 | } 536 | ) 537 | $('#ClearLog').click( 538 | function(){ 539 | console.log("check changed") 540 | var btn = document.getElementById('ShowStars') 541 | btn.disabled = true 542 | var text = document.getElementById('solveStatusText'); 543 | text.innerHTML = ""; 544 | } 545 | ) 546 | 547 | $('#saveImages').click( 548 | function() { 549 | 550 | var checkBox = document.getElementById("saveImages"); 551 | if (checkBox.checked == true) { 552 | sks.consts.showSolution = 1; 553 | } 554 | else { 555 | sks.consts.showSolution = 0; 556 | } 557 | let x = sks.consts.showSolution; 558 | 559 | $.post("/saveImages/" + x, data = { 560 | suggest: x 561 | }, function(result) {}); 562 | } 563 | ) 564 | $('#idverbose').click( 565 | function() { 566 | 567 | var checkBox = document.getElementById("idverbose"); 568 | var x = (checkBox.checked == true) 569 | console.log("was checked",x) 570 | $.post("/verbose/" + x, data = { 571 | suggest: x 572 | }, function(result) {}); 573 | } 574 | ) 575 | 576 | 577 | }); 578 | 579 | 580 | 581 | -------------------------------------------------------------------------------- /static/radec.txt: -------------------------------------------------------------------------------- 1 | 02:18:46 165.628789 55.770433 2 | -------------------------------------------------------------------------------- /templates/starHistory.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Sky Solve 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 147 | 148 | 149 |
150 |

History

151 |
152 |
153 |
154 | 155 | 157 | 159 | 161 | 163 | 165 | 168 | 169 | 170 |
171 | 172 |
173 |
174 |
175 |
176 |

177 | 178 |
179 |
180 | 181 |
182 |
183 |



184 |

185 |
186 |
187 |
188 | 189 |
190 | 191 | 192 | 237 | 238 | 239 | 240 | 241 | --------------------------------------------------------------------------------