mirror of
https://github.com/kamilsss655/uv-k5-firmware-custom
synced 2024-11-21 17:57:59 +00:00
Revert "UART disabled in locked state."
This reverts commit 1227460f95
.
This commit is contained in:
parent
3bce162b0d
commit
a40072069f
35
app/uart.c
35
app/uart.c
@ -191,7 +191,7 @@ static void SendVersion(void)
|
||||
Reply.Header.ID = 0x0515;
|
||||
Reply.Header.Size = sizeof(Reply.Data);
|
||||
strcpy(Reply.Data.Version, Version);
|
||||
Reply.Data.bHasCustomAesKey = false;
|
||||
Reply.Data.bHasCustomAesKey = bHasCustomAesKey;
|
||||
Reply.Data.bIsInLockScreen = bIsInLockScreen;
|
||||
Reply.Data.Challenge[0] = gChallenge[0];
|
||||
Reply.Data.Challenge[1] = gChallenge[1];
|
||||
@ -223,6 +223,7 @@ static void CMD_051B(const uint8_t *pBuffer)
|
||||
{
|
||||
const CMD_051B_t *pCmd = (const CMD_051B_t *)pBuffer;
|
||||
REPLY_051B_t Reply;
|
||||
bool bLocked = false;
|
||||
|
||||
if (pCmd->Timestamp != Timestamp)
|
||||
return;
|
||||
@ -239,8 +240,11 @@ static void CMD_051B(const uint8_t *pBuffer)
|
||||
Reply.Data.Offset = pCmd->Offset;
|
||||
Reply.Data.Size = pCmd->Size;
|
||||
|
||||
if (bHasCustomAesKey)
|
||||
bLocked = gIsLocked;
|
||||
|
||||
EEPROM_ReadBuffer(pCmd->Offset, Reply.Data.Data, pCmd->Size);
|
||||
if (!bLocked)
|
||||
EEPROM_ReadBuffer(pCmd->Offset, Reply.Data.Data, pCmd->Size);
|
||||
|
||||
SendReply(&Reply, pCmd->Size + 8);
|
||||
}
|
||||
@ -250,6 +254,7 @@ static void CMD_051D(const uint8_t *pBuffer)
|
||||
const CMD_051D_t *pCmd = (const CMD_051D_t *)pBuffer;
|
||||
REPLY_051D_t Reply;
|
||||
bool bReloadEeprom;
|
||||
bool bIsLocked;
|
||||
|
||||
if (pCmd->Timestamp != Timestamp)
|
||||
return;
|
||||
@ -266,23 +271,27 @@ static void CMD_051D(const uint8_t *pBuffer)
|
||||
Reply.Header.Size = sizeof(Reply.Data);
|
||||
Reply.Data.Offset = pCmd->Offset;
|
||||
|
||||
bIsLocked = bHasCustomAesKey ? gIsLocked : bHasCustomAesKey;
|
||||
|
||||
unsigned int i;
|
||||
for (i = 0; i < (pCmd->Size / 8); i++)
|
||||
if (!bIsLocked)
|
||||
{
|
||||
const uint16_t Offset = pCmd->Offset + (i * 8U);
|
||||
unsigned int i;
|
||||
for (i = 0; i < (pCmd->Size / 8); i++)
|
||||
{
|
||||
const uint16_t Offset = pCmd->Offset + (i * 8U);
|
||||
|
||||
if (Offset >= 0x0F30 && Offset < 0x0F40)
|
||||
bReloadEeprom = true;
|
||||
if (Offset >= 0x0F30 && Offset < 0x0F40)
|
||||
if (!gIsLocked)
|
||||
bReloadEeprom = true;
|
||||
|
||||
if ((Offset < 0x0E98 || Offset >= 0x0EA0) || !bIsInLockScreen || pCmd->bAllowPassword)
|
||||
EEPROM_WriteBuffer(Offset, &pCmd->Data[i * 8U], true);
|
||||
if ((Offset < 0x0E98 || Offset >= 0x0EA0) || !bIsInLockScreen || pCmd->bAllowPassword)
|
||||
EEPROM_WriteBuffer(Offset, &pCmd->Data[i * 8U], true);
|
||||
}
|
||||
|
||||
if (bReloadEeprom)
|
||||
BOARD_EEPROM_Init();
|
||||
}
|
||||
|
||||
if (bReloadEeprom)
|
||||
BOARD_EEPROM_Init();
|
||||
|
||||
|
||||
SendReply(&Reply, sizeof(Reply));
|
||||
}
|
||||
|
||||
|
12
board.c
12
board.c
@ -727,6 +727,18 @@ void BOARD_EEPROM_Init(void)
|
||||
}
|
||||
}
|
||||
|
||||
// 0F30..0F3F
|
||||
EEPROM_ReadBuffer(0x0F30, gCustomAesKey, sizeof(gCustomAesKey));
|
||||
bHasCustomAesKey = false;
|
||||
for (i = 0; i < ARRAY_SIZE(gCustomAesKey); i++)
|
||||
{
|
||||
if (gCustomAesKey[i] != 0xFFFFFFFFu)
|
||||
{
|
||||
bHasCustomAesKey = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_SPECTRUM_SHOW_CHANNEL_NAME
|
||||
BOARD_gMR_LoadChannels();
|
||||
#endif
|
||||
|
1
main.c
1
main.c
@ -177,7 +177,6 @@ void Main(void)
|
||||
if (gEeprom.POWER_ON_PASSWORD < PASSWORD_OFF)
|
||||
{
|
||||
bIsInLockScreen = true;
|
||||
gIsLocked = true;
|
||||
UI_DisplayLock();
|
||||
bIsInLockScreen = false;
|
||||
}
|
||||
|
3
misc.c
3
misc.c
@ -97,6 +97,7 @@ uint8_t gSetting_battery_text;
|
||||
bool gMonitor = false; // true opens the squelch
|
||||
|
||||
uint32_t gCustomAesKey[4];
|
||||
bool bHasCustomAesKey;
|
||||
uint32_t gChallenge[4];
|
||||
uint8_t gTryCount;
|
||||
|
||||
@ -248,7 +249,7 @@ volatile uint8_t boot_counter_10ms;
|
||||
|
||||
int16_t gCurrentRSSI[2] = {0, 0}; // now one per VFO
|
||||
|
||||
bool gIsLocked = false;
|
||||
uint8_t gIsLocked = 0xFF;
|
||||
|
||||
|
||||
|
||||
|
3
misc.h
3
misc.h
@ -173,6 +173,7 @@ extern bool gMonitor;
|
||||
|
||||
extern const uint32_t gDefaultAesKey[4];
|
||||
extern uint32_t gCustomAesKey[4];
|
||||
extern bool bHasCustomAesKey;
|
||||
extern uint32_t gChallenge[4];
|
||||
extern uint8_t gTryCount;
|
||||
|
||||
@ -353,7 +354,7 @@ extern volatile uint8_t gVFOStateResumeCountdown_500ms;
|
||||
extern volatile bool gScheduleFM;
|
||||
#endif
|
||||
extern int16_t gCurrentRSSI[2]; // now one per VFO
|
||||
extern bool gIsLocked;
|
||||
extern uint8_t gIsLocked;
|
||||
extern volatile uint8_t boot_counter_10ms;
|
||||
|
||||
int32_t NUMBER_AddWithWraparound(int32_t Base, int32_t Add, int32_t LowerLimit, int32_t UpperLimit);
|
||||
|
@ -112,7 +112,6 @@ void UI_DisplayLock(void)
|
||||
if ((gEeprom.POWER_ON_PASSWORD) == Password)
|
||||
{
|
||||
AUDIO_PlayBeep(BEEP_1KHZ_60MS_OPTIONAL);
|
||||
gIsLocked = false;
|
||||
gEeprom.PASSWORD_WRONG_ATTEMPTS = 0;
|
||||
return;
|
||||
}
|
||||
@ -156,6 +155,13 @@ void UI_DisplayLock(void)
|
||||
gKeyReading0 = Key;
|
||||
}
|
||||
|
||||
if (UART_IsCommandAvailable())
|
||||
{
|
||||
__disable_irq();
|
||||
UART_HandleCommand();
|
||||
__enable_irq();
|
||||
}
|
||||
|
||||
if (gUpdateDisplay)
|
||||
{
|
||||
Render();
|
||||
|
Loading…
Reference in New Issue
Block a user