@@ -56,6 +56,7 @@ usage() {
5656 echo " --dtim-period <num> Set DTIM period in numbers of beacons (default 2)"
5757 echo " --country <code> Set two-letter country code for 802.11d regulatory domain (example: US)"
5858 echo " --timezone Advertise local timezone in beacons (following 802.11v-2011 7.3.2.87)"
59+ echo " --gps <LAT,LNG> Advertise location in beacons (coordinates are in 10^5 degree)"
5960 echo " --freq-band <GHz> Set frequency band. Valid inputs: 2.4, 5 (default: 2.4)"
6061 echo " --driver Choose your WiFi adapter driver (default: nl80211)"
6162 echo " --no-virt Do not create virtual interface"
@@ -659,6 +660,7 @@ DRIVER=nl80211
659660NO_VIRT=0
660661COUNTRY=
661662TIMEZONE=
663+ GPS=
662664FREQ_BAND=2.4
663665BEACON_INTERVAL=100
664666DTIM_PERIOD=2
@@ -674,7 +676,7 @@ HOSTAPD_DEBUG_ARGS=
674676REDIRECT_TO_LOCALHOST=0
675677
676678CONFIG_OPTS=(CHANNEL GATEWAY WPA_VERSION ETC_HOSTS DHCP_DNS DHCP_DNS6 NO_DNS NO_DNSMASQ HIDDEN MAC_FILTER MAC_FILTER_ACCEPT ISOLATE_CLIENTS
677- SHARE_METHOD IEEE80211N IEEE80211AC HT_CAPAB VHT_CAPAB DRIVER NO_VIRT COUNTRY TIMEZONE FREQ_BAND
679+ SHARE_METHOD IEEE80211N IEEE80211AC HT_CAPAB VHT_CAPAB DRIVER NO_VIRT COUNTRY TIMEZONE GPS FREQ_BAND
678680 NEW_MACADDR DAEMONIZE DAEMON_PIDFILE DAEMON_LOGFILE WIFI_IFACE INTERNET_IFACE
679681 SSID PASSPHRASE USE_PSK BEACON_INTERVAL DTIM_PERIOD IPV6 ADDN_HOSTS WPS METERED)
680682
@@ -1132,7 +1134,7 @@ for ((i=0; i<$#; i++)); do
11321134 fi
11331135done
11341136
1135- GETOPT_ARGS=$( getopt -o hc:w:g:de:nm: -l " help" ," hidden" ," hostapd-debug:" ," redirect-to-localhost" ," mac-filter" ," mac-filter-accept:" ," isolate-clients" ," ieee80211n" ," ieee80211ac" ," ht_capab:" ," vht_capab:" ," driver:" ," no-virt" ," fix-unmanaged" ," country:" ," timezone" ," freq-band:" ," mac:" ," dhcp-dns:" ," dhcp-dns6:" ," daemon" ," pidfile:" ," logfile:" ," stop:" ," list" ," list-running" ," list-clients:" ," version" ," psk" ," no-dns" ," no-dnsmasq" ," ipv6" ," mkconfig:" ," config:" ," wps" ," wps-pbc:" ," wps-pin:" ," metered" -n " $PROGNAME " -- " $@ " )
1137+ GETOPT_ARGS=$( getopt -o hc:w:g:de:nm: -l " help" ," hidden" ," hostapd-debug:" ," redirect-to-localhost" ," mac-filter" ," mac-filter-accept:" ," isolate-clients" ," ieee80211n" ," ieee80211ac" ," ht_capab:" ," vht_capab:" ," driver:" ," no-virt" ," fix-unmanaged" ," country:" ," timezone" ," gps: " , " freq-band:" ," mac:" ," dhcp-dns:" ," dhcp-dns6:" ," daemon" ," pidfile:" ," logfile:" ," stop:" ," list" ," list-running" ," list-clients:" ," version" ," psk" ," no-dns" ," no-dnsmasq" ," ipv6" ," mkconfig:" ," config:" ," wps" ," wps-pbc:" ," wps-pin:" ," metered" -n " $PROGNAME " -- " $@ " )
11361138[[ $? -ne 0 ]] && exit 1
11371139eval set -- " $GETOPT_ARGS "
11381140
@@ -1245,6 +1247,11 @@ while :; do
12451247 shift
12461248 TIMEZONE=1
12471249 ;;
1250+ --gps)
1251+ shift
1252+ GPS=" $1 "
1253+ shift
1254+ ;;
12481255 --freq-band)
12491256 shift
12501257 FREQ_BAND=" $1 "
@@ -1892,6 +1899,26 @@ rsn_pairwise=CCMP
18921899EOF
18931900fi
18941901
1902+ if [[ -n " $GPS " ]]; then
1903+ # The format is defined in this French law requiring UAVs/drones to broadcast
1904+ # their GPS position and heading via WiFi beacons:
1905+ # https://www.legifrance.gouv.fr/eli/arrete/2019/12/27/ECOI1934044A/jo/texte
1906+ # Wireshark dissector clarifies some things:
1907+ # https://gitlab.com/wireshark/wireshark/commit/7ed3180
1908+ # Other fields such as "takeoff" coords, takeoff-relative altitude, and heading seem pointless
1909+ # for a non-aircraft application.
1910+
1911+ IFS=, read LAT LNG <<< " $GPS"
1912+ [[ $LAT -lt 0 ]] && LAT=$(( 0x100000000 + $LAT ))
1913+ [[ $LNG -lt 0 ]] && LNG=$(( 0x100000000 + $LNG ))
1914+ VENDOR_ELEMENTS+=" dd136a5c3501"
1915+ VENDOR_ELEMENTS+=" 010101" # version (01) = 01 "sa valeur est fixée à 1"
1916+ VENDOR_ELEMENTS+=$( printf " 0404%08x" $LAT ) # current latitude (+N,-S) in 10^-5 degrees
1917+ VENDOR_ELEMENTS+=$( printf " 0504%08x" $LNG ) # current longitude (+W,-E) in 10^-5 degrees
1918+ # VENDOR_ELEMENTS+="06020000" # absolute altitude in m
1919+ # VENDOR_ELEMENTS+="0a0100" # horizontal speed in m/s
1920+ fi
1921+
18951922if [[ -n " $VENDOR_ELEMENTS " ]]; then
18961923 echo " vendor_elements=$VENDOR_ELEMENTS " >> $CONFDIR /hostapd.conf
18971924fi
0 commit comments