codec2_talkie/README.md

162 wiersze
11 KiB
Markdown
Czysty Zwykły widok Historia

2020-12-10 11:44:49 +00:00
![CI](https://github.com/sh123/codec2_talkie/workflows/CI/badge.svg)
2021-01-27 13:28:39 +00:00
# Table of contents
- [Introduction](#introduction)
- [Requirements](#requirements)
- [Features](#features)
- [Suitable radios and modems](#suitable-radios-and-modems)
- [Related projects](#related-projects)
- [FAQ](#faq)
2021-02-07 16:15:09 +00:00
- [KISS command extensions](#kiss-command-extensions)
2021-01-27 13:28:39 +00:00
- [Planned features](#todo)
2020-12-06 09:44:20 +00:00
2021-01-27 13:28:39 +00:00
# Introduction
2021-10-15 08:16:47 +00:00
**Turn your Android phone into real VHF/UHF Walkie-Talkie (requires additional digital radio modem).**
2021-10-11 14:25:01 +00:00
2021-01-27 15:53:51 +00:00
![alt text](images/diagram.png)
2020-12-06 10:21:21 +00:00
![alt text](images/screenshot.png)
2021-01-25 12:08:13 +00:00
![alt text](images/screenshot_settings.png)
2020-12-06 10:13:29 +00:00
2021-01-31 18:31:57 +00:00
This minimalistic Android application is a Walkie-Talkie style digital voice frontend for your radio, which uses open source [Codec2](https://github.com/drowe67/codec2) for speech audio frame encoding/decoding.
2021-01-27 12:05:52 +00:00
2021-02-10 11:07:28 +00:00
It is mainly intended for DV experimentation with ultra low cost 3-8$ radio modems, such as LoRa and 15-25$ esp32 board flavours with built-in LoRa module: T-Beam,
2021-10-14 16:30:49 +00:00
LoPy, TTGO, Heltec and others, but could also be used with custom hardware of software (Direwolf) modems + external transceivers or as a test harness for Codec2 frames generation and their playback.
2021-02-08 10:27:07 +00:00
2021-02-10 08:05:18 +00:00
![alt text](images/tracker.jpg)
2021-01-27 13:40:02 +00:00
2021-10-14 16:23:51 +00:00
Application connects to your radio KISS Bluetooth/USB/TCPIP modem, records speech from the phone microphone on transmit, encodes audio into Codec2 format, encapsulates into KISS frames and sends to your modem.
2021-10-11 09:59:24 +00:00
On receive, modem sends KISS packets to the phone with Codec2 speech, application decodes Codec2 frames and plays them through phone speaker.
2021-01-27 12:05:52 +00:00
2021-10-14 16:23:51 +00:00
It does not deal with radio management, modulation, etc, it is up to your modem and radio, it could be just AFSK1200, GMSK 9600, LoRa, FSK, FreeDV or any other modulation scheme. Radio just needs to expose KISS Bluetooth/USB/TCPIP interface for speech frames.
2021-01-27 12:05:52 +00:00
2020-12-06 09:56:08 +00:00
# Requirements
2021-07-29 16:34:38 +00:00
- Android 7.0 (API 24) or higher
2021-01-27 12:25:13 +00:00
- Application could also be used with your Android network radio, such as Inrico TM-7, apk just needs to be installed over USB, see [Discussion](https://github.com/sh123/codec2_talkie/issues/4)
2021-10-14 11:58:56 +00:00
- Android 5.0, 5.1, 6.0 (API 21, 22, 23)
2021-10-14 11:59:35 +00:00
- Separate apk package is released with "legacy" suffix from legacy branch
2021-10-11 12:41:28 +00:00
- Modem, radio module or transceiver which supports [KISS protocol](https://en.wikipedia.org/wiki/KISS_(TNC)) or can process KISS or raw Codec2 audio frames over serial Bluetooth, USB or TCP/IP
2020-12-06 09:56:08 +00:00
2020-12-06 09:44:20 +00:00
# Features
2021-01-08 08:35:30 +00:00
- **PTT UI button**, push and talk, Codec2 speech frames will be transmitted to the modem
2021-02-10 17:02:13 +00:00
- **PTT hardware button**, `KEYCODE_TV_DATA SERVICE` (230 key code) hardware buttons are used for PTT (latter is used on some Android network radios), `KEYCODE_HEADSETHOOK` tx on/off on click, volume up/down buttons could be used for ptt if enabled in Preferences
2021-01-24 18:35:38 +00:00
- **USB serial connectivity** (default 115200 bps, 8 data bits, 1 stop bit, no parity), just select this app after connecting to USB and it will use given connection, baud rate could be changed from Preferences
- **Bluetooth connectivity** on startup, lists paired devices, so you can choose your modem and connect, you need to pair with your Bluetooth device first from Android Bluetooth Settings, default Bluetooth device could be set from Preferences
2021-10-15 08:19:18 +00:00
- **TCP/IP connectivity** on startup, application can connect to TCP/IP based modem and operate through the network, for example, with [Direwolf](https://github.com/wb2osz/direwolf) application and your existing analog transceiver
2021-10-11 09:59:24 +00:00
- **Voice Codec2 mode selection**, which allows you to select various Codec2 modes from 450 up to 3200 bps on the fly, sender and receiver should agree on the codec mode and use the same codec mode on both ends as Codec2 mode negotiation between clients is not implemented at the moment
2021-10-14 16:29:45 +00:00
- **Codec2 loopback mode**, which records and plays your recorded voice back to test and evaluate different Codec2 modes and speech quality, could be enabled or disabled from Preferences, this mode is also activated if no USB/Bluetooth/TCPIP connection was made
2021-02-13 19:22:11 +00:00
- **Voice level VU indicator**, display audio level on transmit or receive
2021-02-08 09:53:55 +00:00
- **S-meter**, displayed only when KISS extensions are enabled and modem is able to send signal level information
2021-01-28 15:06:45 +00:00
- **Parrot mode**, received voice will be digirepated in addition to playback through the speaker
2021-10-11 09:59:24 +00:00
- **KISS buffered mode**, non-real time, playback will start only after all speech is received, use when modem bit rate is lower than Codec2 bit rate to avoid gaps during playback at the cost of longer receiving delay before playback
2021-01-24 18:33:24 +00:00
- **Preferences**, allow to modify default parameters
2021-02-10 17:02:13 +00:00
- **Application Settings**
- Enable PTT with volume up/down buttons
- Keep screen ON
2021-10-14 13:31:12 +00:00
- Use phone speaker instead of headset
2021-01-25 09:44:02 +00:00
- **Codec2**
- Set Codec2 mode/speed from 450 up to 3200 bps
2021-10-17 13:52:52 +00:00
- Set maximum super frame size in bytes
2021-10-17 20:12:54 +00:00
- On transmit, multiple Codec2 voice samples are aggregated into one super frame of size not larger than this value
2021-10-10 14:23:07 +00:00
- Enable/disable echo/loopback test mode
- Enable/disable RX/TX recorder
2021-01-25 09:44:02 +00:00
- **TNC parameters**
- Change default baud rate for USB port
- Set default Bluetooth device for automatic connectivity on startup
2021-10-11 09:35:20 +00:00
- Enable KISS over TCP/IP, when enabled USB and Bluetooth connectivity is disabled
- Set TCP/IP parameters: IP address, port number, number of re-reconnect retries and delay between connect re-tries
2021-02-10 17:02:13 +00:00
- **KISS**
2021-10-11 09:59:24 +00:00
- Enable/Disable KISS, when disabled raw Codec2 audio frames will be transmitted
2021-02-13 06:31:06 +00:00
- Set basic KISS parmaters (P persistence, Slot Time, TX delay, TX tail)
2021-02-10 17:02:13 +00:00
- Enable/Disable parrot (digirepeater) mode
- Enable/Disable KISS non-real time buffered playback mode
- Enable/Disable KISS extensions for radio module control and signal levels (modem must support them to work correctly!)
- Set radio parameters (frequency, bandwidth, spreading factor, coding rate, power, sync word, crc checksum enable/disable)
2021-10-12 18:52:31 +00:00
- Send reboot command to the modem
2021-10-11 14:48:03 +00:00
- **Recording player**, simple Voicemail style player, which allows TX/RX recording playback and removal
2021-10-10 14:52:05 +00:00
- Click on recording starts playback
- Long click on recording removes it
- Recording menu allows
- Remove all items
- Stop current playback
- Play all recordings sequentially
2020-12-09 11:57:54 +00:00
# Suitable radios and modems
2020-12-08 11:34:50 +00:00
- Tested, works:
2021-10-14 16:27:42 +00:00
- (BT) LoRa modem 450/700 bps Codec2 modes tested at 1300 bps and 900 bps LoRa speeds: https://github.com/sh123/esp32_loraprs
2021-01-07 11:20:01 +00:00
- (BT) custom AFSK1200 LibAPRS based modem with increased TXTail parameter and Baofeng handheld transceiver: 450 works fine, 700 works with small gaps, probably LibAPRS needs some tweaks: https://github.com/markqvist/LibAPRS
2021-01-24 18:35:38 +00:00
- (USB) HC-12 modules: works, but application needs to use lower USB serial bit rate (change from Preferences), because module RF bit rate is hardwired to its serial bit rate, also module needs to be preconfigured with AT commands first
2020-12-15 08:26:24 +00:00
- Tested, works, but not too stable, probably needs TXTail tuning:
2020-12-14 17:04:30 +00:00
- (USB) AFSK1200 PicoAPRS: http://www.db1nto.de/index_en.html
- (BT) AFSK1200/GMSK9600 Kenwood TH-D74A: https://dl1gkk.com/kenwood-th-d74-bluetooth-packet-radio-setup/
2020-12-06 14:15:24 +00:00
- Could work, needs testing:
2020-12-14 17:04:30 +00:00
- (USB) AFSK1200 MicroModem: https://unsigned.io/micromodem
- (BT/USB) AFSK1200/GMSK9600 Mobilinkd TNC3: https://store.mobilinkd.com/products/mobilinkd-tnc3
- (USB) nRF2401L01 2.4 GHz: https://github.com/sh123/nrf24l01_arduino_kiss_modem
2020-12-06 09:53:20 +00:00
2020-12-06 09:44:20 +00:00
# Related Projects
2021-01-07 11:35:48 +00:00
- Source code is integrated into this project for easier building and customization:
- Codec2 codec: https://github.com/drowe67/codec2
- Android Codec2 wrapper code: https://github.com/UstadMobile/Codec2-Android
- Fetched with gradle as dependency:
- Android USB serial: https://github.com/mik3y/usb-serial-for-android
2021-02-13 10:45:42 +00:00
- Other related projects:
2021-02-08 10:08:56 +00:00
- ESP32 LoRa APRS modem (used with this application for testing): https://github.com/sh123/esp32_loraprs
2021-02-09 07:15:16 +00:00
- Version adopted for M17 protocol usage: https://github.com/mobilinkd/m17-kiss-ht
2021-01-07 11:35:48 +00:00
- iOS Codec2 wrapper: https://github.com/Beartooth/codec2-ios
2021-02-09 07:53:06 +00:00
- Minimal Arduino LoRa KISS modem: https://github.com/sh123/lora_arduino_kiss_modem
- Minimal Arduino NRF24 KISS modem: https://github.com/sh123/nrf24l01_arduino_kiss_modem
2021-02-13 10:45:42 +00:00
- Other interesting projects:
- LoRa mesh GPS communicator: https://github.com/meshtastic/Meshtastic-device
2020-12-06 14:36:47 +00:00
2020-12-11 15:31:04 +00:00
# FAQ
2021-01-30 19:40:01 +00:00
- **Gaps in received audio**, indicator often changes between RX/IDLE on the receiver side when sender and recipient are close by then
2021-01-31 18:35:54 +00:00
- most likely you do not have enough bandwidth, use higher throughput modem mode, for LoRa modems you need approximately 100-150% of data rate for the given codec2 bitrate, AFSK1200 modems should work at 450 bps codec2 mode, 700 bps might work, but not on all modems, higher speed codec2 modes won't work on AFSK1200 for real time, need to enable KISS non-realtime buffering mode
2020-12-14 16:49:04 +00:00
- modem goes into RX state too fast after sending first packet, increase TxTail parameter for your modem if it does not handle corresponding KISS command, so it will stay longer in TX before switching to RX
2021-01-30 19:40:01 +00:00
- if you are using LibAPRS based modem, set TxTail and TxPreamble programatically by using `APRS_setPreamble` and `APRS_setTail` methods as it does not seem to set these values from `CMD_TXDELAY` and `CMD_TXTAIL` KISS commands
- enable KISS buffering mode in Preferences, this will help with gaps at the cost of larger delay on receive before playback
2021-01-17 10:03:27 +00:00
- **Receiving audio on PC/Raspberry**
- For raw audio frames `sudo cat /dev/ttyUSB0 | c2dec 700 - - | play -t raw -r 8000 -e signed-integer -b 16 -c 1 -`
- For KISS encapsulated audio frames command above could be used, but instead of `cat` use https://pypi.org/project/kiss/
2021-10-10 14:41:31 +00:00
- **App is not installed** error when installing new application
- Uninstall previous version and try to install again
2021-10-10 14:55:11 +00:00
- Cannot install application from unknown source
- You need to allow installation of apps from unknown sources from Android settings, or just install Android Studio and build-install application yourself
2021-02-07 16:15:09 +00:00
# KISS command extensions
2021-02-08 18:23:42 +00:00
KISS command extensions are used for radio module control and signal report events on port 0, command for radio control is defined as 6 (KISS SetHardware) and signal report command as 7. Radio modules/modems can implement these commands, so they will be controllable from the application and application will be able to show signal levels on S-meter.
2021-02-07 16:15:09 +00:00
Payloads for commands are sent and expected as big endian and defined as:
```
2021-02-08 18:23:42 +00:00
// KISS SetHardware 6
2021-02-08 18:32:18 +00:00
struct SetHardware {
2021-02-07 16:15:09 +00:00
uint32_t freq;
uint32_t bw;
uint16_t sf;
uint16_t cr;
uint16_t pwr;
uint16_t sync;
uint8_t crc;
} __attribute__((packed));
2021-02-08 18:23:42 +00:00
// KISS command 7
2021-02-08 18:32:18 +00:00
struct SignalReport {
2021-02-08 18:23:42 +00:00
int16_t rssi;
int16_t snr; // snr * 100
} __attribute__((packed));
2021-10-12 18:46:17 +00:00
// KISS command 8
struct RebootModem {
} __attribute__((packed));
`
2021-02-07 16:15:09 +00:00
```
2020-12-06 14:36:47 +00:00
# TODO
2021-10-15 08:21:16 +00:00
- BLE modems support
2021-02-14 12:19:20 +00:00
- Investigate support for other protocols over KISS
2021-10-14 16:27:03 +00:00
- AX.25 protocol support, voice over AX.25 (VoAX.25)
2021-02-10 08:18:28 +00:00
- [M17 Project](https://m17project.org) protocol support, including possible gating to [M17 reflectors](https://m17project.org/reflector/) on modem side
2021-02-06 17:04:46 +00:00
- Support for non-KISS modems control if needed
- HC-12 module control by using AT commands
2021-02-14 12:20:57 +00:00
- E32-433T30D, should be pre-configured, but can be controlled with AT commands or not?