0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-05-02 00:01:27 +03:00

Only append DTMF-ID to TX user code if D_DCD is enable

This commit is contained in:
OneOfEleven 2023-09-17 16:51:35 +01:00
parent 71375f31b2
commit 66afde980a
11 changed files with 71 additions and 41 deletions

View File

@ -1803,10 +1803,11 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gKeyLockCountdown = 30; // 15 seconds gKeyLockCountdown = 30; // 15 seconds
#ifdef ENABLE_DTMF_DECODER #ifdef ENABLE_DTMF_DECODER
if (Key == KEY_EXIT && bKeyPressed && bKeyHeld) if (Key == KEY_EXIT && bKeyPressed && bKeyHeld && gDTMF_ReceivedSaved[0] > 0)
{ // clear the DTMF RX display buffer { // clear the live DTMF RX if the EXIT key is held
gDTMF_RecvTimeoutSaved = 0; gDTMF_RecvTimeoutSaved = 0;
gDTMF_ReceivedSaved[0] = '\0'; gDTMF_ReceivedSaved[0] = '\0';
gUpdateDisplay = true;
} }
#endif #endif

View File

@ -15,6 +15,7 @@
*/ */
#include <string.h> #include <string.h>
#include <stdio.h> // NULL
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
#include "app/fm.h" #include "app/fm.h"
@ -161,7 +162,7 @@ void DTMF_Append(char Code)
if (gDTMF_InputIndex == 0) if (gDTMF_InputIndex == 0)
{ {
memset(gDTMF_InputBox, '-', sizeof(gDTMF_InputBox)); memset(gDTMF_InputBox, '-', sizeof(gDTMF_InputBox));
gDTMF_InputBox[14] = 0; gDTMF_InputBox[sizeof(gDTMF_InputBox) - 1] = 0;
} }
else else
if (gDTMF_InputIndex >= sizeof(gDTMF_InputBox)) if (gDTMF_InputIndex >= sizeof(gDTMF_InputBox))
@ -295,12 +296,15 @@ void DTMF_HandleRequest(void)
void DTMF_Reply(void) void DTMF_Reply(void)
{ {
char String[20];
const char *pString;
uint16_t Delay; uint16_t Delay;
char String[20];
const char *pString = NULL;
switch (gDTMF_ReplyState) switch (gDTMF_ReplyState)
{ {
case DTMF_REPLY_NONE:
return;
case DTMF_REPLY_ANI: case DTMF_REPLY_ANI:
if (gDTMF_CallMode == DTMF_CALL_MODE_DTMF) if (gDTMF_CallMode == DTMF_CALL_MODE_DTMF)
{ {
@ -308,6 +312,7 @@ void DTMF_Reply(void)
} }
else else
{ {
// append out ID code onto the end of the DTMF code to send
sprintf(String, "%s%c%s", gDTMF_String, gEeprom.DTMF_SEPARATE_CODE, gEeprom.ANI_DTMF_ID); sprintf(String, "%s%c%s", gDTMF_String, gEeprom.DTMF_SEPARATE_CODE, gEeprom.ANI_DTMF_ID);
pString = String; pString = String;
} }
@ -334,16 +339,15 @@ void DTMF_Reply(void)
gDTMF_ReplyState = DTMF_REPLY_NONE; gDTMF_ReplyState = DTMF_REPLY_NONE;
if (pString == NULL)
return;
Delay = gEeprom.DTMF_PRELOAD_TIME; Delay = gEeprom.DTMF_PRELOAD_TIME;
if (gEeprom.DTMF_SIDE_TONE) if (gEeprom.DTMF_SIDE_TONE)
{ {
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
gEnableSpeaker = true; gEnableSpeaker = true;
Delay = (gEeprom.DTMF_PRELOAD_TIME < 60) ? 60 : gEeprom.DTMF_PRELOAD_TIME;
Delay = gEeprom.DTMF_PRELOAD_TIME;
if (gEeprom.DTMF_PRELOAD_TIME < 60)
Delay = 60;
} }
SYSTEM_DelayMs(Delay); SYSTEM_DelayMs(Delay);

View File

@ -21,34 +21,34 @@
#include <stdint.h> #include <stdint.h>
enum DTMF_State_t { enum DTMF_State_t {
DTMF_STATE_0 = 0U, DTMF_STATE_0 = 0,
DTMF_STATE_TX_SUCC = 1U, DTMF_STATE_TX_SUCC,
DTMF_STATE_CALL_OUT_RSP = 2U, DTMF_STATE_CALL_OUT_RSP
}; };
typedef enum DTMF_State_t DTMF_State_t; typedef enum DTMF_State_t DTMF_State_t;
enum DTMF_CallState_t { enum DTMF_CallState_t {
DTMF_CALL_STATE_NONE = 0U, DTMF_CALL_STATE_NONE = 0,
DTMF_CALL_STATE_CALL_OUT = 1U, DTMF_CALL_STATE_CALL_OUT,
DTMF_CALL_STATE_RECEIVED = 2U, DTMF_CALL_STATE_RECEIVED
}; };
typedef enum DTMF_CallState_t DTMF_CallState_t; typedef enum DTMF_CallState_t DTMF_CallState_t;
enum DTMF_ReplyState_t { enum DTMF_ReplyState_t {
DTMF_REPLY_NONE = 0U, DTMF_REPLY_NONE = 0,
DTMF_REPLY_ANI = 1U, DTMF_REPLY_ANI,
DTMF_REPLY_AB = 2U, DTMF_REPLY_AB,
DTMF_REPLY_AAAAA = 3U, DTMF_REPLY_AAAAA
}; };
typedef enum DTMF_ReplyState_t DTMF_ReplyState_t; typedef enum DTMF_ReplyState_t DTMF_ReplyState_t;
enum DTMF_CallMode_t { enum DTMF_CallMode_t {
DTMF_CALL_MODE_NOT_GROUP = 0U, DTMF_CALL_MODE_NOT_GROUP = 0,
DTMF_CALL_MODE_GROUP = 1U, DTMF_CALL_MODE_GROUP,
DTMF_CALL_MODE_DTMF = 2U, DTMF_CALL_MODE_DTMF
}; };
typedef enum DTMF_CallMode_t DTMF_CallMode_t; typedef enum DTMF_CallMode_t DTMF_CallMode_t;
@ -94,4 +94,3 @@ void DTMF_HandleRequest(void);
void DTMF_Reply(void); void DTMF_Reply(void);
#endif #endif

View File

@ -179,16 +179,22 @@ void GENERIC_Key_PTT(bool bKeyPressed)
if (gDTMF_InputMode) if (gDTMF_InputMode)
{ {
if (gDTMF_InputIndex || gDTMF_PreviousIndex) if (gDTMF_InputIndex > 0 || gDTMF_PreviousIndex > 0)
{ {
if (gDTMF_InputIndex == 0) if (gDTMF_InputIndex == 0)
gDTMF_InputIndex = gDTMF_PreviousIndex; gDTMF_InputIndex = gDTMF_PreviousIndex;
gDTMF_InputBox[gDTMF_InputIndex] = 0; gDTMF_InputBox[gDTMF_InputIndex] = 0;
if (gDTMF_InputIndex == 3) #if 0
gDTMF_CallMode = DTMF_CheckGroupCall(gDTMF_InputBox, 3); if (gDTMF_InputIndex == 3)
else gDTMF_CallMode = DTMF_CheckGroupCall(gDTMF_InputBox, 3); // this will cause our ID tobe appened to the DTMF code
else
#else
if (gDTMF_InputIndex == 3 && gTxVfo->DTMF_DECODING_ENABLE > 0)
gDTMF_CallMode = DTMF_CheckGroupCall(gDTMF_InputBox, 3); // this will cause our ID tobe appened to the DTMF code
else
#endif
gDTMF_CallMode = DTMF_CALL_MODE_DTMF; gDTMF_CallMode = DTMF_CALL_MODE_DTMF;
strcpy(gDTMF_String, gDTMF_InputBox); strcpy(gDTMF_String, gDTMF_InputBox);

View File

@ -509,7 +509,7 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld)
{ {
gKeyInputCountdown = key_input_timeout_500ms; gKeyInputCountdown = key_input_timeout_500ms;
gDTMF_InputMode = true; gDTMF_InputMode = true;
memmove(gDTMF_InputBox, gDTMF_String, 15); memmove(gDTMF_InputBox, gDTMF_String, sizeof(gDTMF_InputBox));
gDTMF_InputIndex = 0; gDTMF_InputIndex = 0;
gRequestDisplayScreen = DISPLAY_MAIN; gRequestDisplayScreen = DISPLAY_MAIN;
return; return;

26
board.c
View File

@ -648,36 +648,50 @@ void BOARD_EEPROM_Init(void)
if (DTMF_ValidateCodes((char *)Data, 8)) if (DTMF_ValidateCodes((char *)Data, 8))
memmove(gEeprom.ANI_DTMF_ID, Data, 8); memmove(gEeprom.ANI_DTMF_ID, Data, 8);
else else
// Original firmware overflows into the next string {
memmove(gEeprom.ANI_DTMF_ID, "123\0\0\0\0", 8); memset(gEeprom.ANI_DTMF_ID, 0, sizeof(gEeprom.ANI_DTMF_ID));
strcpy(gEeprom.ANI_DTMF_ID, "123");
}
// 0EE8..0EEF // 0EE8..0EEF
EEPROM_ReadBuffer(0x0EE8, Data, 8); EEPROM_ReadBuffer(0x0EE8, Data, 8);
if (DTMF_ValidateCodes((char *)Data, 8)) if (DTMF_ValidateCodes((char *)Data, 8))
memmove(gEeprom.KILL_CODE, Data, 8); memmove(gEeprom.KILL_CODE, Data, 8);
else else
memmove(gEeprom.KILL_CODE, "ABCD9\0\0", 8); {
memset(gEeprom.KILL_CODE, 0, sizeof(gEeprom.KILL_CODE));
strcpy(gEeprom.KILL_CODE, "ABCD9");
}
// 0EF0..0EF7 // 0EF0..0EF7
EEPROM_ReadBuffer(0x0EF0, Data, 8); EEPROM_ReadBuffer(0x0EF0, Data, 8);
if (DTMF_ValidateCodes((char *)Data, 8)) if (DTMF_ValidateCodes((char *)Data, 8))
memmove(gEeprom.REVIVE_CODE, Data, 8); memmove(gEeprom.REVIVE_CODE, Data, 8);
else else
memmove(gEeprom.REVIVE_CODE, "9DCBA\0\0", 8); {
memset(gEeprom.REVIVE_CODE, 0, sizeof(gEeprom.REVIVE_CODE));
strcpy(gEeprom.REVIVE_CODE, "9DCBA");
}
// 0EF8..0F07 // 0EF8..0F07
EEPROM_ReadBuffer(0x0EF8, Data, 16); EEPROM_ReadBuffer(0x0EF8, Data, 16);
if (DTMF_ValidateCodes((char *)Data, 16)) if (DTMF_ValidateCodes((char *)Data, 16))
memmove(gEeprom.DTMF_UP_CODE, Data, 16); memmove(gEeprom.DTMF_UP_CODE, Data, 16);
else else
memmove(gEeprom.DTMF_UP_CODE, "12345\0\0\0\0\0\0\0\0\0\0", 16); {
memset(gEeprom.DTMF_UP_CODE, 0, sizeof(gEeprom.DTMF_UP_CODE));
strcpy(gEeprom.DTMF_UP_CODE, "12345");
}
// 0F08..0F17 // 0F08..0F17
EEPROM_ReadBuffer(0x0F08, Data, 16); EEPROM_ReadBuffer(0x0F08, Data, 16);
if (DTMF_ValidateCodes((char *)Data, 16)) if (DTMF_ValidateCodes((char *)Data, 16))
memmove(gEeprom.DTMF_DOWN_CODE, Data, 16); memmove(gEeprom.DTMF_DOWN_CODE, Data, 16);
else else
memmove(gEeprom.DTMF_DOWN_CODE, "54321\0\0\0\0\0\0\0\0\0\0", 16); {
memset(gEeprom.DTMF_DOWN_CODE, 0, sizeof(gEeprom.DTMF_DOWN_CODE));
strcpy(gEeprom.DTMF_DOWN_CODE, "54321");
}
// 0F18..0F1F // 0F18..0F1F
EEPROM_ReadBuffer(0x0F18, Data, 8); EEPROM_ReadBuffer(0x0F18, Data, 8);

View File

@ -14,6 +14,8 @@
* limitations under the License. * limitations under the License.
*/ */
#include <stdio.h> // NULL
#include "bk4819.h" #include "bk4819.h"
#include "bsp/dp32g030/gpio.h" #include "bsp/dp32g030/gpio.h"
#include "bsp/dp32g030/portcon.h" #include "bsp/dp32g030/portcon.h"
@ -818,6 +820,10 @@ void BK4819_PlayDTMF(char Code)
void BK4819_PlayDTMFString(const char *pString, bool bDelayFirst, uint16_t FirstCodePersistTime, uint16_t HashCodePersistTime, uint16_t CodePersistTime, uint16_t CodeInternalTime) void BK4819_PlayDTMFString(const char *pString, bool bDelayFirst, uint16_t FirstCodePersistTime, uint16_t HashCodePersistTime, uint16_t CodePersistTime, uint16_t CodeInternalTime)
{ {
unsigned int i; unsigned int i;
if (pString == NULL)
return;
for (i = 0; pString[i]; i++) for (i = 0; pString[i]; i++)
{ {
uint16_t Delay; uint16_t Delay;

BIN
firmware

Binary file not shown.

Binary file not shown.

Binary file not shown.

2
main.c
View File

@ -74,7 +74,7 @@ void Main(void)
memset(&gEeprom, 0, sizeof(gEeprom)); memset(&gEeprom, 0, sizeof(gEeprom));
memset(gDTMF_String, '-', sizeof(gDTMF_String)); memset(gDTMF_String, '-', sizeof(gDTMF_String));
gDTMF_String[14] = 0; gDTMF_String[sizeof(gDTMF_String) - 1] = 0;
BK4819_Init(); BK4819_Init();