85 lines
3.2 KiB
Python
85 lines
3.2 KiB
Python
# DJI FCC Patch Script for Windows
|
|
#
|
|
# This script sends a "magic packet" to a DJI controller
|
|
# to enable FCC mode, which can increase the drone's signal range.
|
|
#
|
|
# Credits:
|
|
# - Based on the Android app by Mathieu Broillet: https://github.com/M4TH1EU/DJI-FCC-HACK
|
|
# - Original research by @galbb on MavicPilots.com
|
|
#
|
|
# HOW TO USE:
|
|
# 1. Install Python from the Microsoft Store or python.org.
|
|
# 2. Install the pyserial library by opening a Command Prompt or PowerShell and running:
|
|
# pip install pyserial
|
|
# 3. Turn on your drone and controller, and wait for them to connect.
|
|
# 4. Connect your PC to the bottom USB port of the controller.
|
|
# 5. Run this script.
|
|
# 6. If successful, disconnect the PC and connect your phone to the top USB port of the controller.
|
|
#
|
|
# DISCLAIMER: Use at your own risk. This script modifies your device's operation.
|
|
# The authors are not responsible for any damage or legal issues that may arise.
|
|
|
|
import serial
|
|
import serial.tools.list_ports
|
|
import time
|
|
|
|
# DJI Controller USB identifiers
|
|
VENDOR_ID = 11427
|
|
PRODUCT_ID = 4128
|
|
|
|
# The "magic bytes" that enable FCC mode
|
|
# (from ch.mathieubroillet.djiffchack.Constants.kt)
|
|
BYTES_1 = bytes([85, 13, 4, 33, 42, 31, 0, 0, 0, 0, 1, -122 & 0xFF, 32])
|
|
BYTES_2 = bytes([85, 24, 4, 32, 2, 9, 0, 0, 64, 9, 39, 0, 2, 72, 0, -1 & 0xFF, -1 & 0xFF, 2, 0, 0, 0, 0, -127 & 0xFF, 31])
|
|
|
|
def find_dji_controller():
|
|
"""Finds the COM port of the connected DJI controller."""
|
|
ports = serial.tools.list_ports.comports()
|
|
for port in ports:
|
|
if port.vid == VENDOR_ID and port.pid == PRODUCT_ID:
|
|
print(f"Found DJI Controller at {port.device}")
|
|
return port.device
|
|
return None
|
|
|
|
def send_patch(com_port):
|
|
"""Opens the serial port and sends the patch bytes."""
|
|
try:
|
|
with serial.Serial(com_port, baudrate=19200, bytesize=8, parity='N', stopbits=1, timeout=1) as ser:
|
|
print("Sending patch...")
|
|
|
|
# Send first byte array
|
|
ser.write(BYTES_1)
|
|
print(f"Sent {len(BYTES_1)} bytes (Packet 1).")
|
|
time.sleep(0.1) # Small delay between writes
|
|
|
|
# Send second byte array
|
|
ser.write(BYTES_2)
|
|
print(f"Sent {len(BYTES_2)} bytes (Packet 2).")
|
|
|
|
print("\nPatch sent successfully!")
|
|
print("You can now disconnect the controller from your PC.")
|
|
return True
|
|
except serial.SerialException as e:
|
|
print(f"Error: Could not open or write to serial port {com_port}.")
|
|
print(f"Details: {e}")
|
|
print("\nPlease ensure the controller is properly connected and no other software is using the COM port.")
|
|
return False
|
|
|
|
if __name__ == "__main__":
|
|
print("--- DJI FCC Patch Script ---")
|
|
print("Searching for DJI Controller...")
|
|
|
|
controller_port = find_dji_controller()
|
|
|
|
if controller_port:
|
|
send_patch(controller_port)
|
|
else:
|
|
print("\nDJI Controller not found.")
|
|
print("Please make sure:")
|
|
print("1. The controller is turned on and connected to the drone.")
|
|
print("2. Your PC is connected to the BOTTOM USB port of the controller.")
|
|
print("3. The necessary USB drivers are installed.")
|
|
|
|
print("\nPress Enter to exit.")
|
|
input()
|