### Build and Get Help for djictl CLI Source: https://github.com/xaionaro-go/djictl/blob/main/README.md This snippet demonstrates how to build the djictl CLI tool using 'make' and then display its general help information. It's the initial step to verify the build and understand the tool's capabilities. ```shell make ./build/djictl-linux-amd64 --help ``` -------------------------------- ### Connect WiFi and Start RTMP Streaming (CLI) Source: https://context7.com/xaionaro-go/djictl/llms.txt Connects a DJI device to a WiFi network and initiates RTMP streaming. This command handles BLE pairing, WiFi configuration, and stream setup with customizable resolution, bitrate, and frame rate. Supports various resolutions (480p, 720p, 1080p) and FPS (25, 30), with bitrate typically ranging from 1000-10000 kbps. ```bash # Basic streaming setup with default settings (1080p, 6000kbps, 30fps) sudo ./djictl ble connect-wifi-and-start-streaming \ --wifi-ssid "MyNetwork" \ --wifi-psk "MyPassword" \ --rtmp-url "rtmp://streaming.server.com/live/stream-key" # Custom resolution and bitrate sudo ./djictl ble connect-wifi-and-start-streaming \ --wifi-ssid "MyNetwork" \ --wifi-psk "MyPassword" \ --rtmp-url "rtmp://192.168.1.100:1935/live/camera1" \ --resolution 720p \ --bitrate-kbps 4000 \ --fps 25 # With debug logging and device filter sudo ./djictl --log-level debug ble --filter-device-addr "AA:BB:CC" \ connect-wifi-and-start-streaming \ --wifi-ssid "StudioWiFi" \ --wifi-psk "securepassword" \ --rtmp-url "rtmp://localhost/live/test" \ --resolution 1080p \ --bitrate-kbps 8000 \ --fps 30 ``` -------------------------------- ### Configure and Start RTMP Live Streaming (Go) Source: https://context7.com/xaionaro-go/djictl/llms.txt Configures and starts RTMP live streaming on an initialized DJI device. Allows customization of resolution, bitrate, and FPS. Requires the device to be connected to WiFi and prepared for streaming. It utilizes `djible` and `duml` packages. ```go package main import ( "context" "fmt" "github.com/xaionaro-go/djictl/pkg/djible" "github.com/xaionaro-go/djictl/pkg/duml" ) func startLiveStream(ctx context.Context, dev *djible.Device, rtmpURL string) error { // Prepare device for live streaming (sends initialization messages) if err := dev.AppToVideoTransmission().PrepareToLiveStream(ctx); err != nil { return fmt.Errorf("failed to prepare for streaming: %w", err) } // Configure and start the live stream // Parameters: resolution, bitrate (kbps), fps, rtmp url err := dev.AppToVideoTransmission().LiveStream( ctx, duml.Resolution1080p, // Options: Resolution480p, Resolution720p, Resolution1080p 6000, // Bitrate in kbps (e.g., 4000-8000 for good quality) duml.FPS30, // Options: FPS24, FPS25, FPS30 rtmpURL, ) if err != nil { return fmt.Errorf("failed to start streaming: %w", err) } return nil } // Complete streaming workflow example func startStreamingWorkflow(ctx context.Context, dev *djible.Device) error { // 1. Initialize device if err := dev.Init(ctx); err != nil { return err } // 2. Pair with device if err := dev.AppToWiFiGroundStation().Pair(ctx); err != nil { return err } // 3. Prepare for streaming if err := dev.AppToVideoTransmission().PrepareToLiveStream(ctx); err != nil { return err } // 4. Connect to WiFi if err := dev.AppToWiFiGroundStation().ConnectToWiFi(ctx, "MyNetwork", "password"); err != nil { return err } // 5. For Osmo Action 4/5 Pro, optionally set image stabilization if dev.Type == duml.DeviceTypeOsmoAction4 || dev.Type == duml.DeviceTypeOsmoAction5Pro { if err := dev.AppToCamera().SetImageStabilization(ctx, duml.ImageStabilizationRockSteadyPlus); err != nil { return err } } // 6. Start streaming (this blocks and reports battery status) return dev.AppToVideoTransmission().LiveStream( ctx, duml.Resolution1080p, 6000, duml.FPS30, "rtmp://streaming.server.com/live/key", ) } ``` -------------------------------- ### Get Help for djictl BLE Commands Source: https://github.com/xaionaro-go/djictl/blob/main/README.md This command displays the help information specifically for the BLE-related subcommands of the djictl CLI. It outlines available BLE operations such as scanning, starting streaming, and retrieving device information. ```shell ./build/djictl-linux-amd64 ble --help ``` -------------------------------- ### WiFi-based Control Commands (CLI) Source: https://context7.com/xaionaro-go/djictl/llms.txt Controls DJI devices over WiFi using UDP protocol on port 9004. These commands require the device to be on the same network. Functionality includes starting video streaming, enabling FCC mode, and configuring RTMP broadcasts. ```bash # Start video streaming via WiFi (connects to default 192.168.2.1:9004) sudo ./djictl wifi start-video # Connect to device at specific address sudo ./djictl wifi --addr "192.168.1.50:9004" start-video # Enable FCC mode via WiFi sudo ./djictl wifi fcc-enable # Configure RTMP broadcast via WiFi sudo ./djictl wifi rtmp-broadcast --url "rtmp://server/live/key" # Disable RTMP broadcast sudo ./djictl wifi rtmp-broadcast --url "rtmp://server/live/key" --disable ``` -------------------------------- ### Start RTMP Streaming with djictl Source: https://github.com/xaionaro-go/djictl/blob/main/README.md This command initiates RTMP streaming from a DJI Osmo device. It requires the Wi-Fi SSID and password for the device to connect to, and the target RTMP URL for the stream. Note that this command may require root privileges (`sudo`). ```shell sudo ./build/djictl-linux-amd64 ble connect-wifi-and-start-streaming --wifi-ssid '' --wifi-psk '' --rtmp-url 'rtmp://MY_HOST/live/stream' ``` -------------------------------- ### Establish WiFi Control and Send Commands with Go Source: https://context7.com/xaionaro-go/djictl/llms.txt Demonstrates initializing a WiFi controller to communicate with a DJI device over UDP. It covers handshaking, configuring RTMP broadcasts, enabling FCC mode, and sending flight simulator data. ```go package main import ( "context" "fmt" "time" "github.com/xaionaro-go/djictl/pkg/djiwifi" "github.com/xaionaro-go/djictl/pkg/duml" ) func main() { ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() ctrl, err := djiwifi.NewController(ctx, "192.168.2.1:9004") if err != nil { fmt.Printf("Failed to create controller: %v\n", err) return } defer ctrl.Close() if err := ctrl.SendHandshake(ctx); err != nil { fmt.Printf("Handshake failed: %v\n", err) return } if err := ctrl.SendVideoHandshake(ctx); err != nil { fmt.Printf("Video handshake failed: %v\n", err) return } if err := ctrl.SendConfigureBroadcast(ctx, "rtmp://server/live/key", true); err != nil { fmt.Printf("Configure broadcast failed: %v\n", err) return } if err := ctrl.SendFCCEnable(ctx, true); err != nil { fmt.Printf("FCC enable failed: %v\n", err) return } simulatorData := duml.RemoteControllerSimulatorData{ RightStickHorizontal: 1024, RightStickVertical: 1024, LeftStickHorizontal: 1024, LeftStickVertical: 1024, } if err := ctrl.SendSimulatorData(ctx, simulatorData); err != nil { fmt.Printf("Simulator data send failed: %v\n", err) return } if err := ctrl.SendStopStreaming(ctx); err != nil { fmt.Printf("Stop streaming failed: %v\n", err) return } fmt.Println("All commands executed successfully") } ``` -------------------------------- ### Initialize and Pair DJI Device (Go) Source: https://context7.com/xaionaro-go/djictl/llms.txt Initializes a BLE connection to a discovered DJI device and completes the pairing process using a default PIN. This is a prerequisite for most other device operations. It requires the `djible` package. ```go package main import ( "context" "fmt" "time" "github.com/xaionaro-go/djictl/pkg/djible" ) func initializeDevice(ctx context.Context, dev *djible.Device) error { // Initialize the BLE connection // This connects to the device and discovers GATT characteristics if err := dev.Init(ctx); err != nil { return fmt.Errorf("failed to initialize device: %w", err) } // Pair with the device using the WiFi Ground Station interface // Default PIN code "5160" is used automatically if err := dev.AppToWiFiGroundStation().Pair(ctx); err != nil { return fmt.Errorf("failed to pair: %w", err) } fmt.Println("Device initialized and paired successfully") return nil } // Example: Scan, find first device, and initialize func main() { ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) defer cancel() deviceCh, errCh, err := djible.Scan(ctx) if err != nil { fmt.Printf("Scan failed: %v\n", err) return } select { case dev := <-deviceCh: if err := initializeDevice(ctx, dev); err != nil { fmt.Printf("Init failed: %v\n", err) } case err := <-errCh: fmt.Printf("Error: %v\n", err) case <-ctx.Done(): fmt.Println("No devices found") } } ``` -------------------------------- ### Connect DJI Device to WiFi (Go) Source: https://context7.com/xaionaro-go/djictl/llms.txt Connects an initialized DJI device to a specified WiFi network using the provided SSID and password. This is necessary for enabling streaming capabilities. The device must be initialized before calling this function. It depends on the `djible` package. ```go package main import ( "context" "fmt" "github.com/xaionaro-go/djictl/pkg/djible" ) func connectDeviceToWiFi(ctx context.Context, dev *djible.Device, ssid, password string) error { // Device must be initialized first if !dev.IsInitialized() { return fmt.Errorf("device not initialized") } // Connect the device to the specified WiFi network // The device will use this network for RTMP streaming if err := dev.AppToWiFiGroundStation().ConnectToWiFi(ctx, ssid, password); err != nil { return fmt.Errorf("failed to connect to WiFi: %w", err) } fmt.Printf("Device connected to WiFi network: %s\n", ssid) return nil } // Usage after device initialization: // err := connectDeviceToWiFi(ctx, dev, "MyNetwork", "MyPassword") ``` -------------------------------- ### Send Custom DUML Messages in Go Source: https://context7.com/xaionaro-go/djictl/llms.txt Demonstrates how to construct a custom duml.Message and transmit it to a DJI device using the djible package. It covers both asynchronous message sending and synchronous request-response patterns. ```go package main import ( "context" "fmt" "github.com/xaionaro-go/djictl/pkg/djible" "github.com/xaionaro-go/djictl/pkg/duml" ) func sendCustomMessage(ctx context.Context, dev *djible.Device) error { // Create a custom DUML message msg := &duml.Message{ Interface: duml.InterfaceIDAppToCamera, ID: duml.MessageIDConfigureStreaming, Type: duml.MessageTypeConfigureStreaming, Payload: []byte{0x00, 0x01, 0x02}, // Custom payload } // Send message without expecting response if err := dev.SendMessage(ctx, msg, true); err != nil { return fmt.Errorf("failed to send message: %w", err) } // Or send request and wait for response response, err := dev.Request(ctx, msg, true) if err != nil { return fmt.Errorf("request failed: %w", err) } fmt.Printf("Response payload: %X\n", response.Payload) return nil } ``` -------------------------------- ### BLE Device Scanning (Go Library) Source: https://context7.com/xaionaro-go/djictl/llms.txt Scans for and discovers DJI devices via Bluetooth Low Energy (BLE) using the `djible` package. This Go code snippet demonstrates how to initiate a scan, process discovered devices, and handle potential errors. It supports various DJI device types. ```go package main import ( "context" "fmt" "time" "github.com/xaionaro-go/djictl/pkg/djible" ) func main() { ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() // Start scanning for DJI devices deviceCh, errCh, err := djible.Scan(ctx) if err != nil { fmt.Printf("Failed to start scanning: %v\n", err) return } // Process discovered devices for { select { case dev := <-deviceCh: fmt.Printf("Found device: %s (Type: %v)\n", dev.ID, dev.Type) // Device types: DeviceTypeOsmoAction4, DeviceTypeOsmoAction5Pro, // DeviceTypeOsmoPocket3, DeviceTypeMiniSE, DeviceTypeAir2S, DeviceTypeMavic3 case err := <-errCh: fmt.Printf("Scan error: %v\n", err) return case <-ctx.Done(): fmt.Println("Scan completed") return } } } ``` -------------------------------- ### Query Battery Information via BLE with Go Source: https://context7.com/xaionaro-go/djictl/llms.txt Retrieves the battery status from a connected DJI device using the BLE package. Requires the device to be initialized before querying. ```go func getBatteryInfo(ctx context.Context, dev *djible.Device) error { if err := dev.Init(ctx); err != nil { return fmt.Errorf("failed to initialize: %w", err) } status, err := dev.AppToBattery().GetInfo(ctx) if err != nil { return fmt.Errorf("failed to get battery info: %w", err) } fmt.Printf("Battery capacity: %s\n", status.Capacity) return nil } ``` -------------------------------- ### Configure Image Stabilization via BLE with Go Source: https://context7.com/xaionaro-go/djictl/llms.txt Sets image stabilization modes for compatible devices like Osmo Action 4 and 5 Pro. Validates device support before applying settings. ```go func setImageStabilization(ctx context.Context, dev *djible.Device) error { if dev.Type != duml.DeviceTypeOsmoAction4 && dev.Type != duml.DeviceTypeOsmoAction5Pro { return fmt.Errorf("image stabilization not supported on this device") } err := dev.AppToCamera().SetImageStabilization(ctx, duml.ImageStabilizationRockSteadyPlus) if err != nil { return fmt.Errorf("failed to set image stabilization: %w", err) } fmt.Println("Image stabilization set to RockSteady+") return nil } ``` -------------------------------- ### Scan for DJI Devices (CLI) Source: https://context7.com/xaionaro-go/djictl/llms.txt Scans for nearby DJI devices using Bluetooth Low Energy (BLE). This command continuously outputs discovered device information. Requires root privileges for BLE access. Supports filtering by device address and debug logging. ```bash sudo ./djictl ble scan # Scan with debug logging sudo ./djictl --log-level debug ble scan # Filter by device address sudo ./djictl ble --filter-device-addr "AA:BB:CC" scan ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.