No line: the modem started on its own, without a SIP account

A fifth line, "No line (the modem on its own)": the engine starts as on
a peer line (no SIP, no network needed) with nothing behind it. It
answers AT commands in the terminal and on the serial bridges; a dial
gets NO DIALTONE, as a modem with no phone cable plugged in (the
engine's new peer event NO LINE), an answer NO CARRIER.

Home offers "Start without a line" beside "Set up SIP" when there's no
account: the line set to none and the modem started in one tap. iOS has
the same line and button.

Tests: c_api_test (NO LINE: NO DIALTONE), DModemKitTests.testNoLine
(started without an account, a dial NO DIALTONE, commands still
answered), PeerShotsTest.noLine, DashboardShotsTest.firstRun.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0172Hejd12i4aYikYW9vgpZs
This commit is contained in:
Claude committed 2026-10-18 23:57:13 +00:00
1 parent e999857e57
commit 06e4a41050
16 files changed
+148 -16

No files matched your search

+5
View File
@@ -40,6 +40,11 @@ Fax doesn't get through at all (V.cvm has no fax; V.27ter's training at 2400 bit
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
+2 -1
View File
@@ -85,7 +85,8 @@ void dmodem_stop(void);
int dmodem_running(void);
/* a peer line's event to the modem: RING, CANCEL, ANSWERED, FAILED
<SIP status>, DROPPED */
<SIP status>, DROPPED; NO LINE (a dial with nothing plugged in: NO
DIALTONE) */
void dmodem_peer_event(const char *line);
#ifdef __cplusplus
+3
View File
@@ -304,6 +304,9 @@ void PeerModem::act(const char *s)
m.line_answered();
else if (!strncmp(s, "FAILED ", 7))
m.line_failed(failure(atoi(s + 7)));
else if (!strcmp(s, "NO LINE"))
/* (nothing plugged in: as a modem with no phone cable) */
m.line_failed(dcore::Result::NoDialtone);
else if (!strcmp(s, "DROPPED")) {
if (m.started())
m.line_dropped();
@@ -236,7 +236,7 @@ class ModemService : Service() {
speakerSocket = s
ModemState.speaker.start(java.io.FileInputStream(s.fileDescriptor))
}
if (settings.peer) com.neodesktop.dmodem.peer.Peers.start(this, settings, ::log)
if (settings.peer && !settings.noLine) com.neodesktop.dmodem.peer.Peers.start(this, settings, ::log)
val start = settings.startCommands()
if (start.isNotBlank()) ModemState.dte.write(start + "\r")
return true
@@ -327,6 +327,12 @@ class ModemService : Service() {
}
override fun onLine(caller: Boolean, dial: String, line: android.os.ParcelFileDescriptor) {
if (settings.noLine) {
// (nothing plugged in: a dial gets NO DIALTONE, an answer NO CARRIER)
NativeModem.peerEvent(if (caller) "NO LINE" else "FAILED 503")
runCatching { line.close() }
return
}
com.neodesktop.dmodem.peer.Peers.lineStarted(caller, dial, line)
}
@@ -425,6 +431,7 @@ class ModemService : Service() {
ModemSettings.LINE_WIFI -> " (line: another phone on Wi-Fi)"
ModemSettings.LINE_BLUETOOTH -> " (line: another phone on Bluetooth)"
ModemSettings.LINE_CELL -> " (line: mobile calls)"
ModemSettings.LINE_NONE -> " (no line)"
else -> ""
}
}
@@ -53,9 +53,12 @@ data class ModemSettings(
*/
val cellSpeed: String = CELL_VCVM,
) {
/** the line is another phone (or this phone's mobile calls), not SIP: the app carries its samples */
/** the line is another phone (or this phone's mobile calls, or none), not SIP: the app carries its samples */
val peer: Boolean get() = line != LINE_SIP
/** no line at all: the modem on its own (AT commands, the terminal, the bridges); a dial gets NO DIALTONE */
val noLine: Boolean get() = line == LINE_NONE
/** Enough to start: an account (or the line another phone's). */
val complete: Boolean get() = peer || (user.isNotBlank() && domain.isNotBlank())
@@ -77,6 +80,7 @@ data class ModemSettings(
const val LINE_WIFI = "wifi"
const val LINE_BLUETOOTH = "bluetooth"
const val LINE_CELL = "cell"
const val LINE_NONE = "none"
/** the mobile-call line's V.cvm (D-Modem-RE's +MS=V_CVM) */
const val CELL_VCVM = "V_CVM"
@@ -130,6 +130,12 @@ fun DashboardScreen(
onHangUp = { scope.launch { Terminal.session.hangUp(status.link == NativeModem.Link.ONLINE) } },
onTerminal = onOpenTerminal,
onSetUp = onOpenSettings,
onStartNoLine = {
scope.launch {
SettingsStore(context).save(settings.copy(line = ModemSettings.LINE_NONE))
ModemService.start(context)
}
},
)
if (appearance != null && !lightsOnTop) ModemLights()
@@ -202,6 +208,7 @@ private fun HeroCard(
onHangUp: () -> Unit,
onTerminal: () -> Unit,
onSetUp: () -> Unit,
onStartNoLine: () -> Unit = {},
) {
val online = run == ModemState.Run.RUNNING && status.link == NativeModem.Link.ONLINE
val (dot, title, sub) = when {
@@ -249,8 +256,11 @@ private fun HeroCard(
Spacer(Modifier.height(4.dp))
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
when {
run == ModemState.Run.STOPPED && !configured ->
run == ModemState.Run.STOPPED && !configured -> {
Button(onClick = onSetUp) { Text("Set up SIP") }
// (the modem on its own: its AT commands, the terminal, the bridges)
OutlinedButton(onClick = onStartNoLine) { Text("Start without a line") }
}
run == ModemState.Run.STOPPED ->
Button(onClick = onStart) { Text("Start modem") }
online || status.offhook ->
@@ -288,6 +298,11 @@ private fun LineCard(s: ModemSettings, run: ModemState.Run, network: String?, on
Card(Modifier.fillMaxWidth().clickable(onClick = onSettings)) {
Column(Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) {
Text("Line", style = MaterialTheme.typography.labelLarge, color = MaterialTheme.colorScheme.primary)
if (s.noLine) {
InfoRow("Line", "none: the modem on its own")
Text("AT commands answered; a dial gets NO DIALTONE", style = MaterialTheme.typography.bodySmall)
return@Column
}
if (s.peer) {
PeerLineRows(s, run, network)
return@Column
@@ -54,6 +54,7 @@ fun LineChoice(s: ModemSettings, onChange: (ModemSettings) -> Unit) {
ModemSettings.LINE_WIFI to "Another phone with D-Modem, on Wi-Fi",
ModemSettings.LINE_BLUETOOTH to "Another phone with D-Modem, on Bluetooth",
ModemSettings.LINE_CELL to "This phone's mobile calls (slow; root)",
ModemSettings.LINE_NONE to "No line (the modem on its own)",
)
var open by remember { mutableStateOf(false) }
ExposedDropdownMenuBox(expanded = open, onExpandedChange = { open = it }) {
@@ -73,7 +74,7 @@ fun LineChoice(s: ModemSettings, onChange: (ModemSettings) -> Unit) {
onClick = {
open = false
when (line) {
ModemSettings.LINE_SIP, ModemSettings.LINE_CELL -> onChange(s.copy(line = line))
ModemSettings.LINE_SIP, ModemSettings.LINE_CELL, ModemSettings.LINE_NONE -> onChange(s.copy(line = line))
ModemSettings.LINE_WIFI -> onChange(
s.copy(line = line, peerAddress = if (s.line == line) s.peerAddress else "", peerName = ""),
)
@@ -98,6 +99,15 @@ fun LineChoice(s: ModemSettings, onChange: (ModemSettings) -> Unit) {
*/
@Composable
fun PeerLineFields(s: ModemSettings, onChange: (ModemSettings) -> Unit) {
if (s.noLine) {
Text(
"The modem starts with nothing on its line: no SIP account, no network needed. It answers AT commands " +
"in the terminal and on the serial bridges (ATI, AT&V, its registers, its settings); a dial gets NO DIALTONE, " +
"as a modem with no phone cable plugged in.",
style = MaterialTheme.typography.bodySmall,
)
return
}
if (s.line == ModemSettings.LINE_CELL) {
CellLineFields(s, onChange)
return
@@ -4,6 +4,7 @@ package com.neodesktop.dmodem.ui
import android.graphics.Bitmap
import androidx.compose.ui.graphics.asAndroidBitmap
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.captureToImage
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.onRoot
@@ -51,6 +52,9 @@ class DashboardShotsTest {
ModemState.setStatus(ModemState.IDLE)
compose.waitForIdle()
shot("home-1-first-run")
// no SIP account yet: set one up, or start the modem on its own
compose.onNodeWithText("Set up SIP").assertExists()
compose.onNodeWithText("Start without a line").assertExists()
}
@Test
@@ -64,6 +64,18 @@ class PeerShotsTest {
shot("peer-0-line-menu")
}
@Test
fun noLine() {
save(ModemSettings(line = ModemSettings.LINE_SIP))
compose.onNodeWithText("Settings").performClick()
compose.onNodeWithText("A SIP account (calls over the internet)").performScrollTo().performClick()
compose.onNodeWithText("No line (the modem on its own)").performClick()
compose.onNodeWithText("a dial gets NO DIALTONE", substring = true).assertExists()
// (no SIP account asked for)
compose.onNodeWithText("SIP account (saved with the button below)").assertDoesNotExist()
shot("peer-4-no-line")
}
@Test
fun homeOnACall() {
save(ModemSettings(line = ModemSettings.LINE_WIFI, peerAddress = "192.168.1.20:5070", peerName = "D-Modem on Pixel 8", listen = true))
+2 -2
View File
@@ -136,13 +136,13 @@ final class AppModel: ObservableObject {
// (the background audio first: the call keeps the app running)
audio.begin()
// (the line to another phone first: the modem's start commands may dial)
if s.peer { peer.start(s, session: session) } else { session.onLine = nil }
if s.peer && !s.noLine { peer.start(s, session: session) } else { session.onLine = nil }
if !session.start(s, dns: SystemDNS.servers(), dataFile: dataFile) {
peer.stop()
audio.end()
}
}
watchPeer(s.peer)
watchPeer(s.peer && !s.noLine)
}
func stop() {
+15 -2
View File
@@ -43,7 +43,10 @@ struct HomeView: View {
.padding(.vertical, 6)
}
Section("Line") {
if model.settings.line == .wifi {
if model.settings.noLine {
LabeledContent("Line", value: "none: the modem on its own")
Text("AT commands answered; a dial gets NO DIALTONE").foregroundStyle(.secondary)
} else if model.settings.line == .wifi {
LabeledContent("Another phone", value: model.settings.peerAddress.isEmpty ? "none chosen" : model.settings.peerAddress)
Text(model.peerState ?? "Starts with the modem").foregroundStyle(.secondary)
if let e = model.peerError {
@@ -53,7 +56,9 @@ struct HomeView: View {
LabeledContent("SIP account", value: model.settings.complete ? "\(model.settings.user)@\(model.settings.domain)" : "not set up")
LabeledContent("Fax", value: model.settings.t38 ? "audio or T.38" : "audio")
}
LabeledContent("Incoming calls", value: model.settings.listen ? "taken" : "off")
if !model.settings.noLine {
LabeledContent("Incoming calls", value: model.settings.listen ? "taken" : "off")
}
}
if model.run == .running {
Section("AT command") {
@@ -86,6 +91,14 @@ struct HomeView: View {
Button("Start the modem") { model.start() }
.buttonStyle(.borderedProminent)
.disabled(!model.settings.complete)
if !model.settings.complete {
// (the modem on its own: its AT commands in the terminal)
Button("Start without a line") {
model.settings.line = .none
model.start()
}
.buttonStyle(.bordered)
}
case .running:
if model.status.offHook {
Button("Hang up") { model.hangUp() }.buttonStyle(.borderedProminent)
+10 -5
View File
@@ -17,19 +17,24 @@ struct SettingsView: View {
Picker("Line", selection: $model.settings.line) {
Text("SIP account").tag(ModemSettings.Line.sip)
Text("Another phone (Wi-Fi)").tag(ModemSettings.Line.wifi)
Text("No line (the modem on its own)").tag(ModemSettings.Line.none)
}
} footer: {
Text(model.settings.line == .sip
? "The modem calls through a SIP provider to the phone network."
: "The two phones' modems call each other as on a perfect phone line, no SIP account: each dials (ATD) or answers as usual. The other phone needs D-Modem (Android or iOS) on the same Wi-Fi, taking calls.")
switch model.settings.line {
case .sip: Text("The modem calls through a SIP provider to the phone network.")
case .wifi: Text("The two phones' modems call each other as on a perfect phone line, no SIP account: each dials (ATD) or answers as usual. The other phone needs D-Modem (Android or iOS) on the same Wi-Fi, taking calls.")
case .none: Text("The modem starts with nothing on its line, no SIP account or network: it answers AT commands in the terminal; a dial gets NO DIALTONE, as a modem with no phone cable plugged in.")
}
}
if model.settings.line == .wifi {
PeerSection(model: model)
} else {
} else if model.settings.line == .sip {
sipSection
}
Section("Calls") {
Toggle(model.settings.line == .sip ? "Take incoming calls" : "Take calls from the other phone", isOn: $model.settings.listen)
if !model.settings.noLine {
Toggle(model.settings.line == .sip ? "Take incoming calls" : "Take calls from the other phone", isOn: $model.settings.listen)
}
if model.settings.line == .sip {
Toggle("Fax over T.38", isOn: $model.settings.t38)
Stepper("Local SIP port: \(model.settings.sipPort)", value: $model.settings.sipPort, in: 1024...65535)
@@ -19,6 +19,8 @@ public final class ModemSession: EngineListener, @unchecked Sendable {
private var dte: DTE?
/// the job the DTE is lent to (a fax call, a transfer, dial-up): its data goes there, not to [onData]
private var claimant: ((Data) -> Void)?
/// the settings' line is none: the engine's dials answered here
private var noLine = false
/// the most of the log and the console kept
public var logMax = 2000
@@ -63,6 +65,7 @@ public final class ModemSession: EngineListener, @unchecked Sendable {
let d = try engine.start(settings.engineConfig(dns: dns, dataFile: dataFile), listener: self)
lock.lock()
dte = d
noLine = settings.noLine
_run = .running
_status = ModemStatus()
_error = nil
@@ -181,6 +184,13 @@ public final class ModemSession: EngineListener, @unchecked Sendable {
}
public func engineLine(caller: Bool, dial: String, fd: Int32) {
lock.lock(); let none = noLine; lock.unlock()
if none {
// (nothing plugged in: a dial gets NO DIALTONE, an answer NO CARRIER)
engine.peerEvent(caller ? "NO LINE" : "FAILED 503")
close(fd)
return
}
if let h = onLine { h(caller, dial, fd) } else { close(fd) }
}
@@ -6,7 +6,8 @@ import Foundation
/// a SIP account, or another phone with the app on the same Wi-Fi).
public struct ModemSettings: Codable, Equatable, Sendable {
public enum Line: String, Codable, Sendable {
case sip, wifi
/// a SIP account; another phone with the app on Wi-Fi; nothing at all (the modem on its own)
case sip, wifi, none
}
/// the SIP account
@@ -54,9 +55,12 @@ public struct ModemSettings: Codable, Equatable, Sendable {
("sip-password", \.password), ("peer-pin", \.peerPin), ("isp-password", \.ispPassword),
]
/// the line another phone's, not SIP
/// the line another phone's (or none), not SIP
public var peer: Bool { line != .sip }
/// no line: the modem on its own (AT commands, the terminal); a dial gets NO DIALTONE
public var noLine: Bool { line == .none }
/// enough to start: an account (or the line another phone's)
public var complete: Bool { peer || (!user.isEmpty && !domain.isEmpty) }
@@ -134,6 +134,27 @@ final class DModemKitTests: XCTestCase {
session.stop()
}
func testNoLine() {
signal(SIGPIPE, SIG_IGN)
let session = ModemSession()
var settings = ModemSettings()
settings.line = .none
settings.initCommands = "ATE0"
// (no SIP account: it starts all the same)
XCTAssertTrue(settings.complete)
XCTAssertTrue(session.start(settings))
XCTAssertTrue(waitFor { session.console.contains("OK") }, session.console)
// a dial: nothing plugged in
session.command("ATX3D5551234")
XCTAssertTrue(waitFor { session.console.contains("NO DIALTONE") }, session.console)
// still answering commands
session.command("ATI3")
XCTAssertTrue(waitFor { session.console.contains("peer") }, session.console)
session.stop()
// the setting kept
XCTAssertEqual(try JSONDecoder().decode(ModemSettings.self, from: JSONEncoder().encode(settings)).line, .none)
}
func testIncompleteSettingsDontStart() {
let session = ModemSession()
XCTAssertFalse(session.start(ModemSettings()))
+18
View File
@@ -127,6 +127,24 @@ int main(void)
if (fd >= 0)
close(fd);
CHECK(expect(dte, "BUSY", 10), "the program's FAILED 486: BUSY");
/* no line at all (the app's "no line"): NO DIALTONE */
pthread_mutex_lock(&mu);
line_fd = -1;
pthread_mutex_unlock(&mu);
fd = -1;
put(dte, "ATD1\r");
for (int i = 0; i < 50 && fd < 0; i++) {
usleep(100000);
pthread_mutex_lock(&mu);
fd = line_fd;
pthread_mutex_unlock(&mu);
}
CHECK(fd >= 0, "ATD again: the line to the program");
dmodem_peer_event("NO LINE");
if (fd >= 0)
close(fd);
CHECK(expect(dte, "NO DIALTONE", 10), "the program's NO LINE: NO DIALTONE");
CHECK(statuses > 0 && logs > 0, "status (%d) and log (%d) reported", statuses, logs);
/* the DTE closed: the modem ends */