mirror of
https://github.com/D-Modem/app.git
synced 2026-11-28 17:38:05 -08:00
D-Modem-RE's V.cvm (+MS=V_CVM), made for speech codecs: V.8, 15 to 20 s probing the codec, a mode loaded for it, LAPM. Through AMR-NB 12.2 the app's engines connect at CONNECT 1200/CVM/LAPM/V44 (750 to 1200 bit/s coded each way, one renegotiation): four times V.21's 300. The mobile- call line starts in it, S7 long enough for the start-up; V.21, V.22 and V.22bis stay as choices (V.cvm offers modems without it V.22, which a codec garbles: V.21 for those). Settings saved before keep their speed. The dashboard says what the CONNECT was beyond its rate (ConnectInfo: "V.cvm · LAPM · V.44"). CellLineTest's call in V.cvm through AMR 12.2: the data whole each way, +CVM?'s figures; the README's mobile section. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0172Hejd12i4aYikYW9vgpZs
188 lines
9.5 KiB
Markdown
188 lines
9.5 KiB
Markdown
# D-Modem for Android
|
|
|
|
An Android app that is a dial-up modem: V.92/V.90/V.91, V.34 and below, and
|
|
class 1 fax, over SIP calls. No modem hardware: the modem is
|
|
[D-Modem-RE](https://github.com/Neo-Desktop/D-Modem-RE)'s open modem core
|
|
and DSP, built for Android with the NDK, and the telephone line is a SIP
|
|
account's G.711 call (Wi-Fi or mobile data).
|
|
|
|
Over SIP the phone is on the digital side of the network: toward an
|
|
analogue modem (a BBS on a real phone line) it is the V.90/V.92 digital
|
|
modem, up to 56000 bit/s downstream; toward another digital modem
|
|
(D-Modem, an ISP's modem bank) V.91, up to 62667 bit/s both ways, or V.34.
|
|
The SIP provider must carry G.711 (PCMU/PCMA) end to end to the telephone
|
|
network.
|
|
|
|
The phone's own mobile calls can be the line too, slowly, where Android
|
|
lets the app have a call's sound: Android 13 or later, the app privileged
|
|
(CALL_AUDIO_INTERCEPTION; on a rooted phone the app installs itself as a
|
|
Magisk module), and a phone whose audio supports it. Mobile calls carry
|
|
speech through codecs that wreck modem signals; native-test's
|
|
`codec_line` measured it, two modems back to back through each codec:
|
|
|
|
| Codec | Gets through |
|
|
|---|---|
|
|
| AMR-NB 12.2 kbit/s (a 3G/4G call, good signal) | V.21 (300 bit/s); V.22 and V.22bis connect but lose data about half the time; V.32 and up don't connect |
|
|
| AMR-NB 7.95, 5.9 kbit/s (a busy network) | V.21 only |
|
|
| AMR-NB 4.75 kbit/s, GSM full rate (2G) | nothing reliable |
|
|
|
|
Between two D-Modems, V.cvm (D-Modem-RE's modem for speech codecs,
|
|
`+MS=V_CVM`) does better: after V.8 it spends 15 to 20 s probing the
|
|
codec, then loads a mode for it, with LAPM over it. Through AMR-NB 12.2
|
|
the app's engines connect at about 1200 bit/s coded (750 to 1200 each
|
|
way, `CONNECT 1200/CVM/LAPM/V44`; D-Modem-RE measured 175 to 350 through
|
|
AMR 7.4). So the mobile-call line starts the modem in V.cvm, which offers
|
|
V.22 and V.21 to modems without it; V.21 (and 1200 and 2400 bit/s) are
|
|
settings for those. The dashboard says what the connection is ("V.cvm ·
|
|
LAPM · V.44").
|
|
|
|
Fax doesn't get through at all (V.cvm has no fax; V.27ter's training at 2400 bit/s comes
|
|
through AMR 12.2 with about one bit in sixteen wrong), so the app turns
|
|
fax down on that line.
|
|
|
|
Two phones with the app can also be each other's line, over Wi-Fi or
|
|
Bluetooth, with no SIP account: the modems connect as over a perfect line.
|
|
An optional PIN, the same on both phones, keeps other callers out (a
|
|
challenge and response: the PIN never goes over the connection).
|
|
|
|
## Fax
|
|
|
|
Class 1 fax (T.30, MH coding, V.27ter, V.29 and V.17 up to 14400 bit/s),
|
|
sending PDFs and images and receiving into PDFs, on the SIP line (audio,
|
|
or T.38 when the far end asks for it) and the line to another phone.
|
|
Error correction mode (T.30 Annex A) when the other machine has it: the
|
|
page in numbered HDLC frames, those a noisy line spoils sent again. Tested
|
|
against efax, against D-Modem-RE's own T.30 machine (native-test's
|
|
`t30_line`, on a clean line and a noisy one), and over SIP with T.38
|
|
between the app's engine and dmodemd (`sip_fax_line`).
|
|
|
|
## The app
|
|
|
|
- **Home**: what the modem is doing (off, ready, connecting, online with
|
|
its rates down and up and the call's time) and the one thing to do about
|
|
it (set up SIP, start, hang up, stop); the line (the SIP account,
|
|
incoming calls, the network, fax); quick dial of the systems last
|
|
dialled; the terminal and the directory; the modem's console (folded,
|
|
with an AT command line).
|
|
- **Settings**: the SIP account (or paste `user:password@host`, as
|
|
dmodemd's `SIP_LOGIN`), taking incoming calls, T.38, the AT commands
|
|
sent at start (`ATX3` by default: SIP has no dial tone), the log levels.
|
|
- **Terminal**: a VT100/VT220/xterm terminal on the modem (256 and 24-bit
|
|
colours, the alternate screen, bracketed paste, DEC line drawing) that
|
|
also speaks what BBSes expect: CP437, ANSI.SYS's cursor save/restore and
|
|
clear-home, bold as bright, iCE colours, and box drawing and block
|
|
characters drawn to fill their cells so ANSI art has no gaps. Colour
|
|
themes (VGA, xterm, Solarized, Dracula, Monokai, Gruvbox, Nord, green
|
|
and amber phosphor), fonts (Cascadia Code, Sauce Code Pro Nerd Font,
|
|
Source Code Pro, Roboto Mono, JetBrains Mono, Fira Code, OpenDyslexic
|
|
Mono, Inconsolata, Droid Sans Mono or the system's; real bold weights
|
|
from the variable fonts, optional ligatures; `app/src/main/assets/fonts`), 80/132/40 fixed columns or pinch to zoom, scrollback
|
|
with fling, long-press selection with copy, paste, share and open link,
|
|
an extra keys bar (Esc, sticky Ctrl/Alt, Tab, arrows with auto-repeat,
|
|
Home/End/PgUp/PgDn, F1-F12), volume keys as font size or Ctrl/Alt,
|
|
bell as vibration or flash, full screen, snippets, session capture to a
|
|
file (shared to other apps), hang up (+++ with its guard times, ATH).
|
|
- **Dial**: the dialing directory: each system's number (or SIP user), the
|
|
AT commands it needs before ATD, its character set and backspace; one
|
|
tap starts the modem if it is off and dials.
|
|
- **Log**: the modem's and SIP's log.
|
|
|
|
The modem runs in a foreground service (`ModemService`) with the CPU and
|
|
Wi-Fi kept awake for the call's real-time audio. The SIP user agent binds
|
|
to the addresses the phone has when it starts, so the service starts the
|
|
modem again when the default network changes (after the call, if one is
|
|
in progress). The DNS servers come from the active network: Android has
|
|
no `/etc/resolv.conf` for libre to read.
|
|
|
|
## Layout
|
|
|
|
- `external/d-modem-re`: D-Modem-RE (git submodule): the modem core, the
|
|
data pumps, the data link layer, the SIP user agent (on libre) and
|
|
`libdmodem_sip`, the modem on a SIP line as a library.
|
|
- `app/src/main/cpp`: the native library, `libdmodem_jni.so`:
|
|
`engine.cpp` runs the modem in a thread of its own with its DTE on a
|
|
socket pair whose other end is the app's; `jni.cpp` binds it to
|
|
`com.neodesktop.dmodem.NativeModem`.
|
|
- `app/src/main/java/com/neodesktop/dmodem`: `modem/` the service, the
|
|
state the UI observes and `DteHub`, the modem's DTE shared by the
|
|
console, the terminal and the bridges; `settings/`; `ui/` (Compose).
|
|
- `app/src/main/java/com/neodesktop/dmodem/terminal`: the terminal:
|
|
`TerminalEmulator` (pure Kotlin, unit tested), `TerminalView` (drawing
|
|
and input), `TerminalSession` (the emulator on the modem's DTE),
|
|
`BoxDrawing`, `Themes`, the directory and snippets.
|
|
- `native-test`: the engine on the build host, against a dmodemd over
|
|
loopback SIP (dialling out, data both ways, restarting, a call coming
|
|
in, the app closing its end).
|
|
|
|
## Building
|
|
|
|
git submodule update --init
|
|
./gradlew assembleDebug testDebugUnitTest
|
|
|
|
You need JDK 17 or later and the Android SDK with platform 37, NDK
|
|
29.0.14206865 and CMake 3.31.6 (`sdkmanager "platforms;android-37.0"
|
|
"ndk;29.0.14206865" "cmake;3.31.6"`). D-Modem-RE's CMake fetches libre and
|
|
Mbed TLS (git) while configuring and builds them with the NDK's toolchain
|
|
for each ABI. `./gradlew connectedDebugAndroidTest` runs the instrumented
|
|
tests on a device or emulator (the native library loads and answers AT
|
|
commands).
|
|
|
|
The native library alone, without Gradle:
|
|
|
|
cmake -S app/src/main/cpp -B build-arm64 -G Ninja \
|
|
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
|
|
-DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=android-26
|
|
cmake --build build-arm64 --target dmodem_jni
|
|
|
|
The host test needs OpenSSL's headers (libssl-dev):
|
|
|
|
cmake -S native-test -B build-host -G Ninja
|
|
cmake --build build-host
|
|
ctest --test-dir build-host --output-on-failure
|
|
|
|
With `build-host` built, the unit tests also make calls on its test
|
|
lines (fax between modems, against efax and D-Modem-RE's own T.30, over
|
|
SIP with T.38, phone to phone, through mobile codecs); without it those
|
|
are skipped. The lines run at twice a phone line's pace
|
|
(`DMODEM_LINE_SPEED=1` for a real one's).
|
|
|
|
Each test run's logs go to `build/test-runs/<date_time>/<module>-<task>/`,
|
|
one file for each test (`<class>/<test>.log`: what it printed, the line
|
|
tools' logs among it, and a failure's stack trace). A run where nothing
|
|
failed deletes its folder; the build names the one it kept.
|
|
`KERMIT_TRACE=1` and `TRANSFER_TRACE=1` add the transfer tests' bytes
|
|
each way.
|
|
|
|
CI (`.github/workflows/android.yml`) runs all three; it needs a
|
|
`DMODEM_RE_TOKEN` secret that can read the private D-Modem-RE submodule.
|
|
|
|
## Apple's systems (the iOS app to come)
|
|
|
|
The native modem builds for iOS and macOS too: the engine's C API,
|
|
`app/src/main/cpp/dmodem_engine.h` (what Swift calls in place of
|
|
Android's JNI), with D-Modem-RE, libre and Mbed TLS as one XCFramework:
|
|
|
|
ios/build-native.sh # macOS with Xcode, CMake, Ninja
|
|
swift test --package-path ios/DModemSmoke
|
|
|
|
The Kotlin the two apps share is `shared/` (Kotlin Multiplatform: the
|
|
JVM for Android, iOS's framework `DModemShared`; Linux native for its
|
|
tests): the terminal's emulator, the file transfers (X/Y/ZMODEM, Kermit),
|
|
PPP (its client and server, the chat scripts), fax (T.4, T.30, class 1,
|
|
the PDF) and the line to another phone (PeerLine), on a small common I/O
|
|
layer (`shared/.../io`). What stays each app's own: the UI, the modem
|
|
service, sockets and Bluetooth, Android's VPN and files. Its tests run on
|
|
the JVM and natively: `./gradlew :shared:allTests`.
|
|
|
|
D-Modem-RE's `portable.h` has Apple's ways where Linux has its own
|
|
(close-on-exec sockets, SIGPIPE, a monotonic sleep, a peer's hang-up);
|
|
the Linux build tests them too with `-DDMODEM_PORTABLE_FALLBACKS`. CI
|
|
(`.github/workflows/apple.yml`) builds the XCFramework and runs the Swift
|
|
tests on macOS.
|
|
|
|
## License
|
|
|
|
GNU Affero General Public License version 3 only ([COPYING](COPYING)), as
|
|
D-Modem-RE (see its LICENSING.md for the parts it fetches: libre is
|
|
BSD-3-Clause, Mbed TLS Apache-2.0).
|