HighwayStar/MageneRawSender

Android app to send custom raw comands to Magene bike computers

★ 0Forks 0KotlinGitHub ↗Compare

README

Magene Raw (Android)

A one-screen Android app that speaks the same Magene "SRAP" BLE protocol as pymagene and fires a raw control frame at the device on a button tap. It's the Android equivalent of examples/service_mode_raw.py: it scans, connects, subscribes to notifications, and writes one frame — no bond/sync handshake.

What it does

  • Target: a MAC (18:8B:0E:DD:F8:08), a name prefix (C606), or the device's factory/service QR string (mpr-18:8b:0e:dd:f8:08-C606_63318).
  • Scan QR button reads that QR with the camera and fills in the target.
  • Frame fields default to the pymagene example: WRITE 0xF2 · CONTROL 0x10 · page 0xE1 · node 0x29 · payload 0e01ff. The frame sent is (node|0x80) function resource page payload… — no CRC, byte-identical to MageneClient.send_raw.
  • Connect & Send scans for the target (service-mode advertising is bursty, so it keeps scanning ~30 s), connects, enables notifications on the RX characteristic, writes the frame to TX, and logs every reply — decoded where recognised (e.g. BOND_SYNC_STATE_CONTROL [CANCEL_BOND status=0]).

⚠️ The default payload 0e 01 ff is CANCEL_BOND — it likely unbonds the device (the next normal connect will re-prompt for pairing). Change the payload if you don't want that.

Protocol details (shared with pymagene)

UUID
UART service 8ce5cc01-0a4d-11e9-ab14-d663bd873d93
RX (device→host, notify) 8ce5cc05-0a4d-11e9-ab14-d663bd873d93
TX (host→device, write) 8ce5cc06-0a4d-11e9-ab14-d663bd873d93

Frame = [node_addr|0x80] [function] [resource] [page] [payload…], little-endian. See MageneProtocol.kt (frame builder + reply describer) and the Python magene/protocol.py for the full map.

Build

Needs the Android SDK and a JDK 17–21. The build is pinned to the JDK bundled with Android Studio via org.gradle.java.home in gradle.properties — edit that line (or remove it and set JAVA_HOME) if your Studio lives elsewhere. local.properties points sdk.dir at ~/Android/Sdk.

cd android
./gradlew assembleDebug
# APK at app/build/outputs/apk/debug/app-debug.apk
./gradlew installDebug        # with a device/emulator connected via adb

Layout

File Purpose
app/src/main/java/.../MageneProtocol.kt Frame builder, parsers, reply describer. No Android deps.
app/src/main/java/.../MainActivity.kt UI, runtime permissions, BLE scan/connect/write, QR launcher.
app/src/main/res/layout/activity_main.xml The single screen.

QR scanning uses com.journeyapps:zxing-android-embedded (offline, no Google Play Services). Runtime permissions requested: BLUETOOTH_SCAN + BLUETOOTH_CONNECT (API 31+) or ACCESS_FINE_LOCATION (API ≤ 30), and CAMERA for the QR scanner.

Contributors

HighwayStar

Issues