Drone Cam
A Flutter controller for toy Wi-Fi drones, rebuilt from the logic of WiFi_CAM
6.1.8. It shows the live camera, flies the drone with two on-screen sticks, and
captures photos and video.
Not yet tested on a real drone. Keep the drone tied down or remove the
propellers on first use, and be ready to unplug the battery. See
Before flying.
Try the browser demo or
download a build.
Browsers cannot open UDP sockets, so the demo flies a simulated drone and has
no photo or video capture. It cannot connect to a real drone.
Run it
Connect the phone to the drone's Wi-Fi, then:
flutter run
Build an APK with:
flutter build apk --release
The release build is signed with the debug key. Set up your own key before
distributing it.
Releases
Every push to main runs .github/workflows/dev-release.yml. It tests the app,
then publishes a dev-<n> prerelease with Android, Linux, web and iOS builds.
The web build goes to GitHub Pages at /dev/, and pages.yml serves the newest
stable release at the site root, or the newest dev build if there is none.
The iOS build is unsigned and has never been run. The Android APK is signed with
a debug key, so a later build signed differently will not install over it.
Fly with a controller
Pair an Xbox controller by Bluetooth, or plug it into the phone with a USB OTG
adapter, then touch any stick or button. The app takes over the controller and
hides the on-screen sticks. The phone still reaches the drone over its Wi-Fi.
| Control |
Action |
| Left stick |
Throttle and yaw |
| Right stick |
Roll and pitch |
| Menu, hold 1 s |
Arm or disarm |
| Y, hold 1 s |
Take off |
| A |
Land |
| LB + RB together |
Stop motors |
| X |
Photo |
| B |
Start or stop recording |
| LT + D-pad |
Trim roll and pitch |
| RT + D-pad left/right |
Trim yaw |
| D-pad up |
Change speed |
| D-pad down |
Prepare a flip, then push the right stick |
| View |
Headless mode |
- If the controller disconnects: the sticks center and the on-screen sticks
return. Until the phone notices a Bluetooth dropout, the last stick position
keeps being sent, which can take seconds. USB is noticed at once.
- Do not press the Xbox button in flight. It can send the app to the
background, and the app then stops sending flight frames.
Other controllers should work if the phone reports them as gamepads, but their
buttons may differ. No physical controller has been tested yet.
If the drone drifts
The drone reports no motion back to the app, so drift cannot be corrected
automatically. Calibrate on level ground first, then hover and trim against the
drift: if it slides left, step roll to the right. Open Trim while armed, or
use the controller. Each step is saved and applied on every launch.
Calibrating resets the trims to center.
If there is no signal
Connect the phone to the drone's Wi-Fi. The app keeps retrying while disarmed,
or press Try again.
Try it without a drone
dart run tool/fake_drone.dart # 8-byte drone
dart run tool/fake_drone.dart --type 2 # 20-byte drone
flutter run -d linux --dart-define=DRONE_HOST=127.0.0.1
Tests
flutter test
test/fixtures/basecmd_vectors.txt holds 76,616 control frames produced by
compiling the original app's decompiled BaseCmd class. The Dart port must
match them byte for byte. The link tests run the real UDP code against
tool/fake_drone.dart.
Layout
| Path |
Purpose |
lib/src/protocol/ |
Flight frames, video reassembly, stick mapping, UDP link, browser demo link |
lib/src/pilot_controller.dart |
Ties sticks, commands and capture together |
lib/src/media/ |
Motion JPEG AVI recording and playback, file storage |
lib/src/ui/ |
Live view, joysticks, pilot screen, gallery |
android/.../MainActivity.kt |
Binds the app to Wi-Fi and keeps the screen on |
docs/PROTOCOL.md |
The recovered protocol |
Before flying
- Signal loss: the drone's reaction to lost commands is set by its firmware
and is unknown. The app stops sending flight frames when you disarm or leave
the app.
- Emergency stop:
STOP MOTORS sends the app's emergency flag.
Inferred: it cuts the motors, so the drone will fall.
- Controls: check each stick direction with the propellers off.
Deliberate differences from the original
Fixed:
- Full right stick no longer wraps to full left.
- The stick deadzone works on both sides of center.
- Saved roll and pitch trims are applied at launch, not only yaw.
- Disarming during a takeoff, land, emergency or calibrate pulse clears its
flag. The original left it set for the next arm.
- The camera type reply is accepted at any time, not only within 50 ms.
- A frame bigger than the buffer is dropped instead of overflowing it.
- The speed tier shown is actually applied at launch. The original starts at
±127 while showing tier 1.
Changed:
- Takeoff needs a one-second press, and disarming asks for confirmation.
- Speed tier 1 is gone because it was too slow to be useful. The app starts at
tier 2 and switches between tiers 2 and 3.
- Video is saved as Motion JPEG AVI instead of MP4, so no FFmpeg is needed. The
AVI has no audio track, and it plays in VLC and in this app's gallery, but
some phone galleries will not open it.
- Photos are saved as the camera's own JPEG, without upscaling.
Not ported
Ads, analytics, tilt control, gesture and face capture, voice control,
draw-a-path flight, photo filters, background music, VR view and the app's
language options. The drawn path feature would need more safety work than the
others.