python-gopro 0.1.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.
@@ -0,0 +1,5 @@
1
+ __pycache__/
2
+ *.pyc
3
+ .venv/
4
+ dist/
5
+ .pytest_cache/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Hudson Brendon
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,103 @@
1
+ Metadata-Version: 2.5
2
+ Name: python-gopro
3
+ Version: 0.1.0
4
+ Summary: Async local client for GoPro cameras (HTTPS over Camera-on-Home-Network + BLE), built from reverse engineering the MAX2 firmware
5
+ Project-URL: Homepage, https://github.com/hudsonbrendon/python-gopro
6
+ Project-URL: Repository, https://github.com/hudsonbrendon/python-gopro
7
+ Project-URL: Issues, https://github.com/hudsonbrendon/python-gopro/issues
8
+ Author-email: Hudson Brendon <contato.hudsonbrendon@gmail.com>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: ble,cohn,gopro,hero13,home-assistant,max2,open-gopro,reverse-engineering
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Framework :: AsyncIO
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Topic :: Home Automation
20
+ Classifier: Topic :: Multimedia :: Video :: Capture
21
+ Requires-Python: >=3.12
22
+ Requires-Dist: aiohttp>=3.9
23
+ Provides-Extra: ble
24
+ Requires-Dist: bleak>=0.22; extra == 'ble'
25
+ Description-Content-Type: text/markdown
26
+
27
+ # python-gopro
28
+
29
+ [![PyPI](https://img.shields.io/pypi/v/python-gopro.svg)](https://pypi.org/project/python-gopro/)
30
+ [![Tests](https://github.com/hudsonbrendon/python-gopro/actions/workflows/tests.yml/badge.svg)](https://github.com/hudsonbrendon/python-gopro/actions/workflows/tests.yml)
31
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
32
+
33
+ Async, local client for GoPro cameras: HTTPS over **Camera on the Home Network (COHN)** and **BLE**.
34
+ It was built by reverse engineering a **GoPro MAX2** (firmware H24.02.01.34.00) and its Linux userland,
35
+ and it is the communication layer of the [GoPro Home Assistant integration](https://github.com/hudsonbrendon/ha-gopro).
36
+
37
+ * No cloud, no USB cable: the camera joins your Wi-Fi once (provisioned over BLE) and is reachable at
38
+ `https://<ip>` with basic auth and its own root CA.
39
+ * **Self-describing**: settings, options, statuses, modes, commands and option filters are read from the
40
+ camera itself (`GET /gp/gpControl`), so HERO12/HERO13/MAX2 and future firmwares work without code changes.
41
+ * Legacy `/gp/gpControl/command/*` routes recovered from the firmware (locate, sleep, tag moment...).
42
+ * BLE: pairing, hardware info, statuses, settings, shutter, presets, date/time, Wi-Fi scan + provisioning,
43
+ COHN certificate/status, keep-alive and wake.
44
+
45
+ ## Install
46
+
47
+ ```bash
48
+ pip install python-gopro # HTTP only
49
+ pip install "python-gopro[ble]" # + BLE (bleak)
50
+ ```
51
+
52
+ ## Quick start
53
+
54
+ ```python
55
+ import asyncio
56
+ from pygopro import GoProBle, GoProHttp
57
+
58
+ async def main():
59
+ # 1) one-time: put the camera in pairing mode (Preferences > Connections > Connect Device)
60
+ async with GoProBle("GoPro 8832") as ble:
61
+ creds = await ble.provision_cohn("MyWiFi", "wifi-password")
62
+
63
+ # 2) from now on, plain HTTPS on the home network
64
+ async with GoProHttp(creds.host, username=creds.username, password=creds.password,
65
+ certificate=creds.certificate) as cam:
66
+ print(await cam.get_info())
67
+ state = await cam.get_state()
68
+ schema = await cam.get_schema() # every setting/status with names and options
69
+ for sid, value in state.settings.items():
70
+ s = schema.settings.get(sid)
71
+ if s:
72
+ print(s.name, s.option_names.get(value))
73
+ await cam.shutter(True) # start recording
74
+ await cam.shutter(False)
75
+ print(await cam.get_media_list())
76
+
77
+ asyncio.run(main())
78
+ ```
79
+
80
+ CLI:
81
+
82
+ ```bash
83
+ pygopro ble-scan
84
+ pygopro provision --ssid MyWiFi --wifi-password secret --out gopro.json
85
+ pygopro --creds gopro.json state
86
+ pygopro --creds gopro.json locate on
87
+ ```
88
+
89
+ ## Things learned the hard way
90
+
91
+ * **Never call `/gopro/camera/control/wired_usb`.** On the MAX2 it hung and left every `/gopro/*` route
92
+ answering `503 "Unable to establish comminucation with settings controller"`. The power button only
93
+ suspends the camera, so the state survives until the **battery is removed**. The client refuses that
94
+ path and raises `GoProControllerUnavailableError` for the 503.
95
+ * Over BLE, messages must fit in one write; continuation packets written with response are rejected
96
+ (GATT 0xD1). Protobuf queries (`0xF5`) go to the query characteristic.
97
+ * Without valid basic auth the COHN server closes the socket without an answer.
98
+
99
+ See [docs/PROTOCOL.md](docs/PROTOCOL.md) for the full write-up.
100
+
101
+ ## License
102
+
103
+ MIT. Not affiliated with GoPro, Inc. "GoPro" is a trademark of GoPro, Inc.
@@ -0,0 +1,77 @@
1
+ # python-gopro
2
+
3
+ [![PyPI](https://img.shields.io/pypi/v/python-gopro.svg)](https://pypi.org/project/python-gopro/)
4
+ [![Tests](https://github.com/hudsonbrendon/python-gopro/actions/workflows/tests.yml/badge.svg)](https://github.com/hudsonbrendon/python-gopro/actions/workflows/tests.yml)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
6
+
7
+ Async, local client for GoPro cameras: HTTPS over **Camera on the Home Network (COHN)** and **BLE**.
8
+ It was built by reverse engineering a **GoPro MAX2** (firmware H24.02.01.34.00) and its Linux userland,
9
+ and it is the communication layer of the [GoPro Home Assistant integration](https://github.com/hudsonbrendon/ha-gopro).
10
+
11
+ * No cloud, no USB cable: the camera joins your Wi-Fi once (provisioned over BLE) and is reachable at
12
+ `https://<ip>` with basic auth and its own root CA.
13
+ * **Self-describing**: settings, options, statuses, modes, commands and option filters are read from the
14
+ camera itself (`GET /gp/gpControl`), so HERO12/HERO13/MAX2 and future firmwares work without code changes.
15
+ * Legacy `/gp/gpControl/command/*` routes recovered from the firmware (locate, sleep, tag moment...).
16
+ * BLE: pairing, hardware info, statuses, settings, shutter, presets, date/time, Wi-Fi scan + provisioning,
17
+ COHN certificate/status, keep-alive and wake.
18
+
19
+ ## Install
20
+
21
+ ```bash
22
+ pip install python-gopro # HTTP only
23
+ pip install "python-gopro[ble]" # + BLE (bleak)
24
+ ```
25
+
26
+ ## Quick start
27
+
28
+ ```python
29
+ import asyncio
30
+ from pygopro import GoProBle, GoProHttp
31
+
32
+ async def main():
33
+ # 1) one-time: put the camera in pairing mode (Preferences > Connections > Connect Device)
34
+ async with GoProBle("GoPro 8832") as ble:
35
+ creds = await ble.provision_cohn("MyWiFi", "wifi-password")
36
+
37
+ # 2) from now on, plain HTTPS on the home network
38
+ async with GoProHttp(creds.host, username=creds.username, password=creds.password,
39
+ certificate=creds.certificate) as cam:
40
+ print(await cam.get_info())
41
+ state = await cam.get_state()
42
+ schema = await cam.get_schema() # every setting/status with names and options
43
+ for sid, value in state.settings.items():
44
+ s = schema.settings.get(sid)
45
+ if s:
46
+ print(s.name, s.option_names.get(value))
47
+ await cam.shutter(True) # start recording
48
+ await cam.shutter(False)
49
+ print(await cam.get_media_list())
50
+
51
+ asyncio.run(main())
52
+ ```
53
+
54
+ CLI:
55
+
56
+ ```bash
57
+ pygopro ble-scan
58
+ pygopro provision --ssid MyWiFi --wifi-password secret --out gopro.json
59
+ pygopro --creds gopro.json state
60
+ pygopro --creds gopro.json locate on
61
+ ```
62
+
63
+ ## Things learned the hard way
64
+
65
+ * **Never call `/gopro/camera/control/wired_usb`.** On the MAX2 it hung and left every `/gopro/*` route
66
+ answering `503 "Unable to establish comminucation with settings controller"`. The power button only
67
+ suspends the camera, so the state survives until the **battery is removed**. The client refuses that
68
+ path and raises `GoProControllerUnavailableError` for the 503.
69
+ * Over BLE, messages must fit in one write; continuation packets written with response are rejected
70
+ (GATT 0xD1). Protobuf queries (`0xF5`) go to the query characteristic.
71
+ * Without valid basic auth the COHN server closes the socket without an answer.
72
+
73
+ See [docs/PROTOCOL.md](docs/PROTOCOL.md) for the full write-up.
74
+
75
+ ## License
76
+
77
+ MIT. Not affiliated with GoPro, Inc. "GoPro" is a trademark of GoPro, Inc.
@@ -0,0 +1,78 @@
1
+ # GoPro MAX2 — reverse engineering notes
2
+
3
+ Camera: MAX2 (model 64), firmware **H24.02.01.34.00** (2026-10-20). Firmware image from the public
4
+ catalogue `https://api.gopro.com/firmware/v2/catalog`.
5
+
6
+ ## Firmware layout
7
+
8
+ * `UPDATE.zip` → `DATA.bin` (container magic `GPRO`), Socionext **Milbeaut** SoC.
9
+ * First ~80 MB: compressed/encrypted RTOS + boot (EL3 loader verifies hash/signature/AES).
10
+ * Linux **5.15.127** (Yocto poky, aarch64). Root filesystem = ext4 at offset `0x5d03860`, size `0x8bc6000`.
11
+ * GoPro userland in `/usr/local/gopro/bin`: `gpHttpServer` (civetweb 1.11), `gpControlD`, `gpBleSdkD`,
12
+ `gpCamApi`, `gpCertMgr`, `gpNet`, `gpWifi`, `gpUsb`, `gpMtpServer`, `gpsv` (supervisor)...
13
+ * Per-model schema: `/usr/local/gopro/etc/{62,64,65}/settings.json` (HERO12, MAX2, HERO13), served at
14
+ `GET /gp/gpControl`.
15
+
16
+ ## Transport
17
+
18
+ | Link | Address | Auth |
19
+ |------|---------|------|
20
+ | USB (CDC-NCM, VID 0x2672 PID 0x0059) | `http://172.2X.1YZ.51:8080` (X/YZ = serial digits) | none |
21
+ | Camera AP | `http://10.5.5.9:8080` | none (Wi-Fi password) |
22
+ | Home network (COHN) | `https://<dhcp ip>` | basic auth `gopro:<password>`, root CA from BLE |
23
+ | mDNS | `_gopro-web._tcp`, instance = serial | TXT: model, fw_version, protocol_version |
24
+
25
+ Firewall (`/usr/local/gopro/scripts/iptrules`): on `wlan0` only 80, 8080, 443 (tcp/udp), 554, 8554 and ICMP echo.
26
+
27
+ ## Web server
28
+
29
+ * One civetweb context with `listening_ports = 80,8000,8001,8080,443s`, `ssl_certificate=/tmp/fuse_b/s/cw/s.c`,
30
+ `ssl_protocol_version=4` (TLS 1.2+). If the certificate fails to load, `mg_start` returns NULL and *no*
31
+ port listens at all (all interfaces).
32
+ * `gpOpenGoProHandler` (all `/gopro/*`): opens a POSIX mqueue session with `gpControlD` per request
33
+ (`/to_gpCtlD` + reply queue `/to_GPCU<pid>`, 5 × 10000 bytes). Failure → `503 Unable to establish
34
+ comminucation with settings controller`.
35
+ * Legacy `/gp/gpControl/...` command table (`command_handler_table`, 67 entries) and
36
+ `custom_command_handler_table` (20 entries) — see the list below.
37
+
38
+ ### Legacy commands (`/gp/gpControl/<path>`)
39
+
40
+ ```
41
+ command/shutter command/mode command/sub_mode
42
+ command/setup/date_time command/setup/date_time_dst command/fwupdate/download/{start,done,cancel}
43
+ command/storage/tag_moment command/storage/tag_moment/playback[/photo]
44
+ command/storage/delete/{last,all,group,list} command/storage/delete
45
+ command/wireless/ap/control command/wireless/band/select command/wireless/ssid/{scan,list,select,delete}
46
+ command/wireless/rc/pair[/cancel] command/wireless/pair/cancel
47
+ command/{video,photo,multi_shot}/protune/reset command/protune/reset
48
+ command/system/{shutdown,sleep,locate,factory_reset,reset}
49
+ status setting notifications info
50
+ command/transcode/{history,video_to_video,photo_to_video,status,cancel}
51
+ command/liveview/exposure_mode debug/server_level command/set_client_info
52
+ command/digital_zoom command/photo_timer
53
+ command/mobile_offload/{clear_new_media_flag,get_state}
54
+ command/system/{notify_event,get_beacon,set_beacon,enable_beacon}
55
+ command/ble/control command/set_mode command/set_preset
56
+ command/system/{logs_clear,logs_prepare,logs_list}
57
+ command/onscreen_shortcuts_reset command/timewarp_speed_ramp[_active] command/button_set
58
+ command/set_in_contextual_menu command/set_camera_control_status command/system/wired_usb (!)
59
+ command/ble/{pairing_available,pairing_phase,configure,scan,scan/list}
60
+ command/ble/pair/{start,cancel,status} command/ble/whitelist/{list,device,configure}
61
+ execute analytics/get analytics/clear debug/client_level
62
+ command/wireless/pair/complete command/wirelessOffload/{start,stop,pause}
63
+ command/system/suspend_resume_state
64
+ ```
65
+
66
+ Other routes: `/gp/gpMediaList`, `/gp/gpMediaListEx`, `/gp/gpMediaMetadata`, `/gp/version`,
67
+ `/videos/DCIM/...` (directory listing on), `/fa_log` (file access log), `/GoProRootCA.crt`, `/bacpac/cv`.
68
+
69
+ ## COHN certificates (`gpCertMgr`)
70
+
71
+ `openssl` CLI: GoPro root + intermediate CA, camera key, CSR, camera cert for the current IP
72
+ (182 days), concatenated into `s.c`; `killall gpHttpServer` + restart. `ReconcileTime` /
73
+ `ReconcileCertDates` run first; the cert is regenerated when the IP changes.
74
+
75
+ ## Power
76
+
77
+ The power button suspends (`gpSuspend.sh` / `gpResume.sh`); RAM state persists. Pulling the battery is the
78
+ only real reboot.
@@ -0,0 +1,67 @@
1
+ """Local async client for GoPro cameras (Open GoPro HTTP/COHN + BLE)."""
2
+
3
+ from .const import GOPRO_MANUFACTURER_ID, GOPRO_SERVICE_UUID, PresetGroup, Status
4
+ from .exceptions import (
5
+ GoProAuthError,
6
+ GoProBleError,
7
+ GoProCommandError,
8
+ GoProConnectionError,
9
+ GoProControllerUnavailableError,
10
+ GoProError,
11
+ )
12
+ from .firmware import fetch_catalog, latest_for
13
+ from .http import GoProHttp, build_ssl_context
14
+ from .models import (
15
+ AccessPoint,
16
+ CameraInfo,
17
+ CameraState,
18
+ CohnCredentials,
19
+ CohnStatus,
20
+ FirmwareRelease,
21
+ HardwareInfo,
22
+ MediaFile,
23
+ Preset,
24
+ )
25
+ from .schema import Schema, Setting, SettingOption, StatusField
26
+
27
+ __version__ = "0.1.0"
28
+
29
+ __all__ = [
30
+ "GOPRO_MANUFACTURER_ID",
31
+ "GOPRO_SERVICE_UUID",
32
+ "AccessPoint",
33
+ "CameraInfo",
34
+ "CameraState",
35
+ "CohnCredentials",
36
+ "CohnStatus",
37
+ "FirmwareRelease",
38
+ "GoProAuthError",
39
+ "GoProBle",
40
+ "GoProBleError",
41
+ "GoProCommandError",
42
+ "GoProConnectionError",
43
+ "GoProControllerUnavailableError",
44
+ "GoProError",
45
+ "GoProHttp",
46
+ "HardwareInfo",
47
+ "MediaFile",
48
+ "Preset",
49
+ "PresetGroup",
50
+ "Schema",
51
+ "Setting",
52
+ "SettingOption",
53
+ "Status",
54
+ "StatusField",
55
+ "build_ssl_context",
56
+ "fetch_catalog",
57
+ "latest_for",
58
+ ]
59
+
60
+
61
+ def __getattr__(name: str):
62
+ # bleak is optional: import the BLE client lazily.
63
+ if name == "GoProBle":
64
+ from .ble import GoProBle
65
+
66
+ return GoProBle
67
+ raise AttributeError(name)
@@ -0,0 +1,3 @@
1
+ from .cli import main
2
+
3
+ main()