From dfb7699317376e614fbe4a94da56031ddec2cb07 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 18 Oct 2026 01:04:20 +0000 Subject: [PATCH] Mobile-call line: V.cvm, by default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Claude-Session: https://claude.ai/code/session_0172Hejd12i4aYikYW9vgpZs --- README.md | 14 ++++++-- .../neodesktop/dmodem/modem/ConnectInfo.kt | 27 ++++++++++++++ .../dmodem/settings/ModemSettings.kt | 12 +++++-- .../neodesktop/dmodem/ui/DashboardScreen.kt | 4 +++ .../com/neodesktop/dmodem/ui/PeerLineUi.kt | 4 ++- .../neodesktop/dmodem/cell/CellLineTest.kt | 35 +++++++++++++++++++ .../dmodem/cell/CellSettingsTest.kt | 17 +++++++-- 7 files changed, 104 insertions(+), 9 deletions(-) create mode 100644 app/src/main/java/com/neodesktop/dmodem/modem/ConnectInfo.kt diff --git a/README.md b/README.md index 5e79f40..9b33a1b 100644 --- a/README.md +++ b/README.md @@ -26,9 +26,17 @@ speech through codecs that wreck modem signals; native-test's | 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 | -So the mobile-call line starts the modem at V.21 (+MS=V21), with 1200 and -2400 bit/s as settings to try. -Fax doesn't get through at all (V.27ter's training at 2400 bit/s comes +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. diff --git a/app/src/main/java/com/neodesktop/dmodem/modem/ConnectInfo.kt b/app/src/main/java/com/neodesktop/dmodem/modem/ConnectInfo.kt new file mode 100644 index 0000000..b66e707 --- /dev/null +++ b/app/src/main/java/com/neodesktop/dmodem/modem/ConnectInfo.kt @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: AGPL-3.0-only +// Copyright (C) 2026 Neo-Desktop +package com.neodesktop.dmodem.modem + +/** + * What a CONNECT result says beyond the rate ("CONNECT 1200/CVM/LAPM", + * "CONNECT 56000/V92/LAPM/V44"): the modulation, the error correction, + * the compression, as the dashboard shows them ("V.cvm · LAPM"). + */ +object ConnectInfo { + private val NAMES = mapOf( + "CVM" to "V.cvm", "V92" to "V.92", "V90" to "V.90", "V91" to "V.91", "V34" to "V.34", + "V32B" to "V.32bis", "V32" to "V.32", "V22B" to "V.22bis", "V22" to "V.22", "V23" to "V.23", + "V21" to "V.21", "B103" to "Bell 103", "B212" to "Bell 212", "LAPM" to "LAPM", "MNP" to "MNP", + "V44" to "V.44", "V42BIS" to "V.42bis", "MNP5" to "MNP 5", + ) + + /** the last CONNECT line in [console]: its parts after the rate, named; empty when there's none */ + fun label(console: String): String { + val i = console.lastIndexOf("CONNECT") + if (i < 0) return "" + val line = console.substring(i).substringBefore('\n').substringBefore('\r') + return line.removePrefix("CONNECT").trim().split('/').drop(1) + .mapNotNull { NAMES[it.trim().uppercase()] } + .joinToString(" · ") + } +} diff --git a/app/src/main/java/com/neodesktop/dmodem/settings/ModemSettings.kt b/app/src/main/java/com/neodesktop/dmodem/settings/ModemSettings.kt index 4df43d1..74328b1 100644 --- a/app/src/main/java/com/neodesktop/dmodem/settings/ModemSettings.kt +++ b/app/src/main/java/com/neodesktop/dmodem/settings/ModemSettings.kt @@ -45,8 +45,11 @@ data class ModemSettings( val peerPin: String = "", /** the modem's speaker on the phone's: the dialling and the handshake heard (as ATM and ATL have it) */ val speaker: Boolean = true, - /** the modulation on mobile calls (+MS): V21 (300 bit/s, what a speech codec carries), V22, V22B */ - val cellSpeed: String = "V21", + /** + * the modulation on mobile calls (+MS): V_CVM (V.cvm, made for speech codecs: about 1200 bit/s + * through AMR 12.2, to another D-Modem; V.22 or V.21 to other modems), V21 (300 bit/s), V22, V22B + */ + val cellSpeed: String = CELL_VCVM, ) { /** the line is another phone (or this phone's mobile calls), not SIP: the app carries its samples */ val peer: Boolean get() = line != LINE_SIP @@ -58,7 +61,8 @@ data class ModemSettings( fun startCommands(): String { val init = initCommands.trim() if (line != LINE_CELL) return init - val ms = "AT+MS=$cellSpeed" + // (V.cvm's start-up, probing the codec, takes 15 to 21 s after V.8: S7 has room for it) + val ms = "AT+MS=$cellSpeed" + if (cellSpeed == CELL_VCVM) ";S7=90" else "" return when { init.isEmpty() -> ms init.startsWith("AT", ignoreCase = true) -> "$ms;" + init.substring(2) @@ -71,6 +75,8 @@ data class ModemSettings( const val LINE_WIFI = "wifi" const val LINE_BLUETOOTH = "bluetooth" const val LINE_CELL = "cell" + /** the mobile-call line's V.cvm (D-Modem-RE's +MS=V_CVM) */ + const val CELL_VCVM = "V_CVM" /** * An account as `user:password@host[:port]` (dmodemd's SIP_LOGIN): null if it isn't one. diff --git a/app/src/main/java/com/neodesktop/dmodem/ui/DashboardScreen.kt b/app/src/main/java/com/neodesktop/dmodem/ui/DashboardScreen.kt index c4fab4a..18d4453 100644 --- a/app/src/main/java/com/neodesktop/dmodem/ui/DashboardScreen.kt +++ b/app/src/main/java/com/neodesktop/dmodem/ui/DashboardScreen.kt @@ -236,6 +236,10 @@ private fun HeroCard( Rate("↓ down", status.rxRate) Rate("↑ up", status.txRate) } + // (what the CONNECT said: "V.cvm · LAPM", "V.92 · LAPM · V.44") + val console by ModemState.console.flow.collectAsStateWithLifecycle() + val how = com.neodesktop.dmodem.modem.ConnectInfo.label(console) + if (how.isNotEmpty()) Text(how, style = MaterialTheme.typography.bodyMedium) } else if (sub.isNotEmpty()) { Text(sub, style = MaterialTheme.typography.bodyLarge) } diff --git a/app/src/main/java/com/neodesktop/dmodem/ui/PeerLineUi.kt b/app/src/main/java/com/neodesktop/dmodem/ui/PeerLineUi.kt index 171cf2a..aa1d014 100644 --- a/app/src/main/java/com/neodesktop/dmodem/ui/PeerLineUi.kt +++ b/app/src/main/java/com/neodesktop/dmodem/ui/PeerLineUi.kt @@ -282,7 +282,9 @@ fun CellLineFields(s: ModemSettings, onChange: (ModemSettings) -> Unit) { result?.let { Text(it, style = MaterialTheme.typography.bodySmall) } Text("Speed", style = MaterialTheme.typography.bodyMedium) for ((ms, label) in listOf( - "V21" to "300 bit/s (V.21): what mobile calls carry", + ModemSettings.CELL_VCVM to "About 1200 bit/s (V.cvm, made for mobile calls), to another phone with D-Modem: " + + "15 to 20 s to connect. Other modems get V.22, which a mobile call garbles: V.21 for those", + "V21" to "300 bit/s (V.21): what any modem's call carries", "V22" to "1200 bit/s (V.22): a good signal, may lose data", "V22B" to "2400 bit/s (V.22bis): a good signal, may lose data", )) { diff --git a/app/src/test/java/com/neodesktop/dmodem/cell/CellLineTest.kt b/app/src/test/java/com/neodesktop/dmodem/cell/CellLineTest.kt index 3d26af3..d0639e4 100644 --- a/app/src/test/java/com/neodesktop/dmodem/cell/CellLineTest.kt +++ b/app/src/test/java/com/neodesktop/dmodem/cell/CellLineTest.kt @@ -81,6 +81,41 @@ class CellLineTest { assertTrue(b.expect(data.take(40), 30).endsWith(data.take(40))) } + @Test + fun throughAmrInVcvm() { + assumeTrue("codec_line isn't built (native-test)", FakeNetwork.codecLine() != null) + 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 + // loading a mode for it; S7 long enough for that + a.command("ATE0\\V1+MS=V_CVM;S7=90") + b.command("ATE0\\V1S0=1+MS=V_CVM;S7=90") + a.send("ATD5550002\r") + val ca = a.connectLine() + val cb = b.connectLine() + println("V.cvm through AMR 12.2: A ${ca.trim()}, B ${cb.trim()}") + assertTrue(ca, ca.contains("/CVM")) + assertTrue(cb, cb.contains("/CVM")) + // through AMR 12.2 about 1200 bit/s, coded (V.21's four times) + assertTrue(ca, rate(ca) >= 600) + // LAPM over it: the data whole, each way + val r = kotlin.random.Random(4) + val data = (1..600).joinToString("") { ('a' + r.nextInt(26)).toString() } + a.send(data + "\r\n") + assertTrue(b.expect(data.takeLast(40), 60).contains(data)) + b.send("and back over V.cvm\r\n") + a.expect("and back over V.cvm", 30) + // the call's figures (+CVM?: the modes, then raw and coded rates each way, ...) + Thread.sleep(1200) + a.send("+++") + a.expect("OK", 10) + a.send("AT+CVM?\r") + val fig = a.expect("OK", 10) + println("A's figures: " + fig.lines().filter { it.startsWith("+CVM") }) + assertTrue(fig, Regex("\\+CVM: \\d+,\\d+,\\d+,\\d+,").containsMatchIn(fig)) + } + @Test fun nobodyAndNotForTheModem() { val net = FakeNetwork(closers = closers) diff --git a/app/src/test/java/com/neodesktop/dmodem/cell/CellSettingsTest.kt b/app/src/test/java/com/neodesktop/dmodem/cell/CellSettingsTest.kt index 39eafaa..d6091eb 100644 --- a/app/src/test/java/com/neodesktop/dmodem/cell/CellSettingsTest.kt +++ b/app/src/test/java/com/neodesktop/dmodem/cell/CellSettingsTest.kt @@ -11,11 +11,24 @@ class CellSettingsTest { @Test fun startCommands() { val cell = ModemSettings(line = ModemSettings.LINE_CELL) - assertEquals("AT+MS=V21;X3", cell.startCommands()) + // (V.cvm by default, S7 long enough for its start-up) + assertEquals("AT+MS=V_CVM;S7=90;X3", cell.startCommands()) + assertEquals("AT+MS=V21;X3", cell.copy(cellSpeed = "V21").startCommands()) assertEquals("AT+MS=V22B;X3M2", cell.copy(cellSpeed = "V22B", initCommands = "atX3M2").startCommands()) - assertEquals("AT+MS=V21", cell.copy(initCommands = " ").startCommands()) + assertEquals("AT+MS=V21", cell.copy(cellSpeed = "V21", initCommands = " ").startCommands()) // (another line: the init commands as they are) assertEquals("ATX3", ModemSettings().startCommands()) assertEquals("ATX3", ModemSettings(line = ModemSettings.LINE_WIFI).startCommands()) } + + @Test + fun whatTheConnectSaid() { + val label = com.neodesktop.dmodem.modem.ConnectInfo::label + assertEquals("V.cvm · LAPM", label("ATD5550002\r\nCONNECT 1200/CVM/LAPM\r\n")) + assertEquals("V.92 · LAPM · V.44", label("CONNECT 48000/V92/LAPM/V44\r\nhello")) + assertEquals("", label("CONNECT 300\r\n")) + assertEquals("", label("OK\r\n")) + // (the last one) + assertEquals("V.cvm", label("CONNECT 9600/V32\r\nNO CARRIER\r\nCONNECT 1200/CVM\r\n")) + } }