Skip to content
This repository was archived by the owner on Sep 30, 2021. It is now read-only.

Commit 6bbdbe2

Browse files
committed
Enable GPS location advertisement ("French drone format")
The format is defined in this French legislative document specifying how UAVs/drones should broadcast their GPS position and heading via vendor elemnts in WiFi beacons: https://www.legifrance.gouv.fr/eli/arrete/2019/12/27/ECOI1934044A/jo/texte Wireshark dissector shows how the sub-fields are decoded: https://gitlab.com/wireshark/wireshark/commit/7ed3180 There are other fields such as "takeoff" coordinates, takeoff-relative altitude, heading, and aircraft serial numbers; these seem pointless for a non-aircraft application.
1 parent 23964b4 commit 6bbdbe2

2 files changed

Lines changed: 32 additions & 2 deletions

File tree

create_ap

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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
659660
NO_VIRT=0
660661
COUNTRY=
661662
TIMEZONE=
663+
GPS=
662664
FREQ_BAND=2.4
663665
BEACON_INTERVAL=100
664666
DTIM_PERIOD=2
@@ -674,7 +676,7 @@ HOSTAPD_DEBUG_ARGS=
674676
REDIRECT_TO_LOCALHOST=0
675677

676678
CONFIG_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
11331135
done
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
11371139
eval 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
18921899
EOF
18931900
fi
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+
18951922
if [[ -n "$VENDOR_ELEMENTS" ]]; then
18961923
echo "vendor_elements=$VENDOR_ELEMENTS" >> $CONFDIR/hostapd.conf
18971924
fi

create_ap.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ FREQ_BAND=2.4
4545
COUNTRY=
4646
# Whether to advertise local timezone (802.11v-2011 7.3.2.87)
4747
TIMEZONE=0
48+
# Advertise location in GPS coordinates, lat/lng in 10^-5 degrees
49+
# (e.g. '4078628,-7396287' for Central Park in New York)
50+
GPS=
4851
# WPA version
4952
# Available options: "1", "2", "1+2" (or "3")
5053
WPA_VERSION=2

0 commit comments

Comments
 (0)