Commands¶
BLE Commands¶
gopro_sdk.commands.ble_commands.BleCommands
¶
BLE command interface.
Implements commands that need to be executed via BLE, mainly: - COHN configuration workflow - Network management commands - Other BLE-specific commands
Initialize BLE command interface.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ble_manager
|
BleConnectionManager
|
BLE connection manager |
required |
Functions¶
set_shutter
async
¶
Control recording shutter via BLE.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enable
|
bool
|
True to start recording, False to stop recording |
required |
Raises:
| Type | Description |
|---|---|
BleConnectionError
|
Command send failed or response error |
set_date_time
async
¶
Set camera date and time via BLE.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dt
|
datetime | None
|
Datetime to set, None uses current system time |
None
|
tz_offset
|
int
|
Timezone offset (UTC hours), e.g., UTC+8 is 8 |
0
|
is_dst
|
bool
|
Whether daylight saving time |
False
|
Raises:
| Type | Description |
|---|---|
BleConnectionError
|
Command send failed or response error |
tag_hilight
async
¶
Tag highlight during recording via BLE.
Raises:
| Type | Description |
|---|---|
BleConnectionError
|
Command send failed or response error |
load_preset
async
¶
Load specified preset via BLE.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
preset_id
|
int
|
Preset ID |
required |
Raises:
| Type | Description |
|---|---|
BleConnectionError
|
Command send failed or response error |
load_preset_group
async
¶
Load preset group via BLE.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group_id
|
int
|
Preset group ID |
required |
Raises:
| Type | Description |
|---|---|
BleConnectionError
|
Command send failed or response error |
sleep
async
¶
Put camera to sleep via BLE.
Raises:
| Type | Description |
|---|---|
BleConnectionError
|
Command send failed or response error |
reboot
async
¶
Reboot camera via BLE.
Raises:
| Type | Description |
|---|---|
BleConnectionError
|
Command send failed or response error |
release_network
async
¶
Disconnect camera's WiFi connection (return from STA mode to AP mode).
Purpose: - When camera is connected to router (STA mode), WiFi chip is occupied and cannot scan - Call this method to disconnect, return camera to AP mode for WiFi reconfiguration
Raises:
| Type | Description |
|---|---|
BleConnectionError
|
Disconnect failed |
get_cohn_status
async
¶
Get current COHN status.
Returns:
| Type | Description |
|---|---|
NotifyCOHNStatus
|
COHN status information, including network connection state, configuration state, IP address, etc. |
Raises:
| Type | Description |
|---|---|
BleConnectionError
|
BLE communication failed |
configure_cohn
async
¶
Configure COHN (Camera on Home Network).
Workflow: 1. Clear existing certificate 2. Create new certificate 3. Get certificate and credentials 4. Wait for network connection
Returns:
| Type | Description |
|---|---|
CohnCredentials
|
COHN credentials |
Raises:
| Type | Description |
|---|---|
CohnConfigurationError
|
Configuration failed |
scan_wifi_networks
async
¶
Scan WiFi networks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
float | None
|
Scan timeout (seconds), defaults to configured value - Normal scan usually completes within 3-5 seconds - If camera is in STA mode (connected to WiFi), scan will fail - Using shorter timeout can quickly detect failure and fall back to direct connect mode |
None
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
List of WiFi networks, each containing ssid, signal_strength, flags, etc. |
Raises:
| Type | Description |
|---|---|
BleConnectionError
|
Scan failed |
TimeoutError
|
Scan timeout (possibly because camera is in STA mode) |
connect_to_wifi
async
¶
connect_to_wifi(
ssid: str,
password: str,
timeout: float | None = None,
has_cohn_credentials: bool = False,
) -> None
Connect to WiFi network (compliant with OpenGoPro official specification).
Correct workflow (official requirement): 1. Scan WiFi networks 2. Check target SSID's SCAN_FLAG_CONFIGURED flag 3. Choose command based on flag: - Has CONFIGURED flag → RequestConnect (no password) - No CONFIGURED flag → RequestConnectNew (with password)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ssid
|
str
|
WiFi SSID |
required |
password
|
str
|
WiFi password |
required |
timeout
|
float | None
|
Connection timeout (seconds), defaults to configured value |
None
|
has_cohn_credentials
|
bool
|
Whether has COHN credentials (for optimization: can skip scan when has credentials) |
False
|
Raises:
| Type | Description |
|---|---|
BleConnectionError
|
Connection failed |
Reference: https://gopro.github.io/OpenGoPro/ble/features/access_points.html
enable_wifi_ap
async
¶
Enable/disable WiFi access point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enable
|
bool
|
True to enable, False to disable |
required |
Raises:
| Type | Description |
|---|---|
BleConnectionError
|
Command failed |
get_hardware_info
async
¶
Get hardware information.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Hardware information dictionary |
Raises:
| Type | Description |
|---|---|
BleConnectionError
|
Command failed |
HTTP Commands¶
gopro_sdk.commands.http_commands.HttpCommands
¶
HTTP command interface.
Implements commands executed via HTTP (recording, settings, status, etc.).
Initialize HTTP command interface.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
http_manager
|
HttpConnectionManager
|
HTTP connection manager |
required |
Functions¶
set_shutter
async
¶
Control recording shutter (start/stop recording).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enable
|
bool
|
True to start recording, False to stop recording |
required |
Raises:
| Type | Description |
|---|---|
HttpConnectionError
|
Command failed |
set_preview_stream
async
¶
Control preview stream (start/stop).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enable
|
bool
|
True to start, False to stop |
required |
port
|
int | None
|
Preview stream port (only required when starting), default 8554 |
None
|
Raises:
| Type | Description |
|---|---|
HttpConnectionError
|
Command failed |
tag_hilight
async
¶
get_camera_state
async
¶
Get complete camera state (including all settings and status).
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Status dictionary |
Raises:
| Type | Description |
|---|---|
HttpConnectionError
|
Command failed |
get_camera_info
async
¶
Get camera information (firmware version, etc.).
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Camera information dictionary |
Raises:
| Type | Description |
|---|---|
HttpConnectionError
|
Command failed |
set_keep_alive
async
¶
Send keep-alive signal to maintain connection.
Raises:
| Type | Description |
|---|---|
HttpConnectionError
|
Command failed |
set_date_time
async
¶
Set camera date and time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dt
|
datetime | None
|
Datetime object, default uses current time |
None
|
tz_offset
|
int
|
Timezone offset (hours), default 0 |
0
|
is_dst
|
bool
|
Whether daylight saving time is active, default False |
False
|
Raises:
| Type | Description |
|---|---|
HttpConnectionError
|
Command failed |
get_date_time
async
¶
Get camera date and time.
Returns:
| Type | Description |
|---|---|
datetime
|
Datetime object |
Raises:
| Type | Description |
|---|---|
HttpConnectionError
|
Command failed |
get_setting
async
¶
Get value of specified setting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
setting_id
|
int
|
Setting ID |
required |
Returns:
| Type | Description |
|---|---|
Any
|
Setting value |
Raises:
| Type | Description |
|---|---|
HttpConnectionError
|
Command failed |
set_setting
async
¶
Modify value of specified setting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
setting_id
|
int
|
Setting ID |
required |
value
|
int
|
Setting value |
required |
Raises:
| Type | Description |
|---|---|
HttpConnectionError
|
Command failed |
get_preset_status
async
¶
Get preset status.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include_hidden
|
bool
|
Whether to include hidden presets |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Preset status dictionary |
Raises:
| Type | Description |
|---|---|
HttpConnectionError
|
Command failed |
load_preset
async
¶
Load specified preset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
preset_id
|
int
|
Preset ID |
required |
Raises:
| Type | Description |
|---|---|
HttpConnectionError
|
Command failed |
load_preset_group
async
¶
Load preset group.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group_id
|
int
|
Preset group ID |
required |
Raises:
| Type | Description |
|---|---|
HttpConnectionError
|
Command failed |
set_digital_zoom
async
¶
Set digital zoom.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
percent
|
int
|
Zoom percentage (0-100) |
required |
Raises:
| Type | Description |
|---|---|
HttpConnectionError
|
Command failed |
reboot
async
¶
Media Commands¶
gopro_sdk.commands.media_commands.MediaCommands
¶
Media management command interface.
Initialize media command interface.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
http_manager
|
HttpConnectionManager
|
HTTP connection manager |
required |
Functions¶
get_media_list
async
¶
List all media files.
Uses the Open GoPro SDK's MediaList to parse the response, then converts to custom MediaFile.
Returns:
| Type | Description |
|---|---|
list[MediaFile]
|
Media file list (MediaFile objects) |
Raises:
| Type | Description |
|---|---|
HttpConnectionError
|
Command failed |
download_file
async
¶
download_file(
media_file: MediaFile | str,
save_path: str | Path,
progress_callback: Callable[[int, int], None]
| None = None,
) -> int
Download media file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
media_file
|
MediaFile | str
|
MediaFile object or file path (e.g., "100GOPRO/GX010001.MP4") |
required |
save_path
|
str | Path
|
Save path |
required |
progress_callback
|
Callable[[int, int], None] | None
|
Progress callback function (downloaded: int, total: int) -> None |
None
|
Returns:
| Type | Description |
|---|---|
int
|
Number of bytes downloaded |
Raises:
| Type | Description |
|---|---|
HttpConnectionError
|
Download failed |
delete_file
async
¶
Delete single media file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
File path (e.g., "100GOPRO/GX010001.MP4") |
required |
Raises:
| Type | Description |
|---|---|
HttpConnectionError
|
Deletion failed |
delete_all_media
async
¶
get_media_metadata
async
¶
Get media file metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
File path |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Metadata dictionary |
Raises:
| Type | Description |
|---|---|
HttpConnectionError
|
Command failed |
get_last_captured_media
async
¶
Get information about last captured media file.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Media information dictionary |
Raises:
| Type | Description |
|---|---|
HttpConnectionError
|
Command failed |
set_turbo_mode
async
¶
Enable/disable Turbo transfer mode (accelerates downloads).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enable
|
bool
|
True to enable, False to disable |
required |
Raises:
| Type | Description |
|---|---|
HttpConnectionError
|
Command failed |
Webcam Commands¶
gopro_sdk.commands.webcam_commands.WebcamCommands
¶
Webcam mode command interface.
Initialize Webcam command interface.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
http_manager
|
HttpConnectionManager
|
HTTP connection manager |
required |
Functions¶
webcam_start
async
¶
webcam_start(
resolution: int | None = None,
fov: int | None = None,
port: int | None = None,
protocol: str | None = None,
) -> dict[str, Any]
Start Webcam mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resolution
|
int | None
|
Resolution (4=480p, 7=720p, 12=1080p) |
None
|
fov
|
int | None
|
Field of view (0=Wide, 2=Linear, 3=Narrow) |
None
|
port
|
int | None
|
Port (default 8554) |
None
|
protocol
|
str | None
|
Protocol (default "TS") |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Webcam response |
Raises:
| Type | Description |
|---|---|
HttpConnectionError
|
Command failed |
webcam_stop
async
¶
Stop Webcam mode.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Webcam response |
Raises:
| Type | Description |
|---|---|
HttpConnectionError
|
Command failed |
webcam_status
async
¶
Get Webcam status.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Webcam status dictionary |
Raises:
| Type | Description |
|---|---|
HttpConnectionError
|
Command failed |
webcam_preview
async
¶
Start Webcam preview.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Webcam response |
Raises:
| Type | Description |
|---|---|
HttpConnectionError
|
Command failed |
webcam_exit
async
¶
Exit Webcam mode.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Webcam response |
Raises:
| Type | Description |
|---|---|
HttpConnectionError
|
Command failed |
get_webcam_version
async
¶
Get Webcam implementation version.
Returns:
| Type | Description |
|---|---|
str
|
Version string |
Raises:
| Type | Description |
|---|---|
HttpConnectionError
|
Command failed |
Command Base¶
gopro_sdk.commands.base
¶
Command base classes and decorators.
Classes¶
Functions¶
with_http_retry
¶
with_http_retry(
max_retries: int = 3, backoff_factor: float = 1.0
) -> Callable[[Callable[..., T]], Callable[..., T]]
HTTP command retry decorator.
Automatically retries failed HTTP commands using exponential backoff strategy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_retries
|
int
|
Maximum retry count |
3
|
backoff_factor
|
float
|
Backoff factor (seconds) |
1.0
|
Returns:
| Type | Description |
|---|---|
Callable[[Callable[..., T]], Callable[..., T]]
|
Decorated function |
Usage example
@with_http_retry(max_retries=3, backoff_factor=2.0) ... async def my_http_command(self): ... # HTTP command implementation ... pass