Software Configuration - K7MDL2/IC-705-BLE-Serial-Example GitHub Wiki
Updated 27 Dec 2024
============================================
This page lists the main user configuration parameters. Several hardware combinations are possible requiring a way to enable resources as appropriate. CPU modules are form MtStack.com. The following models have been used and tested along with various combinations of IO and BT modes. Most of my development is on the M5Core2 since it has BT 4.2 which supports both BLE and BT Classic and it has dedicated touch buttons with good response.
- M5AtomS3 - uses i2c IO and relay Units
- M5Stack M5Core - uses IO and relay modules and i2c IO and relay Units
- M5Stack M5Core2 - uses IO and relay modules and i2c IO and relay Units
- M5Stack M5Core3-SE - uses IO and relay modules and i2c IO and relay Units
- M5Stack M5StampS3 - runs headless with I2c IO Units
- M5Stack M5StampC3U - used for embedded controller in the XV Box only using 2x MCP23017 port expander modules
The code will automatically determine the CPU models listed and set the right environment as things like display formatting, hardware addresses, IO pin assignments, and touch button methods are unique. Most of the settings are located in the M5Stack_CI_V_Band_Decoder.h file. For a few that do not, the file location will be specified near the setting listed. The M5StampC3U must be specified manually.
#define CLEAN_SD_DB_FILE
// used when the data structure has changed, force an overwrite with default data This forces the stored configuration to be overwritten on each bootup. This is to be used at least once after any changed to the data structures during development. Normally you leave this commented out so config changes are saved on the SD card (if it exists).
#define M5STAMPC3U
// Set this when the target CPU is the M5StampC3U as used in the K7MDL IC-705 Transverter Box controller
// Comment this parameter out and the CPU architecture is automatically selected for all other CPUs (AtomS3, Core, Core2, CoreS3/SE)
Set this when sending the code down to the M5StampC3U embedded on the 3-band transverter box. The IO is fixed to match the hardware and is quite different, has no BT features, and acts as a general wired-input based band decoder and sequencer with a small OLED display for status. It is possible to swap in a M5StampS3 and gain BLE feature which could remove the need for the external M5Corexx controller but you lose the display, the Xvtr band buttons, and the extra loading may affect hardware timing such as PTT detection and PTT delays. If you are not using a transverter and just want a PTT and antenna switch breakout box with no or minimal display or buttons, then this may be a good solution. If using a radio side controller (M5Corexx or M5AtomS3) then set teh XVBOPX define and send the code to that module so it runs as a matched pair.
#define XVBOX
// set some data config specific to usage with the 705 transverter box
This configures the radio side controller (A M5Corexx module) to send 3-wire BCD band info and PTT on specific digital IO module pins. The XVBox itself (M5StampC3U) is configured to read exactly those pins.
uint8_t bd_address[7] = { 0x30, 0x31, 0x7d, 0xBA, 0x44, 0xF9, 0x00 }; // Mike's 705
BT classic address for your IC-705. Edit the config.ini file on a SD card (M5Corexx modules only have SD cards) This is found in BT_USB_CIV_Band_Decoder.cpp. You can find your radio address in the radio menus: SET->Bluetooth Set->Bluetooth Device Information. Use the 6 hex bytes listed on the screen under BD Address.
The Classic BT address for your IC-705 is normally read from a config.ini file located on a SD card. That card also stores operating state. Only the M5CoreXX modules have a SD card. The SD card info overrides the default address in the code but works when you do not have a SAD card. BLE operates differently and currently has no custom address required.
#define IC705 0xA4
#define IC905 0xAC
#define RADIO_ADDR IC705
This code should work with multiple Icom CI-V control capable radios. It has been tested only on the IC-705 and periodically on the IC-905. The IC-905 does not have BT so must use USB serial for CI-V CAT control (or LAN). I have not been able to reliably keep the USB Host Serial code running so it only works for a random short period. Change the address to match your radio. The IC-9700 should work decent but I do not have one to test.
#define WIRED_PTT 1
// 1 = use the wired input for fastest PTT response
// 0 = poll radio for TX status. Polling delay can be adjusted with parameters below.
Wired PTT Option: Can use the TX state obtained by polling the radio to activate the PTT out signal, or use the radio SEND output wired to a module digital input for faster hardware-based PTT detection. Polled PTT time depends on how fast you poll the radio. Too fast and thigs get clogged up and funny things start to happen. Wired is preferred when operating T/R relays (this amplifiers) that has the risk of being hot switched.
Most config items are described well enough in their own comments.
#define PTT_DELAY 30
// PTT sequencing delay. At start of PTT -> TX event, turns OFF IF switch to prevent
// RF flowing while downstream relays are switching.
#define POLL_PTT_DEFAULT 247
// poll the radio for PTT status odd numbers to stagger them a bit. USB on both the 705 and 905 respond to PTT requests slower on USB than BT on the 705. Also polls the wired inputs. Can go down to a few ms.
#define POLL_PTT_USBHOST 262
// Dynamically changes value based on detected radio address. By observation, on USB, the radio only responds once every few seconds when the radio has not changed states. It will immediately reply to a poll if the Tx state changed. Still have to poll fast for controlling external PTT, most requests will not be answered. Unlike other modes. BT seems to answer every request. USB engine is likely the same in all radios, where BT got a capacity upgrade. The 905 acts the same as the 905 (905 is USB only). Have not compared to a LAN connection.
#define POLL_RADIO_FREQ 708
// poll the radio for frequency
#define POLL_RADIO_UTC 998
// poll radio for time and location
#define POLL_RADIO_MODE 6101
// poll radio for extended mode, filter and datamode
#define POLL_RADIO_AGC 3403
// poll radio for AGC
#define POLL_RADIO_ATTN 3305
// poll radio for atten status
#define POLL_RADIO_PRE 3204
// poll radio for preamp status
#define POLL_RADIO_SPLIT 3102
// poll radio for split status
None of the following apply to the M5StampC3U as used in the 705 Transverter project Choose the combination needed. Note that at least one comm service must be enabled.
#define BTCLASSIC
// Can define BTCLASSIC *** OR *** BLE, not both. No BT version is OK if USB Host is enabled
// BT Classic does not work on Core3. It might on Core2 (untested)
#define BLE
// Core 3 (BT5). Works on Core 2, (BT4.2) not on Core
#define USBHOST
// if no BLE or BTCLASSIC this must be enabled. *** USB Host is not stable so far ****
#define IO_MODULE
// enable the 4-In/8-Out module OR EXT_IO2_UNIT - BOTH are default at addr = 0x45
#define EXT_IO2_UNIT
// EXT.IO2 UNIT GIO extender - plugs into Port A i2c Grove port on CPU module, adds 8 GPIO ports at 3.3V max.
#define SD_CARD
// enable sd card features
#define RELAY2_UNIT
// enable 1 or 2 channel UNIT-RELAY module on Port A, B or C
#define RELAY4_UNIT
// enable the i2c Relay-4 unit, typically plugged into Port A (i2C).
#define MODULE_4RELAY_13_2
// enable the stacking 4 channel relay module - be sure to set the jumpers for each port relay contacts addr = 0x26
#define PC_PASSTHROUGH
// fwd serial CI-V data through BT or USBHOST data to a PC if connected. All debug must be off!
#ifndef PC_PASSTHROUGH // shut off by default when PASSTHRU MODE is on #define PRINT_VFO_TO_SERIAL // uncomment to visually see VFO updates from the radio on Serial #define PRINT_PTT_TO_SERIAL // uncomment to visually see PTT updates from the radio on Serial #define NO_SEND // block changes to radio from controller - used for PC pass thru #else #undef NO_SEND // block changes to radio from controller - used for PC pass thru #endif PC Pass through is intended act as a Radio BT serial to PC USB bridge. The single USB serial channel cannot have debug traffic if a PC is to talk to the radio for CAT control. This is not fully functional yet. You can turn off #define DEBUG in the debugprint.h file and that should shut off (hopefully) all non-CI-V traffic. However, the controller polls the radio for radio settings and frequency and an app like WSJT-X gets thoroughly confused by unsolicited messages it is not programmed to deal with.