dronecot 2.2.2__tar.gz → 2.2.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dronecot-2.2.2 → dronecot-2.2.4}/CHANGELOG.md +7 -0
- {dronecot-2.2.2/dronecot.egg-info → dronecot-2.2.4}/PKG-INFO +1 -1
- {dronecot-2.2.2 → dronecot-2.2.4/dronecot.egg-info}/PKG-INFO +1 -1
- {dronecot-2.2.2 → dronecot-2.2.4}/dronecot.egg-info/SOURCES.txt +3 -1
- dronecot-2.2.4/src/dronecot/VERSION +1 -0
- {dronecot-2.2.2 → dronecot-2.2.4}/src/dronecot/classes.py +33 -0
- {dronecot-2.2.2 → dronecot-2.2.4}/src/dronecot/wifi_parse.py +17 -36
- dronecot-2.2.4/tests/test_adsb_vehicle.py +43 -0
- dronecot-2.2.4/tests/test_wifi_parse.py +53 -0
- dronecot-2.2.2/src/dronecot/VERSION +0 -1
- {dronecot-2.2.2 → dronecot-2.2.4}/LICENSE +0 -0
- {dronecot-2.2.2 → dronecot-2.2.4}/MANIFEST.in +0 -0
- {dronecot-2.2.2 → dronecot-2.2.4}/README.md +0 -0
- {dronecot-2.2.2 → dronecot-2.2.4}/dronecot.egg-info/dependency_links.txt +0 -0
- {dronecot-2.2.2 → dronecot-2.2.4}/dronecot.egg-info/entry_points.txt +0 -0
- {dronecot-2.2.2 → dronecot-2.2.4}/dronecot.egg-info/requires.txt +0 -0
- {dronecot-2.2.2 → dronecot-2.2.4}/dronecot.egg-info/top_level.txt +0 -0
- {dronecot-2.2.2 → dronecot-2.2.4}/setup.cfg +0 -0
- {dronecot-2.2.2 → dronecot-2.2.4}/setup.py +0 -0
- {dronecot-2.2.2 → dronecot-2.2.4}/src/dronecot/__init__.py +0 -0
- {dronecot-2.2.2 → dronecot-2.2.4}/src/dronecot/ble_capture.py +0 -0
- {dronecot-2.2.2 → dronecot-2.2.4}/src/dronecot/ble_parse.py +0 -0
- {dronecot-2.2.2 → dronecot-2.2.4}/src/dronecot/commands.py +0 -0
- {dronecot-2.2.2 → dronecot-2.2.4}/src/dronecot/constants.py +0 -0
- {dronecot-2.2.2 → dronecot-2.2.4}/src/dronecot/dji_exceptions.py +0 -0
- {dronecot-2.2.2 → dronecot-2.2.4}/src/dronecot/dji_functions.py +0 -0
- {dronecot-2.2.2 → dronecot-2.2.4}/src/dronecot/dji_text_parser.py +0 -0
- {dronecot-2.2.2 → dronecot-2.2.4}/src/dronecot/functions.py +0 -0
- {dronecot-2.2.2 → dronecot-2.2.4}/src/dronecot/odid.py +0 -0
- {dronecot-2.2.2 → dronecot-2.2.4}/src/dronecot/open_drone_id.py +0 -0
- {dronecot-2.2.2 → dronecot-2.2.4}/src/dronecot/rid_normalize.py +0 -0
- {dronecot-2.2.2 → dronecot-2.2.4}/src/dronecot/udp_rid.py +0 -0
- {dronecot-2.2.2 → dronecot-2.2.4}/src/dronecot/wifi_capture.py +0 -0
- {dronecot-2.2.2 → dronecot-2.2.4}/tests/test_functions.py +0 -0
- {dronecot-2.2.2 → dronecot-2.2.4}/tests/test_rid_normalize.py +0 -0
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## DroneCOT 2.2.3
|
|
2
|
+
|
|
3
|
+
- SerialWorker: handle MAVLink **ADSB_VEHICLE** messages (in addition to
|
|
4
|
+
OPEN_DRONE_ID_MESSAGE_PACK), so Remote ID receivers that emit ADS-B-style
|
|
5
|
+
frames — e.g. the **BlueMark DroneScout Bridge (DS101)** in ADS-B output mode
|
|
6
|
+
— are decoded to CoT. Adds a test for the ADSB_VEHICLE -> RID conversion.
|
|
7
|
+
|
|
1
8
|
## DroneCOT 2.2.2
|
|
2
9
|
|
|
3
10
|
- Fix UTC timestamp handling on Python 3.9 and 3.10.
|
|
@@ -27,5 +27,7 @@ src/dronecot/rid_normalize.py
|
|
|
27
27
|
src/dronecot/udp_rid.py
|
|
28
28
|
src/dronecot/wifi_capture.py
|
|
29
29
|
src/dronecot/wifi_parse.py
|
|
30
|
+
tests/test_adsb_vehicle.py
|
|
30
31
|
tests/test_functions.py
|
|
31
|
-
tests/test_rid_normalize.py
|
|
32
|
+
tests/test_rid_normalize.py
|
|
33
|
+
tests/test_wifi_parse.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.2.4
|
|
@@ -87,6 +87,35 @@ class SerialWorker(pytak.QueueWorker):
|
|
|
87
87
|
parsed = dronecot.odid.message_pack_to_dict(messages, pack_size)
|
|
88
88
|
return dronecot.rid_normalize.odid_parsed_to_rid_dict(parsed)
|
|
89
89
|
|
|
90
|
+
@staticmethod
|
|
91
|
+
def _adsb_vehicle_to_rid_dict(msg) -> dict:
|
|
92
|
+
"""Convert a MAVLink ADSB_VEHICLE to a RIDWorker dict.
|
|
93
|
+
|
|
94
|
+
The DroneScout Bridge (and similar Remote ID receivers) can emit detected
|
|
95
|
+
Remote ID as MAVLink ADSB_VEHICLE instead of OPEN_DRONE_ID_MESSAGE_PACK.
|
|
96
|
+
Units: lat/lon 1e-7 deg, altitude mm, hor/ver velocity cm/s, heading cdeg.
|
|
97
|
+
Returns {} when there is no position.
|
|
98
|
+
"""
|
|
99
|
+
lat = getattr(msg, "lat", 0) / 1e7
|
|
100
|
+
lon = getattr(msg, "lon", 0) / 1e7
|
|
101
|
+
if not lat and not lon:
|
|
102
|
+
return {}
|
|
103
|
+
callsign = getattr(msg, "callsign", "") or ""
|
|
104
|
+
if isinstance(callsign, bytes):
|
|
105
|
+
callsign = callsign.decode("ascii", "ignore")
|
|
106
|
+
callsign = callsign.replace("\x00", "").strip()
|
|
107
|
+
icao = int(getattr(msg, "ICAO_address", 0) or 0)
|
|
108
|
+
return {
|
|
109
|
+
"BasicID": callsign or f"ICAO-{icao:06X}",
|
|
110
|
+
"Latitude": lat,
|
|
111
|
+
"Longitude": lon,
|
|
112
|
+
"AltitudeGeo": getattr(msg, "altitude", 0) / 1000.0, # mm -> m
|
|
113
|
+
"SpeedHorizontal": getattr(msg, "hor_velocity", 0) / 100.0, # cm/s -> m/s
|
|
114
|
+
"SpeedVertical": getattr(msg, "ver_velocity", 0) / 100.0,
|
|
115
|
+
"Direction": getattr(msg, "heading", 0) / 100.0, # cdeg -> deg
|
|
116
|
+
"data": {"type": "MAVLink ADSB_VEHICLE"},
|
|
117
|
+
}
|
|
118
|
+
|
|
90
119
|
async def run(self, _=-1) -> None:
|
|
91
120
|
"""Read MAVLink messages from serial and enqueue decoded ODID payloads."""
|
|
92
121
|
self._logger.info("Running SerialWorker")
|
|
@@ -154,6 +183,10 @@ class SerialWorker(pytak.QueueWorker):
|
|
|
154
183
|
msg.messages, msg.msg_pack_size
|
|
155
184
|
)
|
|
156
185
|
await self.put_queue(parsed_payload)
|
|
186
|
+
elif msg_type == "ADSB_VEHICLE":
|
|
187
|
+
rid = self._adsb_vehicle_to_rid_dict(msg)
|
|
188
|
+
if rid:
|
|
189
|
+
await self.put_queue(rid)
|
|
157
190
|
elif msg_type == "HEARTBEAT":
|
|
158
191
|
self._logger.debug(
|
|
159
192
|
"MAVLink heartbeat received at %s",
|
|
@@ -157,9 +157,16 @@ def extract_odid_from_dot11(frame_bytes: bytes) -> Optional[Tuple[bytes, Dict[st
|
|
|
157
157
|
|
|
158
158
|
|
|
159
159
|
def extract_odid_from_scapy_packet(packet) -> Optional[Tuple[bytes, Dict[str, Any]]]:
|
|
160
|
-
"""Extract ODID from a Scapy packet (Dot11 layer).
|
|
160
|
+
"""Extract ODID from a Scapy packet (Dot11 layer).
|
|
161
|
+
|
|
162
|
+
Delegates to the byte-level ``extract_odid_from_dot11`` parser on the
|
|
163
|
+
serialized Dot11 frame. This avoids a class of Scapy field-type bugs — e.g.
|
|
164
|
+
``Dot11EltVendorSpecific.oui`` is an int, so ``bytes(elt.oui)`` builds a huge
|
|
165
|
+
zero buffer instead of the 3 OUI bytes and the ASTM vendor element never
|
|
166
|
+
matches — and keeps Wi-Fi Beacon and NAN decoding on one proven code path.
|
|
167
|
+
"""
|
|
161
168
|
try:
|
|
162
|
-
from scapy.layers.dot11 import Dot11,
|
|
169
|
+
from scapy.layers.dot11 import Dot11, RadioTap # noqa
|
|
163
170
|
except ImportError:
|
|
164
171
|
return None
|
|
165
172
|
|
|
@@ -167,40 +174,14 @@ def extract_odid_from_scapy_packet(packet) -> Optional[Tuple[bytes, Dict[str, An
|
|
|
167
174
|
return None
|
|
168
175
|
|
|
169
176
|
dot11 = packet.getlayer(Dot11)
|
|
170
|
-
|
|
177
|
+
result = extract_odid_from_dot11(bytes(dot11))
|
|
178
|
+
if not result:
|
|
179
|
+
return None
|
|
171
180
|
|
|
172
|
-
|
|
173
|
-
|
|
181
|
+
pack, meta = result
|
|
182
|
+
# Enrich with Scapy-only signal info when present.
|
|
183
|
+
if packet.haslayer(RadioTap):
|
|
184
|
+
rssi = getattr(packet[RadioTap], "dBm_AntSignal", None)
|
|
174
185
|
if rssi is not None:
|
|
175
186
|
meta["RSSI"] = int(rssi)
|
|
176
|
-
|
|
177
|
-
subtype = dot11.subtype
|
|
178
|
-
|
|
179
|
-
if subtype == 8: # beacon
|
|
180
|
-
elt = packet.getlayer(Dot11EltVendorSpecific)
|
|
181
|
-
while elt:
|
|
182
|
-
if hasattr(elt, "oui") and hasattr(elt, "info"):
|
|
183
|
-
oui = bytes(elt.oui) if not isinstance(elt.oui, bytes) else elt.oui
|
|
184
|
-
info = bytes(elt.info) if elt.info else b""
|
|
185
|
-
ie_data = oui + info
|
|
186
|
-
pack = parse_beacon_vendor_ie(ie_data)
|
|
187
|
-
if pack:
|
|
188
|
-
meta["type"] = "WiFi beacon"
|
|
189
|
-
if dot11.IDinfo:
|
|
190
|
-
meta["channel"] = int(getattr(dot11.IDinfo, "channel", 0) or 0)
|
|
191
|
-
return pack, meta
|
|
192
|
-
elt = elt.payload.getlayer(Dot11EltVendorSpecific)
|
|
193
|
-
elif subtype == 13: # action
|
|
194
|
-
raw = bytes(packet[Dot11].payload) if dot11.payload else b""
|
|
195
|
-
if not raw and packet.haslayer("Raw"):
|
|
196
|
-
raw = bytes(packet["Raw"].load)
|
|
197
|
-
frame = bytes(dot11.build()) + raw if raw else bytes(packet.build())
|
|
198
|
-
# Rebuild full frame for NAN parser
|
|
199
|
-
full = bytes(packet.build())
|
|
200
|
-
result = extract_odid_from_dot11(full)
|
|
201
|
-
if result:
|
|
202
|
-
pack, nan_meta = result
|
|
203
|
-
meta.update(nan_meta)
|
|
204
|
-
return pack, meta
|
|
205
|
-
|
|
206
|
-
return None
|
|
187
|
+
return pack, meta
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# Copyright Sensors & Signals LLC https://www.snstac.com/
|
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
"""Tests for SerialWorker MAVLink ADSB_VEHICLE -> RID dict (DroneScout Bridge)."""
|
|
5
|
+
|
|
6
|
+
import types
|
|
7
|
+
import unittest
|
|
8
|
+
|
|
9
|
+
from dronecot.classes import SerialWorker
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def _adsb(**kw):
|
|
13
|
+
return types.SimpleNamespace(**kw)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class AdsbVehicleTestCase(unittest.TestCase):
|
|
17
|
+
def test_full_conversion(self):
|
|
18
|
+
rid = SerialWorker._adsb_vehicle_to_rid_dict(
|
|
19
|
+
_adsb(
|
|
20
|
+
lat=407128000, lon=-740060000, altitude=120500,
|
|
21
|
+
hor_velocity=825, ver_velocity=-50, heading=27000,
|
|
22
|
+
callsign="DRONE1\x00\x00", ICAO_address=0x123456,
|
|
23
|
+
)
|
|
24
|
+
)
|
|
25
|
+
self.assertAlmostEqual(rid["Latitude"], 40.7128, places=6)
|
|
26
|
+
self.assertAlmostEqual(rid["Longitude"], -74.0060, places=6)
|
|
27
|
+
self.assertEqual(rid["AltitudeGeo"], 120.5) # mm -> m
|
|
28
|
+
self.assertEqual(rid["SpeedHorizontal"], 8.25) # cm/s -> m/s
|
|
29
|
+
self.assertEqual(rid["Direction"], 270.0) # cdeg -> deg
|
|
30
|
+
self.assertEqual(rid["BasicID"], "DRONE1")
|
|
31
|
+
|
|
32
|
+
def test_no_callsign_falls_back_to_icao(self):
|
|
33
|
+
rid = SerialWorker._adsb_vehicle_to_rid_dict(
|
|
34
|
+
_adsb(lat=407128000, lon=-740060000, callsign="", ICAO_address=0x123456)
|
|
35
|
+
)
|
|
36
|
+
self.assertEqual(rid["BasicID"], "ICAO-123456")
|
|
37
|
+
|
|
38
|
+
def test_no_position_dropped(self):
|
|
39
|
+
self.assertEqual(SerialWorker._adsb_vehicle_to_rid_dict(_adsb(lat=0, lon=0)), {})
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
if __name__ == "__main__":
|
|
43
|
+
unittest.main()
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"""Tests for Wi-Fi Open Drone ID frame parsing.
|
|
2
|
+
|
|
3
|
+
Regression for the Scapy beacon path: ``Dot11EltVendorSpecific.oui`` is an int,
|
|
4
|
+
so the old ``bytes(elt.oui)`` built a huge zero buffer and the ASTM vendor
|
|
5
|
+
element never matched — ``extract_odid_from_scapy_packet`` decoded nothing even
|
|
6
|
+
though ``extract_odid_from_dot11`` decoded the same frame.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import struct
|
|
10
|
+
|
|
11
|
+
import pytest
|
|
12
|
+
|
|
13
|
+
from dronecot import wifi_parse
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _astm_beacon_frame(pack_body: bytes) -> bytes:
|
|
17
|
+
"""Build a raw 802.11 beacon carrying an ASTM ODID vendor IE."""
|
|
18
|
+
fc = struct.pack("<H", 0x0080) # mgmt, subtype 8 (beacon)
|
|
19
|
+
dur = b"\x00\x00"
|
|
20
|
+
dst = b"\xff\xff\xff\xff\xff\xff"
|
|
21
|
+
src = b"\xaa\xbb\xcc\xdd\xee\xff"
|
|
22
|
+
bssid = src
|
|
23
|
+
seq = b"\x00\x00"
|
|
24
|
+
fixed = b"\x00" * 8 + b"\x64\x00" + b"\x00\x00" # timestamp + interval + caps
|
|
25
|
+
# Vendor IE: OUI FA:0B:BC, type 0x0D, msg_counter 0x01, then the pack body.
|
|
26
|
+
ie_payload = wifi_parse.ASTM_WIFI_OUI + bytes([0x0D, 0x01]) + pack_body
|
|
27
|
+
ie = bytes([0xDD, len(ie_payload)]) + ie_payload
|
|
28
|
+
return fc + dur + dst + src + bssid + seq + fixed + ie
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def test_extract_odid_from_dot11_beacon():
|
|
32
|
+
body = bytes(range(25))
|
|
33
|
+
frame = _astm_beacon_frame(body)
|
|
34
|
+
result = wifi_parse.extract_odid_from_dot11(frame)
|
|
35
|
+
assert result is not None
|
|
36
|
+
pack, meta = result
|
|
37
|
+
assert pack == body
|
|
38
|
+
assert meta.get("type") == "WiFi beacon"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def test_extract_odid_from_scapy_packet_matches_raw():
|
|
42
|
+
"""The Scapy path must decode the same beacon the byte parser does."""
|
|
43
|
+
scapy_dot11 = pytest.importorskip("scapy.layers.dot11")
|
|
44
|
+
body = bytes(range(25))
|
|
45
|
+
frame = _astm_beacon_frame(body)
|
|
46
|
+
pkt = scapy_dot11.Dot11(frame)
|
|
47
|
+
|
|
48
|
+
raw = wifi_parse.extract_odid_from_dot11(frame)
|
|
49
|
+
viascapy = wifi_parse.extract_odid_from_scapy_packet(pkt)
|
|
50
|
+
|
|
51
|
+
assert raw is not None
|
|
52
|
+
assert viascapy is not None, "scapy path failed on a frame the byte parser decoded"
|
|
53
|
+
assert viascapy[0] == raw[0] == body
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
2.2.2
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|