diff --git a/Makefile b/Makefile index a535f4b..fd5754e 100644 --- a/Makefile +++ b/Makefile @@ -36,6 +36,7 @@ ENABLE_SHOW_CHARGE_LEVEL := 0 ENABLE_REVERSE_BAT_SYMBOL := 1 ENABLE_FREQ_SEARCH_TIMEOUT := 0 ENABLE_CODE_SEARCH_TIMEOUT := 0 +ENABLE_KILL_REVIVE := 0 ENABLE_AM_FIX := 1 ENABLE_AM_FIX_SHOW_DATA := 1 ENABLE_SQUELCH_MORE_SENSITIVE := 1 @@ -328,6 +329,9 @@ endif ifeq ($(ENABLE_CODE_SEARCH_TIMEOUT),1) CFLAGS += -DENABLE_CODE_SEARCH_TIMEOUT endif +ifeq ($(ENABLE_KILL_REVIVE),1) + CFLAGS += -DENABLE_KILL_REVIVE +endif ifeq ($(ENABLE_FREQ_SEARCH_TIMEOUT),1) CFLAGS += -DENABLE_FREQ_SEARCH_TIMEOUT endif diff --git a/README.md b/README.md index 52b9ece..a7936d5 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ ENABLE_SHOW_CHARGE_LEVEL := 0 show the charge level when the radio ENABLE_REVERSE_BAT_SYMBOL := 1 mirror the battery symbol on the status bar (+ pole on the right) ENABLE_FREQ_SEARCH_TIMEOUT := 1 timeout if FREQ not found when using F+4 search function ENABLE_CODE_SEARCH_TIMEOUT := 0 timeout if CTCSS/CDCSS not found when using F+* search function +ENABLE_KILL_REVIVE := 0 '1' = include kill and revive code ENABLE_AM_FIX := 1 dynamically adjust the front end gains when in AM mode to helo prevent AM demodulator saturation, ignore the on-screen RSSI level (for now) ENABLE_AM_FIX_SHOW_DATA := 1 show debug data for the AM fix (still tweaking it) ENABLE_SQUELCH_MORE_SENSITIVE := 1 make squelch levels a little bit more sensitive - I plan to let user adjust the values themselves diff --git a/app/aircopy.c b/app/aircopy.c index 8478997..55a5988 100644 --- a/app/aircopy.c +++ b/app/aircopy.c @@ -543,6 +543,11 @@ void AIRCOPY_process_fsk_rx_10ms(void) data[3] = 0xffff; //#endif } + else + if (eeprom_addr == 0x0F40) + { // killed flag is here + data[2] = false; // remove it + } EEPROM_WriteBuffer(eeprom_addr, data); // 8 bytes at a time data += write_size / sizeof(data[0]); diff --git a/app/app.c b/app/app.c index c14f619..85cef6f 100644 --- a/app/app.c +++ b/app/app.c @@ -225,7 +225,11 @@ static void APP_process_incoming_rx(void) if (g_scan_state_dir == SCAN_STATE_DIR_OFF && g_css_scan_mode == CSS_SCAN_MODE_OFF) { // not scanning - if (g_rx_vfo->dtmf_decoding_enable || g_setting_radio_disabled) + #ifdef ENABLE_KILL_REVIVE + if (g_rx_vfo->dtmf_decoding_enable || g_setting_radio_disabled) + #else + if (g_rx_vfo->dtmf_decoding_enable) + #endif { // DTMF DCD is enabled DTMF_HandleRequest(); @@ -479,8 +483,10 @@ void APP_start_listening(function_type_t Function, const bool reset_am_fix) const unsigned int chan = g_eeprom.rx_vfo; // const unsigned int chan = g_rx_vfo->channel_save; - if (g_setting_radio_disabled) - return; + #ifdef ENABLE_KILL_REVIVE + if (g_setting_radio_disabled) + return; + #endif #ifdef ENABLE_FMRADIO if (g_fm_radio_mode) @@ -888,7 +894,11 @@ void APP_process_radio_interrupts(void) g_update_display = true; } - if (g_rx_vfo->dtmf_decoding_enable || g_setting_radio_disabled) + #ifdef ENABLE_KILL_REVIVE + if (g_rx_vfo->dtmf_decoding_enable || g_setting_radio_disabled) + #else + if (g_rx_vfo->dtmf_decoding_enable) + #endif { if (g_dtmf_rx_index >= (sizeof(g_dtmf_rx) - 1)) { // make room @@ -999,8 +1009,10 @@ void APP_end_tx(void) #ifdef ENABLE_VOX static void APP_process_vox(void) { - if (g_setting_radio_disabled) - return; + #ifdef ENABLE_KILL_REVIVE + if (g_setting_radio_disabled) + return; + #endif if (g_vox_resume_count_down == 0) { @@ -1350,37 +1362,44 @@ void APP_check_keys(void) key_code_t key; - if (g_setting_radio_disabled) - return; + #ifdef ENABLE_KILL_REVIVE + if (g_setting_radio_disabled) + return; + #endif // ***************** // PTT is treated completely separately from all the other buttons if (ptt_pressed) { // PTT pressed - #ifdef ENABLE_AIRCOPY - if (!g_setting_radio_disabled && !g_ptt_is_pressed && g_screen_to_display != DISPLAY_AIRCOPY) - #else - if (!g_setting_radio_disabled && !g_ptt_is_pressed) + #ifdef ENABLE_KILL_REVIVE + if (!g_setting_radio_disabled) #endif { - if (++g_ptt_debounce >= 3) // 30ms - { // start TX'ing - - g_boot_counter_10ms = 0; // cancel the boot-up screen - g_ptt_is_pressed = true; - g_ptt_was_released = false; - g_ptt_debounce = 0; - - APP_process_key(KEY_PTT, true, false); - - #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG) -// UART_printf(" ptt key %3u %u %u\r\n", KEY_PTT, g_ptt_is_pressed, g_ptt_was_released); - #endif + #ifdef ENABLE_AIRCOPY + if (!g_ptt_is_pressed && g_screen_to_display != DISPLAY_AIRCOPY) + #else + if (!g_ptt_is_pressed) + #endif + { + if (++g_ptt_debounce >= 3) // 30ms + { // start TX'ing + + g_boot_counter_10ms = 0; // cancel the boot-up screen + g_ptt_is_pressed = true; + g_ptt_was_released = false; + g_ptt_debounce = 0; + + APP_process_key(KEY_PTT, true, false); + + #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG) +// UART_printf(" ptt key %3u %u %u\r\n", KEY_PTT, g_ptt_is_pressed, g_ptt_was_released); + #endif + } } + else + g_ptt_debounce = 0; } - else - g_ptt_debounce = 0; } else { // PTT released diff --git a/app/dtmf.c b/app/dtmf.c index df0bd14..9dd9179 100644 --- a/app/dtmf.c +++ b/app/dtmf.c @@ -215,79 +215,85 @@ void DTMF_HandleRequest(void) return; } - if (!g_rx_vfo->dtmf_decoding_enable && !g_setting_radio_disabled) - { // D-DCD is disabled or we're alive + #ifdef ENABLE_KILL_REVIVE + if (!g_rx_vfo->dtmf_decoding_enable && !g_setting_radio_disabled) + #else + if (!g_rx_vfo->dtmf_decoding_enable) + #endif + { // D-DCD is disabled or we're enabled DTMF_clear_RX(); return; } g_dtmf_rx_pending = false; - if (g_dtmf_rx_index >= 9) - { // look for the KILL code - - sprintf(String, "%s%c%s", g_eeprom.ani_dtmf_id, g_eeprom.dtmf_separate_code, g_eeprom.kill_code); - - Offset = g_dtmf_rx_index - strlen(String); - - if (DTMF_CompareMessage(g_dtmf_rx + Offset, String, strlen(String), true)) - { // bugger - - if (g_eeprom.permit_remote_kill) - { - g_setting_radio_disabled = true; // oooerr ! + #ifdef ENABLE_KILL_REVIVE + if (g_dtmf_rx_index >= 9) + { // look for the RADIO DISABLE code + + sprintf(String, "%s%c%s", g_eeprom.ani_dtmf_id, g_eeprom.dtmf_separate_code, g_eeprom.kill_code); + + Offset = g_dtmf_rx_index - strlen(String); + + if (DTMF_CompareMessage(g_dtmf_rx + Offset, String, strlen(String), true)) + { // bugger + + if (g_eeprom.permit_remote_kill) + { + g_setting_radio_disabled = true; // :( + + DTMF_clear_RX(); + + SETTINGS_SaveSettings(); + + g_dtmf_reply_state = DTMF_REPLY_AB; + + #ifdef ENABLE_FMRADIO + if (g_fm_radio_mode) + { + FM_TurnOff(); + GUI_SelectNextDisplay(DISPLAY_MAIN); + } + #endif + } + else + { + g_dtmf_reply_state = DTMF_REPLY_NONE; + } + + g_dtmf_call_state = DTMF_CALL_STATE_NONE; + + g_update_display = true; + g_update_status = true; + return; + } + } + if (g_dtmf_rx_index >= 9) + { // look for the REVIVE code + + sprintf(String, "%s%c%s", g_eeprom.ani_dtmf_id, g_eeprom.dtmf_separate_code, g_eeprom.revive_code); + + Offset = g_dtmf_rx_index - strlen(String); + + if (DTMF_CompareMessage(g_dtmf_rx + Offset, String, strlen(String), true)) + { // shit, we're back ! + + g_setting_radio_disabled = false; + DTMF_clear_RX(); - + SETTINGS_SaveSettings(); - + g_dtmf_reply_state = DTMF_REPLY_AB; - - #ifdef ENABLE_FMRADIO - if (g_fm_radio_mode) - { - FM_TurnOff(); - GUI_SelectNextDisplay(DISPLAY_MAIN); - } - #endif + g_dtmf_call_state = DTMF_CALL_STATE_NONE; + + g_update_display = true; + g_update_status = true; + return; } - else - { - g_dtmf_reply_state = DTMF_REPLY_NONE; - } - - g_dtmf_call_state = DTMF_CALL_STATE_NONE; - - g_update_display = true; - g_update_status = true; - return; } - } - - if (g_dtmf_rx_index >= 9) - { // look for the REVIVE code - - sprintf(String, "%s%c%s", g_eeprom.ani_dtmf_id, g_eeprom.dtmf_separate_code, g_eeprom.revive_code); - - Offset = g_dtmf_rx_index - strlen(String); - - if (DTMF_CompareMessage(g_dtmf_rx + Offset, String, strlen(String), true)) - { // shit, we're back ! - - g_setting_radio_disabled = false; - - DTMF_clear_RX(); - - SETTINGS_SaveSettings(); - - g_dtmf_reply_state = DTMF_REPLY_AB; - g_dtmf_call_state = DTMF_CALL_STATE_NONE; - - g_update_display = true; - g_update_status = true; - return; - } - } + #endif if (g_dtmf_rx_index >= 2) { // look for ACK reply @@ -300,7 +306,6 @@ void DTMF_HandleRequest(void) { // ends with "AB" if (g_dtmf_reply_state != DTMF_REPLY_NONE) // 1of11 -// if (g_dtmf_call_state != DTMF_CALL_STATE_NONE) // 1of11 // if (g_dtmf_call_state == DTMF_CALL_STATE_CALL_OUT) // 1of11 { g_dtmf_state = DTMF_STATE_TX_SUCC; @@ -328,10 +333,10 @@ void DTMF_HandleRequest(void) } } - if (g_setting_radio_disabled || g_dtmf_call_state == DTMF_CALL_STATE_CALL_OUT) - { // we've been disabled, or expecting a reply - return; - } + #ifdef ENABLE_KILL_REVIVE + if (g_setting_radio_disabled) + return; // we've been disabled + #endif if (g_dtmf_rx_index >= 7) { // see if we're being called diff --git a/app/uart.c b/app/uart.c index a9b48fa..e370a32 100644 --- a/app/uart.c +++ b/app/uart.c @@ -350,6 +350,13 @@ static void cmd_051D(const uint8_t *pBuffer) memset(data, 0xff, 8); // wipe the AES key #endif + //#ifndef ENABLE_KILL_REVIVE + if (Offset == 0x0F40) + { // killed flag is here + data[2] = false; // remove it + } + //#endif + #ifdef ENABLE_PWRON_PASSWORD if ((Offset < 0x0E98 || Offset >= 0x0E9C) || !g_password_locked || pCmd->allow_password) EEPROM_WriteBuffer(Offset, data); diff --git a/board.c b/board.c index 8b011ea..e9dfe08 100644 --- a/board.c +++ b/board.c @@ -729,7 +729,9 @@ void BOARD_EEPROM_load(void) g_setting_freq_lock = (Data[0] < 6) ? Data[0] : FREQ_LOCK_NORMAL; #endif g_setting_350_tx_enable = (Data[1] < 2) ? Data[1] : false; // was true - g_setting_radio_disabled = (Data[2] < 2) ? Data[2] : false; + #ifdef ENABLE_KILL_REVIVE + g_setting_radio_disabled = (Data[2] < 2) ? Data[2] : false; + #endif g_setting_174_tx_enable = (Data[3] < 2) ? Data[3] : false; g_setting_470_tx_enable = (Data[4] < 2) ? Data[4] : false; g_setting_350_enable = (Data[5] < 2) ? Data[5] : true; diff --git a/firmware.bin b/firmware.bin index fc71f43..cf5c023 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index a7aaae0..5d7ec60 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/misc.c b/misc.c index ec17c65..623fa00 100644 --- a/misc.c +++ b/misc.c @@ -90,8 +90,11 @@ const uint32_t g_default_aes_key[4] = {0x4AA5CC60, 0x0312C const uint8_t g_mic_gain_dB_2[5] = {3, 8, 16, 24, 31}; +#ifdef ENABLE_KILL_REVIVE + bool g_setting_radio_disabled; +#endif + bool g_setting_350_tx_enable; -bool g_setting_radio_disabled; bool g_setting_174_tx_enable; bool g_setting_470_tx_enable; bool g_setting_350_enable; diff --git a/misc.h b/misc.h index 831db51..4ad665f 100644 --- a/misc.h +++ b/misc.h @@ -171,8 +171,11 @@ extern const uint16_t scan_pause_7_10ms; extern const uint8_t g_mic_gain_dB_2[5]; +#ifdef ENABLE_KILL_REVIVE + extern bool g_setting_radio_disabled; +#endif + extern bool g_setting_350_tx_enable; -extern bool g_setting_radio_disabled; extern bool g_setting_174_tx_enable; extern bool g_setting_470_tx_enable; extern bool g_setting_350_enable; diff --git a/radio.c b/radio.c index 6777e46..7e8a1c3 100644 --- a/radio.c +++ b/radio.c @@ -791,7 +791,11 @@ void RADIO_setup_registers(bool switch_to_function_0) BK4819_SetCompander((g_rx_vfo->am_mode == 0 && g_rx_vfo->compander >= 2) ? g_rx_vfo->compander : 0); #if 0 - if (!g_rx_vfo->dtmf_decoding_enable && !g_setting_radio_disabled) + #ifdef ENABLE_KILL_REVIVE + if (!g_rx_vfo->dtmf_decoding_enable && !g_setting_radio_disabled) + #else + if (!g_rx_vfo->dtmf_decoding_enable) + #endif { BK4819_DisableDTMF(); } diff --git a/settings.c b/settings.c index 5429684..6be4627 100644 --- a/settings.c +++ b/settings.c @@ -310,7 +310,11 @@ void SETTINGS_SaveSettings(void) memset(State, 0xFF, sizeof(State)); State[0] = g_setting_freq_lock; State[1] = g_setting_350_tx_enable; - State[2] = g_setting_radio_disabled; + #ifdef ENABLE_KILL_REVIVE + State[2] = g_setting_radio_disabled; + #else + State[2] = false; + #endif State[3] = g_setting_174_tx_enable; State[4] = g_setting_470_tx_enable; State[5] = g_setting_350_enable; diff --git a/ui/main.c b/ui/main.c index db2ece3..855262b 100644 --- a/ui/main.c +++ b/ui/main.c @@ -817,8 +817,13 @@ void UI_DisplayMain(void) } // show the DTMF decoding symbol - if (g_eeprom.vfo_info[vfo_num].dtmf_decoding_enable || g_setting_radio_disabled) - UI_PrintStringSmall("DTMF", LCD_WIDTH + 78, 0, line + 1); + #ifdef ENABLE_KILL_REVIVE + if (g_eeprom.vfo_info[vfo_num].dtmf_decoding_enable || g_setting_radio_disabled) + UI_PrintStringSmall("DTMF", LCD_WIDTH + 78, 0, line + 1); + #else + if (g_eeprom.vfo_info[vfo_num].dtmf_decoding_enable) + UI_PrintStringSmall("DTMF", LCD_WIDTH + 78, 0, line + 1); + #endif // show the audio scramble symbol if (g_eeprom.vfo_info[vfo_num].scrambling_type > 0 && g_setting_scramble_enable) diff --git a/ui/status.c b/ui/status.c index f595333..760453e 100644 --- a/ui/status.c +++ b/ui/status.c @@ -79,12 +79,15 @@ void UI_DisplayStatus(const bool test_display) // hmmm, what to put in it's place #endif - if (g_setting_radio_disabled) + #ifdef ENABLE_KILL_REVIVE + if (g_setting_radio_disabled) + { + memset(line + x, 0xFF, 10); + x1 = x + 10; + } + else + #endif { - memset(line + x, 0xFF, 10); - x1 = x + 10; - } - else #ifdef ENABLE_FMRADIO // FM indicator if (g_fm_radio_mode || test_display) @@ -114,6 +117,7 @@ void UI_DisplayStatus(const bool test_display) } x1 = x + 7; } + } x += 7; // font character width #ifdef ENABLE_VOICE