Skip to content

Commit

Permalink
Clean messenger code & fix MDC bug
Browse files Browse the repository at this point in the history
  • Loading branch information
LolloDev5123 committed Jan 10, 2024
1 parent fc038ce commit 3bb9583
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 55 deletions.
17 changes: 10 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ ENABLE_DTMF_CALLING := 0
ENABLE_DTMF_SIDETONES := 1
ENABLE_TX1750 := 0
# Keep this in stock options, and add option in mods for extra rogers
ENABLE_ROGERBEEP := 1
ENABLE_MDC := 0
ENABLE_ROGERBEEP := 1
ENABLE_MDC := 1

#==================== MODIFICATIONS ===================#
# AM Modulation Fix - 544 bytes
Expand All @@ -44,11 +44,11 @@ ENABLE_FASTER_CHANNEL_SCAN := 1
# CW Modulation
ENABLE_CW := 1

#================== EXTRA: MESSENGER ==================#
ENABLE_MESSENGER := 1
ENABLE_MESSENGER_DELIVERY_ACK_NOTIFICATION := 1
ENABLE_MESSENGER_DELIVERY_SOUND_NOTIFICATION := 0
ENABLE_MESSENGER_MORE_ONE_LINE := 1
#============ EXTRA: MESSENGER ============#
ENABLE_MESSENGER := 1
ENABLE_MESSENGER_DELIVERY_NOTIFICATION := 1
ENABLE_MESSENGER_MORE_ONE_LINE := 1
ENABLE_MESSENGER_WARN_UNKWN_FSK := 1
# 124 bytes
ENABLE_MESSENGER_SHOW_RX_FREQ := 1
# 124 (+20) bytes
Expand Down Expand Up @@ -358,6 +358,9 @@ endif
ifeq ($(ENABLE_MESSENGER_MORE_ONE_LINE),1)
CFLAGS += -DENABLE_MESSENGER_MORE_ONE_LINE
endif
ifeq ($(ENABLE_MESSENGER_WARN_UNKWN_FSK),1)
CFLAGS += -DENABLE_MESSENGER_WARN_UNKWN_FSK
endif
ifeq ($(ENABLE_MESSENGER_SHOW_RX_FREQ),1)
CFLAGS += -DENABLE_MESSENGER_SHOW_RX_FREQ
endif
Expand Down
95 changes: 52 additions & 43 deletions app/messenger.c
Original file line number Diff line number Diff line change
Expand Up @@ -676,65 +676,74 @@ void MSG_StorePacket(const uint16_t interrupt_bits)
gUpdateStatus = true;
gUpdateDisplay = true;

BK4819_DisableDTMF();
RADIO_SetTxParameters();
SYSTEM_DelayMs(500);
BK4819_ExitTxMute();
BK4819_PlayRoger(99);
}
#endif
}
else
{
moveUP(rxMessage);
if (msgFSKBuffer[0] != 'M' || msgFSKBuffer[1] != 'S')
{
#ifdef ENABLE_MESSENGER_MORE_ONE_LINE
snprintf(rxMessage[4], TX_MSG_LENGTH + 2, "? unknown msg format!");
}
else
{
snprintf(rxMessage[4], TX_MSG_LENGTH + 2, "< %s", &msgFSKBuffer[2]);
}
#else
snprintf(rxMessage[3], TX_MSG_LENGTH + 2, "? unknown msg format!");
}
else
{
snprintf(rxMessage[3], TX_MSG_LENGTH + 2, "< %s", &msgFSKBuffer[2]);
}
#endif
#ifdef ENABLE_MESSENGER_UART
UART_printf("SMS<%s\r\n", &msgFSKBuffer[2]);
#endif
#ifdef ENABLE_MESSENGER_DELIVERY_SOUND_NOTIFICATION
BK4819_DisableDTMF();
RADIO_SetTxParameters();
SYSTEM_DelayMs(500);
BK4819_ExitTxMute();
BK4819_PlayRoger(99);
#endif
moveUP(rxMessage);
if (msgFSKBuffer[0] == 'M' && msgFSKBuffer[1] == 'S' && msgFSKBuffer[2] != 0x1b) {
// Received new message (not service as handled above)
#ifdef ENABLE_MESSENGER_MORE_ONE_LINE
snprintf(rxMessage[4], TX_MSG_LENGTH + 2, "< %s", &msgFSKBuffer[2]);
#else
snprintf(rxMessage[3], TX_MSG_LENGTH + 2, "< %s", &msgFSKBuffer[2]);
#endif

#ifdef ENABLE_MESSENGER_UART
UART_printf("SMS<%s\r\n", &msgFSKBuffer[2]);
#endif

// This delivery roger sound is supposed to play when an ACK is received,
// but it currently refuses to work?? when placed under the '+' ACK indicator code
// So, for now, it'll serve as a notification when receiving a message.
#ifdef ENABLE_MESSENGER_DELIVERY_NOTIFICATION
BK4819_DisableDTMF();
RADIO_SetTxParameters();
SYSTEM_DelayMs(500);
BK4819_ExitTxMute();
BK4819_PlayRoger(99);
#endif

if (gAppToDisplay != APP_MESSENGER)
{
hasNewMessage = true;
gUpdateStatus = true;
UI_DisplayStatus();
}

} else {
// Invalid/unrecognized FSK Data
#ifdef ENABLE_MESSENGER_WARN_UNKWN_FSK
#ifdef ENABLE_MESSENGER_MORE_ONE_LINE
snprintf(rxMessage[4], TX_MSG_LENGTH + 2, "? INVALID %s", &msgFSKBuffer[2]);
#else
snprintf(rxMessage[3], TX_MSG_LENGTH + 2, "? INVALID %s", &msgFSKBuffer[2]);
#endif
#endif
}


}

if (gAppToDisplay != APP_MESSENGER)
{
hasNewMessage = true;
gUpdateStatus = true;
gUpdateDisplay = true;

UI_DisplayStatus();
}
else
{
gUpdateDisplay = true;
}
}

gFSKWriteIndex = 0;
// Transmit a message to the sender that we have received the message (Unless it's a service message)
if (msgFSKBuffer[0] == 'M' && msgFSKBuffer[1] == 'S' && msgFSKBuffer[2] != 0x1b)
{
#ifdef ENABLE_MESSENGER_DELIVERY_ACK_NOTIFICATION
MSG_Send("\x1b\x1b\x1bRCVD ", true);
#endif
if (rx_finished && gAppToDisplay != APP_MESSENGER)
{
hasNewMessage = true;
gUpdateStatus = true;
gUpdateDisplay = true;
UI_DisplayStatus();
}
}
}
}
Expand Down
6 changes: 1 addition & 5 deletions radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -923,11 +923,7 @@ void RADIO_SendEndOfTransmission(void) {
} else if (gEeprom.ROGER == ROGER_MODE_MDC) {
BK4819_PlayRogerMDC();
}



ROGER_MODE_UV5RC,


#elif defined (ENABLE_ROGERBEEP) && !defined (ENABLE_MDC)
if (gEeprom.ROGER == ROGER_MODE_DEFAULT) {
BK4819_PlayRoger(0);
Expand Down

0 comments on commit 3bb9583

Please sign in to comment.