pyhubblenetwork 0.11.0__tar.gz → 0.13.0__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.
Files changed (36) hide show
  1. {pyhubblenetwork-0.11.0 → pyhubblenetwork-0.13.0}/PKG-INFO +43 -7
  2. {pyhubblenetwork-0.11.0 → pyhubblenetwork-0.13.0}/README.md +41 -5
  3. {pyhubblenetwork-0.11.0 → pyhubblenetwork-0.13.0}/pyproject.toml +2 -2
  4. {pyhubblenetwork-0.11.0 → pyhubblenetwork-0.13.0}/src/hubblenetwork/__init__.py +28 -24
  5. {pyhubblenetwork-0.11.0 → pyhubblenetwork-0.13.0}/src/hubblenetwork/ble.py +14 -13
  6. {pyhubblenetwork-0.11.0 → pyhubblenetwork-0.13.0}/src/hubblenetwork/cli.py +462 -287
  7. {pyhubblenetwork-0.11.0 → pyhubblenetwork-0.13.0}/src/hubblenetwork/cloud.py +20 -19
  8. {pyhubblenetwork-0.11.0 → pyhubblenetwork-0.13.0}/src/hubblenetwork/crypto.py +47 -26
  9. pyhubblenetwork-0.13.0/src/hubblenetwork/detect.py +196 -0
  10. {pyhubblenetwork-0.11.0 → pyhubblenetwork-0.13.0}/src/hubblenetwork/device.py +6 -6
  11. {pyhubblenetwork-0.11.0 → pyhubblenetwork-0.13.0}/src/hubblenetwork/errors.py +23 -23
  12. {pyhubblenetwork-0.11.0 → pyhubblenetwork-0.13.0}/src/hubblenetwork/org.py +13 -16
  13. {pyhubblenetwork-0.11.0 → pyhubblenetwork-0.13.0}/src/hubblenetwork/packets.py +21 -17
  14. {pyhubblenetwork-0.11.0 → pyhubblenetwork-0.13.0}/src/hubblenetwork/ready.py +53 -47
  15. pyhubblenetwork-0.13.0/src/hubblenetwork/sat.py +564 -0
  16. {pyhubblenetwork-0.11.0 → pyhubblenetwork-0.13.0}/tests/test_ble_validate.py +3 -104
  17. pyhubblenetwork-0.13.0/tests/test_detect.py +349 -0
  18. {pyhubblenetwork-0.11.0 → pyhubblenetwork-0.13.0}/tests/test_sat.py +461 -4
  19. {pyhubblenetwork-0.11.0 → pyhubblenetwork-0.13.0}/tests/test_sat_decrypt.py +130 -3
  20. pyhubblenetwork-0.11.0/src/hubblenetwork/sat.py +0 -294
  21. {pyhubblenetwork-0.11.0 → pyhubblenetwork-0.13.0}/.gitignore +0 -0
  22. {pyhubblenetwork-0.11.0 → pyhubblenetwork-0.13.0}/LICENSE +0 -0
  23. {pyhubblenetwork-0.11.0 → pyhubblenetwork-0.13.0}/plugins/pyhubblenetwork/skills/hubble-ready-test/README.md +0 -0
  24. {pyhubblenetwork-0.11.0 → pyhubblenetwork-0.13.0}/tests/__init__.py +0 -0
  25. {pyhubblenetwork-0.11.0 → pyhubblenetwork-0.13.0}/tests/conftest.py +0 -0
  26. {pyhubblenetwork-0.11.0 → pyhubblenetwork-0.13.0}/tests/test_aes_eax.py +0 -0
  27. {pyhubblenetwork-0.11.0 → pyhubblenetwork-0.13.0}/tests/test_cli_ctr_autodetect.py +0 -0
  28. {pyhubblenetwork-0.11.0 → pyhubblenetwork-0.13.0}/tests/test_cli_payload.py +0 -0
  29. {pyhubblenetwork-0.11.0 → pyhubblenetwork-0.13.0}/tests/test_cloud_integration.py +0 -0
  30. {pyhubblenetwork-0.11.0 → pyhubblenetwork-0.13.0}/tests/test_counter_eid.py +0 -0
  31. {pyhubblenetwork-0.11.0 → pyhubblenetwork-0.13.0}/tests/test_metrics.py +0 -0
  32. {pyhubblenetwork-0.11.0 → pyhubblenetwork-0.13.0}/tests/test_org_delete_device.py +0 -0
  33. {pyhubblenetwork-0.11.0 → pyhubblenetwork-0.13.0}/tests/test_register_device_cloud.py +0 -0
  34. {pyhubblenetwork-0.11.0 → pyhubblenetwork-0.13.0}/tests/test_register_device_validation.py +0 -0
  35. {pyhubblenetwork-0.11.0 → pyhubblenetwork-0.13.0}/tests/test_sat_integration.py +0 -0
  36. {pyhubblenetwork-0.11.0 → pyhubblenetwork-0.13.0}/tests/test_unencrypted.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyhubblenetwork
3
- Version: 0.11.0
3
+ Version: 0.13.0
4
4
  Summary: Hubble SDK host-side tools
5
5
  Author-email: Paul Buckley <paul@hubble.com>
6
6
  License-Expression: Apache-2.0
@@ -18,7 +18,7 @@ Requires-Dist: tabulate>=0.9.0
18
18
  Provides-Extra: dev
19
19
  Requires-Dist: pytest-cov; extra == 'dev'
20
20
  Requires-Dist: pytest>=7; extra == 'dev'
21
- Requires-Dist: ruff; extra == 'dev'
21
+ Requires-Dist: ruff==0.16.2; extra == 'dev'
22
22
  Description-Content-Type: text/markdown
23
23
 
24
24
  # pyhubblenetwork
@@ -250,15 +250,20 @@ hubblenetwork sat scan -o json --timeout 60 -n 20
250
250
  # Decrypt payloads locally with a device key (hex or base64, 16 or 32 bytes)
251
251
  hubblenetwork sat scan --key "a562a2f7e4c62bed52ab09633878f62b"
252
252
 
253
+ # Force the DEVICE_UPTIME counter instead of auto-detecting
254
+ hubblenetwork sat scan --key "<key>" --counter-mode DEVICE_UPTIME
255
+
253
256
  # Show packets the key can't decrypt too (adds a DECRYPT OK/FAIL column)
254
257
  hubblenetwork sat scan --key "<key>" --show-failed-decryption
255
258
  ```
256
259
 
257
260
  When `--key` is supplied, each packet's payload is decrypted locally using the
258
- same AES-CTR scheme as BLE. Satellite packets always use the UNIX_TIME (day-based)
259
- counter; `--days` controls how many days around each packet's timestamp are
260
- searched (default 2). Packets the key cannot decrypt are hidden unless
261
- `--show-failed-decryption` is given.
261
+ same AES-CTR scheme as BLE, which supports both the UNIX_TIME (day-based) and
262
+ DEVICE_UPTIME counter sources. The counter source is auto-detected from the
263
+ packets (and announced) unless `--counter-mode UNIX_TIME|DEVICE_UPTIME` is given.
264
+ For the UNIX_TIME counter, `--days` controls how many days around each packet's
265
+ timestamp are searched (default 2). Packets the key cannot decrypt are hidden
266
+ unless `--show-failed-decryption` is given.
262
267
 
263
268
  The command automatically:
264
269
  1. Verifies Docker is available
@@ -268,6 +273,31 @@ The command automatically:
268
273
  5. Streams new packets as they arrive (deduplicating by device ID + sequence number)
269
274
  6. Stops and removes the container on exit or Ctrl+C
270
275
 
276
+ ### One-shot capture (`record` / `signal-report`)
277
+
278
+ Alongside the live `scan` stream, two one-shot commands record for a fixed
279
+ duration, save a single file, and exit. Both accept `--output PATH` (default: an
280
+ auto-generated timestamped name), `--mock` (use the simulated receiver — no
281
+ PlutoSDR required), `--pluto-uri`, and `--debug`.
282
+
283
+ ```bash
284
+ # Capture 10 s of raw IQ samples to a .npy file (for offline analysis / reprocessing)
285
+ hubblenetwork sat record 10
286
+ hubblenetwork sat record 10 --output capture.npy
287
+
288
+ # Record 10 s and save an RF signal-diagnostic report to a .txt file
289
+ hubblenetwork sat signal-report 10
290
+ hubblenetwork sat signal-report 10 --output report.txt --mock
291
+ ```
292
+
293
+ - **`record`** captures the raw radio signal only — no decoding. The output is a
294
+ NumPy `.npy` file of IQ samples.
295
+ - **`signal-report`** records IQ, then re-analyzes it offline into a plain-text
296
+ **link-health diagnostic**: per-symbol timing/drift, channel-hopping
297
+ validation, amplitude/SNR, and chipset metrics. It reports on signal quality
298
+ and does **not** contain decoded packet payloads — to receive payloads, use
299
+ `sat scan` (optionally with `--key`).
300
+
271
301
  ### Python API
272
302
 
273
303
  ```python
@@ -280,7 +310,12 @@ for pkt in sat.scan(timeout=60.0, poll_interval=2.0):
280
310
  # Or fetch the current packet buffer without managing the container yourself
281
311
  packets: list[SatellitePacket] = sat.fetch_packets()
282
312
 
283
- # Decrypt a packet's payload locally (UNIX_TIME counter)
313
+ # One-shot captures (manage the container, run once, return the result)
314
+ iq_bytes: bytes = sat.record(10.0) # raw IQ samples (.npy file body)
315
+ report: str = sat.signal_report(10.0) # plain-text RF signal-diagnostic report
316
+
317
+ # Decrypt a packet's payload locally.
318
+ # counter_mode defaults to UNIX_TIME; pass DEVICE_UPTIME for uptime-based EIDs.
284
319
  from hubblenetwork import decrypt_satellite
285
320
 
286
321
  for pkt in sat.scan(timeout=60.0):
@@ -288,6 +323,7 @@ for pkt in sat.scan(timeout=60.0):
288
323
  plaintext = decrypt_satellite(
289
324
  key, seq_no=pkt.seq_num, auth_tag=pkt.auth_tag,
290
325
  encrypted_payload=pkt.payload, timestamp=pkt.timestamp,
326
+ counter_mode="UNIX_TIME",
291
327
  )
292
328
  if plaintext is not None:
293
329
  print(pkt.device_id, plaintext)
@@ -227,15 +227,20 @@ hubblenetwork sat scan -o json --timeout 60 -n 20
227
227
  # Decrypt payloads locally with a device key (hex or base64, 16 or 32 bytes)
228
228
  hubblenetwork sat scan --key "a562a2f7e4c62bed52ab09633878f62b"
229
229
 
230
+ # Force the DEVICE_UPTIME counter instead of auto-detecting
231
+ hubblenetwork sat scan --key "<key>" --counter-mode DEVICE_UPTIME
232
+
230
233
  # Show packets the key can't decrypt too (adds a DECRYPT OK/FAIL column)
231
234
  hubblenetwork sat scan --key "<key>" --show-failed-decryption
232
235
  ```
233
236
 
234
237
  When `--key` is supplied, each packet's payload is decrypted locally using the
235
- same AES-CTR scheme as BLE. Satellite packets always use the UNIX_TIME (day-based)
236
- counter; `--days` controls how many days around each packet's timestamp are
237
- searched (default 2). Packets the key cannot decrypt are hidden unless
238
- `--show-failed-decryption` is given.
238
+ same AES-CTR scheme as BLE, which supports both the UNIX_TIME (day-based) and
239
+ DEVICE_UPTIME counter sources. The counter source is auto-detected from the
240
+ packets (and announced) unless `--counter-mode UNIX_TIME|DEVICE_UPTIME` is given.
241
+ For the UNIX_TIME counter, `--days` controls how many days around each packet's
242
+ timestamp are searched (default 2). Packets the key cannot decrypt are hidden
243
+ unless `--show-failed-decryption` is given.
239
244
 
240
245
  The command automatically:
241
246
  1. Verifies Docker is available
@@ -245,6 +250,31 @@ The command automatically:
245
250
  5. Streams new packets as they arrive (deduplicating by device ID + sequence number)
246
251
  6. Stops and removes the container on exit or Ctrl+C
247
252
 
253
+ ### One-shot capture (`record` / `signal-report`)
254
+
255
+ Alongside the live `scan` stream, two one-shot commands record for a fixed
256
+ duration, save a single file, and exit. Both accept `--output PATH` (default: an
257
+ auto-generated timestamped name), `--mock` (use the simulated receiver — no
258
+ PlutoSDR required), `--pluto-uri`, and `--debug`.
259
+
260
+ ```bash
261
+ # Capture 10 s of raw IQ samples to a .npy file (for offline analysis / reprocessing)
262
+ hubblenetwork sat record 10
263
+ hubblenetwork sat record 10 --output capture.npy
264
+
265
+ # Record 10 s and save an RF signal-diagnostic report to a .txt file
266
+ hubblenetwork sat signal-report 10
267
+ hubblenetwork sat signal-report 10 --output report.txt --mock
268
+ ```
269
+
270
+ - **`record`** captures the raw radio signal only — no decoding. The output is a
271
+ NumPy `.npy` file of IQ samples.
272
+ - **`signal-report`** records IQ, then re-analyzes it offline into a plain-text
273
+ **link-health diagnostic**: per-symbol timing/drift, channel-hopping
274
+ validation, amplitude/SNR, and chipset metrics. It reports on signal quality
275
+ and does **not** contain decoded packet payloads — to receive payloads, use
276
+ `sat scan` (optionally with `--key`).
277
+
248
278
  ### Python API
249
279
 
250
280
  ```python
@@ -257,7 +287,12 @@ for pkt in sat.scan(timeout=60.0, poll_interval=2.0):
257
287
  # Or fetch the current packet buffer without managing the container yourself
258
288
  packets: list[SatellitePacket] = sat.fetch_packets()
259
289
 
260
- # Decrypt a packet's payload locally (UNIX_TIME counter)
290
+ # One-shot captures (manage the container, run once, return the result)
291
+ iq_bytes: bytes = sat.record(10.0) # raw IQ samples (.npy file body)
292
+ report: str = sat.signal_report(10.0) # plain-text RF signal-diagnostic report
293
+
294
+ # Decrypt a packet's payload locally.
295
+ # counter_mode defaults to UNIX_TIME; pass DEVICE_UPTIME for uptime-based EIDs.
261
296
  from hubblenetwork import decrypt_satellite
262
297
 
263
298
  for pkt in sat.scan(timeout=60.0):
@@ -265,6 +300,7 @@ for pkt in sat.scan(timeout=60.0):
265
300
  plaintext = decrypt_satellite(
266
301
  key, seq_no=pkt.seq_num, auth_tag=pkt.auth_tag,
267
302
  encrypted_payload=pkt.payload, timestamp=pkt.timestamp,
303
+ counter_mode="UNIX_TIME",
268
304
  )
269
305
  if plaintext is not None:
270
306
  print(pkt.device_id, plaintext)
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "pyhubblenetwork"
7
- version = "0.11.0"
7
+ version = "0.13.0"
8
8
  requires-python = ">=3.9"
9
9
  authors = [
10
10
  { name="Paul Buckley", email="paul@hubble.com" },
@@ -57,5 +57,5 @@ markers = [
57
57
  dev = [
58
58
  "pytest>=7",
59
59
  "pytest-cov",
60
- "ruff",
60
+ "ruff==0.16.2",
61
61
  ]
@@ -4,38 +4,42 @@ Hubble Python SDK — public API façade.
4
4
  Import from here; internal module layout may change without notice.
5
5
  """
6
6
 
7
- from . import ble
8
- from . import cloud
9
- from . import ready
10
- from . import sat
11
-
12
- from .packets import Location, EncryptedPacket, UnencryptedPacket, DecryptedPacket, SatellitePacket, AesEaxPacket, UnknownPacket
7
+ from . import ble, cloud, ready, sat
8
+ from .cloud import Credentials, Environment
9
+ from .crypto import DEVICE_UPTIME, UNIX_TIME, decrypt, decrypt_eax, decrypt_satellite
13
10
  from .device import Device
14
- from .org import Organization
15
- from .crypto import decrypt, decrypt_eax, decrypt_satellite, UNIX_TIME, DEVICE_UPTIME
16
11
  from .errors import InvalidCredentialsError
17
- from .cloud import Credentials, Environment
12
+ from .org import Organization
13
+ from .packets import (
14
+ AesEaxPacket,
15
+ DecryptedPacket,
16
+ EncryptedPacket,
17
+ Location,
18
+ SatellitePacket,
19
+ UnencryptedPacket,
20
+ UnknownPacket,
21
+ )
18
22
 
19
23
  __all__ = [
20
- "ble",
21
- "cloud",
22
- "ready",
23
- "sat",
24
- "decrypt",
25
- "decrypt_eax",
26
- "decrypt_satellite",
27
- "UNIX_TIME",
28
24
  "DEVICE_UPTIME",
29
- "SatellitePacket",
30
- "Location",
31
- "EncryptedPacket",
32
- "UnencryptedPacket",
25
+ "UNIX_TIME",
33
26
  "AesEaxPacket",
34
- "UnknownPacket",
27
+ "Credentials",
35
28
  "DecryptedPacket",
36
29
  "Device",
37
- "Organization",
38
- "Credentials",
30
+ "EncryptedPacket",
39
31
  "Environment",
40
32
  "InvalidCredentialsError",
33
+ "Location",
34
+ "Organization",
35
+ "SatellitePacket",
36
+ "UnencryptedPacket",
37
+ "UnknownPacket",
38
+ "ble",
39
+ "cloud",
40
+ "decrypt",
41
+ "decrypt_eax",
42
+ "decrypt_satellite",
43
+ "ready",
44
+ "sat",
41
45
  ]
@@ -1,18 +1,19 @@
1
1
  # hubblenetwork/ble.py
2
2
  from __future__ import annotations
3
+
3
4
  import asyncio
4
5
  import struct
5
6
  from datetime import datetime, timezone
6
- from typing import Optional, List, Union
7
+ from typing import Union
7
8
 
8
9
  from bleak import BleakScanner
9
10
 
10
11
  # Import your dataclass
11
12
  from .packets import (
12
- Location,
13
+ AesEaxPacket,
13
14
  EncryptedPacket,
15
+ Location,
14
16
  UnencryptedPacket,
15
- AesEaxPacket,
16
17
  UnknownPacket,
17
18
  )
18
19
 
@@ -42,7 +43,7 @@ _NETWORK_ID_MASK = (1 << 34) - 1
42
43
  HubblePacket = Union[EncryptedPacket, UnencryptedPacket, AesEaxPacket, UnknownPacket]
43
44
 
44
45
 
45
- def parse_unencrypted(data: bytes) -> Optional[tuple]:
46
+ def parse_unencrypted(data: bytes) -> tuple | None:
46
47
  """Parse unencrypted protocol service data bytes.
47
48
 
48
49
  Returns (protocol_version, network_id, payload) or None if *data* does
@@ -124,7 +125,7 @@ def _make_packet(raw: bytes, rssi: int) -> HubblePacket:
124
125
  )
125
126
 
126
127
 
127
- def _extract_hubble_service_data(adv_data) -> Optional[tuple]:
128
+ def _extract_hubble_service_data(adv_data) -> tuple | None:
128
129
  """Extract Hubble service data payload and RSSI from a BLE advertisement.
129
130
 
130
131
  Returns (payload_bytes, rssi) or None if UUID 0xFCA6 not present.
@@ -141,10 +142,10 @@ def _extract_hubble_service_data(adv_data) -> Optional[tuple]:
141
142
  # ---------------------------------------------------------------------------
142
143
 
143
144
 
144
- async def _scan_async(ttl: float) -> List[HubblePacket]:
145
+ async def _scan_async(ttl: float) -> list[HubblePacket]:
145
146
  """Async implementation of BLE scan."""
146
147
  done = asyncio.Event()
147
- packets: List[HubblePacket] = []
148
+ packets: list[HubblePacket] = []
148
149
 
149
150
  def on_detect(device, adv_data) -> None:
150
151
  nonlocal packets
@@ -162,7 +163,7 @@ async def _scan_async(ttl: float) -> List[HubblePacket]:
162
163
  return packets
163
164
 
164
165
 
165
- def scan(timeout: float) -> List[HubblePacket]:
166
+ def scan(timeout: float) -> list[HubblePacket]:
166
167
  """
167
168
  Scan for BLE advertisements that include service data for UUID 0xFCA6.
168
169
  Automatically detects encrypted vs unencrypted protocol packets.
@@ -187,7 +188,7 @@ def scan(timeout: float) -> List[HubblePacket]:
187
188
  )
188
189
 
189
190
 
190
- async def scan_async(timeout: float) -> List[HubblePacket]:
191
+ async def scan_async(timeout: float) -> list[HubblePacket]:
191
192
  """
192
193
  Async version of scan() for use in async environments like Jupyter notebooks.
193
194
 
@@ -197,10 +198,10 @@ async def scan_async(timeout: float) -> List[HubblePacket]:
197
198
  return await _scan_async(timeout)
198
199
 
199
200
 
200
- async def _scan_single_async(ttl: float) -> Optional[HubblePacket]:
201
+ async def _scan_single_async(ttl: float) -> HubblePacket | None:
201
202
  """Async implementation for scanning a single BLE packet."""
202
203
  done = asyncio.Event()
203
- packet: Optional[HubblePacket] = None
204
+ packet: HubblePacket | None = None
204
205
 
205
206
  def on_detect(device, adv_data) -> None:
206
207
  nonlocal packet
@@ -225,7 +226,7 @@ async def _scan_single_async(ttl: float) -> Optional[HubblePacket]:
225
226
  return packet
226
227
 
227
228
 
228
- def scan_single(timeout: float) -> Optional[HubblePacket]:
229
+ def scan_single(timeout: float) -> HubblePacket | None:
229
230
  """
230
231
  Scan for a BLE advertisement that includes service data for UUID 0xFCA6
231
232
  and return it. Automatically detects encrypted vs unencrypted protocol.
@@ -250,7 +251,7 @@ def scan_single(timeout: float) -> Optional[HubblePacket]:
250
251
  )
251
252
 
252
253
 
253
- async def scan_single_async(timeout: float) -> Optional[HubblePacket]:
254
+ async def scan_single_async(timeout: float) -> HubblePacket | None:
254
255
  """
255
256
  Async version of scan_single() for use in async environments like Jupyter notebooks.
256
257