Start implementing ack
All checks were successful
Build Firmware / build (push) Successful in 1m1s

This commit is contained in:
2025-04-01 14:47:18 +02:00
parent 0ea8767a8b
commit 7b1d31fdef
7 changed files with 110 additions and 47 deletions

View File

@@ -4,7 +4,7 @@
# 1 = enable
# ---- STOCK QUANSHENG FEATURES ----
ENABLE_FMRADIO ?= 1
ENABLE_FMRADIO ?= 0
ENABLE_UART ?= 1
ENABLE_AIRCOPY ?= 0
ENABLE_NOAA ?= 0

View File

@@ -1135,10 +1135,9 @@ static void CheckKeys(void) {
gPttDebounceCounter = 0;
}
#else
if (gPttIsPressed)
{
if (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) || SerialConfigInProgress())
{ // PTT released or serial comms config in progress
if (gPttIsPressed) {
if (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) ||
SerialConfigInProgress()) { // PTT released or serial comms config in progress
if (++gPttDebounceCounter >= 3 || SerialConfigInProgress()) // 30ms
{ // stop transmitting
ProcessKey(KEY_PTT, false, false);
@@ -1146,12 +1145,9 @@ static void CheckKeys(void) {
if (gKeyReading1 != KEY_INVALID)
gPttWasReleased = true;
}
}
else
} else
gPttDebounceCounter = 0;
}
else if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && !SerialConfigInProgress())
{ // PTT pressed
} else if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && !SerialConfigInProgress()) { // PTT pressed
if (++gPttDebounceCounter >= 3) // 30ms
{ // start transmitting
boot_counter_10ms = 0;
@@ -1159,8 +1155,7 @@ static void CheckKeys(void) {
gPttIsPressed = true;
ProcessKey(KEY_PTT, true, false);
}
}
else
} else
gPttDebounceCounter = 0;
#endif
@@ -1626,6 +1621,8 @@ void APP_TimeSlice500ms(void) {
BATTERY_TimeSlice500ms();
SCANNER_TimeSlice500ms();
MESSAGES_TimeSlice500ms();
FSKModem_TimeSlice500ms();
UI_MAIN_TimeSlice500ms();
#ifdef ENABLE_DTMF_CALLING

View File

@@ -17,6 +17,12 @@ uint8_t *dataPTR = dataPacket.data;
SMSEnteringState gEnteringSMS = SMS_NOT_ENTERING;
SMSResponseState gSMSResponseState = SMS_RESPONSE_IDLE;
bool gGotACK = false;
uint8_t SMSResponseCounter = 0;
typedef enum {
Receiving,
Ready
@@ -24,6 +30,28 @@ typedef enum {
RXState rxState = Ready;
void FSKModem_TimeSlice500ms(void) {
if (SMSResponseCounter && SMSResponseCounter++ > 3) {
switch (gSMSResponseState) {
case SMS_RESPONSE_ACK:
inBoundPacket.flags |= 0x64;
inBoundPacket.dest = inBoundPacket.src;
inBoundPacket.src = gEeprom.FSKSRCAddress;
SYSTEM_DelayMs(200);
MSG_FSKSendData(&inBoundPacket);
break;
case SMS_RESPONSE_RETRANSMIT:
SYSTEM_DelayMs(200);
BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1_RED, true);
MSG_FSKSendData(packet);
BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1_RED, false);
break;
default:
break;
}
}
}
void MSG_ConfigureFSK(bool rx) {
BK4819_WriteRegister(BK4819_REG_70, TONE2_ENABLE_BIT | (96U << 0));
@@ -130,6 +158,12 @@ void processReceivedPacket(DataPacket *packet) {
: gEeprom.TX_VFO;
if (packet->dest == gEeprom.FSKSRCAddress) {
if ((packet->flags & 0x128)) {
if (packet->flags & 0x64) {
if (memcmp(inBoundPacket.data, dataPacket.data, DataPacketDataSize) == 0) {
gGotACK = true;
}
} else {
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP);
BK4819_PlaySingleTone(1000, 250, 127, true);
strcpy(String, "SMS by ");
@@ -137,6 +171,10 @@ void processReceivedPacket(DataPacket *packet) {
strcat(String, numBuf);
MESSAGES_SAVE();
UI_DisplayPopup(String);
SMSResponseCounter = 1;
gSMSResponseState = SMS_RESPONSE_ACK;
}
}
#ifdef ENABLE_FEAT_F4HWN
if (isMainOnly()) {
UI_PrintStringSmallNormal(String, 2, 0, 5);
@@ -150,9 +188,8 @@ void processReceivedPacket(DataPacket *packet) {
} else if (VfoState[vfo] == VFO_STATE_NORMAL && !TX_freq_check(gCurrentVfo->freq_config_TX.Frequency)) {
if (packet->ttl--) {
BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1_RED, true);
MSG_FSKSendData(packet);
BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1_RED, false);
SMSResponseCounter = 1;
gSMSResponseState = SMS_RESPONSE_RETRANSMIT;
}
}
@@ -314,6 +351,10 @@ void MSG_FSKSendData(DataPacket *dataPacketIn) {
BK4819_ExitTxMute();
}
if (!(dataPacketIn->flags & 0x64)) {
gGotACK = false;
}
}
void prepareDataPacket() {

View File

@@ -111,10 +111,22 @@ typedef enum {
SMS_ENTERING_MESSAGE
} SMSEnteringState;
typedef enum {
SMS_RESPONSE_IDLE,
SMS_RESPONSE_ACK,
SMS_RESPONSE_RETRANSMIT
} SMSResponseState;
extern SMSEnteringState gEnteringSMS;
extern SMSResponseState gSMSResponseState;
extern uint8_t *dataPTR;
extern bool gGotACK;
extern uint8_t SMSResponseCounter;
void FSK_HANDLE_IRQ(unsigned short irq);
void FSKModem_TimeSlice500ms(void);
#endif //UV_K5_FIRMWARE_CUSTOM_FSKMODEM_H

View File

@@ -26,6 +26,8 @@ uint8_t gActiveMessage = 0;
StoredPacket loadedPacket;
uint8_t gKeyTimeout = 0;
void MESSAGES_SAVE() {
uint8_t Data[8];
EEPROM_ReadBuffer(SEQParameterEEPROM, Data, 8);
@@ -63,8 +65,15 @@ void updatePrevChar(KEY_Code_t Key) {
}
void MESSAGES_TimeSlice500ms(void) {
if (gKeyTimeout && gKeyTimeout++ > 2) {
gKeyTimeout = 0;
prevKey = KEY_EXIT;
}
}
void MESSAGES_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) {
gKeyTimeout = 1;
if (gEnteringSMS != SMS_NOT_ENTERING && !bKeyHeld && Key <= KEY_9) {
if (!dataPTR || dataPTR < dataPacket.data) {
dataPTR = dataPacket.data;
@@ -105,7 +114,7 @@ void MESSAGES_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) {
if (bKeyPressed) {
memset(dataPacket.data, 0, DataPacketDataSize);
prepareDataPacket();
dataPacket.flags = 126;
dataPacket.flags = 0x80 | (gCurrentVfo->OUTPUT_POWER & 0x07);
gEnteringSMS = SMS_ENTERING_MESSAGE;
}
return;
@@ -176,10 +185,10 @@ void MESSAGES_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) {
}
} else {
if (bKeyPressed) {
updatePrevChar(Key);
gRequestDisplayScreen = DISPLAY_MAIN;
}
}
updatePrevChar(Key);
break;
default:
if (!bKeyHeld && bKeyPressed)

View File

@@ -23,9 +23,12 @@ extern uint8_t gActiveMessage;
extern StoredPacket loadedPacket;
extern uint8_t gKeyTimeout;
void MESSAGES_GET();
void MESSAGES_DELETE();
void MESSAGES_SAVE();
void MESSAGES_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld);
void MESSAGES_TimeSlice500ms(void);
//#endif //BRNQUANFW_MESSAGES_H

View File

@@ -28,12 +28,13 @@ void UI_DisplayMessages(void) {
UI_DisplayClear();
if (gEnteringSMS != SMS_NOT_ENTERING) {
if (gEnteringSMS == SMS_ENTERING_DEST) {
UI_PrintString("SMS dest", 0, 0, 1 /*, 8 */);
UI_PrintString("SMS dest", 0, 0, 0 /*, 8 */);
u32_to_str(dataPacket.dest, String);
UI_PrintStringSmallNormal(String, 0, 0, 2);
} else if (gEnteringSMS == SMS_ENTERING_MESSAGE) {
UI_PrintString("SMS data", 0, 0, 1 /*, 8 */);
UI_PrintStringSmallNormal((const char *) dataPacket.data, 1, 0, 2);
UI_PrintString("SMS data", 0, 0, 0 /*, 8 */);
UI_PrintStringSmallNormal((const char *) dataPacket.data, 1, 0, 1);
memset(gFrameBuffer[1] + 2 + (7 * strlen((const char *) dataPacket.data)), gKeyTimeout == 0 ? 0xFF : 0x80, 6);
}
} else {