diff --git a/README.md b/README.md index 4fc868a..09b2ced 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ modem, it uses V.91 at up to 62667 bit/s in the two directions. - Class 1 fax at up to 14400 bit/s: the app sends PDFs and images, and receives faxes as PDFs. T.38 is also available - Voice calls through the modem on the speaker and microphone of the phone, and an answering machine that keeps messages on the phone (disabled until you enable it) - The external modem of a vintage computer, on a USB serial adapter, [pico-serial](https://github.com/D-Modem/hardware), Bluetooth serial or TCP -- Real phone lines through USB modems (for example, the pico-serial Line stick), a Hayes modem on a serial adapter, or a Bluetooth modem +- Real phone lines through USB modems (for example, the pico-serial Line stick), a Hayes modem on a serial adapter, a MultiTech MT9234MU USB modem, or a Bluetooth modem - Two phones as the line for each other, through Wi-Fi or Bluetooth, without a SIP account - The mobile calls of the phone as a slow line, where Android permits it diff --git a/app/src/main/cpp/jni.cpp b/app/src/main/cpp/jni.cpp index b72f956..8e95363 100644 --- a/app/src/main/cpp/jni.cpp +++ b/app/src/main/cpp/jni.cpp @@ -11,7 +11,10 @@ */ #include +#include +#include #include +#include #include #include @@ -230,6 +233,13 @@ jboolean native_running(JNIEnv *, jclass) return Engine::instance().running(); } +/* NativeModem.nativeUsbReset(): the USB device open on fd reset + (usbfs): 0, or -errno */ +jint native_usb_reset(JNIEnv *, jclass, jint fd) +{ + return ioctl(fd, USBDEVFS_RESET, 0) < 0 ? -errno : 0; +} + const JNINativeMethod methods[] = { { "nativeStart", "(Ljava/lang/String;Ljava/lang/String;" "Ljava/lang/String;IZZLjava/lang/String;Ljava/lang/String;" @@ -240,6 +250,7 @@ const JNINativeMethod methods[] = { { "nativeSpeakerFd", "()I", reinterpret_cast(native_speaker_fd) }, { "nativePeerEvent", "(Ljava/lang/String;)V", reinterpret_cast(native_peer_event) }, + { "nativeUsbReset", "(I)I", reinterpret_cast(native_usb_reset) }, }; } // namespace diff --git a/app/src/main/java/org/dmodem/app/android/NativeModem.kt b/app/src/main/java/org/dmodem/app/android/NativeModem.kt index ea5d0ae..267fde0 100644 --- a/app/src/main/java/org/dmodem/app/android/NativeModem.kt +++ b/app/src/main/java/org/dmodem/app/android/NativeModem.kt @@ -109,6 +109,9 @@ object NativeModem { */ fun speakerSound(): ParcelFileDescriptor? = nativeSpeakerFd().takeIf { it >= 0 }?.let { ParcelFileDescriptor.adoptFd(it) } + /** The USB device open on [fd] reset, as if plugged in again (a TUSB3410 then runs its firmware): whether it was. */ + fun usbReset(fd: Int): Boolean = nativeUsbReset(fd) == 0 + /** A peer line's event to the modem: RING, CANCEL, ANSWERED, FAILED , DROPPED. */ fun peerEvent(line: String) = nativePeerEvent(line) @@ -125,6 +128,10 @@ object NativeModem { @JvmStatic private external fun nativePeerEvent(line: String) + /** the USB device open on [fd] reset (usbfs's USBDEVFS_RESET): 0, or -errno */ + @JvmStatic + private external fun nativeUsbReset(fd: Int): Int + /** the speaker sound's socket, -1 after the first call */ @JvmStatic private external fun nativeSpeakerFd(): Int diff --git a/app/src/main/java/org/dmodem/app/android/bridge/SerialAdapter.kt b/app/src/main/java/org/dmodem/app/android/bridge/SerialAdapter.kt index d99fe99..cd8350a 100644 --- a/app/src/main/java/org/dmodem/app/android/bridge/SerialAdapter.kt +++ b/app/src/main/java/org/dmodem/app/android/bridge/SerialAdapter.kt @@ -145,7 +145,11 @@ object SerialAdapters { * The first USB serial adapter plugged in that no one else has, opened for [who] at [format]: * Android asked first if the app may use it (the user has [askMs] to say), unless it has said so. */ - suspend fun open(context: Context, who: String, format: SerialFormat, askMs: Long = 60_000): Opened { + suspend fun open(context: Context, who: String, format: SerialFormat, askMs: Long = 60_000): Opened = + openAdapter(context, who, format, askMs, loaded = false) + + /** as [open]; [loaded]: a MultiTech modem's firmware was just loaded (not again) */ + private suspend fun openAdapter(context: Context, who: String, format: SerialFormat, askMs: Long, loaded: Boolean): Opened { val m = context.getSystemService(UsbManager::class.java) ?: return Opened.Failed("this phone has no USB host") val drivers = UsbSerialAdapters.prober.findAllDrivers(m) if (drivers.isEmpty()) return Opened.Failed("no USB serial adapter plugged in") @@ -157,6 +161,12 @@ object SerialAdapters { val allowed = withTimeoutOrNull(askMs) { ask(context, m, dev) } ?: false if (!allowed) return Opened.Failed("$label wasn't allowed: allow D-Modem to use it, then try again") } + // (a MultiTech modem with a TUSB3410: its firmware first, then the modem that comes back opened) + if (driver is TiSerialDriver && TiFirmware.needsFirmware(dev)) { + if (loaded) return Opened.Failed("$label: its firmware did not start") + TiFirmwareLoader.load(context, m, dev, who, label)?.let { return Opened.Failed(it) } + return openAdapter(context, who, format, askMs, loaded = true) + } if (!take(dev.deviceName, who)) return Opened.Failed("$label is in use (${holder(dev.deviceName)})") val conn = m.openDevice(dev) if (conn == null) { diff --git a/app/src/main/java/org/dmodem/app/android/bridge/TiFirmwareLoader.kt b/app/src/main/java/org/dmodem/app/android/bridge/TiFirmwareLoader.kt new file mode 100644 index 0000000..f9ad86f --- /dev/null +++ b/app/src/main/java/org/dmodem/app/android/bridge/TiFirmwareLoader.kt @@ -0,0 +1,119 @@ +// SPDX-License-Identifier: AGPL-3.0-only +// Copyright (C) 2026 Neo-Desktop +package org.dmodem.app.android.bridge + +import android.content.Context +import android.hardware.usb.UsbConstants +import android.hardware.usb.UsbDevice +import android.hardware.usb.UsbDeviceConnection +import android.hardware.usb.UsbManager +import kotlinx.coroutines.delay +import kotlinx.coroutines.withTimeoutOrNull +import org.dmodem.app.android.NativeModem +import java.io.File +import java.io.IOException + +/** + * The firmware file of the MultiTech modems with a TUSB3410 (MT9234MU, + * MT9234ZBA-USB), as the user imported it. The app has no copy of its own: + * MultiTech gave no licence that lets others distribute it. + */ +object TiFirmwareStore { + private const val PATH = "firmware/mts_mt9234mu.fw" + + /** where the imported file is kept */ + fun file(context: Context): File = File(context.filesDir, PATH) + + /** the imported file, or null if there is none */ + fun read(context: Context): ByteArray? = file(context).takeIf { it.isFile }?.readBytes() + + /** [bytes] kept as the firmware: null, or why they can't be */ + fun import(context: Context, bytes: ByteArray): String? { + TiFirmware.problem(bytes)?.let { return it } + val f = file(context) + f.parentFile?.mkdirs() + val tmp = File(f.parentFile, f.name + ".new") + tmp.writeBytes(bytes) + if (!tmp.renameTo(f)) { + tmp.delete() + return "the file could not be saved" + } + return null + } + + /** the imported file removed */ + fun remove(context: Context) { + file(context).delete() + } + + /** what the imported file is, for the user, or null if there is none */ + fun describe(context: Context): String? = read(context)?.let { TiFirmware.describe(it) } +} + +/** + * A MultiTech modem in its TUSB3410's boot ROM given its firmware: the + * download, the reset, and the wait until it comes back with the + * firmware's configurations. + */ +object TiFirmwareLoader { + /** how long the modem may take to come back */ + private const val BACK_MS = 10_000L + + /** + * [file] downloaded into [dev] through [conn]: its image in 64-octet + * packets to the boot ROM's one bulk OUT pipe; an IOException if a + * packet does not go + */ + fun download(conn: UsbDeviceConnection, dev: UsbDevice, file: ByteArray) { + val itf = dev.getInterface(0) + val ep = (0 until itf.endpointCount).map { itf.getEndpoint(it) } + .firstOrNull { it.type == UsbConstants.USB_ENDPOINT_XFER_BULK && it.direction == UsbConstants.USB_DIR_OUT } + ?: throw IOException("no bulk OUT pipe") + if (!conn.claimInterface(itf, true)) throw IOException("could not claim interface ${itf.id}") + try { + for (p in TiFirmware.packets(TiFirmware.image(file))) { + val n = conn.bulkTransfer(ep, p, p.size, 1000) + if (n != p.size) throw IOException("a packet of the firmware did not go ($n)") + } + } finally { + runCatching { conn.releaseInterface(itf) } + } + } + + /** + * The modem [dev] (in its boot ROM, the app permitted) given its + * firmware, as [who]: null once it is back with its UART, or why not. + */ + suspend fun load(context: Context, m: UsbManager, dev: UsbDevice, who: String, label: String): String? { + val file = TiFirmwareStore.read(context) + ?: return "$label needs its firmware (mts_mt9234mu.fw): import the file in Settings, Line, then try again" + if (!SerialAdapters.take(dev.deviceName, who)) return "$label is in use (${SerialAdapters.holder(dev.deviceName)})" + try { + val conn = m.openDevice(dev) ?: return "can't open $label" + try { + download(conn, dev, file) + delay(200) + // (the TUSB3410 runs the firmware after a reset; the + // modem comes back as a new device) + if (m.deviceList.containsKey(dev.deviceName)) NativeModem.usbReset(conn.fileDescriptor) + } catch (e: IOException) { + return "$label: the firmware download failed (${e.message})" + } finally { + conn.close() + } + } finally { + SerialAdapters.release(dev.deviceName) + } + val back = withTimeoutOrNull(BACK_MS) { + var d: UsbDevice? = null + while (d == null) { + delay(250) + d = m.deviceList.values.firstOrNull { + it.vendorId == dev.vendorId && it.productId == dev.productId && !TiFirmware.needsFirmware(it) + } + } + d + } + return if (back == null) "$label did not come back after its firmware download: disconnect it, connect it again, and try again" else null + } +} diff --git a/app/src/main/java/org/dmodem/app/android/bridge/TiSerialDriver.kt b/app/src/main/java/org/dmodem/app/android/bridge/TiSerialDriver.kt new file mode 100644 index 0000000..f7a3182 --- /dev/null +++ b/app/src/main/java/org/dmodem/app/android/bridge/TiSerialDriver.kt @@ -0,0 +1,460 @@ +// SPDX-License-Identifier: AGPL-3.0-only +// Copyright (C) 2026 Neo-Desktop +package org.dmodem.app.android.bridge + +import android.hardware.usb.UsbConstants +import android.hardware.usb.UsbDevice +import android.hardware.usb.UsbInterface +import com.hoho.android.usbserial.driver.CommonUsbSerialPort +import com.hoho.android.usbserial.driver.UsbSerialDriver +import com.hoho.android.usbserial.driver.UsbSerialPort +import java.io.IOException +import java.security.MessageDigest +import java.util.EnumSet + +/* + * Texas Instruments' TUSB3410 USB UART, as the MultiTech MT9234MU and + * MT9234ZBA-USB fax modems have it between USB and their modem. + * + * The chip has no firmware of its own (no EEPROM with it): plugged in, it + * shows its ROM's boot configuration (one interface, one bulk OUT pipe), + * and the host downloads the firmware into its RAM through that pipe. Then + * the chip is reset and comes back with two configurations; the second + * one has the UART (bulk IN and OUT, an interrupt pipe). The UART is set + * up with vendor requests to the device: the command in bRequest, the + * module (UART 1: 3) in wIndex. + * + * The facts (the requests, the configuration block, the UART's registers + * in the chip's XDATA, the firmware's header) are from TI's TUSB3410 data + * sheet and Linux's ti_usb_3410_5052 driver, which also lists the + * MultiTech IDs. Only the facts are taken from those; the driver is our own. + */ + +/** a control transfer on endpoint 0: the bytes moved, or < 0 */ +fun interface TiControl { + /** the transfer done, [data] (up to [length]) out or in: the bytes moved, or < 0 */ + fun transfer(requestType: Int, request: Int, value: Int, index: Int, data: ByteArray?, length: Int): Int +} + +/** the USB IDs of the modems with a TUSB3410 that the app drives */ +object TiIds { + const val MULTITECH = 0x06E0 + + /** MultiTech MultiMobile MT9234MU */ + const val MT9234MU = 0xF114 + + /** MultiTech MT9234ZBA-USB */ + const val MT9234ZBA = 0xF115 + + /** an older MT9234ZBA-USB */ + const val MT9234ZBA_OLD = 0x0319 + + val products = intArrayOf(MT9234MU, MT9234ZBA, MT9234ZBA_OLD) + + /** whether [vendor]:[product] is one of them */ + fun known(vendor: Int, product: Int): Boolean = vendor == MULTITECH && product in products + + /** the model's name, for the user */ + fun name(product: Int): String = when (product) { + MT9234MU -> "MultiTech MT9234MU" + else -> "MultiTech MT9234ZBA-USB" + } +} + +/** + * The firmware of a TUSB3410: checked, its header made right, sent in + * the boot ROM's 64-octet packets. + */ +object TiFirmware { + /** the most code the chip's RAM takes (the file less its 3-octet header) */ + const val MAX = 16284 + + /** a bulk packet of the download */ + const val PACKET = 64 + + /** the chip's two configurations: the boot ROM's, the firmware's */ + const val BOOT_CONFIG = 1 + const val ACTIVE_CONFIG = 2 + + /** why [file] can't be a TUSB3410 firmware, or null if it can */ + fun problem(file: ByteArray): String? = when { + file.size <= 3 -> "the file is empty" + file.size - 3 > MAX -> "the file is too large for a TUSB3410 (${file.size} octets)" + else -> null + } + + /** + * [file] as the boot ROM takes it: its first 3 octets set to the code's + * length (little-endian) and the code's checksum (its octets' sum, mod 256) + */ + fun image(file: ByteArray): ByteArray { + problem(file)?.let { throw IllegalArgumentException(it) } + val out = file.copyOf() + val len = file.size - 3 + var sum = 0 + for (i in 3 until file.size) sum += file[i].toInt() and 0xff + out[0] = len.toByte() + out[1] = (len shr 8).toByte() + out[2] = sum.toByte() + return out + } + + /** [image] in the download's packets */ + fun packets(image: ByteArray): List = + (image.indices step PACKET).map { image.copyOfRange(it, minOf(it + PACKET, image.size)) } + + /** whether [device] is in its boot ROM (one configuration, one pipe): its firmware not loaded yet */ + fun needsFirmware(device: UsbDevice): Boolean { + if (device.configurationCount != 1 || device.interfaceCount < 1) return false + return device.getInterface(0).endpointCount == 1 + } + + /** what [file] is, for the user: one of the known firmware files, by their SHA-1, or its size */ + fun describe(file: ByteArray): String { + val sha1 = MessageDigest.getInstance("SHA-1").digest(file).joinToString("") { "%02x".format(it) } + return KNOWN[sha1] ?: "a TUSB3410 firmware that the app does not know (${file.size} octets)" + } + + /** the firmware files the app knows, by SHA-1 */ + private val KNOWN = mapOf( + "5537e93217c509129d5a870b9fe089cd58647070" to "MultiTech's mts_mt9234mu.fw", + "a5044256b783f6385a9e90335df7eb12262311c0" to "MultiTech's mts_mt9234zba.fw (the same code as mts_mt9234mu.fw)", + "c79af370e324a6a03d07e2def6e2c66fd3764162" to "TI's ti_3410.fw (not tested on a MultiTech modem)", + ) +} + +/** + * The UART of a TUSB3410 that runs its firmware, by [control]: UART 1, + * the chip's only one. + */ +class TiUart(private val control: TiControl) { + var dtr = false + private set + var rts = false + private set + var flow = UsbSerialPort.FlowControl.NONE + private set + private var baud = 9600 + private var dataBits = 8 + private var stopBits = UsbSerialPort.STOPBITS_1 + private var parity = UsbSerialPort.PARITY_NONE + + /** command [request] to UART 1 with [value] and [data]; an IOException if it fails */ + private fun out(request: Int, value: Int, data: ByteArray? = null) { + val n = control.transfer(0x40, request, value, UART1, data, data?.size ?: 0) + if (n < 0) throw IOException("TUSB3410 command 0x%02x failed".format(request)) + } + + /** + * made ready, as the firmware wants it: the line set, the port opened + * and started, both buffers emptied, then set, opened and started again + * (the firmware is not always ready the first time); DTR and RTS as + * [dtr] and [rts], [flow] control + */ + fun open(dtr: Boolean = false, rts: Boolean = false, flow: UsbSerialPort.FlowControl = UsbSerialPort.FlowControl.NONE) { + this.flow = flow + config() + out(OPEN_PORT, OPEN_SETTINGS) + out(START_PORT, 0) + out(PURGE_PORT, PURGE_INPUT) + out(PURGE_PORT, PURGE_OUTPUT) + config() + out(OPEN_PORT, OPEN_SETTINGS) + out(START_PORT, 0) + lines(dtr, rts) + } + + /** the port closed */ + fun close() = out(CLOSE_PORT, 0) + + /** the speed and character format; IllegalArgumentException or UnsupportedOperationException if they can't be */ + fun setLine(baud: Int, dataBits: Int, stopBits: Int, parity: Int) { + if (baud <= 0) throw IllegalArgumentException("Invalid baud rate: $baud") + val d = divisor(baud) + if (d < 1 || d > 0xffff) throw UnsupportedOperationException("Unsupported baud rate: $baud") + if (dataBits !in 5..8) throw IllegalArgumentException("Invalid data bits: $dataBits") + when (stopBits) { + UsbSerialPort.STOPBITS_1, UsbSerialPort.STOPBITS_1_5, UsbSerialPort.STOPBITS_2 -> {} + else -> throw IllegalArgumentException("Invalid stop bits: $stopBits") + } + if (parity !in UsbSerialPort.PARITY_NONE..UsbSerialPort.PARITY_SPACE) throw IllegalArgumentException("Invalid parity: $parity") + this.baud = baud + this.dataBits = dataBits + this.stopBits = stopBits + this.parity = parity + config() + } + + /** flow control done by the chip: none, RTS/CTS or XON/XOFF */ + fun setFlow(f: UsbSerialPort.FlowControl) { + if (f != UsbSerialPort.FlowControl.NONE && f != UsbSerialPort.FlowControl.RTS_CTS && f != UsbSerialPort.FlowControl.XON_XOFF) { + throw UnsupportedOperationException("Unsupported flow control: $f") + } + flow = f + config() + } + + /** the configuration block (SET_CONFIG) written; it raises DTR and RTS, so they are set again as they were */ + private fun config() { + out(SET_CONFIG, 0, configBlock(baud, dataBits, stopBits, parity, flow)) + lines(dtr, rts) + } + + /** DTR and RTS: the UART's modem control register */ + fun lines(dtr: Boolean, rts: Boolean) { + val mcr = (if (dtr) MCR_DTR else 0) or (if (rts) MCR_RTS else 0) + writeXdata(UART1_BASE + OFFSET_MCR, MCR_DTR or MCR_RTS or MCR_LOOP, mcr) + this.dtr = dtr + this.rts = rts + } + + /** a break held on the line, or ended: the line control register's break bit */ + fun setBreak(on: Boolean) = writeXdata(UART1_BASE + OFFSET_LCR, LCR_BREAK, if (on) LCR_BREAK else 0) + + /** [value] in the bits of [mask] of the octet at [addr] of the chip's XDATA */ + private fun writeXdata(addr: Int, mask: Int, value: Int) { + val d = byteArrayOf( + ADDR_XDATA.toByte(), DATA_BYTE.toByte(), 1, + (addr ushr 24).toByte(), (addr ushr 16).toByte(), (addr ushr 8).toByte(), addr.toByte(), + mask.toByte(), value.toByte(), + ) + val n = control.transfer(0x40, WRITE_DATA, 0, RAM_PORT, d, d.size) + if (n < 0) throw IOException("TUSB3410 write to 0x%04x failed".format(addr)) + } + + /** the lines in (CTS, DSR, CD, RI): the port's status */ + fun status(): Status { + val b = ByteArray(5) + val n = control.transfer(0xC0, GET_PORT_STATUS, 0, UART1, b, b.size) + if (n != b.size) throw IOException("TUSB3410 port status failed") + val msr = b[3].toInt() and 0xff + return Status(cts = msr and MSR_CTS != 0, dsr = msr and MSR_DSR != 0, cd = msr and MSR_CD != 0, ri = msr and MSR_RI != 0) + } + + data class Status(val cts: Boolean, val dsr: Boolean, val cd: Boolean, val ri: Boolean) + + /** the chip's buffers emptied, either way */ + fun purge(tx: Boolean, rx: Boolean) { + if (rx) out(PURGE_PORT, PURGE_INPUT) + if (tx) out(PURGE_PORT, PURGE_OUTPUT) + } + + companion object { + // the commands (bRequest) + const val GET_PORT_STATUS = 0x02 + const val SET_CONFIG = 0x05 + const val OPEN_PORT = 0x06 + const val CLOSE_PORT = 0x07 + const val START_PORT = 0x08 + const val PURGE_PORT = 0x0B + const val WRITE_DATA = 0x80 + + // the modules (wIndex) + const val UART1 = 0x03 + const val RAM_PORT = 0x05 + + /** the bulk pipes in continuous mode, with a timeout of 2 */ + const val OPEN_SETTINGS = 0x01 or 0x80 or (2 shl 2) + + const val PURGE_OUTPUT = 0x00 + const val PURGE_INPUT = 0x80 + + // WRITE_DATA: the address space and the data's size + const val ADDR_XDATA = 0x30 + const val DATA_BYTE = 0x01 + + // UART 1's registers in XDATA + const val UART1_BASE = 0xFFA0 + const val OFFSET_LCR = 0x02 + const val OFFSET_MCR = 0x04 + const val LCR_BREAK = 0x40 + const val MCR_LOOP = 0x04 + const val MCR_DTR = 0x10 + const val MCR_RTS = 0x20 + + // the modem status register + const val MSR_CTS = 0x10 + const val MSR_DSR = 0x20 + const val MSR_RI = 0x40 + const val MSR_CD = 0x80 + + // the configuration block's flags + const val RTS_IN = 0x0001 + const val PARITY_CHECK = 0x0008 + const val CTS_OUT = 0x0020 + const val X_OUT = 0x0040 + const val X_IN = 0x0100 + const val MS_INTS = 0x2000 + const val AUTO_START_DMA = 0x4000 + + /** the TUSB3410's baud divisor for [baud] (its clock: 923077 Hz in these units), rounded */ + fun divisor(baud: Int): Int = (923077 + baud / 2) / baud + + /** + * the 10-octet configuration block: the divisor and the flags + * (big-endian), the data bits, the parity, the stop bits, XON, + * XOFF, and the mode (RS-232) + */ + fun configBlock(baud: Int, dataBits: Int, stopBits: Int, parity: Int, flow: UsbSerialPort.FlowControl): ByteArray { + var flags = MS_INTS or AUTO_START_DMA + if (parity != UsbSerialPort.PARITY_NONE) flags = flags or PARITY_CHECK + when (flow) { + UsbSerialPort.FlowControl.RTS_CTS -> flags = flags or RTS_IN or CTS_OUT + UsbSerialPort.FlowControl.XON_XOFF -> flags = flags or X_IN or X_OUT + else -> {} + } + val d = divisor(baud) + // (the library's parity codes are the chip's: none, odd, even, mark, space) + val stop = when (stopBits) { + UsbSerialPort.STOPBITS_2 -> 2 + UsbSerialPort.STOPBITS_1_5 -> 1 + else -> 0 + } + return byteArrayOf( + (d shr 8).toByte(), d.toByte(), + (flags shr 8).toByte(), flags.toByte(), + (dataBits - 5).toByte(), parity.toByte(), stop.toByte(), + UsbSerialPort.CHAR_XON.code.toByte(), UsbSerialPort.CHAR_XOFF.code.toByte(), + 0, + ) + } + } +} + +/** + * The port of a MultiTech modem with a TUSB3410 for usb-serial-for-android, + * once its firmware runs (SerialAdapters loads the firmware first). + */ +class TiSerialDriver(private val device: UsbDevice) : UsbSerialDriver { + private val port = TiSerialPort() + + /** the device the port is on */ + override fun getDevice(): UsbDevice = device + + /** its one port */ + override fun getPorts(): List = listOf(port) + + inner class TiSerialPort : CommonUsbSerialPort(device, 0) { + private var uart: TiUart? = null + private var itf: UsbInterface? = null + // (kept while closed, as set before open) + private var dtr = false + private var rts = false + + /** the driver the port is of */ + override fun getDriver(): UsbSerialDriver = this@TiSerialDriver + + /** the open port's UART; an IOException when closed */ + private fun uart(): TiUart = uart ?: throw IOException("Port not open") + + /** + * the port opened: the firmware's configuration selected, its + * interface claimed, its bulk pipes found, the UART set up with DTR, + * RTS and flow as set before + */ + override fun openInt() { + if (TiFirmware.needsFirmware(device)) throw IOException("its firmware is not loaded") + val conn = mConnection + val config = (0 until device.configurationCount).map { device.getConfiguration(it) } + .firstOrNull { it.id == TiFirmware.ACTIVE_CONFIG } + ?: throw IOException("no configuration ${TiFirmware.ACTIVE_CONFIG}") + if (!conn.setConfiguration(config)) throw IOException("could not select configuration ${TiFirmware.ACTIVE_CONFIG}") + if (config.interfaceCount < 1) throw IOException("no interface") + val i = config.getInterface(0) + if (!conn.claimInterface(i, true)) throw IOException("Could not claim interface ${i.id}") + itf = i + for (e in 0 until i.endpointCount) { + val ep = i.getEndpoint(e) + if (ep.type != UsbConstants.USB_ENDPOINT_XFER_BULK) continue + if (ep.direction == UsbConstants.USB_DIR_IN) mReadEndpoint = ep else mWriteEndpoint = ep + } + if (mReadEndpoint == null || mWriteEndpoint == null) throw IOException("no bulk pipes") + val u = TiUart { type, req, value, index, buf, len -> + conn.controlTransfer(type, req, value, index, buf, len, TIMEOUT) + } + u.open(dtr, rts, mFlowControl) + uart = u + } + + /** the port closed, its interface let go */ + override fun closeInt() { + runCatching { uart?.close() } + uart = null + itf?.let { i -> runCatching { mConnection.releaseInterface(i) } } + itf = null + } + + /** the UART's speed and character format */ + override fun setParameters(baudRate: Int, dataBits: Int, stopBits: Int, parity: Int) = + uart().setLine(baudRate, dataBits, stopBits, parity) + + /** CD, from the port's status */ + override fun getCD() = uart().status().cd + /** CTS, from the port's status */ + override fun getCTS() = uart().status().cts + /** DSR, from the port's status */ + override fun getDSR() = uart().status().dsr + /** RI, from the port's status */ + override fun getRI() = uart().status().ri + /** DTR as last set */ + override fun getDTR() = dtr + /** RTS as last set */ + override fun getRTS() = rts + + /** DTR set, kept for the next open if closed */ + override fun setDTR(value: Boolean) { + uart?.lines(value, rts) + dtr = value + } + + /** RTS set, kept for the next open if closed */ + override fun setRTS(value: Boolean) { + uart?.lines(dtr, value) + rts = value + } + + /** the lines: DTR and RTS as set, the rest from the port's status */ + override fun getControlLines(): EnumSet { + val s = uart().status() + val l = EnumSet.noneOf(UsbSerialPort.ControlLine::class.java) + if (rts) l.add(UsbSerialPort.ControlLine.RTS) + if (s.cts) l.add(UsbSerialPort.ControlLine.CTS) + if (dtr) l.add(UsbSerialPort.ControlLine.DTR) + if (s.dsr) l.add(UsbSerialPort.ControlLine.DSR) + if (s.cd) l.add(UsbSerialPort.ControlLine.CD) + if (s.ri) l.add(UsbSerialPort.ControlLine.RI) + return l + } + + /** all of them: the modem has every line */ + override fun getSupportedControlLines(): EnumSet = + EnumSet.allOf(UsbSerialPort.ControlLine::class.java) + + /** flow control done by the chip (kept for the next open if closed) */ + override fun setFlowControl(flowControl: UsbSerialPort.FlowControl) { + if (flowControl !in supportedFlowControl) throw UnsupportedOperationException("Unsupported flow control: $flowControl") + uart?.setFlow(flowControl) + mFlowControl = flowControl + } + + /** none, RTS/CTS and XON/XOFF */ + override fun getSupportedFlowControl(): EnumSet = EnumSet.of( + UsbSerialPort.FlowControl.NONE, UsbSerialPort.FlowControl.RTS_CTS, UsbSerialPort.FlowControl.XON_XOFF, + ) + + /** the chip's buffers emptied, either way */ + override fun purgeHwBuffers(purgeWriteBuffers: Boolean, purgeReadBuffers: Boolean) = + uart().purge(tx = purgeWriteBuffers, rx = purgeReadBuffers) + + /** a break held on the line, or ended */ + override fun setBreak(value: Boolean) = uart().setBreak(value) + } + + companion object { + private const val TIMEOUT = 1000 + + /** usb-serial-for-android's table: the MultiTech modems this driver takes */ + @JvmStatic + fun getSupportedDevices(): Map = mapOf(TiIds.MULTITECH to TiIds.products) + } +} diff --git a/app/src/main/java/org/dmodem/app/android/bridge/UsbSerialAdapters.kt b/app/src/main/java/org/dmodem/app/android/bridge/UsbSerialAdapters.kt index 0a4fec6..0dfa1b7 100644 --- a/app/src/main/java/org/dmodem/app/android/bridge/UsbSerialAdapters.kt +++ b/app/src/main/java/org/dmodem/app/android/bridge/UsbSerialAdapters.kt @@ -13,13 +13,14 @@ import com.hoho.android.usbserial.driver.UsbSerialProber /** * The USB serial adapters the app drives: usb-serial-for-android's own table (the chip makers' IDs, * any CDC-ACM device, a few modems), the many adapters on the same chips under their makers' own - * IDs, as Linux's drivers know them (UsbSerialIds), and Exar's XR21V141x/XR21B14xx/XR2280x (XrSerialDriver). + * IDs, as Linux's drivers know them (UsbSerialIds), Exar's XR21V141x/XR21B14xx/XR2280x (XrSerialDriver), and the + * MultiTech modems with a TUSB3410 (TiSerialDriver). */ object UsbSerialAdapters { /** finds them among what's plugged in */ val prober: UsbSerialProber by lazy { UsbSerialProber(table()) } - /** usb-serial-for-android's table, with the adapters' IDs Linux knows and Exar's chips added */ + /** usb-serial-for-android's table, with the adapters' IDs Linux knows, Exar's chips and MultiTech's modems added */ internal fun table(): ProbeTable = UsbSerialProber.getDefaultProbeTable().apply { add(UsbSerialIds.FTDI, FtdiSerialDriver::class.java) add(UsbSerialIds.CP210X, Cp21xxSerialDriver::class.java) @@ -27,6 +28,8 @@ object UsbSerialAdapters { add(UsbSerialIds.CH34X, Ch34xSerialDriver::class.java) // (Exar's: before the CDC-ACM driver, which would take them by their class but can't set their line) for (pid in XrChip.products) addProduct(XrChip.VENDOR, pid, XrSerialDriver::class.java) + // (MultiTech's MT9234MU and MT9234ZBA-USB: a modem behind a TUSB3410) + for (pid in TiIds.products) addProduct(TiIds.MULTITECH, pid, TiSerialDriver::class.java) } /** [driver] for each of [ids] (vendor << 16 | product) */ @@ -35,5 +38,6 @@ object UsbSerialAdapters { } /** how many it knows by their IDs (not counting the CDC-ACM ones, known by their class) */ - val known: Int get() = UsbSerialIds.FTDI.size + UsbSerialIds.CP210X.size + UsbSerialIds.PL2303.size + UsbSerialIds.CH34X.size + XrChip.products.size + val known: Int get() = UsbSerialIds.FTDI.size + UsbSerialIds.CP210X.size + UsbSerialIds.PL2303.size + UsbSerialIds.CH34X.size + XrChip.products.size + + TiIds.products.size } diff --git a/app/src/main/java/org/dmodem/app/android/ui/PeerLineUi.kt b/app/src/main/java/org/dmodem/app/android/ui/PeerLineUi.kt index 3c69e04..a1959c8 100644 --- a/app/src/main/java/org/dmodem/app/android/ui/PeerLineUi.kt +++ b/app/src/main/java/org/dmodem/app/android/ui/PeerLineUi.kt @@ -388,7 +388,7 @@ fun SerialModemFields(s: ModemSettings, onChange: (ModemSettings) -> Unit) { val free = remember { org.dmodem.app.android.bridge.SerialAdapters.free(context) } Text( "An external modem (a US Robotics, a Zoom, any Hayes modem) on a USB serial adapter (Prolific PL2303, FTDI, " + - "CP210x, CH34x, CDC-ACM) plugged into the phone: it dials and answers, and the terminal, the internet, fax " + + "CP210x, CH34x, CDC-ACM), or a MultiTech MT9234MU USB modem, plugged into the phone: it dials and answers, and the terminal, the internet, fax " + "and the Linux's /dev/ttyDM0 talk to it in place of D-Modem's own modem (its own AT commands). DTR is held " + "up while the modem runs; stopping it drops DTR. Android asks once whether D-Modem may use the adapter.", style = MaterialTheme.typography.bodySmall, @@ -397,6 +397,7 @@ fun SerialModemFields(s: ModemSettings, onChange: (ModemSettings) -> Unit) { "Adapter: " + if (free.isEmpty()) "none plugged in (or in use)" else free.joinToString(", "), style = MaterialTheme.typography.bodyMedium, ) + MultiTechFirmwareRow() var open by remember { mutableStateOf(false) } ExposedDropdownMenuBox(expanded = open, onExpandedChange = { open = it }) { OutlinedTextField( @@ -427,6 +428,31 @@ fun SerialModemFields(s: ModemSettings, onChange: (ModemSettings) -> Unit) { } } +/** + * The firmware of a MultiTech MT9234MU (or MT9234ZBA-USB): which file is imported, and a button to import + * one. The app has no copy of its own; the modem gets it each time it is plugged in and the line starts. + */ +@Composable +private fun MultiTechFirmwareRow() { + val context = LocalContext.current + var have by remember { mutableStateOf(org.dmodem.app.android.bridge.TiFirmwareStore.describe(context)) } + var problem by remember { mutableStateOf(null) } + val pick = rememberLauncherForActivityResult(ActivityResultContracts.OpenDocument()) { uri -> + if (uri == null) return@rememberLauncherForActivityResult + val bytes = runCatching { + context.contentResolver.openInputStream(uri)?.use { it.readBytes() } + }.getOrNull() + problem = if (bytes == null) "The file could not be read." else org.dmodem.app.android.bridge.TiFirmwareStore.import(context, bytes) + have = org.dmodem.app.android.bridge.TiFirmwareStore.describe(context) + } + Text( + "MultiTech MT9234MU firmware: " + (have ?: "none. The modem needs mts_mt9234mu.fw (from MultiTech's Linux driver or an older linux-firmware package)."), + style = MaterialTheme.typography.bodySmall, + ) + problem?.let { Text("Not imported: $it", style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.error) } + OutlinedButton(onClick = { pick.launch(arrayOf("*/*")) }) { Text(if (have == null) "Import the firmware file" else "Import another firmware file") } +} + /** a labelled radio button, the whole row tappable */ @Composable private fun LineRadio(label: String, selected: Boolean, onClick: () -> Unit) { diff --git a/app/src/main/res/xml/usb_serial_adapters.xml b/app/src/main/res/xml/usb_serial_adapters.xml index ef443e1..8296ce4 100644 --- a/app/src/main/res/xml/usb_serial_adapters.xml +++ b/app/src/main/res/xml/usb_serial_adapters.xml @@ -20,6 +20,10 @@ + + + + diff --git a/app/src/test/java/org/dmodem/app/android/bridge/TiSerialTest.kt b/app/src/test/java/org/dmodem/app/android/bridge/TiSerialTest.kt new file mode 100644 index 0000000..4bd2a9d --- /dev/null +++ b/app/src/test/java/org/dmodem/app/android/bridge/TiSerialTest.kt @@ -0,0 +1,160 @@ +// SPDX-License-Identifier: AGPL-3.0-only +// Copyright (C) 2026 Neo-Desktop +package org.dmodem.app.android.bridge + +import com.hoho.android.usbserial.driver.UsbSerialPort +import org.junit.Assert.assertArrayEquals +import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse +import org.junit.Assert.assertNull +import org.junit.Assert.assertTrue +import org.junit.Test + +/** + * The TUSB3410's protocol (the MultiTech MT9234MU's UART), the chip faked: + * the requests it is sent recorded, its port status answered; and its + * firmware's image and packets. + */ +class TiSerialTest { + + /** one control transfer: its setup, the bytes sent (a write's) */ + data class Req(val type: Int, val request: Int, val value: Int, val index: Int, val data: List = emptyList()) + + private class FakeChip : TiControl { + val sent = mutableListOf() + /** the modem status register that GET_PORT_STATUS answers */ + var msr = 0 + + /** a status read answered with [msr], a write's bytes kept; each request recorded */ + override fun transfer(requestType: Int, request: Int, value: Int, index: Int, data: ByteArray?, length: Int): Int { + if (requestType and 0x80 != 0) { + sent += Req(requestType, request, value, index) + val b = byteArrayOf(request.toByte(), index.toByte(), 0, msr.toByte(), 0x60) + for (i in 0 until length) data!![i] = b[i] + return length + } + sent += Req(requestType, request, value, index, data?.take(length)?.map { it.toInt() and 0xff }.orEmpty()) + return length + } + } + + /** the MCR write, as the chip is sent it: XDATA 0xFFA4, the DTR, RTS and loop bits, [mcr] */ + private fun mcr(mcr: Int) = Req(0x40, 0x80, 0, 0x05, listOf(0x30, 0x01, 0x01, 0x00, 0x00, 0xff, 0xa4, 0x34, mcr)) + + /** the MultiTech IDs, and the driver's table */ + @Test + fun ids() { + assertTrue(TiIds.known(0x06e0, 0xf114)) + assertTrue(TiIds.known(0x06e0, 0xf115)) + assertTrue(TiIds.known(0x06e0, 0x0319)) + assertFalse(TiIds.known(0x06e0, 0xf110)) + assertFalse(TiIds.known(0x0451, 0x3410)) + assertEquals("MultiTech MT9234MU", TiIds.name(0xf114)) + assertEquals(setOf(0x06e0), TiSerialDriver.getSupportedDevices().keys) + } + + /** the divisor of TI's clock: 115200 is 8, 9600 is 96 */ + @Test + fun divisors() { + assertEquals(8, TiUart.divisor(115200)) + assertEquals(16, TiUart.divisor(57600)) + assertEquals(96, TiUart.divisor(9600)) + assertEquals(1, TiUart.divisor(921600)) + } + + /** the configuration block: big-endian divisor and flags, 8N1, XON/XOFF, RS-232; RTS/CTS sets its two flags */ + @Test + fun configBlock() { + val none = TiUart.configBlock(115200, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_NONE, UsbSerialPort.FlowControl.NONE) + assertArrayEquals(byteArrayOf(0, 8, 0x60, 0, 3, 0, 0, 0x11, 0x13, 0), none) + val hw = TiUart.configBlock(9600, 7, UsbSerialPort.STOPBITS_2, UsbSerialPort.PARITY_EVEN, UsbSerialPort.FlowControl.RTS_CTS) + assertArrayEquals(byteArrayOf(0, 96, 0x60, 0x29, 2, 2, 2, 0x11, 0x13, 0), hw) + } + + /** the open: set, open, start, both purges, then set, open, start again, and DTR and RTS each time after a set */ + @Test + fun openSequence() { + val f = FakeChip() + val u = TiUart(f) + u.open(dtr = true, rts = true) + val cmds = f.sent.map { it.request } + assertEquals(listOf(0x05, 0x80, 0x06, 0x08, 0x0B, 0x0B, 0x05, 0x80, 0x06, 0x08, 0x80), cmds) + // (the port's commands to UART 1, wIndex 3) + assertTrue(f.sent.filter { it.request in setOf(0x05, 0x06, 0x08, 0x0B) }.all { it.index == 3 }) + assertEquals(listOf(0x80, 0x00), f.sent.filter { it.request == 0x0B }.map { it.value }) + assertEquals(0x89, f.sent.first { it.request == 0x06 }.value) + assertEquals(mcr(0x30), f.sent.last()) + assertTrue(u.dtr && u.rts) + } + + /** DTR and RTS: the MCR bits; a break: the LCR's */ + @Test + fun linesAndBreak() { + val f = FakeChip() + val u = TiUart(f) + u.lines(dtr = true, rts = false) + u.lines(dtr = false, rts = false) + u.setBreak(true) + assertEquals(mcr(0x10), f.sent[0]) + assertEquals(mcr(0x00), f.sent[1]) + assertEquals(Req(0x40, 0x80, 0, 0x05, listOf(0x30, 0x01, 0x01, 0x00, 0x00, 0xff, 0xa2, 0x40, 0x40)), f.sent[2]) + } + + /** a new speed: one SET_CONFIG with its divisor, DTR and RTS kept */ + @Test + fun setLineKeepsTheLines() { + val f = FakeChip() + val u = TiUart(f) + u.lines(dtr = true, rts = true) + f.sent.clear() + u.setLine(57600, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_NONE) + assertEquals(0x05, f.sent[0].request) + assertEquals(listOf(0, 16), f.sent[0].data.take(2)) + assertEquals(mcr(0x30), f.sent[1]) + } + + /** a speed the divisor can't make is refused */ + @Test(expected = UnsupportedOperationException::class) + fun tooFast() { + TiUart(FakeChip()).setLine(3_000_000, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_NONE) + } + + /** the lines in, from the port status's MSR */ + @Test + fun status() { + val f = FakeChip() + f.msr = 0x80 or 0x10 + val s = TiUart(f).status() + assertTrue(s.cd) + assertTrue(s.cts) + assertFalse(s.dsr) + assertFalse(s.ri) + assertEquals(Req(0xC0, 0x02, 0, 0x03), f.sent.single()) + } + + /** the firmware's header: the code's length and checksum, whatever the file had there */ + @Test + fun firmwareImage() { + val file = byteArrayOf(0x55, 0x55, 0x55, 1, 2, 3, 0xff.toByte()) + val img = TiFirmware.image(file) + assertArrayEquals(byteArrayOf(4, 0, 5, 1, 2, 3, 0xff.toByte()), img) + assertNull(TiFirmware.problem(file)) + assertEquals("the file is empty", TiFirmware.problem(byteArrayOf(1, 2, 3))) + assertTrue(TiFirmware.problem(ByteArray(TiFirmware.MAX + 4))!!.contains("too large")) + } + + /** the download's packets: 64 octets, the last one less */ + @Test + fun firmwarePackets() { + val p = TiFirmware.packets(ByteArray(13769)) + assertEquals(216, p.size) + assertTrue(p.dropLast(1).all { it.size == 64 }) + assertEquals(13769 - 215 * 64, p.last().size) + } + + /** an unknown file is described by its size */ + @Test + fun describe() { + assertEquals("a TUSB3410 firmware that the app does not know (7 octets)", TiFirmware.describe(ByteArray(7))) + } +} diff --git a/app/src/test/java/org/dmodem/app/android/bridge/UsbSerialAdaptersTest.kt b/app/src/test/java/org/dmodem/app/android/bridge/UsbSerialAdaptersTest.kt index aaf6036..d7b0b7a 100644 --- a/app/src/test/java/org/dmodem/app/android/bridge/UsbSerialAdaptersTest.kt +++ b/app/src/test/java/org/dmodem/app/android/bridge/UsbSerialAdaptersTest.kt @@ -40,6 +40,15 @@ class UsbSerialAdaptersTest { assertEquals(XrSerialDriver::class.java, driver(0x04e2, 0x1422)) } + /** MultiTech's USB fax modems with a TUSB3410 get our own driver; MultiTech's other devices none */ + @Test + fun multiTechsTheirOwn() { + assertEquals(TiSerialDriver::class.java, driver(0x06e0, 0xf114)) + assertEquals(TiSerialDriver::class.java, driver(0x06e0, 0xf115)) + assertEquals(TiSerialDriver::class.java, driver(0x06e0, 0x0319)) + assertNull(driver(0x06e0, 0xf110)) + } + /** the chip makers' own IDs still get theirs */ @Test fun theChipMakersStill() { diff --git a/docs/README.md b/docs/README.md index 7123f82..268c0d9 100644 --- a/docs/README.md +++ b/docs/README.md @@ -3,7 +3,7 @@ - [The modem's line](lines.md): SIP, the mobile calls of the phone, no line, two phones as the line for each other - [Fax](fax.md) - [Voice calls and the answering machine](voice.md) -- [Serial adapters and real phone lines](adapters.md): pico-serial, USB modems, a modem on a USB serial adapter, a Bluetooth modem +- [Serial adapters and real phone lines](adapters.md): pico-serial, USB modems, a modem on a USB serial adapter, a MultiTech MT9234MU, a Bluetooth modem - [The app, screen by screen](features.md) - [Terminal types](terminals.md): the DEC line, PETSCII, ATASCII, videotex, ANSI-BBS and the graphics terminals, and how to test them - [Settings reference](settings.md): each setting, with its key and default, made from the code (`tools/settings_ref.py`) diff --git a/docs/adapters.md b/docs/adapters.md index 3de5db9..3151967 100644 --- a/docs/adapters.md +++ b/docs/adapters.md @@ -76,6 +76,60 @@ 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 MultiTech MT9234MU USB modem + + +The MultiTech MultiMobile MT9234MU (USB 06E0:F114) is a V.92 data and fax +modem with a USB connector. The MT9234ZBA-USB (06E0:F115, and 06E0:0319 on +older units) is the same modem in a desktop case. These modems have a TI +TUSB3410 USB UART between USB and the modem. The app uses its own driver for +this chip (`TiSerialDriver`). Connect the modem to the phone (USB OTG), and +select Settings, Line, "A phone line, through a modem on a USB serial +adapter". After this step, the modem operates as an external modem on a +serial adapter (see the section above). Set the speed to 115200 and set +RTS/CTS on. The factory setting of the modem is `&K3`. + +The TUSB3410 has no firmware of its own. Each time you connect the modem, +the modem shows only the boot ROM of the chip. The app must download the +firmware into the RAM of the chip before it can use the modem. The app does +not include the firmware file, because MultiTech gave no license that lets +other persons distribute it. For the same reason, linux-firmware removed the +file in 2026. Get the file `mts_mt9234mu.fw` from the Linux driver of +MultiTech or from a linux-firmware package of a Linux distribution from +before June 2026 (`/lib/firmware/mts_mt9234mu.fw`). The file +`mts_mt9234zba.fw` has the same code. Then, in Settings, Line, select +"Import the firmware file". + +When the line starts, the app does these steps: + +1. It sends the firmware to the boot ROM in packets of 64 octets. +2. It resets the modem (`USBDEVFS_RESET`). The modem connects again as a + new USB device, with the configuration of the firmware. +3. Android asks again if D-Modem can use the modem. +4. The app selects configuration 2 and opens the UART. + +The app reads DCD, CTS, DSR and RI from the port status of the chip. The +firmware of the chip stays in its RAM until you disconnect the modem. + +The modem has its own AT commands (the MultiTech MT9234 AT Commands +Reference Guide, S000434). These items are important: + +- Set the country of the line with `AT%T19,0,` (hexadecimal), then + `AT&F&W`. `ATI9` shows the country. `AT%T19,0,34` is the default (North + America and Europe). +- `ATI11` shows the last call on two pages. After the first page, the modem + waits for a key. Push a key in the terminal to see the second page. +- Commands for the serial port of the modem (`$SB`, `$EB`, `%DC` and other + commands) do not operate on the USB models. + +The MT9234MU-CDC and the MT9234MU-CDC-XR are CDC-ACM models. They do not +need a firmware file. The CDC-ACM driver of the app operates them. + +We wrote the driver from the data sheet of the TUSB3410 and from the +ti_usb_3410_5052 driver of Linux. The unit tests (`TiSerialTest`) examine the +requests to a simulated chip. We did not test the driver yet on a phone with +a real MT9234MU. + ## A real phone line: a Bluetooth modem