diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 2b43751..e9110c0 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -13,7 +13,7 @@ # Packages: apt's downloads are cached (.github/actions/apt), keyed on # the runner image and the package list. # -# D-Modem-RE is a private submodule: the DMODEM_TOKEN secret is a token +# D-Modem is a private submodule: the DMODEM_TOKEN secret is a token # that can read it (a fine-grained personal access token with Contents: # read on D-Modem/D-Modem). # @@ -26,12 +26,15 @@ # (and its release build is unsigned). name: Android -# (a branch's commits run once, as its pull request: pushed, only main's) +# (a branch's commits run once, as its pull request: pushed, only main's; +# a change to docs alone runs nothing: the Markdown, docs/ and COPYING) on: push: branches: [main] tags: ["v*"] + paths: ['**', '!**.md', '!docs/**', '!COPYING'] pull_request: + paths: ['**', '!**.md', '!docs/**', '!COPYING'] workflow_dispatch: # a newer commit on a pull request cancels the run before it (main's all run) diff --git a/.github/workflows/apple.yml b/.github/workflows/apple.yml index 5955837..4eb4b8f 100644 --- a/.github/workflows/apple.yml +++ b/.github/workflows/apple.yml @@ -1,18 +1,21 @@ -# The modem for Apple's systems, and the Kotlin the apps share on iOS: the engine with D-Modem-RE, libre and +# The modem for Apple's systems, and the Kotlin the apps share on iOS: the engine with D-Modem, libre and # Mbed TLS built for iOS (devices and simulator) and macOS as an # XCFramework (ios/build-native.sh), and its Swift tests run on macOS # (ios/DModemSmoke): the modem through its C API, as the iOS app has it; # DModemKit's tests, and the iOS app (ios/DModem) built for the simulator. # -# D-Modem-RE is a private submodule: the DMODEM_TOKEN secret (as +# D-Modem is a private submodule: the DMODEM_TOKEN secret (as # android.yml's). name: Apple -# (a branch's commits run once, as its pull request: pushed, only main's) +# (a branch's commits run once, as its pull request: pushed, only main's; +# a change to docs alone runs nothing: the Markdown, docs/ and COPYING) on: push: branches: [main] + paths: ['**', '!**.md', '!docs/**', '!COPYING'] pull_request: + paths: ['**', '!**.md', '!docs/**', '!COPYING'] workflow_dispatch: # a newer commit on a pull request cancels the run before it (main's all run) diff --git a/Dockerfile b/Dockerfile index 50889c2..ceae788 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ # CMake 3.31.6, and gawk for proot; and for the unit tests, the host's # compilers (the engine's host build, native-test) and the SSH tools. # -# D-Modem-RE is a private submodule, so it isn't cloned here: check the +# D-Modem is a private submodule, so it isn't cloned here: check the # submodules out first (git submodule update --init --recursive), and the # build takes them from the tree. # diff --git a/README.md b/README.md index 8cdeebb..43c18f5 100644 --- a/README.md +++ b/README.md @@ -1,407 +1,51 @@ -# D-Modem for Android +# D-Modem app -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/D-Modem/D-Modem)'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). +A dial-up modem in your pocket: the D-Modem app for Android and iOS. -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 app is a V.92/V.90/V.91, V.34 and class 1 fax modem whose telephone +line is a SIP account's G.711 call, over Wi-Fi or mobile data. The modem +is [D-Modem](https://github.com/D-Modem/D-Modem)'s open modem core and +DSP, built for the phone; no modem hardware is needed. Toward a BBS on a +real phone line it is the digital modem, up to 56000 bit/s downstream; +toward another digital modem, V.91 at up to 62667 bit/s both ways. -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: +- A terminal, a dialling directory and the modem's AT console +- Class 1 fax up to 14400 bit/s: PDFs and images sent, faxes received as PDFs, T.38 too +- A vintage computer's external modem, on a USB serial adapter, [pico-serial](https://github.com/D-Modem/hardware), Bluetooth serial or TCP +- Real phone lines through USB modems (the pico-serial Line stick among them), a Hayes modem on a serial adapter, or a Bluetooth modem +- Two phones as each other's line over Wi-Fi or Bluetooth, no SIP account needed +- The phone's own mobile calls as a slow line, where Android allows it -| 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 | +## Quick start -Between two D-Modems, V.cvm (D-Modem-RE's modem for speech codecs, -`+MS=VCVM`) 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. - -Or no line at all: the modem starts on its own, no SIP account or -network needed, and answers AT commands in the terminal and on the serial -bridges; a dial gets NO DIALTONE, as a modem with no phone cable. Home -offers it beside setting up SIP ("Start without a 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. -A call answered is a fax or a data call by what the caller sends -(D-Modem-RE's adaptive answer, `AT+FAA=1`, on unless the settings turn -it off): a fax machine's CNG, a V.8 fax call or T.38 from the far end -and the modem says FAX, and the app's fax receiver takes the call by -itself; a modem's handshake and it says DATA, then its CONNECT, for the -terminal and the bridges. -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`). - -## A modem for a vintage computer: pico-serial - -The phone can be a computer's external modem on a serial cable: on a -USB serial adapter (FTDI, CP210x, CH34x, PL2303 and CDC-ACM chips, under -the chip makers' IDs and the 1100 or so adapter makers' own that Linux's -drivers know: tools/usb-serial-ids; and Exar's XR21V141x and XR21B14xx), -Bluetooth serial, or TCP. [pico-serial](https://github.com/D-Modem/hardware) -is a USB-C to DB25 adapter made for it: plugged into the computer's -serial port it is the modem there. The app finds its control interface -and uses its lines and settings (its firmware/PROTOCOL.md): - -- the modem's DCD, DSR and RI each their own: a call ringing in raises RI - on the computer, as a real modem's ring does; -- the computer's DTR read from the board, so dropping it hangs up; -- the board's role (automatic, modem or computer port), where its speed - comes from (learned from the computer's typing, as a Hayes modem does, - or the app's), RTS/CTS flow control, and what it has carried, in the - serial port settings. - -Any other CDC-ACM adapter's line notifications (`SERIAL_STATE`) are read -too, so the computer dropping DTR hangs up there as well. - -## A real phone line: USB modems - -The modem's line can also be a telephone line, through a USB modem that -carries the modem's sound (D-Modem-RE's `usb_line.cpp`, as -`dmodemd --usb` drives them): a Smart Link SmartUSB56 (USB 0483:7554, -with caller ID, its ST7554 or ST75951 DAA), or a -[pico-serial](https://github.com/D-Modem/hardware) Line stick -(1209:0002, a Si3056 DAA: caller ID on hook, and the country's line -settings in its registers), or an Agere USB 2.0 soft modem (047E:2892, -047E:2828: 8000 Hz, caller ID, on its ROM's own isochronous stream, -nothing downloaded into it; a USB 2.0 port), or Apple's USB Modem for -Macs (A1101, 05AC:1401: a Si3056 DAA, USB audio for its samples, -`usb_apple.cpp`; caller ID and the country's line settings; not yet -tried on a real one). The phone runs the modem; plugged into it -(USB OTG) the stick is its line, with no SIP account or network. Settings, -Line, "A phone line, through a USB modem"; Android asks once whether -D-Modem may use it, and offers the app when one is plugged in. - -## A real phone line: a modem on a USB serial adapter - -An external modem of its own (a US Robotics, a Zoom, any Hayes modem) on a -USB serial adapter plugged into the phone (a Prolific PL2303, PL2303GS -among them, FTDI, CP210x, CH34x, CDC-ACM, Exar: the adapters the serial -bridges know) can take D-Modem's modem's place: Settings, Line, "A phone -line, through a modem on a USB serial adapter", its speed (8N1) and -RTS/CTS. As with a Bluetooth modem, the terminal, the internet, fax and the -Linux's `/dev/ttyDM0` talk to it with its own AT commands; the status comes -from its result codes and its DCD, where the adapter reads it. DTR is held -up while the modem runs, and stopping it drops DTR (a modem at `&D2` hangs -up). Android asks once whether D-Modem may use the adapter -(`SerialAdapters`, which also keeps the modem's line, the Linux's -`/dev/ttyUSB0` and the USB bridge off each other's adapter). `SerialModemTest`. - -## A real phone line: a Bluetooth modem - -A modem of its own with Bluetooth's Dial-Up Networking profile, such as -Sony's BTA-NW1 (Bluetooth 1.1) on a phone line, can take D-Modem's -modem's place: Settings, Line, "A phone line, through a Bluetooth modem", -and the paired modem chosen (pair it in Android's Bluetooth settings -first; an older one asks for its PIN). The app connects to its DUN -service (unencrypted, or its serial port, if need be) and the terminal, -the internet and fax talk to it with its own AT commands; the status -(online, its speed) comes from its result codes. Its connection -dropping, the app connects again once. - -An app can't list the USB devices itself: Android opens the one the user -allowed and gives its descriptor. libusb is built for Android in the app -(`app/src/main/cpp/usb/libusb.cmake`, D-Modem-RE's pinned release) and -`usb_line.cpp` built with its three calls that look for the device -renamed to `usb/usb_android.cpp`'s, which start libusb without its device -discovery and give it that descriptor, wrapped, as the only device on the -bus. Tested on the build host on D-Modem-RE's fake pico-serial Line -sticks, Agere modems and Apple USB Modems, and simulated exchange (`native-test/usb_line_test.py`, its `agere` run on the ROM's isochronous stream, its `apple` run on USB audio's streams: dialling, -caller ID, answering, CONNECT 33600, data each way, hanging up, unplugged); -not yet on a phone with a real stick. The phone's speaker isn't fed on -this 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). -- **A call ringing in** (SIP, the other phone, a mobile call): the - phone's incoming call notification (heads-up, over the lock screen, - the ringtone) and a popup over the app, with who's calling when the - line says (the other phone's name): Answer (ATA: a fax machine's call - goes to the fax receiver by itself, a modem's to the terminal), or - Ignore (it rings on, out of sight); Answer as fax too when adaptive - answer is off. Gone when the modem - answers (here, a computer on a bridge, S0) or the caller gives up. -- **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; - the country, from the ITU's list of 192 (D-Modem-RE's, after E.180): - the modem's line settings and how it hears busy, and the call progress - tones the app plays in its tones (a second of dial tone as an entry is - dialled, the ringing tone while the other phone rings, the busy or - congestion tone when a call can't be made), with a button to hear them. - `tools/country_tones.py` makes the shared Kotlin's copy of the table. -- **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), - and Start PPP: once a call is up (dialled and logged in by hand), the - app's PPP takes it, the phone's traffic through it as the internet's - own dial has it (`PppTakeoverTest`). - Files sent and received by ZMODEM, YMODEM, XMODEM(-1K) and Kermit, and - as Intel HEX or Motorola S-records for EPROM programmers, monitors and - boot loaders: a file sent as records (a file of them already, as it is: - S1/S2/S3 by the image's size, Intel's extended addresses past 64 KB), - records received with their checksums checked into the binary image - they hold (gaps 0xFF). Plain text too: a file's bytes sent verbatim, - as if typed (to an editor, a BBS, `cat > file`), and what comes saved - as it is until the line is quiet for 10 s. -- **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 (Copy for all of it). -- **AT commands** (Settings, AT commands, and the terminal's menu): the - AT command reference, D-Modem-RE's manual (`docs/at_commands.pdf`, the - A5 edition) in the app (`app/src/main/assets/docs`), its pages shown - in the app with a zoom, or opened in the phone's PDF app for its search - and its contents' links. -- **Back**: from any other tab back to Home; on Home the app goes to the - background (the modem keeps running), as the Home button would. -- **Local Linux** (Settings, Linux): distributions installed and run - under proot, as root in /root, the phone's storage at /sdcard, and the - modem as a serial port at `/dev/ttyDM0` (a pty of the app's, bound in): - `minicom -D /dev/ttyDM0`, pppd, efax and the like work as on a real - modem. The program that opens it has the modem as a serial bridge's - client has it (one at a time, with the TCP, Bluetooth and USB bridges); - closing it drops DTR, so the call hangs up as a serial cable's end - would. `ModemTtyTest`, and `LinuxSystemTest` in a real Alpine under - proot: ATI from the distro, the modem's answer back. - A USB serial adapter plugged into the phone is `/dev/ttyUSB0` there (a - pty of the app's too: Android lets no app's programs at a USB device): - the app opens the adapter when a program opens the port and closes it - (DTR down) when the program does; the speed, stop bits, RTS/CTS and B0's - hang-up follow what the program sets (`stty`, minicom, pppd); a pty keeps - no character size or parity, so it is 8 data bits, no parity. - `SerialTtyTest`. -- **Dial-in** (Settings, Dial-up internet): the phone as an ISP for whoever - calls the modem, on SIP or any other line. A call that rings is answered - (unless the fax settings answer calls already); once it connects, the - modem's DTE is taken and a PPP server on the call gives the caller - 10.64.64.2, DNS at 10.64.64.1 and the phone's network through the same - NAT the serial bridges' internet host uses. When the caller's PPP ends, - or none starts, the app hangs up; when the call drops, PPP stops. Home - shows the caller online, with what has gone each way and a Hang up - button. Tested over two of D-Modem's modems back to back - (`DialInLineTest`: answer, CONNECT 33600, the address, DNS and a ping - through the phone, the hang-up). - -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, on SIP, a peer line - (`peer_modem.cpp`) or a USB modem (`usb/`); `jni.cpp` binds it to - `org.dmodem.app.android.NativeModem`. -- `app/src/main/java/org/dmodem/app/android`: `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/org/dmodem/app/android/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) and through the C API, as GoogleTest - tests (`engine_test.cpp`, `c_api_test.cpp`), and on fake USB modems - (`usb_line_test.py`). - -## Building +Android: open the project in Android Studio, or git submodule update --init - ./gradlew assembleDebug testDebugUnitTest + ./gradlew assembleDebug -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). +iOS: see [docs/ios.md](docs/ios.md). The full steps, Docker included, are +in [docs/building.md](docs/building.md). -Or in Docker, with the same toolchain as CI (the submodules checked out -first: the build takes them from the tree), the debug APK into `out/`: +## Documentation - docker build --target apk --output out . +[docs/](docs/README.md) covers the modem's lines, fax, adapters and +phone lines, every screen of the app, building for Android and iOS, and +the source layout. -`docker build -t dmodem-android .` makes an image with the toolchain and -the source to run Gradle in; the `Dockerfile` has the rest (a release -build, the unit tests, a proxy's CA). +## The D-Modem suite -The native library alone, without Gradle: +| Repository | What it is | +| --- | --- | +| [D-Modem](https://github.com/D-Modem/D-Modem) | The open V.92 softmodem: dmodemd, libdmodem and the Asterisk, FreeSWITCH and ARI modules | +| [app](https://github.com/D-Modem/app) | The D-Modem app for Android and iOS: a dial-up modem on a SIP call | +| [hardware](https://github.com/D-Modem/hardware) | pico-serial: RP2040 serial adapters and phone-line USB sticks | +| [menu](https://github.com/D-Modem/menu) | modemmenu: the login and menu dial-up callers reach | +| [bbs](https://github.com/D-Modem/bbs) | A bulletin board for telnet, SSH, TN3270 and modem callers | +| [go3270](https://github.com/D-Modem/go3270) | A Go library for 3270 terminal servers, used by bbs | +| [brand](https://github.com/D-Modem/brand) | Logos, colours, type and the naming guide | - 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), and GoogleTest -(libgtest-dev, else CMake fetches it): - - cmake -S native-test -B build-host -G Ninja - cmake --build build-host - ctest --test-dir build-host --output-on-failure - -Each engine test is a ctest test of its own (`ctest -R engine.` for -those alone); `build-host/engine_test --gtest_filter=*Ringing` runs one -directly, `ENGINE_TEST_LOG=1` with the engine's log as it comes. - -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//-/`, -one file for each 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. - -Every function has a comment on the line just above it, or above its -annotations (Kotlin, Swift, shell), or a docstring (Python); C and C++ as -D-Modem-RE's own rule has it. `tools/doc_check.py` lists any that don't -(and fails). - -CI (`.github/workflows/android.yml`) runs all three, and that check; it needs a -`DMODEM_TOKEN` secret that can read the private D-Modem-RE submodule. - -Signing comes from the environment: `ANDROID_KEYSTORE_FILE` (a PKCS12 -keystore), `ANDROID_KEYSTORE_PASSWORD`, `ANDROID_KEY_ALIAS` and -`ANDROID_KEY_PASSWORD` (the store's password if unset). Without them a -debug build takes the SDK's debug key and a release build is unsigned. CI -decodes `ANDROID_KEYSTORE_BASE64` into that file: the repository's secrets -hold the debug keystore, the protected `release` environment's (main and -`v*` tags) the release one, which CI's `release` job signs with. - -## Apple's systems: the iOS app - -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, Intel HEX and S-records, plain text), -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`. - -The iOS app (`ios/DModem`, SwiftUI, iOS 16) is the modem on a SIP -account, or on the line to another phone with the app (Android or iOS) -on the same Wi-Fi: the shared PeerLine on POSIX sockets (its PIN too), -offered and found with Bonjour (`_dmodem._tcp`, as Android's NSD). It has: - -- Home: the modem's state, the rates and what the CONNECT was, start, - hang up, stop, an AT command line, the log -- the terminal (the shared emulator drawn in SwiftUI, CP437 and the VGA - colours, Esc/Ctrl/Tab/arrows) and its file transfers (ZMODEM, YMODEM, - XMODEM, Kermit, Intel HEX, S-records, plain text; a remote's `sz` or `kermit -s` - starts one by itself) -- Fax: PDFs, images and text sent; a ringing call answered as a fax, by - hand or each one; the received faxes as PDFs -- Internet: dial-up to an ISP (its login script if it has one, PPP), the - phone's traffic through it as a VPN (the `DModemTunnel` packet tunnel - extension, its packets to the app's PPP on the loopback) -- Settings: the SIP account or the other phone, the modem's commands - -The modem's calls are the phone's own (CallKit): one ringing in rings -as a phone call does, answered or turned down there; one dialled shows -as a call, hung up from the call screen. The passwords and the PIN are -in the Keychain. Received files and faxes are in the Files app (On My -iPhone › D-Modem). The modem keeps going in the background on the audio -session (its speaker, or quiet); calls ring in while the app runs (with -no push service, a call can't wake it). Dial-up's VPN needs the Network -Extensions capability on the app's team. - -What the screens run is the shared Kotlin's jobs (`shared/.../jobs`: a -fax call, a transfer, dial-up, each lent the modem's DTE while it lasts), -tested on the JVM and natively. The modem apart from the views is the -`ios/DModemKit` Swift package (the engine from Swift, its DTE and who -it's lent to, the settings and their secrets, the session), whose tests -run on Linux too, against the host build: - - ./gradlew :shared:assembleDModemSharedReleaseXCFramework - ios/build-native.sh - cd ios/DModem && xcodegen generate && open DModem.xcodeproj - - DMODEM_HOST_BUILD=$PWD/build-host swift test --package-path ios/DModemKit # Linux or macOS - -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, runs the Swift -tests on macOS and builds the app for the simulator; the Linux job runs -DModemKit's tests on the host engine. - -## License +## Licence 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 +D-Modem (see its LICENSING.md for the parts it fetches: libre is BSD-3-Clause, Mbed TLS Apache-2.0). diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 1592e9c..67c5796 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -59,7 +59,7 @@ android { } externalNativeBuild { cmake { - // only the app's libraries (the modem's, the local shell's ptys): not dmodemd or D-Modem-RE's other programs + // only the app's libraries (the modem's, the local shell's ptys): not dmodemd or D-Modem's other programs targets += listOf("dmodem_jni", "dmodem_pty") arguments += listOf("-DANDROID_STL=c++_static") // (a special build's name for the native code too: "led-probe" probes the Agere's LEDs) diff --git a/app/src/main/assets/docs/README.md b/app/src/main/assets/docs/README.md index cc72bb6..a2e53e1 100644 --- a/app/src/main/assets/docs/README.md +++ b/app/src/main/assets/docs/README.md @@ -1,6 +1,6 @@ # The AT command reference -`at_commands.pdf` is D-Modem-RE's AT command reference, the A5 manual: +`at_commands.pdf` is D-Modem's AT command reference, the A5 manual: `docs/at_commands.pdf` in [D-Modem/D-Modem](https://github.com/D-Modem/D-Modem), built from `docs/at/at_commands.tex` (`docs/at/build.sh`). This copy is from its main at 7f53883. When the manual changes, copy the new PDF here. diff --git a/app/src/main/cpp/CMakeLists.txt b/app/src/main/cpp/CMakeLists.txt index e79b525..ff5d1f2 100644 --- a/app/src/main/cpp/CMakeLists.txt +++ b/app/src/main/cpp/CMakeLists.txt @@ -1,9 +1,9 @@ # SPDX-License-Identifier: AGPL-3.0-only # Copyright (C) 2026 Neo-Desktop # libdmodem_jni.so: D-Modem's modem on a SIP line (libdmodem_sip, from the -# D-Modem-RE submodule) with the app's engine and its JNI binding. +# D-Modem submodule) with the app's engine and its JNI binding. # -# D-Modem-RE fetches libre and Mbed TLS while configuring and builds them +# D-Modem fetches libre and Mbed TLS while configuring and builds them # with the NDK's toolchain for each ABI (cmake/libre.cmake there). cmake_minimum_required(VERSION 3.22) project(dmodem_android LANGUAGES C CXX) @@ -12,12 +12,12 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(DMODEM_RE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../../external/d-modem-re - CACHE PATH "the D-Modem-RE tree") + CACHE PATH "the D-Modem tree") if(NOT EXISTS ${DMODEM_RE_DIR}/CMakeLists.txt) - message(FATAL_ERROR "D-Modem-RE not found in ${DMODEM_RE_DIR}: " + message(FATAL_ERROR "D-Modem not found in ${DMODEM_RE_DIR}: " "git submodule update --init") endif() -# dmodemd's sources: D-Modem-RE's frontend/dmodemd (dmodemd/ in trees +# dmodemd's sources: D-Modem's frontend/dmodemd (dmodemd/ in trees # from before frontend/ and platforms/) if(EXISTS ${DMODEM_RE_DIR}/frontend/dmodemd/CMakeLists.txt) set(DMODEM_RE_DMODEMD ${DMODEM_RE_DIR}/frontend/dmodemd CACHE INTERNAL "") @@ -45,7 +45,7 @@ target_compile_options(dmodem_engine PRIVATE -Wall -Wextra) set_target_properties(dmodem_engine PROPERTIES POSITION_INDEPENDENT_CODE ON) if(ANDROID) - # the USB modems (D-Modem-RE's usb_line.cpp: a SmartUSB56, a + # the USB modems (D-Modem's usb_line.cpp: a SmartUSB56, a # pico-serial Line stick, an Agere USB 2.0 soft modem, usb_agere.cpp, # Apple's USB Modem, usb_apple.cpp, a pico-serial WB stick, usb_wb.cpp) # on the @@ -66,7 +66,7 @@ if(ANDROID) PROPERTIES COMPILE_DEFINITIONS "libusb_init=dmodem_libusb_init;libusb_get_device_list=dmodem_libusb_get_device_list;libusb_open=dmodem_libusb_open;libusb_submit_transfer=dmodem_libusb_submit_transfer") # (a special build, -Pdmodem.special=led-probe: the Agere's GPIOs - # flipped one by one at start, docs/agere-usb.md in D-Modem-RE) + # flipped one by one at start, docs/agere-usb.md in D-Modem) set(agere_defs "libusb_submit_transfer=dmodem_libusb_submit_transfer") if(DMODEM_SPECIAL STREQUAL "led-probe") list(APPEND agere_defs DMODEM_AGERE_LED_PROBE) diff --git a/app/src/main/cpp/usb/libusb.cmake b/app/src/main/cpp/usb/libusb.cmake index 77db4a4..5b14ee5 100644 --- a/app/src/main/cpp/usb/libusb.cmake +++ b/app/src/main/cpp/usb/libusb.cmake @@ -2,7 +2,7 @@ # Copyright (C) 2026 Neo-Desktop # libusb-1.0 for Android, as the static library `dmodem_android_libusb` # (the build host's tests take its libusb.h alone, DMODEM_LIBUSB_SRC): -# D-Modem-RE's pinned release (its cmake/libusb.cmake: the same version +# D-Modem's pinned release (its cmake/libusb.cmake: the same version # and SHA-256), downloaded once while configuring into the build tree, # its core and Linux backend (usbfs) built with the NDK, with the config.h # it ships for Android. An app can't list the USB devices itself: the diff --git a/app/src/main/cpp/usb/usb_android.h b/app/src/main/cpp/usb/usb_android.h index 65fd607..49f12c3 100644 --- a/app/src/main/cpp/usb/usb_android.h +++ b/app/src/main/cpp/usb/usb_android.h @@ -2,7 +2,7 @@ * SPDX-License-Identifier: AGPL-3.0-only * Copyright (C) 2026 Neo-Desktop * - * usb_android.h - D-Modem-RE's USB line (usb_line.cpp) on a device + * usb_android.h - D-Modem's USB line (usb_line.cpp) on a device * Android has opened for the app * * An app can't list the USB devices (no /dev/bus/usb to read): Android diff --git a/app/src/main/cpp/usb/usb_modem.h b/app/src/main/cpp/usb/usb_modem.h index 3f37d88..fd3c856 100644 --- a/app/src/main/cpp/usb/usb_modem.h +++ b/app/src/main/cpp/usb/usb_modem.h @@ -3,7 +3,7 @@ * Copyright (C) 2026 Neo-Desktop * * usb_modem.h - the modem core on a telephone line through a USB - * modem (D-Modem-RE's UsbLine: a Smart Link SmartUSB56, + * modem (D-Modem's UsbLine: a Smart Link SmartUSB56, * or a pico-serial Line stick), its DTE a descriptor * * As dmodemd --usb runs it (its run_line()), on the device Android diff --git a/app/src/main/java/org/dmodem/app/android/BuildInfo.kt b/app/src/main/java/org/dmodem/app/android/BuildInfo.kt index d4485a5..e138e93 100644 --- a/app/src/main/java/org/dmodem/app/android/BuildInfo.kt +++ b/app/src/main/java/org/dmodem/app/android/BuildInfo.kt @@ -4,13 +4,13 @@ package org.dmodem.app.android /** which build this is: logged when the modem starts, so a log says what made it */ object BuildInfo { - /** "D-Modem 0.1.0 03a196a-dirty (D-Modem-RE e2b9d1c), debug, special: agere-iso" */ + /** "D-Modem 0.1.0 03a196a-dirty (D-Modem core e2b9d1c), debug, special: agere-iso" */ val described: String get() = describe(BuildConfig.VERSION_NAME, BuildConfig.COMMIT, BuildConfig.RE_COMMIT, BuildConfig.BUILD_TYPE, BuildConfig.SPECIAL) /** see [described]: the build type left out if it's a release, the special build's name if it has one */ fun describe(version: String, commit: String, reCommit: String, buildType: String, special: String): String = buildString { - append("D-Modem $version $commit (D-Modem-RE $reCommit)") + append("D-Modem $version $commit (D-Modem core $reCommit)") if (buildType != "release") append(", $buildType") if (special.isNotEmpty()) append(", special: $special") } diff --git a/app/src/main/java/org/dmodem/app/android/fax/Fax.kt b/app/src/main/java/org/dmodem/app/android/fax/Fax.kt index c591865..e8f45df 100644 --- a/app/src/main/java/org/dmodem/app/android/fax/Fax.kt +++ b/app/src/main/java/org/dmodem/app/android/fax/Fax.kt @@ -244,7 +244,7 @@ object Fax { if (c.command("E0V1X3") != "OK" || c.command("+FCLASS=1") != "OK") throw FaxException("the modem has no fax mode") rates = T30.modemRates(c, s.maxBps) } else { - // (no commands now: the modem's waiting for our frames. D-Modem-RE has every rate) + // (no commands now: the modem's waiting for our frames. D-Modem has every rate) rates = T30.RATES.filter { it.bps <= s.maxBps } } val (p, f) = body(c, s) diff --git a/app/src/main/java/org/dmodem/app/android/modem/CallTones.kt b/app/src/main/java/org/dmodem/app/android/modem/CallTones.kt index 684e9ef..1438239 100644 --- a/app/src/main/java/org/dmodem/app/android/modem/CallTones.kt +++ b/app/src/main/java/org/dmodem/app/android/modem/CallTones.kt @@ -7,7 +7,7 @@ import org.dmodem.app.tones.Tone import org.dmodem.app.tones.ToneSynth /** - * The country's call progress tones on the phone's speaker (D-Modem-RE's + * The country's call progress tones on the phone's speaker (D-Modem's * ITU table, the shared [CountryTones]): the dial tone as an entry is * dialled, the ringing tone while the other phone rings, the busy and * congestion tones when a call can't be made. What a phone line would diff --git a/app/src/main/java/org/dmodem/app/android/modem/LineRecordings.kt b/app/src/main/java/org/dmodem/app/android/modem/LineRecordings.kt index 86b7bb8..bdb9013 100644 --- a/app/src/main/java/org/dmodem/app/android/modem/LineRecordings.kt +++ b/app/src/main/java/org/dmodem/app/android/modem/LineRecordings.kt @@ -6,7 +6,7 @@ import android.content.Context import java.io.File /** - * Calls on a USB modem's line recorded, for a bug report (the settings' "Record each call"): D-Modem-RE + * Calls on a USB modem's line recorded, for a bug report (the settings' "Record each call"): D-Modem * writes each, off hook to on hook, as a stereo WAV (left what came from the line, right what the modem * sent) into the captures folder, where the log screen shares the latest. The last [KEEP] are kept. */ @@ -17,7 +17,7 @@ object LineRecordings { /** the app's captures folder on external storage (null: none to have) */ private fun dir(context: Context): File? = context.applicationContext.getExternalFilesDir("captures") - /** the path D-Modem-RE's DMODEM_USB_REC is given (null: nowhere to record to) */ + /** the path D-Modem's DMODEM_USB_REC is given (null: nowhere to record to) */ fun path(context: Context): String? = dir(context)?.let { File(it, PREFIX).path } /** the recordings there are, the newest first */ diff --git a/app/src/main/java/org/dmodem/app/android/modem/ModemService.kt b/app/src/main/java/org/dmodem/app/android/modem/ModemService.kt index 4e0535c..bafc6bf 100644 --- a/app/src/main/java/org/dmodem/app/android/modem/ModemService.kt +++ b/app/src/main/java/org/dmodem/app/android/modem/ModemService.kt @@ -278,7 +278,7 @@ class ModemService : Service() { else -> 100 }, ) - // each call on a USB modem's line recorded if the settings say so (D-Modem-RE's DMODEM_USB_REC) + // each call on a USB modem's line recorded if the settings say so (D-Modem's DMODEM_USB_REC) val rec = if (settings.usb && settings.recordLine) LineRecordings.path(this) else null runCatching { if (rec != null) { @@ -288,7 +288,7 @@ class ModemService : Service() { android.system.Os.unsetenv("DMODEM_USB_REC") } } - // the modem's sound to a USB modem's line louder or softer (D-Modem-RE's DMODEM_USB_TX_GAIN) + // the modem's sound to a USB modem's line louder or softer (D-Modem's DMODEM_USB_TX_GAIN) runCatching { val gain = settings.usbTxGainEnv if (gain != null) { diff --git a/app/src/main/java/org/dmodem/app/android/modem/UsbModems.kt b/app/src/main/java/org/dmodem/app/android/modem/UsbModems.kt index 2d08094..80f5f3a 100644 --- a/app/src/main/java/org/dmodem/app/android/modem/UsbModems.kt +++ b/app/src/main/java/org/dmodem/app/android/modem/UsbModems.kt @@ -17,7 +17,7 @@ import kotlinx.coroutines.withTimeoutOrNull import kotlin.coroutines.resume /** - * The USB modems that can be the modem's line (D-Modem-RE's usb_line.cpp, + * The USB modems that can be the modem's line (D-Modem's usb_line.cpp, * on the device Android opens for the app): a Smart Link SmartUSB56 * (ST7554), a pico-serial Line stick (a Si3056 DAA on a phone line), an * Agere USB 2.0 soft modem and Apple's USB Modem (a Si3056 too). @@ -27,9 +27,9 @@ object UsbModems { enum class Kind(val vendor: Int, val products: List, val label: String, val rate: Int) { SMART_USB56(0x0483, listOf(0x7554), "SmartUSB56", 9600), PICO_LINE(0x1209, listOf(0x0002), "pico-serial Line", 9600), - /** on its ROM's own isochronous stream (D-Modem-RE's usb_agere.cpp); a USB 2.0 port */ + /** on its ROM's own isochronous stream (D-Modem's usb_agere.cpp); a USB 2.0 port */ AGERE(0x047E, listOf(0x2892, 0x2828), "Agere USB 2.0 modem", 8000), - /** Apple's USB Modem for Macs (A1101): USB audio for its samples, CDC's line control (D-Modem-RE's usb_apple.cpp) */ + /** Apple's USB Modem for Macs (A1101): USB audio for its samples, CDC's line control (D-Modem's usb_apple.cpp) */ APPLE(0x05AC, listOf(0x1401, 0x8220), "Apple USB Modem", 9600), ; diff --git a/app/src/main/java/org/dmodem/app/android/settings/ModemSettings.kt b/app/src/main/java/org/dmodem/app/android/settings/ModemSettings.kt index 2e3c11e..cb7cfc3 100644 --- a/app/src/main/java/org/dmodem/app/android/settings/ModemSettings.kt +++ b/app/src/main/java/org/dmodem/app/android/settings/ModemSettings.kt @@ -51,7 +51,7 @@ data class ModemSettings( /** the country's call progress tones (dial, ringing, busy, congestion) where the line has none of its own */ val callTones: Boolean = true, /** - * calls answered as fax or data by what they turn out to be (D-Modem-RE's adaptive answer, AT+FAA=1): + * calls answered as fax or data by what they turn out to be (D-Modem's adaptive answer, AT+FAA=1): * a fax machine's to the fax receiver, a modem's to the terminal */ val adaptiveAnswer: Boolean = true, @@ -70,12 +70,12 @@ data class ModemSettings( val serialModemRtsCts: Boolean = true, /** each call on a USB modem's line recorded (LineRecordings), for a bug report */ val recordLine: Boolean = false, - /** a USB modem's line: the modem's sound to it louder or softer, dB (-20 to 20; D-Modem-RE's DMODEM_USB_TX_GAIN) */ + /** a USB modem's line: the modem's sound to it louder or softer, dB (-20 to 20; D-Modem's DMODEM_USB_TX_GAIN) */ val usbTxGain: Int = 0, /** a USB modem's line: its transmit level set for each call from the remote's answer tone (DMODEM_USB_TX_GAIN=auto), not [usbTxGain] */ val usbTxAuto: Boolean = true, ) { - /** D-Modem-RE's DMODEM_USB_TX_GAIN for this line: "auto", the dB, or null (none: 0 dB, or not a USB line) */ + /** D-Modem's DMODEM_USB_TX_GAIN for this line: "auto", the dB, or null (none: 0 dB, or not a USB line) */ val usbTxGainEnv: String? get() = when { !usb -> null @@ -129,7 +129,7 @@ data class ModemSettings( const val LINE_SERIAL_MODEM = "serial_modem" /** the speeds offered for a serial adapter's modem */ val SERIAL_SPEEDS = listOf(2400, 9600, 19200, 38400, 57600, 115200, 230400) - /** the mobile-call line's V.cvm (D-Modem-RE's +MS=VCVM) */ + /** the mobile-call line's V.cvm (D-Modem's +MS=VCVM) */ const val CELL_VCVM = "VCVM" /** diff --git a/app/src/main/java/org/dmodem/app/android/ui/AtReference.kt b/app/src/main/java/org/dmodem/app/android/ui/AtReference.kt index 17d232d..0d7fc4c 100644 --- a/app/src/main/java/org/dmodem/app/android/ui/AtReference.kt +++ b/app/src/main/java/org/dmodem/app/android/ui/AtReference.kt @@ -61,7 +61,7 @@ import kotlinx.coroutines.withContext import java.io.File /** - * D-Modem's AT command reference (the A5 manual, D-Modem-RE's + * D-Modem's AT command reference (the A5 manual, D-Modem's * docs/at_commands.pdf), in the app's assets: out of them into the cache * for PdfRenderer and PDF apps, which want a file. */ diff --git a/app/src/main/java/org/dmodem/app/android/ui/SettingsScreen.kt b/app/src/main/java/org/dmodem/app/android/ui/SettingsScreen.kt index fa5d783..82e83fc 100644 --- a/app/src/main/java/org/dmodem/app/android/ui/SettingsScreen.kt +++ b/app/src/main/java/org/dmodem/app/android/ui/SettingsScreen.kt @@ -417,7 +417,7 @@ private fun Toggle(label: String, value: Boolean, onChange: (Boolean) -> Unit) { /** * the modem's country (its line settings, how it hears busy) and the call - * progress tones': D-Modem-RE's ITU list, searched by name, each with its + * progress tones': D-Modem's ITU list, searched by name, each with its * tones; the value its name ("" for the default, the USA) */ @Composable diff --git a/app/src/test/java/org/dmodem/app/android/BuildInfoTest.kt b/app/src/test/java/org/dmodem/app/android/BuildInfoTest.kt index d1d3b32..e768162 100644 --- a/app/src/test/java/org/dmodem/app/android/BuildInfoTest.kt +++ b/app/src/test/java/org/dmodem/app/android/BuildInfoTest.kt @@ -10,14 +10,14 @@ class BuildInfoTest { /** a release build says its version and the two commits, nothing more */ @Test fun releaseIsPlain() = assertEquals( - "D-Modem 0.1.0 03a196a (D-Modem-RE e2b9d1c)", + "D-Modem 0.1.0 03a196a (D-Modem core e2b9d1c)", BuildInfo.describe("0.1.0", "03a196a", "e2b9d1c", "release", ""), ) /** a dirty debug build with a special variant says so after the commits */ @Test fun dirtyDebugSpecial() = assertEquals( - "D-Modem 0.1.0 03a196a-dirty (D-Modem-RE e2b9d1c-dirty), debug, special: agere-iso", + "D-Modem 0.1.0 03a196a-dirty (D-Modem core e2b9d1c-dirty), debug, special: agere-iso", BuildInfo.describe("0.1.0", "03a196a-dirty", "e2b9d1c-dirty", "debug", "agere-iso"), ) diff --git a/app/src/test/java/org/dmodem/app/android/cell/CellLineTest.kt b/app/src/test/java/org/dmodem/app/android/cell/CellLineTest.kt index 40098c0..8072659 100644 --- a/app/src/test/java/org/dmodem/app/android/cell/CellLineTest.kt +++ b/app/src/test/java/org/dmodem/app/android/cell/CellLineTest.kt @@ -93,7 +93,7 @@ class CellLineTest { val net = FakeNetwork("amr122", closers) val a = CellModem("cvmA", net.phone("5550001"), listen = false) val b = CellModem("cvmB", net.phone("5550002"), listen = true) - // V.cvm (D-Modem-RE's, for speech codecs): V.8, then 15 to 21 s probing the codec and + // V.cvm (D-Modem's, for speech codecs): V.8, then 15 to 21 s probing the codec and // loading a mode for it; S7 long enough for that a.command("ATE0\\V1+MS=VCVM;S7=90") b.command("ATE0\\V1S0=1+MS=VCVM;S7=90") diff --git a/app/src/test/java/org/dmodem/app/android/fax/T30InteropTest.kt b/app/src/test/java/org/dmodem/app/android/fax/T30InteropTest.kt index bdd7d71..52d17c8 100644 --- a/app/src/test/java/org/dmodem/app/android/fax/T30InteropTest.kt +++ b/app/src/test/java/org/dmodem/app/android/fax/T30InteropTest.kt @@ -18,7 +18,7 @@ import java.io.File /** * Our fax (its T.30 on a class 1 modem) against another machine's: - * D-Modem-RE's own T.30 (dsp/t30.cpp), on the far end of a phone line + * D-Modem's own T.30 (dsp/t30.cpp), on the far end of a phone line * from the modem (native-test's t30_line: cmake -S native-test -B * build-host && cmake --build build-host, or DMODEM_T30_LINE; skipped * without it). With error correction mode both ways, on a clean line @@ -64,7 +64,7 @@ class T30InteropTest { return mapOf("ok" to f[1], "pages" to f[3], "bps" to f[5], "ecm" to f[7], "why" to f.drop(8).joinToString(" ")) } - /** two pages from us to D-Modem-RE's T.30, [ecm] or not, on a line [snr] dB clean if given: it got them, every pel, as we sent them */ + /** two pages from us to D-Modem's T.30, [ecm] or not, on a line [snr] dB clean if given: it got them, every pel, as we sent them */ private fun theyReceive(ecm: Boolean, snr: Double = 0.0) { val dir = tmp.newFolder() val args = mutableListOf("receive", dir.path) @@ -92,7 +92,7 @@ class T30InteropTest { } } - /** D-Modem-RE's T.30 sends us its pages, [ecm] or not, at most [maxBps], [snr] dB clean if given: every pel as it sent them; the pages */ + /** D-Modem's T.30 sends us its pages, [ecm] or not, at most [maxBps], [snr] dB clean if given: every pel as it sent them; the pages */ private fun theySend(ecm: Boolean, snr: Double = 0.0, maxBps: Int = 14400): List { val dir = tmp.newFolder() val args = mutableListOf("send", dir.path, "--bps", maxBps.toString()) @@ -135,7 +135,7 @@ class T30InteropTest { theySend(ecm = true) } - // (at V.17's 14400, which lost a row of 1-pel runs before D-Modem-RE's + // (at V.17's 14400, which lost a row of 1-pel runs before D-Modem's // steadier V.17 receiver, d2b0626) @Test fun weReceiveWithoutEcm() { diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..c676886 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,10 @@ +# D-Modem app documentation + +- [The modem's line](lines.md): SIP, the phone's own mobile calls, no line, two phones as each other's line +- [Fax](fax.md) +- [Serial adapters and real phone lines](adapters.md): pico-serial, USB modems, a modem on a USB serial adapter, a Bluetooth modem +- [The app, screen by screen](features.md) +- [Building the Android app](building.md) +- [The iOS app](ios.md): building and running on iPhone and iPad +- [Source layout](layout.md) +- [The AT command reference](../app/src/main/assets/docs/README.md), shown in the app diff --git a/docs/adapters.md b/docs/adapters.md new file mode 100644 index 0000000..ea89ef4 --- /dev/null +++ b/docs/adapters.md @@ -0,0 +1,84 @@ +# Serial adapters and real phone lines + +## A modem for a vintage computer: pico-serial + + +The phone can be a computer's external modem on a serial cable: on a +USB serial adapter (FTDI, CP210x, CH34x, PL2303 and CDC-ACM chips, under +the chip makers' IDs and the 1100 or so adapter makers' own that Linux's +drivers know: tools/usb-serial-ids; and Exar's XR21V141x and XR21B14xx), +Bluetooth serial, or TCP. [pico-serial](https://github.com/D-Modem/hardware) +is a USB-C to DB25 adapter made for it: plugged into the computer's +serial port it is the modem there. The app finds its control interface +and uses its lines and settings (its firmware/PROTOCOL.md): + +- the modem's DCD, DSR and RI each their own: a call ringing in raises RI + on the computer, as a real modem's ring does; +- the computer's DTR read from the board, so dropping it hangs up; +- the board's role (automatic, modem or computer port), where its speed + comes from (learned from the computer's typing, as a Hayes modem does, + or the app's), RTS/CTS flow control, and what it has carried, in the + serial port settings. + +Any other CDC-ACM adapter's line notifications (`SERIAL_STATE`) are read +too, so the computer dropping DTR hangs up there as well. + +## A real phone line: USB modems + + +The modem's line can also be a telephone line, through a USB modem that +carries the modem's sound (D-Modem's `usb_line.cpp`, as +`dmodemd --usb` drives them): a Smart Link SmartUSB56 (USB 0483:7554, +with caller ID, its ST7554 or ST75951 DAA), or a +[pico-serial](https://github.com/D-Modem/hardware) Line stick +(1209:0002, a Si3056 DAA: caller ID on hook, and the country's line +settings in its registers), or an Agere USB 2.0 soft modem (047E:2892, +047E:2828: 8000 Hz, caller ID, on its ROM's own isochronous stream, +nothing downloaded into it; a USB 2.0 port), or Apple's USB Modem for +Macs (A1101, 05AC:1401: a Si3056 DAA, USB audio for its samples, +`usb_apple.cpp`; caller ID and the country's line settings; not yet +tried on a real one). The phone runs the modem; plugged into it +(USB OTG) the stick is its line, with no SIP account or network. Settings, +Line, "A phone line, through a USB modem"; Android asks once whether +D-Modem may use it, and offers the app when one is plugged in. + +## A real phone line: a modem on a USB serial adapter + + +An external modem of its own (a US Robotics, a Zoom, any Hayes modem) on a +USB serial adapter plugged into the phone (a Prolific PL2303, PL2303GS +among them, FTDI, CP210x, CH34x, CDC-ACM, Exar: the adapters the serial +bridges know) can take D-Modem's modem's place: Settings, Line, "A phone +line, through a modem on a USB serial adapter", its speed (8N1) and +RTS/CTS. As with a Bluetooth modem, the terminal, the internet, fax and the +Linux's `/dev/ttyDM0` talk to it with its own AT commands; the status comes +from its result codes and its DCD, where the adapter reads it. DTR is held +up while the modem runs, and stopping it drops DTR (a modem at `&D2` hangs +up). Android asks once whether D-Modem may use the adapter +(`SerialAdapters`, which also keeps the modem's line, the Linux's +`/dev/ttyUSB0` and the USB bridge off each other's adapter). `SerialModemTest`. + +## A real phone line: a Bluetooth modem + + +A modem of its own with Bluetooth's Dial-Up Networking profile, such as +Sony's BTA-NW1 (Bluetooth 1.1) on a phone line, can take D-Modem's +modem's place: Settings, Line, "A phone line, through a Bluetooth modem", +and the paired modem chosen (pair it in Android's Bluetooth settings +first; an older one asks for its PIN). The app connects to its DUN +service (unencrypted, or its serial port, if need be) and the terminal, +the internet and fax talk to it with its own AT commands; the status +(online, its speed) comes from its result codes. Its connection +dropping, the app connects again once. + +An app can't list the USB devices itself: Android opens the one the user +allowed and gives its descriptor. libusb is built for Android in the app +(`app/src/main/cpp/usb/libusb.cmake`, D-Modem's pinned release) and +`usb_line.cpp` built with its three calls that look for the device +renamed to `usb/usb_android.cpp`'s, which start libusb without its device +discovery and give it that descriptor, wrapped, as the only device on the +bus. Tested on the build host on D-Modem's fake pico-serial Line +sticks, Agere modems and Apple USB Modems, and simulated exchange (`native-test/usb_line_test.py`, its `agere` run on the ROM's isochronous stream, its `apple` run on USB audio's streams: dialling, +caller ID, answering, CONNECT 33600, data each way, hanging up, unplugged); +not yet on a phone with a real stick. The phone's speaker isn't fed on +this line. diff --git a/docs/building.md b/docs/building.md new file mode 100644 index 0000000..7f72419 --- /dev/null +++ b/docs/building.md @@ -0,0 +1,69 @@ +# Building the Android app + + + 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'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). + +Or in Docker, with the same toolchain as CI (the submodules checked out +first: the build takes them from the tree), the debug APK into `out/`: + + docker build --target apk --output out . + +`docker build -t dmodem-android .` makes an image with the toolchain and +the source to run Gradle in; the `Dockerfile` has the rest (a release +build, the unit tests, a proxy's CA). + +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), and GoogleTest +(libgtest-dev, else CMake fetches it): + + cmake -S native-test -B build-host -G Ninja + cmake --build build-host + ctest --test-dir build-host --output-on-failure + +Each engine test is a ctest test of its own (`ctest -R engine.` for +those alone); `build-host/engine_test --gtest_filter=*Ringing` runs one +directly, `ENGINE_TEST_LOG=1` with the engine's log as it comes. + +With `build-host` built, the unit tests also make calls on its test +lines (fax between modems, against efax and D-Modem'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//-/`, +one file for each 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. + +Every function has a comment on the line just above it, or above its +annotations (Kotlin, Swift, shell), or a docstring (Python); C and C++ as +D-Modem's own rule has it. `tools/doc_check.py` lists any that don't +(and fails). + +CI (`.github/workflows/android.yml`) runs all three, and that check; it needs a +`DMODEM_TOKEN` secret that can read the private D-Modem submodule. + +Signing comes from the environment: `ANDROID_KEYSTORE_FILE` (a PKCS12 +keystore), `ANDROID_KEYSTORE_PASSWORD`, `ANDROID_KEY_ALIAS` and +`ANDROID_KEY_PASSWORD` (the store's password if unset). Without them a +debug build takes the SDK's debug key and a release build is unsigned. CI +decodes `ANDROID_KEYSTORE_BASE64` into that file: the repository's secrets +hold the debug keystore, the protected `release` environment's (main and +`v*` tags) the release one, which CI's `release` job signs with. diff --git a/docs/fax.md b/docs/fax.md new file mode 100644 index 0000000..9046614 --- /dev/null +++ b/docs/fax.md @@ -0,0 +1,17 @@ +# 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. +A call answered is a fax or a data call by what the caller sends +(D-Modem's adaptive answer, `AT+FAA=1`, on unless the settings turn +it off): a fax machine's CNG, a V.8 fax call or T.38 from the far end +and the modem says FAX, and the app's fax receiver takes the call by +itself; a modem's handshake and it says DATA, then its CONNECT, for the +terminal and the bridges. +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'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`). diff --git a/docs/features.md b/docs/features.md new file mode 100644 index 0000000..22a062b --- /dev/null +++ b/docs/features.md @@ -0,0 +1,97 @@ +# The app, screen by screen + + +- **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). +- **A call ringing in** (SIP, the other phone, a mobile call): the + phone's incoming call notification (heads-up, over the lock screen, + the ringtone) and a popup over the app, with who's calling when the + line says (the other phone's name): Answer (ATA: a fax machine's call + goes to the fax receiver by itself, a modem's to the terminal), or + Ignore (it rings on, out of sight); Answer as fax too when adaptive + answer is off. Gone when the modem + answers (here, a computer on a bridge, S0) or the caller gives up. +- **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; + the country, from the ITU's list of 192 (D-Modem's, after E.180): + the modem's line settings and how it hears busy, and the call progress + tones the app plays in its tones (a second of dial tone as an entry is + dialled, the ringing tone while the other phone rings, the busy or + congestion tone when a call can't be made), with a button to hear them. + `tools/country_tones.py` makes the shared Kotlin's copy of the table. +- **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), + and Start PPP: once a call is up (dialled and logged in by hand), the + app's PPP takes it, the phone's traffic through it as the internet's + own dial has it (`PppTakeoverTest`). + Files sent and received by ZMODEM, YMODEM, XMODEM(-1K) and Kermit, and + as Intel HEX or Motorola S-records for EPROM programmers, monitors and + boot loaders: a file sent as records (a file of them already, as it is: + S1/S2/S3 by the image's size, Intel's extended addresses past 64 KB), + records received with their checksums checked into the binary image + they hold (gaps 0xFF). Plain text too: a file's bytes sent verbatim, + as if typed (to an editor, a BBS, `cat > file`), and what comes saved + as it is until the line is quiet for 10 s. +- **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 (Copy for all of it). +- **AT commands** (Settings, AT commands, and the terminal's menu): the + AT command reference, D-Modem's manual (`docs/at_commands.pdf`, the + A5 edition) in the app (`app/src/main/assets/docs`), its pages shown + in the app with a zoom, or opened in the phone's PDF app for its search + and its contents' links. +- **Back**: from any other tab back to Home; on Home the app goes to the + background (the modem keeps running), as the Home button would. +- **Local Linux** (Settings, Linux): distributions installed and run + under proot, as root in /root, the phone's storage at /sdcard, and the + modem as a serial port at `/dev/ttyDM0` (a pty of the app's, bound in): + `minicom -D /dev/ttyDM0`, pppd, efax and the like work as on a real + modem. The program that opens it has the modem as a serial bridge's + client has it (one at a time, with the TCP, Bluetooth and USB bridges); + closing it drops DTR, so the call hangs up as a serial cable's end + would. `ModemTtyTest`, and `LinuxSystemTest` in a real Alpine under + proot: ATI from the distro, the modem's answer back. + A USB serial adapter plugged into the phone is `/dev/ttyUSB0` there (a + pty of the app's too: Android lets no app's programs at a USB device): + the app opens the adapter when a program opens the port and closes it + (DTR down) when the program does; the speed, stop bits, RTS/CTS and B0's + hang-up follow what the program sets (`stty`, minicom, pppd); a pty keeps + no character size or parity, so it is 8 data bits, no parity. + `SerialTtyTest`. +- **Dial-in** (Settings, Dial-up internet): the phone as an ISP for whoever + calls the modem, on SIP or any other line. A call that rings is answered + (unless the fax settings answer calls already); once it connects, the + modem's DTE is taken and a PPP server on the call gives the caller + 10.64.64.2, DNS at 10.64.64.1 and the phone's network through the same + NAT the serial bridges' internet host uses. When the caller's PPP ends, + or none starts, the app hangs up; when the call drops, PPP stops. Home + shows the caller online, with what has gone each way and a Hang up + button. Tested over two of D-Modem's modems back to back + (`DialInLineTest`: answer, CONNECT 33600, the address, DNS and a ping + through the phone, the hang-up). + +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. diff --git a/docs/ios.md b/docs/ios.md new file mode 100644 index 0000000..ffe2908 --- /dev/null +++ b/docs/ios.md @@ -0,0 +1,65 @@ +# The iOS app + + +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, 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, Intel HEX and S-records, plain text), +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`. + +The iOS app (`ios/DModem`, SwiftUI, iOS 16) is the modem on a SIP +account, or on the line to another phone with the app (Android or iOS) +on the same Wi-Fi: the shared PeerLine on POSIX sockets (its PIN too), +offered and found with Bonjour (`_dmodem._tcp`, as Android's NSD). It has: + +- Home: the modem's state, the rates and what the CONNECT was, start, + hang up, stop, an AT command line, the log +- the terminal (the shared emulator drawn in SwiftUI, CP437 and the VGA + colours, Esc/Ctrl/Tab/arrows) and its file transfers (ZMODEM, YMODEM, + XMODEM, Kermit, Intel HEX, S-records, plain text; a remote's `sz` or `kermit -s` + starts one by itself) +- Fax: PDFs, images and text sent; a ringing call answered as a fax, by + hand or each one; the received faxes as PDFs +- Internet: dial-up to an ISP (its login script if it has one, PPP), the + phone's traffic through it as a VPN (the `DModemTunnel` packet tunnel + extension, its packets to the app's PPP on the loopback) +- Settings: the SIP account or the other phone, the modem's commands + +The modem's calls are the phone's own (CallKit): one ringing in rings +as a phone call does, answered or turned down there; one dialled shows +as a call, hung up from the call screen. The passwords and the PIN are +in the Keychain. Received files and faxes are in the Files app (On My +iPhone › D-Modem). The modem keeps going in the background on the audio +session (its speaker, or quiet); calls ring in while the app runs (with +no push service, a call can't wake it). Dial-up's VPN needs the Network +Extensions capability on the app's team. + +What the screens run is the shared Kotlin's jobs (`shared/.../jobs`: a +fax call, a transfer, dial-up, each lent the modem's DTE while it lasts), +tested on the JVM and natively. The modem apart from the views is the +`ios/DModemKit` Swift package (the engine from Swift, its DTE and who +it's lent to, the settings and their secrets, the session), whose tests +run on Linux too, against the host build: + + ./gradlew :shared:assembleDModemSharedReleaseXCFramework + ios/build-native.sh + cd ios/DModem && xcodegen generate && open DModem.xcodeproj + + DMODEM_HOST_BUILD=$PWD/build-host swift test --package-path ios/DModemKit # Linux or macOS + +D-Modem'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, runs the Swift +tests on macOS and builds the app for the simulator; the Linux job runs +DModemKit's tests on the host engine. diff --git a/docs/layout.md b/docs/layout.md new file mode 100644 index 0000000..9386410 --- /dev/null +++ b/docs/layout.md @@ -0,0 +1,23 @@ +# Source layout + + +- `external/d-modem-re`: D-Modem (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, on SIP, a peer line + (`peer_modem.cpp`) or a USB modem (`usb/`); `jni.cpp` binds it to + `org.dmodem.app.android.NativeModem`. +- `app/src/main/java/org/dmodem/app/android`: `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/org/dmodem/app/android/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) and through the C API, as GoogleTest + tests (`engine_test.cpp`, `c_api_test.cpp`), and on fake USB modems + (`usb_line_test.py`). diff --git a/docs/lines.md b/docs/lines.md new file mode 100644 index 0000000..cd97ae2 --- /dev/null +++ b/docs/lines.md @@ -0,0 +1,51 @@ +# The modem's line + +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](https://github.com/D-Modem/D-Modem)'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's modem for speech codecs, +`+MS=VCVM`) 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 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. + +Or no line at all: the modem starts on its own, no SIP account or +network needed, and answers AT commands in the terminal and on the serial +bridges; a dial gets NO DIALTONE, as a modem with no phone cable. Home +offers it beside setting up SIP ("Start without a 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). diff --git a/ios/DModem/Sources/SettingsView.swift b/ios/DModem/Sources/SettingsView.swift index 1321026..eaaabc0 100644 --- a/ios/DModem/Sources/SettingsView.swift +++ b/ios/DModem/Sources/SettingsView.swift @@ -160,7 +160,7 @@ private struct PeerSection: View { } } -/// the modem's country (D-Modem-RE's ITU list: its line settings, how it hears busy), searched by name +/// the modem's country (D-Modem's ITU list: its line settings, how it hears busy), searched by name private struct CountryList: View { @Binding var selection: String @Environment(\.dismiss) private var dismiss diff --git a/ios/build-native.sh b/ios/build-native.sh index 3c157fb..cfa330a 100755 --- a/ios/build-native.sh +++ b/ios/build-native.sh @@ -3,7 +3,7 @@ # Copyright (C) 2026 Neo-Desktop # # The modem for Apple's systems: the app's engine (app/src/main/cpp) with -# D-Modem-RE, libre and Mbed TLS, built for iOS (devices), the iOS +# D-Modem, libre and Mbed TLS, built for iOS (devices), the iOS # simulator and macOS, each as one static library, together as # build-apple/DModemEngine.xcframework (its header dmodem_engine.h, its # module DModemEngine: Swift imports it). @@ -32,7 +32,7 @@ build() { -DCMAKE_OSX_DEPLOYMENT_TARGET="$min" \ -DDMODEM_CRYPTO=mbedtls if [ "$system" = iOS ]; then - # (no app bundles: D-Modem-RE's dmodemd, which is never built + # (no app bundles: D-Modem's dmodemd, which is never built # here, is an executable that CMake would make a bundle on iOS, # and its install rule has no BUNDLE DESTINATION for one) set -- "$@" -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_MACOSX_BUNDLE=OFF diff --git a/native-test/CMakeLists.txt b/native-test/CMakeLists.txt index e0e7f6e..b428865 100644 --- a/native-test/CMakeLists.txt +++ b/native-test/CMakeLists.txt @@ -1,7 +1,7 @@ # SPDX-License-Identifier: AGPL-3.0-only # Copyright (C) 2026 Neo-Desktop # The app's native engine on the build host: the same CMake as the app's -# (app/src/main/cpp), with dmodemd from the same D-Modem-RE tree as the +# (app/src/main/cpp), with dmodemd from the same D-Modem tree as the # other end of the calls. # # cmake -S native-test -B build-host && cmake --build build-host @@ -11,11 +11,11 @@ project(dmodem_android_test LANGUAGES C CXX) enable_testing() add_subdirectory(../app/src/main/cpp app) -# (D-Modem-RE's u8 .. s64, its include/dm_types.h) +# (D-Modem's u8 .. s64, its include/dm_types.h) include_directories(${DMODEM_RE_INCLUDE}) # GoogleTest for the engine's tests: the system's (libgtest-dev) or else -# fetched, as D-Modem-RE has it (its cmake/gtest.cmake) +# fetched, as D-Modem has it (its cmake/gtest.cmake) find_package(GTest 1.10 QUIET) if(NOT GTest_FOUND) include(FetchContent) @@ -60,7 +60,7 @@ target_compile_definitions(sip_fax_line PRIVATE DMODEMD_PATH="$) set_tests_properties(usb_line PROPERTIES TIMEOUT 300) -# the same on D-Modem-RE's fake Agere USB 2.0 soft modems +# the same on D-Modem's fake Agere USB 2.0 soft modems # (test/fake_agere.cpp): the ROM's isochronous stream add_library(dmodem_engine_agere STATIC ${_app}/engine.cpp ${_app}/peer_modem.cpp ${_app}/dmodem_engine.cpp @@ -162,7 +162,7 @@ add_test(NAME agere_line COMMAND python3 $ agere) set_tests_properties(agere_line PROPERTIES TIMEOUT 300) -# the same on D-Modem-RE's fake Apple USB Modems (test/fake_apple.cpp): +# the same on D-Modem's fake Apple USB Modems (test/fake_apple.cpp): # USB audio's streams, CDC's line control add_library(dmodem_engine_apple STATIC ${_app}/engine.cpp ${_app}/peer_modem.cpp ${_app}/dmodem_engine.cpp diff --git a/native-test/codec_line.cpp b/native-test/codec_line.cpp index 4430e4a..dfb2700 100644 --- a/native-test/codec_line.cpp +++ b/native-test/codec_line.cpp @@ -2,7 +2,7 @@ * SPDX-License-Identifier: AGPL-3.0-only * Copyright (C) 2026 Neo-Desktop * - * codec_line.cpp - two modems back to back (D-Modem-RE's PipeModem, + * codec_line.cpp - two modems back to back (D-Modem's PipeModem, * a pty for each one's DTE) on a cellular call's * line: each way through a speech codec, 20 ms * frames encoded and decoded as a phone and the diff --git a/native-test/fax_line.cpp b/native-test/fax_line.cpp index 7f1a7d7..c32d923 100644 --- a/native-test/fax_line.cpp +++ b/native-test/fax_line.cpp @@ -2,7 +2,7 @@ * SPDX-License-Identifier: AGPL-3.0-only * Copyright (C) 2026 Neo-Desktop * - * fax_line.cpp - D-Modem-RE's modem_test (two modems back to back on + * fax_line.cpp - D-Modem's modem_test (two modems back to back on * an audio pipe, a pty for each one's DTE) paced as a * phone line is: at the sample clock (MODEM_REALTIME, * as the interop tests have it), so that a fax diff --git a/native-test/t30_line.cpp b/native-test/t30_line.cpp index 661e3f8..fbe06cc 100644 --- a/native-test/t30_line.cpp +++ b/native-test/t30_line.cpp @@ -2,8 +2,8 @@ * SPDX-License-Identifier: AGPL-3.0-only * Copyright (C) 2026 Neo-Desktop * - * t30_line.cpp - a class 1 modem (D-Modem-RE's PipeModem, a pty for - * its DTE) on a phone line to D-Modem-RE's own T.30 + * t30_line.cpp - a class 1 modem (D-Modem's PipeModem, a pty for + * its DTE) on a phone line to D-Modem's own T.30 * fax machine (dsp/t30.cpp), with or without error * correction mode, noise on the line if asked: the * app's fax (its T.30 on the DTE) against another diff --git a/native-test/usb_host.cpp b/native-test/usb_host.cpp index 3b9db33..9953b68 100644 --- a/native-test/usb_host.cpp +++ b/native-test/usb_host.cpp @@ -4,7 +4,7 @@ * * usb_host.cpp - the app's engine on a USB modem's line (engine.h, * usb_modem.h) as a program, for usb_line_test.py: the - * device D-Modem-RE's fake pico-serial Line stick + * device D-Modem's fake pico-serial Line stick * (test/fake_pico_line.cpp, linked in as libusb), its * line the simulated exchange's at $FAKE_PICO_LINE_SOCKET * diff --git a/native-test/usb_line_test.py b/native-test/usb_line_test.py index d4281c2..4fd5cb2 100644 --- a/native-test/usb_line_test.py +++ b/native-test/usb_line_test.py @@ -4,10 +4,10 @@ # # usb_line_test.py [agere|apple]: the app's # engine on a USB modem's line (usb_modem.h), two of them (usb_host) on -# D-Modem-RE's fake pico-serial Line sticks (or, agere, its fake Agere USB +# D-Modem's fake pico-serial Line sticks (or, agere, its fake Agere USB # 2.0 soft modems at 8000 Hz, on their ROM's isochronous stream; or, # apple, its fake Apple USB Modems) whose lines are the simulated -# exchange's, 1001 and 1002 (as D-Modem-RE's pico_line_test.py, +# exchange's, 1001 and 1002 (as D-Modem's pico_line_test.py, # agere_test.py and apple_test.py run dmodemd --usb): # # - each says what it's on (ATI3); diff --git a/shared/src/commonMain/kotlin/org/dmodem/app/tones/CountryTones.kt b/shared/src/commonMain/kotlin/org/dmodem/app/tones/CountryTones.kt index 5b8ea18..5eb7cb1 100644 --- a/shared/src/commonMain/kotlin/org/dmodem/app/tones/CountryTones.kt +++ b/shared/src/commonMain/kotlin/org/dmodem/app/tones/CountryTones.kt @@ -59,7 +59,7 @@ class Tone(val f1: Int, val f2: Int, val mod: Float, val cadence: FloatArray) { } /** - * A country's call progress tones, from D-Modem-RE's table (the ITU's + * A country's call progress tones, from D-Modem's table (the ITU's * list, after E.180): the ringing tone a caller hears (the ring signal to * the called line keeps its cadence, at [ringHz]), the dial tone, the busy * tone (the called line busy) and the congestion tone (the network's lines diff --git a/shared/src/commonMain/kotlin/org/dmodem/app/tones/CountryTonesTable.kt b/shared/src/commonMain/kotlin/org/dmodem/app/tones/CountryTonesTable.kt index 5ee6b6e..1c989b8 100644 --- a/shared/src/commonMain/kotlin/org/dmodem/app/tones/CountryTonesTable.kt +++ b/shared/src/commonMain/kotlin/org/dmodem/app/tones/CountryTonesTable.kt @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only // Copyright (C) 2026 Neo-Desktop // -// Generated by tools/country_tones.py from D-Modem-RE's dsp/tones.cpp +// Generated by tools/country_tones.py from D-Modem's dsp/tones.cpp // (the ITU's list of the tones of national networks, Annex to ITU // Operational Bulletin No. 955, after E.180). Don't edit: run it again. package org.dmodem.app.tones diff --git a/shared/src/commonTest/kotlin/org/dmodem/app/tones/CountryTonesTest.kt b/shared/src/commonTest/kotlin/org/dmodem/app/tones/CountryTonesTest.kt index cd72161..ec61c72 100644 --- a/shared/src/commonTest/kotlin/org/dmodem/app/tones/CountryTonesTest.kt +++ b/shared/src/commonTest/kotlin/org/dmodem/app/tones/CountryTonesTest.kt @@ -13,7 +13,7 @@ import kotlin.test.assertNull import kotlin.test.assertTrue /** - * The countries' tones (D-Modem-RE's ITU table): found by any of their + * The countries' tones (D-Modem's ITU table): found by any of their * names; their sound, the right frequencies in the right cadence. */ class CountryTonesTest { diff --git a/shared/src/jvmTest/kotlin/org/dmodem/app/tones/CountryTonesSourceTest.kt b/shared/src/jvmTest/kotlin/org/dmodem/app/tones/CountryTonesSourceTest.kt index 6e4357e..f3444e1 100644 --- a/shared/src/jvmTest/kotlin/org/dmodem/app/tones/CountryTonesSourceTest.kt +++ b/shared/src/jvmTest/kotlin/org/dmodem/app/tones/CountryTonesSourceTest.kt @@ -8,12 +8,12 @@ import kotlin.test.Test import kotlin.test.assertEquals /** - * The shared table is D-Modem-RE's as it is now: tools/country_tones.py + * The shared table is D-Modem's as it is now: tools/country_tones.py * run on the submodule's dsp/tones.cpp gives the file there is (when the * submodule and Python are here). */ class CountryTonesSourceTest { - /** tools/country_tones.py run on D-Modem-RE's tones.cpp gives the committed table (skipped without them or Python) */ + /** tools/country_tones.py run on D-Modem's tones.cpp gives the committed table (skipped without them or Python) */ @Test fun theTableIsD_ModemREs() { val root = generateSequence(File("").absoluteFile) { it.parentFile }.firstOrNull { File(it, "tools/country_tones.py").exists() } ?: return diff --git a/tools/country_tones.py b/tools/country_tones.py index 6c31d21..1692bc8 100644 --- a/tools/country_tones.py +++ b/tools/country_tones.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: AGPL-3.0-only # Copyright (C) 2026 Neo-Desktop -"""The countries' tones for the apps' shared Kotlin, from D-Modem-RE's +"""The countries' tones for the apps' shared Kotlin, from D-Modem's table (external/d-modem-re/dsp/tones.cpp: the ITU's list of national networks' tones, after E.180): each country's ringing, dial, busy and congestion tones, and the table's other names of them. @@ -45,7 +45,7 @@ def main(): out.write("""// SPDX-License-Identifier: AGPL-3.0-only // Copyright (C) 2026 Neo-Desktop // -// Generated by tools/country_tones.py from D-Modem-RE's dsp/tones.cpp +// Generated by tools/country_tones.py from D-Modem's dsp/tones.cpp // (the ITU's list of the tones of national networks, Annex to ITU // Operational Bulletin No. 955, after E.180). Don't edit: run it again. package org.dmodem.app.tones diff --git a/tools/doc_check.py b/tools/doc_check.py index 8eabc08..df068ff 100644 --- a/tools/doc_check.py +++ b/tools/doc_check.py @@ -9,7 +9,7 @@ # usage: tools/doc_check.py [FILE...] # # Without FILEs, git's tracked *.kt, *.kts, *.swift, *.py, *.sh, *.c, -# *.cpp and *.h outside external/. C and C++ go to D-Modem-RE's own +# *.cpp and *.h outside external/. C and C++ go to D-Modem's own # check (external/d-modem-re/cmake/doc_check.py), the same rule. # Prints each undocumented function as file:line and exits 1 if there # are any.