mirror of
https://github.com/D-Modem/app.git
synced 2026-11-28 17:38:05 -08:00
docs: rewrite voice and adapters in Simplified Technical English
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B82eRRRR4BV2CBsQMqfrT6 Signed-off-by: Claude <noreply@anthropic.com>
This commit is contained in:
2 files changed
+149
-116
No files matched your search
+87
-64
@@ -3,82 +3,105 @@
|
||||
## 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 phone can be the external modem of a computer on a serial cable. The
|
||||
connection can be one of these:
|
||||
|
||||
- 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.
|
||||
- A USB serial adapter. The app knows FTDI, CP210x, CH34x, PL2303 and CDC-ACM
|
||||
chips, with the IDs of the chip makers and the IDs of the 1100 (about)
|
||||
adapter makers that the Linux drivers know (tools/usb-serial-ids). It also
|
||||
knows the XR21V141x and XR21B14xx of Exar.
|
||||
- Bluetooth serial.
|
||||
- TCP.
|
||||
|
||||
Any other CDC-ACM adapter's line notifications (`SERIAL_STATE`) are read
|
||||
too, so the computer dropping DTR hangs up there as well.
|
||||
[pico-serial](https://github.com/D-Modem/hardware) is a USB-C to DB25 adapter
|
||||
for this use. When you connect it to the serial port of the computer, it is
|
||||
the modem on that port. The app finds its control interface and uses its
|
||||
lines and settings (refer to its firmware/PROTOCOL.md):
|
||||
|
||||
- The DCD, DSR and RI of the modem are each separate lines. An incoming call
|
||||
that rings raises RI on the computer, as the ring of a real modem does.
|
||||
- The app reads the DTR of the computer from the board. Thus, when the
|
||||
computer drops DTR, the call hangs up.
|
||||
- The serial port settings have these items: the role of the board
|
||||
(automatic, modem or computer port), the source of its speed (learned from
|
||||
the typed characters of the computer, as a Hayes modem does, or set by the
|
||||
app), RTS/CTS flow control, and the quantity of data that it carried.
|
||||
|
||||
The app also reads the line notifications (`SERIAL_STATE`) of all other
|
||||
CDC-ACM adapters. Thus, if the computer drops DTR, the call also hangs up on
|
||||
those adapters.
|
||||
|
||||
## 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.
|
||||
The line of the modem can also be a telephone line, through a USB modem that
|
||||
carries the sound of the modem. The app uses `usb_line.cpp` of D-Modem, as
|
||||
`dmodemd --usb` uses it to control these modems. The app supports these USB
|
||||
modems:
|
||||
|
||||
- A Smart Link SmartUSB56 (USB 0483:7554, with caller ID, and its ST7554 or
|
||||
ST75951 DAA).
|
||||
- A [pico-serial](https://github.com/D-Modem/hardware) Line stick
|
||||
(1209:0002, a Si3056 DAA). It has caller ID on hook, and the line settings
|
||||
of the country in its registers.
|
||||
- An Agere USB 2.0 soft modem (047E:2892, 047E:2828). It has 8000 Hz and
|
||||
caller ID, and uses the isochronous stream of its ROM. The app downloads
|
||||
nothing into it. It needs a USB 2.0 port.
|
||||
- The Apple USB Modem for Macs (A1101, 05AC:1401). It has a Si3056 DAA and
|
||||
uses USB audio for its samples (`usb_apple.cpp`). It has caller ID and the
|
||||
line settings of the country. We did not try it on a real modem yet.
|
||||
|
||||
The phone runs the modem. When you connect the stick to the phone (USB OTG),
|
||||
the stick is the line of the modem, without a SIP account or network. Select
|
||||
Settings, Line, "A phone line, through a USB modem". Android asks one time
|
||||
if D-Modem can use the stick. When you connect a stick, Android offers the
|
||||
app.
|
||||
|
||||
## 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 separate external modem (a US Robotics, a Zoom, or any Hayes modem) can
|
||||
replace the modem of D-Modem. Connect it to the phone through a USB serial
|
||||
adapter. The adapter can be one that the serial bridges know: a Prolific
|
||||
PL2303 (for example, PL2303GS), FTDI, CP210x, CH34x, CDC-ACM or Exar. Select
|
||||
Settings, Line, "A phone line, through a modem on a USB serial adapter", and
|
||||
set its speed (8N1) and RTS/CTS.
|
||||
|
||||
As with a Bluetooth modem, the terminal, the internet, fax and the
|
||||
`/dev/ttyDM0` of the Linux send their own AT commands to the modem. The
|
||||
status comes from its result codes and from its DCD, if the adapter reads
|
||||
DCD. The app keeps DTR high while the modem runs. When the modem stops, the
|
||||
app drops DTR (a modem at `&D2` hangs up). Android asks one time if D-Modem
|
||||
can use the adapter. `SerialAdapters` does this. It also prevents conflicts
|
||||
between the line of the modem, the `/dev/ttyUSB0` of the Linux and the USB
|
||||
bridge on an 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.
|
||||
A separate modem with the Dial-Up Networking profile of Bluetooth can
|
||||
replace the modem of D-Modem. An example is the BTA-NW1 of Sony (Bluetooth
|
||||
1.1) on a phone line. Select Settings, Line, "A phone line, through a
|
||||
Bluetooth modem", and select the paired modem. First, pair the modem in the
|
||||
Bluetooth settings of Android. An older modem asks for its PIN. The app
|
||||
connects to its DUN service (unencrypted, or its serial port, if necessary).
|
||||
The terminal, the internet and fax send their own AT commands to the modem.
|
||||
The status (online, its speed) comes from its result codes. If the
|
||||
connection drops, the app connects again one time.
|
||||
|
||||
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.
|
||||
An app cannot list the USB devices itself. Android opens the device that the
|
||||
user permitted and gives its descriptor. The app builds libusb for Android
|
||||
(`app/src/main/cpp/usb/libusb.cmake`, the pinned release of D-Modem). It
|
||||
builds `usb_line.cpp` with its three calls that look for the device renamed
|
||||
to the calls of `usb/usb_android.cpp`. These calls start libusb without its
|
||||
device discovery. They give it that descriptor, wrapped, as the only device
|
||||
on the bus.
|
||||
|
||||
We tested this on the build host with the fake pico-serial Line sticks,
|
||||
Agere modems and Apple USB Modems of D-Modem, and a simulated exchange
|
||||
(`native-test/usb_line_test.py`). Its `agere` run uses the isochronous
|
||||
stream of the ROM, and its `apple` run uses the streams of USB audio. The
|
||||
tests cover: the dial, caller ID, the answer, CONNECT 33600, data in each
|
||||
direction, the hang-up, and a disconnected stick. We did not test it yet on
|
||||
a phone with a real stick. On this line, the app does not send sound to the
|
||||
speaker of the phone.
|
||||
+62
-52
@@ -1,56 +1,65 @@
|
||||
# Voice calls and the answering machine
|
||||
|
||||
The modem makes and takes voice calls: a number called, or the call
|
||||
ringing answered, with the phone's earpiece or loudspeaker and its
|
||||
microphone. When it's turned on, the answering machine takes the calls
|
||||
The modem makes and receives voice calls. It can call a number or answer a
|
||||
call that rings. It uses the earpiece or loudspeaker of the phone, and its
|
||||
microphone. If you enable the answering machine, it answers the calls that
|
||||
nobody answers and keeps the messages on the phone.
|
||||
|
||||
It is D-Modem's V.253 voice mode, as a fax is its class 1: the shared
|
||||
Kotlin's `VoiceJob` (`shared/.../jobs/VoiceJob.kt`) is lent the modem's
|
||||
DTE for the call, and sends
|
||||
This is the V.253 voice mode of D-Modem, as fax uses its class 1. The
|
||||
`VoiceJob` of the shared Kotlin (`shared/.../jobs/VoiceJob.kt`) gets the DTE
|
||||
of the modem for the call, and sends these commands:
|
||||
|
||||
| Step | Command | The modem's answer |
|
||||
| --- | --- | --- |
|
||||
| Voice mode, G.711 μ-law at 8000 Hz | `AT+FCLASS=8`, `AT+VSM=4` | `OK` |
|
||||
| A call made | `ATD<number>` | `OK` once the far end answers; `BUSY`, `NO ANSWER` |
|
||||
| The ringing call answered | `AT+VLS=1` | `OK` |
|
||||
| The call's sound, both ways | `AT+VTR` | `CONNECT`, then the stream |
|
||||
| Hung up | `<DLE>^`, then `ATH`, `AT+FCLASS=0` | `<DLE><ETX>`, `OK` |
|
||||
| Make a call | `ATD<number>` | `OK` when the far end answers. `BUSY`, `NO ANSWER` |
|
||||
| Answer the call that rings | `AT+VLS=1` | `OK` |
|
||||
| The sound of the call, in the two directions | `AT+VTR` | `CONNECT`, then the stream |
|
||||
| Hang up | `<DLE>^`, then `ATH`, `AT+FCLASS=0` | `<DLE><ETX>`, `OK` |
|
||||
|
||||
The stream is μ-law octets both ways, a `<DLE>` doubled. The modem's
|
||||
`<DLE>` codes say what it heard: `l` the far end hung up, `b` a busy
|
||||
tone, `d` a dial tone (both: the exchange saying the caller has gone),
|
||||
the DTMF digits pressed. Our samples go at the line's pace, by the clock,
|
||||
60 ms ahead; silence when the microphone has none. The keypad's digits
|
||||
are DTMF tones in our sound.
|
||||
The stream is μ-law octets in the two directions, with each `<DLE>` doubled.
|
||||
The `<DLE>` codes of the modem tell what it heard:
|
||||
|
||||
Any line the modem has carries it: SIP, the line to another phone, a USB
|
||||
modem's phone line (when that modem has voice mode). A modem without it
|
||||
answers `ERROR` to `AT+FCLASS=8`, and the call stops with "the modem has
|
||||
no voice mode".
|
||||
- `l`: the far end hung up.
|
||||
- `b`: a busy tone.
|
||||
- `d`: a dial tone.
|
||||
- The DTMF digits that the far end pushed.
|
||||
|
||||
A busy tone and a dial tone both mean that the exchange says that the caller
|
||||
is gone. The app sends its samples at the rate of the line, by the clock,
|
||||
60 ms ahead. If the microphone gives no sound, the app sends silence. The
|
||||
digits of the keypad are DTMF tones in the sound of the app.
|
||||
|
||||
Each line of the modem can carry voice: SIP, the line to another phone, and
|
||||
the phone line of a USB modem (if that modem has voice mode). A modem without
|
||||
voice mode answers `ERROR` to `AT+FCLASS=8`, and the call stops with "the
|
||||
modem has no voice mode".
|
||||
|
||||
## The answering machine
|
||||
|
||||
Off until it's turned on (Android: Settings › Phone and answering
|
||||
machine; iOS: the Phone tab). When it's on, after the rings set (4 by
|
||||
default) it answers the call, plays the greeting (or none) and a beep,
|
||||
and records the caller until
|
||||
The answering machine is disabled until you enable it (Android: Settings ›
|
||||
Phone and answering machine. iOS: the Phone tab). When it is enabled, it
|
||||
answers the call after the set number of rings (4 by default). It plays the
|
||||
greeting (or no greeting) and a beep. Then it records the caller until one
|
||||
of these conditions occurs:
|
||||
|
||||
- they hang up (a busy or dial tone's start is cut from the message),
|
||||
- they have been quiet for 7 s (half a second of the quiet is kept), or
|
||||
- the longest message (2 minutes by default) has gone.
|
||||
- The caller hangs up. The app cuts the start of the busy tone or dial tone from the message.
|
||||
- The caller is silent for 7 s. The app keeps half a second of the silence.
|
||||
- The maximum message length (2 minutes by default) is reached.
|
||||
|
||||
A message under a second isn't kept. Each one is a WAV file (16-bit PCM,
|
||||
8000 Hz, mono) named for its time and the caller's number when caller ID
|
||||
gave it, `20261111-093000_5551234.wav`: on Android in the app's own
|
||||
storage (`files/voicemail`), on iOS in Documents/Voicemail (the Files
|
||||
app shows it). Nothing leaves the phone.
|
||||
The app does not keep a message that is shorter than one second. Each
|
||||
message is a WAV file (16-bit PCM, 8000 Hz, mono). Its name is its time and,
|
||||
if caller ID gave it, the number of the caller:
|
||||
`20261111-093000_5551234.wav`. On Android, the files are in the storage of
|
||||
the app (`files/voicemail`). On iOS, they are in Documents/Voicemail (the
|
||||
Files app shows them). No data goes out of the phone.
|
||||
|
||||
While a message is being left, **Listen** plays it on the loudspeaker
|
||||
and **Pick up** turns it into a call (the message isn't kept). The
|
||||
greeting is recorded with the microphone (a minute at most) or chosen
|
||||
from a sound file, at any rate: mixed to one channel and resampled to
|
||||
8000 Hz. The app reads these itself, the same on both phones:
|
||||
While a caller leaves a message, **Listen** plays it on the loudspeaker.
|
||||
**Pick up** changes it into a call (the app does not keep the message). You
|
||||
can record the greeting with the microphone (one minute maximum). You can
|
||||
also select a sound file with any sample rate. The app mixes the file to one
|
||||
channel and resamples it to 8000 Hz. The app reads these files itself, the
|
||||
same on the two phones:
|
||||
|
||||
| File | Kinds |
|
||||
| --- | --- |
|
||||
@@ -58,24 +67,25 @@ from a sound file, at any rate: mixed to one channel and resampled to
|
||||
| AIFF, AIFF-C | PCM, floats, A-law, μ-law |
|
||||
| Sun/NeXT `.au` | PCM, floats, A-law, μ-law |
|
||||
|
||||
The rest goes to the phone's own decoders: on Android MediaCodec (MP3,
|
||||
AAC/M4A, FLAC, Ogg Vorbis, Opus, AMR, and whatever else the phone has),
|
||||
on iOS AVAudioFile (MP3, AAC/M4A, FLAC, ALAC, CAF).
|
||||
The decoders of the phone read all other files. On Android, MediaCodec does
|
||||
this (MP3, AAC/M4A, FLAC, Ogg Vorbis, Opus, AMR, and all other formats that
|
||||
the phone has). On iOS, AVAudioFile does this (MP3, AAC/M4A, FLAC, ALAC, CAF).
|
||||
|
||||
Calls answered as faxes by the fax settings, or by dial-in, are answered
|
||||
on the first ring: with either on, the answering machine waits.
|
||||
The fax settings and dial-in answer their calls on the first ring. If one of
|
||||
them is enabled, the answering machine waits.
|
||||
|
||||
## Where it is
|
||||
|
||||
- Android: Home's **Phone** (call a number, the call as it goes, the
|
||||
messages), the incoming call's popup (**Answer as a voice call**,
|
||||
**Take a message**), Settings › **Phone and answering machine**.
|
||||
`voice/Voice.kt` runs the call, `voice/VoiceAudio.kt` its sound (an
|
||||
AudioTrack for the speaker; an AudioRecord with the phone's echo
|
||||
cancelling, `VOICE_COMMUNICATION`, for the microphone).
|
||||
- iOS: the **Phone** tab. `JobsModel` runs the call, `VoiceSound.swift`
|
||||
- Android: the **Phone** item on Home (call a number, the call while it
|
||||
continues, the messages), the popup for an incoming call (**Answer as a
|
||||
voice call**, **Take a message**), and Settings › **Phone and answering
|
||||
machine**. `voice/Voice.kt` runs the call. `voice/VoiceAudio.kt` runs its
|
||||
sound: an AudioTrack for the speaker, and an AudioRecord with the echo
|
||||
canceller of the phone (`VOICE_COMMUNICATION`) for the microphone.
|
||||
- iOS: the **Phone** tab. `JobsModel` runs the call. `VoiceSound.swift` runs
|
||||
its sound (AVAudioEngine in the voice chat mode).
|
||||
|
||||
The tests (`shared/src/commonTest/.../voice/VoiceTest.kt`) run a call,
|
||||
a busy number, a modem without voice mode, messages that end by a
|
||||
hang-up and by quiet, and one picked up, against a fake V.253 modem.
|
||||
The tests (`shared/src/commonTest/.../voice/VoiceTest.kt`) run against a
|
||||
fake V.253 modem. They test a call, a busy number, a modem without voice
|
||||
mode, messages that end with a hang-up and with silence, and a message that
|
||||
the user picks up.
|
||||
Reference in new issue
Block a user