pyhubblenetwork 0.12.0__tar.gz → 0.14.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.
- {pyhubblenetwork-0.12.0 → pyhubblenetwork-0.14.0}/PKG-INFO +266 -32
- pyhubblenetwork-0.14.0/README.md +618 -0
- {pyhubblenetwork-0.12.0 → pyhubblenetwork-0.14.0}/plugins/pyhubblenetwork/skills/hubble-ready-test/README.md +1 -1
- {pyhubblenetwork-0.12.0 → pyhubblenetwork-0.14.0}/pyproject.toml +4 -4
- {pyhubblenetwork-0.12.0 → pyhubblenetwork-0.14.0}/src/hubblenetwork/__init__.py +29 -25
- {pyhubblenetwork-0.12.0 → pyhubblenetwork-0.14.0}/src/hubblenetwork/ble.py +21 -16
- {pyhubblenetwork-0.12.0 → pyhubblenetwork-0.14.0}/src/hubblenetwork/cli.py +2009 -371
- {pyhubblenetwork-0.12.0 → pyhubblenetwork-0.14.0}/src/hubblenetwork/cloud.py +40 -23
- {pyhubblenetwork-0.12.0 → pyhubblenetwork-0.14.0}/src/hubblenetwork/crypto.py +12 -11
- {pyhubblenetwork-0.12.0 → pyhubblenetwork-0.14.0}/src/hubblenetwork/detect.py +11 -10
- {pyhubblenetwork-0.12.0 → pyhubblenetwork-0.14.0}/src/hubblenetwork/device.py +6 -6
- {pyhubblenetwork-0.12.0 → pyhubblenetwork-0.14.0}/src/hubblenetwork/errors.py +23 -23
- {pyhubblenetwork-0.12.0 → pyhubblenetwork-0.14.0}/src/hubblenetwork/org.py +85 -48
- {pyhubblenetwork-0.12.0 → pyhubblenetwork-0.14.0}/src/hubblenetwork/packets.py +41 -17
- {pyhubblenetwork-0.12.0 → pyhubblenetwork-0.14.0}/src/hubblenetwork/ready.py +54 -47
- {pyhubblenetwork-0.12.0 → pyhubblenetwork-0.14.0}/src/hubblenetwork/sat.py +260 -40
- pyhubblenetwork-0.14.0/src/hubblenetwork/termcaps.py +173 -0
- pyhubblenetwork-0.14.0/tests/conftest.py +17 -0
- {pyhubblenetwork-0.12.0 → pyhubblenetwork-0.14.0}/tests/test_aes_eax.py +6 -2
- pyhubblenetwork-0.14.0/tests/test_cli_doctor.py +186 -0
- pyhubblenetwork-0.14.0/tests/test_cli_help_and_errors.py +376 -0
- pyhubblenetwork-0.14.0/tests/test_cli_org_display.py +346 -0
- pyhubblenetwork-0.14.0/tests/test_cli_scan_display.py +423 -0
- {pyhubblenetwork-0.12.0 → pyhubblenetwork-0.14.0}/tests/test_org_delete_device.py +6 -3
- {pyhubblenetwork-0.12.0 → pyhubblenetwork-0.14.0}/tests/test_register_device_cloud.py +61 -2
- {pyhubblenetwork-0.12.0 → pyhubblenetwork-0.14.0}/tests/test_register_device_validation.py +18 -2
- {pyhubblenetwork-0.12.0 → pyhubblenetwork-0.14.0}/tests/test_sat.py +383 -5
- {pyhubblenetwork-0.12.0 → pyhubblenetwork-0.14.0}/tests/test_sat_decrypt.py +3 -3
- {pyhubblenetwork-0.12.0 → pyhubblenetwork-0.14.0}/tests/test_sat_integration.py +1 -1
- pyhubblenetwork-0.14.0/tests/test_terminal_compat.py +379 -0
- pyhubblenetwork-0.12.0/README.md +0 -384
- pyhubblenetwork-0.12.0/tests/conftest.py +0 -1
- {pyhubblenetwork-0.12.0 → pyhubblenetwork-0.14.0}/.gitignore +0 -0
- {pyhubblenetwork-0.12.0 → pyhubblenetwork-0.14.0}/LICENSE +0 -0
- {pyhubblenetwork-0.12.0 → pyhubblenetwork-0.14.0}/tests/__init__.py +0 -0
- {pyhubblenetwork-0.12.0 → pyhubblenetwork-0.14.0}/tests/test_ble_validate.py +0 -0
- {pyhubblenetwork-0.12.0 → pyhubblenetwork-0.14.0}/tests/test_cli_ctr_autodetect.py +0 -0
- {pyhubblenetwork-0.12.0 → pyhubblenetwork-0.14.0}/tests/test_cli_payload.py +0 -0
- {pyhubblenetwork-0.12.0 → pyhubblenetwork-0.14.0}/tests/test_cloud_integration.py +0 -0
- {pyhubblenetwork-0.12.0 → pyhubblenetwork-0.14.0}/tests/test_counter_eid.py +0 -0
- {pyhubblenetwork-0.12.0 → pyhubblenetwork-0.14.0}/tests/test_detect.py +0 -0
- {pyhubblenetwork-0.12.0 → pyhubblenetwork-0.14.0}/tests/test_metrics.py +0 -0
- {pyhubblenetwork-0.12.0 → pyhubblenetwork-0.14.0}/tests/test_unencrypted.py +0 -0
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: pyhubblenetwork
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.14.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
|
|
7
7
|
License-File: LICENSE
|
|
8
8
|
Classifier: Operating System :: OS Independent
|
|
9
9
|
Classifier: Programming Language :: Python :: 3
|
|
10
|
-
Requires-Python: >=3.
|
|
10
|
+
Requires-Python: >=3.10
|
|
11
11
|
Requires-Dist: bleak
|
|
12
|
-
Requires-Dist: click
|
|
12
|
+
Requires-Dist: click<9,>=8.2
|
|
13
13
|
Requires-Dist: docker>=7.0
|
|
14
14
|
Requires-Dist: httpx>=0.27
|
|
15
15
|
Requires-Dist: pycryptodome
|
|
@@ -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
|
|
@@ -43,6 +43,7 @@ Description-Content-Type: text/markdown
|
|
|
43
43
|
- [Public API (summary)](#public-api-summary)
|
|
44
44
|
- [Development & tests](#development--tests)
|
|
45
45
|
- [Troubleshooting](#troubleshooting)
|
|
46
|
+
- [Telemetry](#telemetry)
|
|
46
47
|
- [Releases & versioning](#releases--versioning)
|
|
47
48
|
|
|
48
49
|
|
|
@@ -55,9 +56,13 @@ Description-Content-Type: text/markdown
|
|
|
55
56
|
|
|
56
57
|
## Requirements & supported platforms
|
|
57
58
|
|
|
58
|
-
- Python **3.
|
|
59
|
+
- Python **3.10+** (3.11/3.12 recommended)
|
|
59
60
|
- BLE platform prerequisites (only needed if you use `ble.scan()`):
|
|
60
|
-
- **macOS**: CoreBluetooth
|
|
61
|
+
- **macOS**: CoreBluetooth. Run from a real terminal app and grant it Bluetooth
|
|
62
|
+
access when prompted. macOS kills any process whose executable has no
|
|
63
|
+
`NSBluetoothAlwaysUsageDescription` in an Info.plist, and a bare Python binary
|
|
64
|
+
has none — see [Troubleshooting](#troubleshooting) if you hit a crash rather
|
|
65
|
+
than a permission prompt.
|
|
61
66
|
- **Linux**: BlueZ required; user must have permission to access the BLE adapter (often `bluetooth` group).
|
|
62
67
|
- **Windows**: Requires a compatible BLE stack/adapter.
|
|
63
68
|
- Satellite scanning prerequisites (only needed if you use `sat.scan()`):
|
|
@@ -76,10 +81,9 @@ pipx install pyhubblenetwork
|
|
|
76
81
|
|
|
77
82
|
### Developers (editable install)
|
|
78
83
|
|
|
79
|
-
From the repo root
|
|
84
|
+
From the repo root:
|
|
80
85
|
|
|
81
86
|
```bash
|
|
82
|
-
cd python
|
|
83
87
|
python3 -m venv .venv && source .venv/bin/activate
|
|
84
88
|
pip install -e '.[dev]'
|
|
85
89
|
```
|
|
@@ -158,7 +162,7 @@ for pkt in sat.scan(timeout=60.0):
|
|
|
158
162
|
|
|
159
163
|
Docker must be running before calling `sat.scan()`. The PlutoSDR dongle must be connected.
|
|
160
164
|
|
|
161
|
-
## CLI usage
|
|
165
|
+
## CLI usage
|
|
162
166
|
|
|
163
167
|
If installed, the `hubblenetwork` command is available:
|
|
164
168
|
|
|
@@ -167,18 +171,149 @@ hubblenetwork --help
|
|
|
167
171
|
hubblenetwork ble scan
|
|
168
172
|
hubblenetwork ble scan --payload-format hex
|
|
169
173
|
hubblenetwork ble scan --key "base64key=" --counter-mode DEVICE_UPTIME # counter-based EID
|
|
170
|
-
hubblenetwork org get-packets --payload-format string
|
|
174
|
+
hubblenetwork org get-packets <id> --payload-format string
|
|
171
175
|
```
|
|
172
176
|
|
|
177
|
+
Start with `hubblenetwork doctor`, which checks whether this machine can actually
|
|
178
|
+
talk to Hubble and names the fix for anything broken:
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
hubblenetwork doctor
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
```
|
|
185
|
+
x Credentials not set
|
|
186
|
+
Set both, or pass --org-id/--token:
|
|
187
|
+
export HUBBLE_ORG_ID=<your org id>
|
|
188
|
+
export HUBBLE_API_TOKEN=<your api token>
|
|
189
|
+
+ Bluetooth usage description present
|
|
190
|
+
x Docker Docker is not available
|
|
191
|
+
Only `sat` commands need Docker.
|
|
192
|
+
|
|
193
|
+
Not ready. | 1 ok | 2 failed
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
It exits 1 when something needed is broken, so a script can gate on it. A skipped
|
|
197
|
+
check is not a failure: it means the check does not apply on this platform, or could
|
|
198
|
+
not be answered without doing real work (pulling the satellite receiver image, say).
|
|
199
|
+
The Bluetooth check reads the interpreter's Info.plist rather than attempting a scan,
|
|
200
|
+
because attempting one is exactly what macOS kills.
|
|
201
|
+
|
|
202
|
+
Every command lives inside a group, so it is always `hubblenetwork <group> <command>`:
|
|
203
|
+
`org` for the cloud, `ble` for nearby devices, `ready` for provisioning, `sat` for
|
|
204
|
+
satellite, `metrics` for fleet counts. `hubblenetwork --help` prints the full list with
|
|
205
|
+
a one-line description and the required arguments for each, and every command takes
|
|
206
|
+
`--help` for its own options.
|
|
207
|
+
|
|
208
|
+
You don't have to remember which group a command is in. If you type one at the wrong
|
|
209
|
+
level the CLI finds it for you:
|
|
210
|
+
|
|
211
|
+
```
|
|
212
|
+
$ hubblenetwork list-devices
|
|
213
|
+
|
|
214
|
+
Usage: hubblenetwork [OPTIONS] COMMAND [ARGS]...
|
|
215
|
+
Try 'hubblenetwork --help' for help.
|
|
216
|
+
|
|
217
|
+
Error: No such command 'list-devices'.
|
|
218
|
+
|
|
219
|
+
Did you mean: hubblenetwork org list-devices
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
The same applies to missing arguments (they say how to find the value), unknown options
|
|
223
|
+
(they list what the command accepts), and missing credentials (they name the environment
|
|
224
|
+
variables and the flags). `validate-credentials` exits 1 when credentials are invalid, so
|
|
225
|
+
scripts can branch on it.
|
|
226
|
+
|
|
173
227
|
### Payload format option
|
|
174
228
|
|
|
175
|
-
Commands that output packet data (`ble scan`, `ble detect`, `org get-packets`) support the `--payload-format` flag to control how payloads are displayed:
|
|
229
|
+
Commands that output packet data (`ble scan`, `sat scan`, `ble detect`, `org get-packets`) support the `--payload-format` flag to control how payloads are displayed:
|
|
176
230
|
|
|
177
|
-
* `
|
|
231
|
+
* `auto` — printable ASCII shows as text, anything else as uppercase hex
|
|
232
|
+
* `base64` — encode payloads as base64
|
|
178
233
|
* `hex` — display payloads as hexadecimal
|
|
179
234
|
* `string` — decode payloads as UTF-8 text (falls back to `<invalid UTF-8>` if bytes are not valid UTF-8)
|
|
180
235
|
|
|
181
|
-
|
|
236
|
+
All four values work with every output format, but the **default** differs by
|
|
237
|
+
format, because a person and a program want different things. Tabular output
|
|
238
|
+
defaults to `auto`, so a decrypted payload reads as `T=21.4` rather than
|
|
239
|
+
`VD0yMS40`. JSON and CSV default to `base64` so the machine contract stays
|
|
240
|
+
stable. An explicit `--payload-format` always wins.
|
|
241
|
+
|
|
242
|
+
### Organization commands
|
|
243
|
+
|
|
244
|
+
`org list-devices` and `org get-packets` stream rows as pages arrive, so the first
|
|
245
|
+
rows appear in about a second rather than after the whole window downloads. A busy
|
|
246
|
+
device can hold tens of thousands of packets; Ctrl+C stops early and still prints a
|
|
247
|
+
summary, and `--limit N` caps the run (it says how it stopped, never silently).
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
hubblenetwork org info
|
|
251
|
+
hubblenetwork org list-devices # streams, tags summarised once
|
|
252
|
+
hubblenetwork org list-devices -f json # machine-readable
|
|
253
|
+
hubblenetwork org list-devices -n 20
|
|
254
|
+
hubblenetwork org get-packets <id> -n 50 --debug
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
`list-devices` takes `--format tabular|json` and `--limit`. `get-packets` takes
|
|
258
|
+
`--limit` and `--debug` (which adds `EPOCH`, `CTR` and `SEQ` columns). As with the
|
|
259
|
+
scan commands, rows go to stdout and headings, progress and summaries go to stderr.
|
|
260
|
+
|
|
261
|
+
The SDK mirrors this: `Organization.iter_devices()` and `Organization.iter_packets()`
|
|
262
|
+
are generators that yield as pages arrive, and both accept an `on_page(page, total)`
|
|
263
|
+
callback for progress. `list_devices()` and `retrieve_packets()` still return lists.
|
|
264
|
+
|
|
265
|
+
### Scan output layout
|
|
266
|
+
|
|
267
|
+
`ble scan` and `sat scan` print one line per packet with a signal bar, and close
|
|
268
|
+
with a summary on stderr:
|
|
269
|
+
|
|
270
|
+
```
|
|
271
|
+
TIME RSSI V EID CTR/SEQ PAYLOAD
|
|
272
|
+
─────────────────────────────────────────────────────────────────────────────
|
|
273
|
+
✓ 00:06:40 -62 ███▏ 2 9c4e2ab77d3f0e1a 20320 T=21.4,B=87
|
|
274
|
+
✓ 00:06:43 -66 ██▉ 2 9c4e2ab77d3f0e1b 20321 T=21.4,B=87
|
|
275
|
+
✗ 00:06:49 -74 ██▏ 2 9c4e2ab77d3f0e1d - D307912C66BA4018E5
|
|
276
|
+
─────────────────────────────────────────────────────────────────────────────
|
|
277
|
+
|
|
278
|
+
4 packets · 3 decrypted, 1 failed · RSSI -62 to -74 dBm · 12s
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
The bar next to RSSI is signal strength: length is the magnitude, so you can watch
|
|
282
|
+
it shrink as you walk away from a device. The `✓`/`✗` mark only appears with
|
|
283
|
+
`--show-failed-decryption`, and the mark carries the state on its own, so the output
|
|
284
|
+
still reads correctly without colour.
|
|
285
|
+
|
|
286
|
+
### Terminals that can't do box-drawing
|
|
287
|
+
|
|
288
|
+
Not every terminal can render `─` and `█`. Writing them to a stdout using a legacy
|
|
289
|
+
code page raises `UnicodeEncodeError`, and because most of them are East Asian Width
|
|
290
|
+
"Ambiguous" they render double-width under a CJK terminal configuration, which shears
|
|
291
|
+
every column.
|
|
292
|
+
|
|
293
|
+
Pass `--ascii` (or set `HUBBLE_ASCII=1`) for a pure-ASCII rendering with identical
|
|
294
|
+
column widths:
|
|
295
|
+
|
|
296
|
+
```
|
|
297
|
+
TIME RSSI V EID CTR/SEQ PAYLOAD
|
|
298
|
+
---------------------------------------------------------------------------
|
|
299
|
+
15:50:13 -62 ###= 0 2030405 300 0A0B0C0D0E0F
|
|
300
|
+
---------------------------------------------------------------------------
|
|
301
|
+
|
|
302
|
+
1 packets | RSSI -62 to -62 dBm | 0s
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
The encoding case is detected automatically, so you only need the flag for the
|
|
306
|
+
double-width one. `--no-ascii` forces the Unicode rendering if the detection is
|
|
307
|
+
wrong for you.
|
|
308
|
+
|
|
309
|
+
Colour is a separate axis: `--no-color`, `NO_COLOR=1`, or a non-TTY stdout all
|
|
310
|
+
disable it, and `FORCE_COLOR=1` keeps it on where a pipe would otherwise strip it
|
|
311
|
+
(useful in CI). Both flags work on any command, before or after the subcommand.
|
|
312
|
+
|
|
313
|
+
Packet rows go to stdout and everything else (the scanning notice, detection
|
|
314
|
+
lines, the summary) goes to stderr, so `hubblenetwork ble scan > packets.txt`
|
|
315
|
+
captures data only. Pass `--debug` to add the forensic columns: `EPOCH`, `TAG`
|
|
316
|
+
and `SALT` for `ble scan`, `RS_CORR`, `SYM_MS` and `GAP_MS` for `sat scan`.
|
|
182
317
|
|
|
183
318
|
## Validating a device end-to-end
|
|
184
319
|
|
|
@@ -241,7 +376,7 @@ hubblenetwork sat scan --timeout 30
|
|
|
241
376
|
# Stop after receiving 5 packets
|
|
242
377
|
hubblenetwork sat scan -n 5
|
|
243
378
|
|
|
244
|
-
# JSON output (
|
|
379
|
+
# JSON output (a single array, streamed as packets arrive)
|
|
245
380
|
hubblenetwork sat scan -o json
|
|
246
381
|
|
|
247
382
|
# Combine options
|
|
@@ -250,15 +385,20 @@ hubblenetwork sat scan -o json --timeout 60 -n 20
|
|
|
250
385
|
# Decrypt payloads locally with a device key (hex or base64, 16 or 32 bytes)
|
|
251
386
|
hubblenetwork sat scan --key "a562a2f7e4c62bed52ab09633878f62b"
|
|
252
387
|
|
|
253
|
-
#
|
|
388
|
+
# Force the DEVICE_UPTIME counter instead of auto-detecting
|
|
389
|
+
hubblenetwork sat scan --key "<key>" --counter-mode DEVICE_UPTIME
|
|
390
|
+
|
|
391
|
+
# Show packets the key can't decrypt too (adds a ✓/✗ decrypt mark per row)
|
|
254
392
|
hubblenetwork sat scan --key "<key>" --show-failed-decryption
|
|
255
393
|
```
|
|
256
394
|
|
|
257
395
|
When `--key` is supplied, each packet's payload is decrypted locally using the
|
|
258
|
-
same AES-CTR scheme as BLE
|
|
259
|
-
counter
|
|
260
|
-
|
|
261
|
-
`--
|
|
396
|
+
same AES-CTR scheme as BLE, which supports both the UNIX_TIME (day-based) and
|
|
397
|
+
DEVICE_UPTIME counter sources. The counter source is auto-detected from the
|
|
398
|
+
packets (and announced) unless `--counter-mode UNIX_TIME|DEVICE_UPTIME` is given.
|
|
399
|
+
For the UNIX_TIME counter, `--days` controls how many days around each packet's
|
|
400
|
+
timestamp are searched (default 2). Packets the key cannot decrypt are hidden
|
|
401
|
+
unless `--show-failed-decryption` is given.
|
|
262
402
|
|
|
263
403
|
The command automatically:
|
|
264
404
|
1. Verifies Docker is available
|
|
@@ -268,6 +408,31 @@ The command automatically:
|
|
|
268
408
|
5. Streams new packets as they arrive (deduplicating by device ID + sequence number)
|
|
269
409
|
6. Stops and removes the container on exit or Ctrl+C
|
|
270
410
|
|
|
411
|
+
### One-shot capture (`record` / `signal-report`)
|
|
412
|
+
|
|
413
|
+
Alongside the live `scan` stream, two one-shot commands record for a fixed
|
|
414
|
+
duration, save a single file, and exit. Both accept `--output PATH` (default: an
|
|
415
|
+
auto-generated timestamped name), `--mock` (use the simulated receiver — no
|
|
416
|
+
PlutoSDR required), `--pluto-uri`, and `--debug`.
|
|
417
|
+
|
|
418
|
+
```bash
|
|
419
|
+
# Capture 10 s of raw IQ samples to a .npy file (for offline analysis / reprocessing)
|
|
420
|
+
hubblenetwork sat record 10
|
|
421
|
+
hubblenetwork sat record 10 --output capture.npy
|
|
422
|
+
|
|
423
|
+
# Record 10 s and save an RF signal-diagnostic report to a .txt file
|
|
424
|
+
hubblenetwork sat signal-report 10
|
|
425
|
+
hubblenetwork sat signal-report 10 --output report.txt --mock
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
- **`record`** captures the raw radio signal only — no decoding. The output is a
|
|
429
|
+
NumPy `.npy` file of IQ samples.
|
|
430
|
+
- **`signal-report`** records IQ, then re-analyzes it offline into a plain-text
|
|
431
|
+
**link-health diagnostic**: per-symbol timing/drift, channel-hopping
|
|
432
|
+
validation, amplitude/SNR, and chipset metrics. It reports on signal quality
|
|
433
|
+
and does **not** contain decoded packet payloads — to receive payloads, use
|
|
434
|
+
`sat scan` (optionally with `--key`).
|
|
435
|
+
|
|
271
436
|
### Python API
|
|
272
437
|
|
|
273
438
|
```python
|
|
@@ -280,7 +445,12 @@ for pkt in sat.scan(timeout=60.0, poll_interval=2.0):
|
|
|
280
445
|
# Or fetch the current packet buffer without managing the container yourself
|
|
281
446
|
packets: list[SatellitePacket] = sat.fetch_packets()
|
|
282
447
|
|
|
283
|
-
#
|
|
448
|
+
# One-shot captures (manage the container, run once, return the result)
|
|
449
|
+
iq_bytes: bytes = sat.record(10.0) # raw IQ samples (.npy file body)
|
|
450
|
+
report: str = sat.signal_report(10.0) # plain-text RF signal-diagnostic report
|
|
451
|
+
|
|
452
|
+
# Decrypt a packet's payload locally.
|
|
453
|
+
# counter_mode defaults to UNIX_TIME; pass DEVICE_UPTIME for uptime-based EIDs.
|
|
284
454
|
from hubblenetwork import decrypt_satellite
|
|
285
455
|
|
|
286
456
|
for pkt in sat.scan(timeout=60.0):
|
|
@@ -288,6 +458,7 @@ for pkt in sat.scan(timeout=60.0):
|
|
|
288
458
|
plaintext = decrypt_satellite(
|
|
289
459
|
key, seq_no=pkt.seq_num, auth_tag=pkt.auth_tag,
|
|
290
460
|
encrypted_payload=pkt.payload, timestamp=pkt.timestamp,
|
|
461
|
+
counter_mode="UNIX_TIME",
|
|
291
462
|
)
|
|
292
463
|
if plaintext is not None:
|
|
293
464
|
print(pkt.device_id, plaintext)
|
|
@@ -304,19 +475,38 @@ for pkt in sat.scan(timeout=60.0):
|
|
|
304
475
|
|
|
305
476
|
## Configuration
|
|
306
477
|
|
|
307
|
-
|
|
478
|
+
The **CLI** reads two environment variables:
|
|
308
479
|
|
|
309
|
-
* `HUBBLE_ORG_ID` —
|
|
310
|
-
* `HUBBLE_API_TOKEN` — API token
|
|
311
|
-
|
|
312
|
-
Example:
|
|
480
|
+
* `HUBBLE_ORG_ID` — your organization id
|
|
481
|
+
* `HUBBLE_API_TOKEN` — your API token, passed through as a bearer token
|
|
313
482
|
|
|
314
483
|
```bash
|
|
315
484
|
export HUBBLE_ORG_ID=org_123
|
|
316
485
|
export HUBBLE_API_TOKEN=sk_XXXX
|
|
317
486
|
```
|
|
318
487
|
|
|
319
|
-
|
|
488
|
+
Every command that needs credentials also takes `--org-id` and `--token`, and
|
|
489
|
+
`--help` names the environment variable for each. On the `org` and `metrics`
|
|
490
|
+
groups those flags belong to the group, so they go before the subcommand:
|
|
491
|
+
|
|
492
|
+
```bash
|
|
493
|
+
hubblenetwork org --org-id <id> --token <token> list-devices
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
Check whichever route you used with `hubblenetwork validate-credentials`.
|
|
497
|
+
|
|
498
|
+
**The SDK does not read the environment.** `Organization()` requires its
|
|
499
|
+
credentials explicitly, so exporting the variables does nothing for library code:
|
|
500
|
+
|
|
501
|
+
```python
|
|
502
|
+
from hubblenetwork import Organization
|
|
503
|
+
import os
|
|
504
|
+
|
|
505
|
+
org = Organization(
|
|
506
|
+
org_id=os.environ["HUBBLE_ORG_ID"],
|
|
507
|
+
api_token=os.environ["HUBBLE_API_TOKEN"],
|
|
508
|
+
)
|
|
509
|
+
```
|
|
320
510
|
|
|
321
511
|
## Public API (summary)
|
|
322
512
|
|
|
@@ -324,10 +514,13 @@ Import from the package top-level for a stable surface:
|
|
|
324
514
|
|
|
325
515
|
```python
|
|
326
516
|
from hubblenetwork import (
|
|
327
|
-
ble, cloud, sat,
|
|
517
|
+
ble, cloud, ready, sat,
|
|
328
518
|
Organization, Device, Credentials, Environment,
|
|
329
|
-
EncryptedPacket,
|
|
330
|
-
|
|
519
|
+
EncryptedPacket, UnencryptedPacket, AesEaxPacket, UnknownPacket,
|
|
520
|
+
DecryptedPacket, SatellitePacket, Location,
|
|
521
|
+
decrypt, decrypt_eax, decrypt_satellite,
|
|
522
|
+
UNIX_TIME, DEVICE_UPTIME,
|
|
523
|
+
InvalidCredentialsError,
|
|
331
524
|
)
|
|
332
525
|
```
|
|
333
526
|
|
|
@@ -340,6 +533,11 @@ Key objects & functions:
|
|
|
340
533
|
* `Location` data about where a packet was seen.
|
|
341
534
|
* `ble.scan` function for locally scanning for devices with BLE.
|
|
342
535
|
* `sat.scan` generator for receiving satellite packets via PlutoSDR (requires Docker).
|
|
536
|
+
* `Organization.iter_devices()` / `iter_packets()` generators that yield as each API
|
|
537
|
+
page arrives instead of accumulating, so you can start processing immediately on a
|
|
538
|
+
device with tens of thousands of packets. Both take an optional
|
|
539
|
+
`on_page(page, total_so_far)` callback. `list_devices()` and `retrieve_packets()`
|
|
540
|
+
are `list()` wrappers over them and still return lists.
|
|
343
541
|
|
|
344
542
|
See code for full details.
|
|
345
543
|
|
|
@@ -348,7 +546,6 @@ See code for full details.
|
|
|
348
546
|
Set up a virtualenv and install dev deps:
|
|
349
547
|
|
|
350
548
|
```bash
|
|
351
|
-
cd python
|
|
352
549
|
python3 -m venv .venv
|
|
353
550
|
source .venv/bin/activate
|
|
354
551
|
pip install -e '.[dev]'
|
|
@@ -363,7 +560,19 @@ ruff check src
|
|
|
363
560
|
## Troubleshooting
|
|
364
561
|
|
|
365
562
|
* **`ble.scan()` finds nothing**: verify BLE permissions and adapter state; try increasing `timeout`.
|
|
366
|
-
* **
|
|
563
|
+
* **macOS: `ble scan` crashes instead of prompting for Bluetooth** — you'll see
|
|
564
|
+
`Termination Reason: Namespace TCC` and a message about a missing
|
|
565
|
+
`NSBluetoothAlwaysUsageDescription` key. macOS refuses CoreBluetooth to any
|
|
566
|
+
executable without that key in an Info.plist, and Homebrew's `python3` binary has
|
|
567
|
+
no Info.plist at all. Run from a real terminal app (Terminal, iTerm) rather than an
|
|
568
|
+
embedded IDE shell and grant it Bluetooth under System Settings → Privacy &
|
|
569
|
+
Security → Bluetooth. If it still aborts, run the CLI through a small app bundle
|
|
570
|
+
that carries the key; the framework build at
|
|
571
|
+
`$(brew --prefix)/Frameworks/Python.framework/Versions/<ver>/Resources/Python.app`
|
|
572
|
+
is a usable starting point to copy and amend.
|
|
573
|
+
* **Auth errors**: confirm `Organization(org_id, api_token)` or env vars are set; check
|
|
574
|
+
token scope/expiry. `hubblenetwork validate-credentials` reports which environment
|
|
575
|
+
accepted them and exits 1 if neither did, so it is safe to use in a script.
|
|
367
576
|
* **Import errors**: ensure you installed into the Python you’re running (`python -m pip …`). Prefer `pipx` for CLI-only usage.
|
|
368
577
|
* **`DockerError: Docker is not available`**: Docker daemon is not running. Start Docker Desktop (macOS/Windows) or `sudo systemctl start docker` (Linux).
|
|
369
578
|
* **`DockerError: The ‘docker’ Python package is required`**: run `pip install docker` (it is bundled with `pyhubblenetwork` but may be missing in some environments).
|
|
@@ -371,6 +580,31 @@ ruff check src
|
|
|
371
580
|
* **`sat scan` hangs pulling the image**: first run fetches `ghcr.io/hubblenetwork/sdr-docker:latest`; this may take a minute on a slow connection. Subsequent runs use the cached image.
|
|
372
581
|
|
|
373
582
|
|
|
583
|
+
## Telemetry
|
|
584
|
+
|
|
585
|
+
**There is none.** The CLI makes no network call except the ones a command
|
|
586
|
+
explicitly needs: the Hubble Cloud API for `org` and `metrics`, `localhost` for the
|
|
587
|
+
satellite receiver container, and Docker pulling that container image from
|
|
588
|
+
`ghcr.io` on first `sat` use. Nothing is reported anywhere about how you use it.
|
|
589
|
+
|
|
590
|
+
If that changes, these are the constraints it would have to meet, recorded here so
|
|
591
|
+
the bar is set before anyone writes the code:
|
|
592
|
+
|
|
593
|
+
* **Opt-in only.** Off by default, no collection before an explicit yes, and no
|
|
594
|
+
dark-pattern prompt that treats a dismissed dialog as consent.
|
|
595
|
+
* **Nothing sensitive, ever.** No API tokens, org IDs, device IDs, encryption keys,
|
|
596
|
+
payloads, coordinates, hostnames, or file paths. This tool handles customer device
|
|
597
|
+
keys, so the bar is higher than for a typical CLI. Command name, exit status, and
|
|
598
|
+
version is the ceiling.
|
|
599
|
+
* **Documented in this file**, listing every field actually sent, not a link to a
|
|
600
|
+
policy page.
|
|
601
|
+
* **Killable two ways**, a flag and an environment variable, both honoured on every
|
|
602
|
+
command.
|
|
603
|
+
* **Never blocks or slows a command.** No network call on the critical path, and
|
|
604
|
+
silent failure when offline.
|
|
605
|
+
* **Tested.** A test asserting the payload contains no credential and no device
|
|
606
|
+
identifier, so a future field cannot quietly widen it.
|
|
607
|
+
|
|
374
608
|
## Releases & versioning
|
|
375
609
|
|
|
376
610
|
Follows **SemVer** (MAJOR.MINOR.PATCH). Pushing a version tag triggers a GitHub Actions workflow that runs tests, builds the package, creates a GitHub Release, and publishes to PyPI.
|