Merge pull request #123 from kamilsss655/rc20.5

Rc20.5
This commit is contained in:
Nunu 2024-02-03 22:03:29 +01:00 committed by GitHub
commit b655393ff7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 270 additions and 64 deletions

View File

@ -46,6 +46,7 @@ ENABLE_SPECTRUM_SHOW_CHANNEL_NAME := 1
ENABLE_SPECTRUM_CHANNEL_SCAN := 1
ENABLE_MESSENGER := 1
ENABLE_MESSENGER_DELIVERY_NOTIFICATION := 1
ENABLE_MESSENGER_FSK_MUTE := 1
ENABLE_MESSENGER_NOTIFICATION := 1
ENABLE_MESSENGER_UART := 0
ENABLE_ENCRYPTION := 1
@ -370,6 +371,9 @@ endif
ifeq ($(ENABLE_MESSENGER_DELIVERY_NOTIFICATION),1)
CFLAGS += -DENABLE_MESSENGER_DELIVERY_NOTIFICATION
endif
ifeq ($(ENABLE_MESSENGER_FSK_MUTE),1)
CFLAGS += -DENABLE_MESSENGER_FSK_MUTE
endif
ifeq ($(ENABLE_MESSENGER_NOTIFICATION),1)
CFLAGS += -DENABLE_MESSENGER_NOTIFICATION
endif

View File

@ -165,6 +165,7 @@ ENABLE_SPECTRUM_SHOW_CHANNEL_NAME := 1 shows channel number and channel n
ENABLE_ADJUSTABLE_RX_GAIN_SETTINGS := 1 keeps the rx gain settings set in spectrum mode after exit (otherwise these are always overwritten to default value), this makes much more sense considering that we have a radio with user adjustable gain so why not use it to adjust to current radio conditions, maximum gain allows to greatly increase reception in scan memory channels mode (in this configuration default gain settings are only set at boot and when exiting AM modulation mode to set it to sane value after am fix)
ENABLE_SPECTRUM_CHANNEL_SCAN := 1 this enables spectrum channel scan mode (enter by going into memory mode and press F+5, this allows SUPER fast channel scanning (4.5x faster than regular scanning), regular scan of 200 memory channels takes roughly 18 seconds, spectrum memory scan takes roughly 4 seconds, if you have less channels stored i.e 50 - the spectrum memory scan will take only **1 second**
ENABLE_MESSENGER := 1 enable messenger
ENABLE_MESSENGER_FSK_MUTE := 1 mutes speaker once it detects fsk sync word (might cause unintentional mutes during ctcss rx)
ENABLE_MESSENGER_NOTIFICATION := 1 enable messenger delivery notification
ENABLE_MESSENGER_UART := 0 enable sending messages via serial with SMS:content command (unreliable)
ENABLE_ENCRYPTION := 1 enable ChaCha20 256 bit encryption for messenger

View File

@ -245,10 +245,24 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax)
case MENU_500TX:
case MENU_350EN:
case MENU_SCREN:
#ifdef ENABLE_ENCRYPTION
case MENU_MSG_ENC:
#endif
#ifdef ENABLE_MESSENGER
case MENU_MSG_RX:
case MENU_MSG_ACK:
#endif
*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_OFF_ON) - 1;
break;
#ifdef ENABLE_MESSENGER
case MENU_MSG_MODULATION:
*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_MSG_MODULATION) - 1;
break;
#endif
case MENU_AM:
*pMin = 0;
*pMax = ARRAY_SIZE(gModulationStr) - 1;
@ -483,10 +497,28 @@ void MENU_AcceptSetting(void)
#ifdef ENABLE_ENCRYPTION
case MENU_ENC_KEY:
memset(gEeprom.ENC_KEY, 0, sizeof(gEeprom.ENC_KEY));
memmove(gEeprom.ENC_KEY, edit, sizeof(edit));
memmove(gEeprom.ENC_KEY, edit, sizeof(gEeprom.ENC_KEY));
memset(edit, 0, sizeof(edit));
gUpdateStatus = true;
break;
case MENU_MSG_ENC:
gEeprom.MESSENGER_CONFIG.data.encrypt = gSubMenuSelection;
break;
#endif
#ifdef ENABLE_MESSENGER
case MENU_MSG_RX:
gEeprom.MESSENGER_CONFIG.data.receive = gSubMenuSelection;
break;
case MENU_MSG_ACK:
gEeprom.MESSENGER_CONFIG.data.ack = gSubMenuSelection;
break;
case MENU_MSG_MODULATION:
gEeprom.MESSENGER_CONFIG.data.modulation = gSubMenuSelection;
break;
#endif
case MENU_W_N:
@ -916,6 +948,26 @@ void MENU_ShowCurrentSetting(void)
gSubMenuSelection = gEeprom.RX_OFFSET;
break;
#ifdef ENABLE_ENCRYPTION
case MENU_MSG_ENC:
gSubMenuSelection = gEeprom.MESSENGER_CONFIG.data.encrypt;
break;
#endif
#ifdef ENABLE_MESSENGER
case MENU_MSG_RX:
gSubMenuSelection = gEeprom.MESSENGER_CONFIG.data.receive;
break;
case MENU_MSG_ACK:
gSubMenuSelection = gEeprom.MESSENGER_CONFIG.data.ack;
break;
case MENU_MSG_MODULATION:
gSubMenuSelection = gEeprom.MESSENGER_CONFIG.data.modulation;
break;
#endif
#ifdef ENABLE_PWRON_PASSWORD
case MENU_PASSWORD:
gSubMenuSelection = gEeprom.POWER_ON_PASSWORD;

View File

@ -29,7 +29,7 @@ const uint8_t MSG_BUTTON_EVENT_LONG = MSG_BUTTON_STATE_HELD;
const uint8_t MAX_MSG_LENGTH = PAYLOAD_LENGTH - 1;
const uint16_t TONE2_FREQ = 0x3065; // 0x2854
uint16_t TONE2_FREQ;
#define NEXT_CHAR_DELAY 100 // 10ms tick
@ -72,13 +72,14 @@ void MSG_FSKSendData() {
uint16_t deviation;
switch (gEeprom.VfoInfo[gEeprom.TX_VFO].CHANNEL_BANDWIDTH)
{
case BK4819_FILTER_BW_WIDE: deviation = 1350; break; // 20k // measurements by kamilsss655
case BK4819_FILTER_BW_WIDE: deviation = 1300; break; // 20k // measurements by kamilsss655
case BK4819_FILTER_BW_NARROW: deviation = 1200; break; // 10k
// case BK4819_FILTER_BW_NARROWAVIATION: deviation = 850; break; // 5k
// case BK4819_FILTER_BW_NARROWER: deviation = 850; break; // 5k
// case BK4819_FILTER_BW_NARROWEST: deviation = 850; break; // 5k
default: deviation = 850; break; // 5k
}
//BK4819_WriteRegister(0x40, (3u << 12) | (deviation & 0xfff));
BK4819_WriteRegister(BK4819_REG_40, (dev_val & 0xf000) | (deviation & 0xfff));
}
@ -152,7 +153,9 @@ void MSG_EnableRX(const bool enable) {
if (enable) {
MSG_ConfigureFSK(true);
BK4819_FskEnableRx();
if(gEeprom.MESSENGER_CONFIG.data.receive)
BK4819_FskEnableRx();
} else {
BK4819_WriteRegister(BK4819_REG_70, 0);
BK4819_WriteRegister(BK4819_REG_58, 0);
@ -266,9 +269,12 @@ void MSG_StorePacket(const uint16_t interrupt_bits) {
//UART_printf("\nMSG : S%i, F%i, E%i | %i", rx_sync, rx_fifo_almost_full, rx_finished, interrupt_bits);
if (rx_sync) {
// prevent listening to fsk data and squelch (kamilsss655)
AUDIO_AudioPathOff();
#ifdef ENABLE_MESSENGER_FSK_MUTE
// prevent listening to fsk data and squelch (kamilsss655)
// CTCSS codes seem to false trigger the rx_sync
if(gCurrentCodeType == CODE_TYPE_OFF)
AUDIO_AudioPathOff();
#endif
gFSKWriteIndex = 0;
MSG_ClearPacketBuffer();
msgStatus = RECEIVING;
@ -382,7 +388,9 @@ void MSG_HandleReceive(){
{
// wait so the correspondent radio can properly receive it
SYSTEM_DelayMs(700);
MSG_SendAck();
if(gEeprom.MESSENGER_CONFIG.data.ack)
MSG_SendAck();
}
}
@ -519,7 +527,14 @@ void MSG_ClearPacketBuffer()
void MSG_Send(const char *cMessage){
MSG_ClearPacketBuffer();
#ifdef ENABLE_ENCRYPTION
dataPacket.data.header=ENCRYPTED_MESSAGE_PACKET;
if(gEeprom.MESSENGER_CONFIG.data.encrypt)
{
dataPacket.data.header=ENCRYPTED_MESSAGE_PACKET;
}
else
{
dataPacket.data.header=MESSAGE_PACKET;
}
#else
dataPacket.data.header=MESSAGE_PACKET;
#endif
@ -551,59 +566,122 @@ void MSG_ConfigureFSK(bool rx)
( 1u << 7) | // 1
(96u << 0)); // 96
// Tone2 baudrate 1200
// Tone2 = FSK baudrate // kamilsss655 2024
switch(gEeprom.MESSENGER_CONFIG.data.modulation)
{
case MOD_AFSK_1200:
TONE2_FREQ = 12389u;
break;
case MOD_FSK_700:
TONE2_FREQ = 7227u;
break;
case MOD_FSK_450:
TONE2_FREQ = 4646u;
break;
}
BK4819_WriteRegister(BK4819_REG_72, TONE2_FREQ);
BK4819_WriteRegister(BK4819_REG_58,
(1u << 13) | // 1 FSK TX mode selection
// 0 = FSK 1.2K and FSK 2.4K TX .. no tones, direct FM
// 1 = FFSK 1200 / 1800 TX
// 2 = ???
// 3 = FFSK 1200 / 2400 TX
// 4 = ???
// 5 = NOAA SAME TX
// 6 = ???
// 7 = ???
//
(7u << 10) | // 0 FSK RX mode selection
// 0 = FSK 1.2K, FSK 2.4K RX and NOAA SAME RX .. no tones, direct FM
// 1 = ???
// 2 = ???
// 3 = ???
// 4 = FFSK 1200 / 2400 RX
// 5 = ???
// 6 = ???
// 7 = FFSK 1200 / 1800 RX
//
(3u << 8) | // 0 FSK RX gain
// 0 ~ 3
//
(0u << 6) | // 0 ???
// 0 ~ 3
//
(0u << 4) | // 0 FSK preamble type selection
// 0 = 0xAA or 0x55 due to the MSB of FSK sync byte 0
// 1 = ???
// 2 = 0x55
// 3 = 0xAA
//
(1u << 1) | // 1 FSK RX bandwidth setting
// 0 = FSK 1.2K .. no tones, direct FM
// 1 = FFSK 1200 / 1800
// 2 = NOAA SAME RX
// 3 = ???
// 4 = FSK 2.4K and FFSK 1200 / 2400
// 5 = ???
// 6 = ???
// 7 = ???
//
(1u << 0)); // 1 FSK enable
// 0 = disable
// 1 = enable
switch(gEeprom.MESSENGER_CONFIG.data.modulation)
{
case MOD_FSK_700:
case MOD_FSK_450:
BK4819_WriteRegister(BK4819_REG_58,
(0u << 13) | // 1 FSK TX mode selection
// 0 = FSK 1.2K and FSK 2.4K TX .. no tones, direct FM
// 1 = FFSK 1200 / 1800 TX
// 2 = ???
// 3 = FFSK 1200 / 2400 TX
// 4 = ???
// 5 = NOAA SAME TX
// 6 = ???
// 7 = ???
//
(0u << 10) | // 0 FSK RX mode selection
// 0 = FSK 1.2K, FSK 2.4K RX and NOAA SAME RX .. no tones, direct FM
// 1 = ???
// 2 = ???
// 3 = ???
// 4 = FFSK 1200 / 2400 RX
// 5 = ???
// 6 = ???
// 7 = FFSK 1200 / 1800 RX
//
(3u << 8) | // 0 FSK RX gain
// 0 ~ 3
//
(0u << 6) | // 0 ???
// 0 ~ 3
//
(0u << 4) | // 0 FSK preamble type selection
// 0 = 0xAA or 0x55 due to the MSB of FSK sync byte 0
// 1 = ???
// 2 = 0x55
// 3 = 0xAA
//
(0u << 1) | // 1 FSK RX bandwidth setting
// 0 = FSK 1.2K .. no tones, direct FM
// 1 = FFSK 1200 / 1800
// 2 = NOAA SAME RX
// 3 = ???
// 4 = FSK 2.4K and FFSK 1200 / 2400
// 5 = ???
// 6 = ???
// 7 = ???
//
(1u << 0)); // 1 FSK enable
// 0 = disable
// 1 = enable
break;
case MOD_AFSK_1200:
BK4819_WriteRegister(BK4819_REG_58,
(1u << 13) | // 1 FSK TX mode selection
// 0 = FSK 1.2K and FSK 2.4K TX .. no tones, direct FM
// 1 = FFSK 1200 / 1800 TX
// 2 = ???
// 3 = FFSK 1200 / 2400 TX
// 4 = ???
// 5 = NOAA SAME TX
// 6 = ???
// 7 = ???
//
(7u << 10) | // 0 FSK RX mode selection
// 0 = FSK 1.2K, FSK 2.4K RX and NOAA SAME RX .. no tones, direct FM
// 1 = ???
// 2 = ???
// 3 = ???
// 4 = FFSK 1200 / 2400 RX
// 5 = ???
// 6 = ???
// 7 = FFSK 1200 / 1800 RX
//
(3u << 8) | // 0 FSK RX gain
// 0 ~ 3
//
(0u << 6) | // 0 ???
// 0 ~ 3
//
(0u << 4) | // 0 FSK preamble type selection
// 0 = 0xAA or 0x55 due to the MSB of FSK sync byte 0
// 1 = ???
// 2 = 0x55
// 3 = 0xAA
//
(1u << 1) | // 1 FSK RX bandwidth setting
// 0 = FSK 1.2K .. no tones, direct FM
// 1 = FFSK 1200 / 1800
// 2 = NOAA SAME RX
// 3 = ???
// 4 = FSK 2.4K and FFSK 1200 / 2400
// 5 = ???
// 6 = ???
// 7 = ???
//
(1u << 0)); // 1 FSK enable
// 0 = disable
// 1 = enable
break;
}
// REG_5A .. bytes 0 & 1 sync pattern
//

View File

@ -40,6 +40,13 @@ typedef enum PacketType {
INVALID_PACKET
} PacketType;
// Modem Modulation // 2024 kamilsss655
typedef enum ModemModulation {
MOD_FSK_450, // for bad conditions
MOD_FSK_700, // for medium conditions
MOD_AFSK_1200 // for good conditions
} ModemModulation;
// Data Packet definition // 2024 kamilsss655
union DataPacket
{
@ -53,6 +60,19 @@ union DataPacket
uint8_t serializedArray[1+PAYLOAD_LENGTH+NONCE_LENGTH];
};
// MessengerConfig // 2024 kamilsss655
typedef union {
struct {
uint8_t
receive :1, // determines whether fsk modem will listen for new messages
ack :1, // determines whether the radio will automatically respond to messages with ACK
encrypt :1, // determines whether outgoing messages will be encrypted
unused :1,
modulation :2, // determines FSK modulation type
unused2 :2;
} data;
uint8_t __val;
} MessengerConfig;
void MSG_EnableRX(const bool enable);
void MSG_StorePacket(const uint16_t interrupt_bits);

View File

@ -593,6 +593,9 @@ void BOARD_EEPROM_Init(void)
#ifdef ENABLE_PWRON_PASSWORD
gEeprom.PASSWORD_WRONG_ATTEMPTS = (Data[2] > PASSWORD_MAX_RETRIES) ? PASSWORD_MAX_RETRIES : Data[2];
#endif
#ifdef ENABLE_MESSENGER
gEeprom.MESSENGER_CONFIG.__val = Data[3];
#endif
// 0EA8..0EAF
EEPROM_ReadBuffer(0x0EA8, Data, 8);

Binary file not shown.

View File

@ -746,8 +746,11 @@ void RADIO_SetupRegisters(bool switchToForeground)
// enable/disable BK4819 selected interrupts
#ifdef ENABLE_MESSENGER
MSG_EnableRX(true);
InterruptMask |= BK4819_REG_3F_FSK_RX_SYNC | BK4819_REG_3F_FSK_RX_FINISHED | BK4819_REG_3F_FSK_FIFO_ALMOST_FULL | BK4819_REG_3F_FSK_TX_FINISHED;
if(gEeprom.MESSENGER_CONFIG.data.receive)
{
MSG_EnableRX(true);
InterruptMask |= BK4819_REG_3F_FSK_RX_SYNC | BK4819_REG_3F_FSK_RX_FINISHED | BK4819_REG_3F_FSK_FIFO_ALMOST_FULL | BK4819_REG_3F_FSK_TX_FINISHED;
}
#endif
BK4819_WriteRegister(BK4819_REG_3F, InterruptMask);

View File

@ -112,6 +112,9 @@ void SETTINGS_SaveSettings(void)
#endif
State[1] = gEeprom.RX_AGC;
State[2] = gEeprom.PASSWORD_WRONG_ATTEMPTS;
#ifdef ENABLE_MESSENGER
State[3] = gEeprom.MESSENGER_CONFIG.__val;
#endif
EEPROM_WriteBuffer(0x0EA0, State, true);
memset(State, 0xFF, sizeof(State));

View File

@ -24,6 +24,9 @@
#include <helper/battery.h>
#include "radio.h"
#include <driver/backlight.h>
#ifdef ENABLE_MESSENGER
#include "app/messenger.h"
#endif
enum POWER_OnDisplayMode_t {
POWER_ON_DISPLAY_MODE_FULL_SCREEN = 0,
@ -242,6 +245,9 @@ typedef struct {
#endif
#ifdef ENABLE_ENCRYPTION
char ENC_KEY[16];
#endif
#ifdef ENABLE_MESSENGER
MessengerConfig MESSENGER_CONFIG;
#endif
uint16_t VOX1_THRESHOLD;
uint16_t VOX0_THRESHOLD;

View File

@ -115,7 +115,13 @@ const t_menu_item MenuList[] =
{"Passwd", VOICE_ID_INVALID, MENU_PASSWORD }, // power on password
#endif
#ifdef ENABLE_ENCRYPTION
{"EncKey", VOICE_ID_INVALID, MENU_ENC_KEY }, // encryption key
{"EncKey", VOICE_ID_INVALID, MENU_ENC_KEY }, // encryption key
{"MsgEnc", VOICE_ID_INVALID, MENU_MSG_ENC }, // messenger encrypt outgoing messages
#endif
#ifdef ENABLE_MESSENGER
{"MsgRx", VOICE_ID_INVALID, MENU_MSG_RX }, // messenger rx
{"MsgAck", VOICE_ID_INVALID, MENU_MSG_ACK }, // messenger respond ACK
{"MsgMod", VOICE_ID_INVALID, MENU_MSG_MODULATION}, // messenger modulation
#endif
{"Sql", VOICE_ID_SQUELCH, MENU_SQL },
// hidden menu items from here on
@ -177,6 +183,15 @@ const char gSubMenu_SAVE[][4] =
"80%"
};
#ifdef ENABLE_MESSENGER
const char gSubMenu_MSG_MODULATION[][10] =
{
"FSK 450",
"FSK 700",
"AFSK 1.2K"
};
#endif
const char gSubMenu_RX_AGC[][6] =
{
"OFF",
@ -658,6 +673,13 @@ void UI_DisplayMenu(void)
#ifdef ENABLE_NOAA
case MENU_NOAA_S:
#endif
#ifdef ENABLE_ENCRYPTION
case MENU_MSG_ENC:
#endif
#ifdef ENABLE_MESSENGER
case MENU_MSG_RX:
case MENU_MSG_ACK:
#endif
case MENU_350TX:
case MENU_200TX:
case MENU_500TX:
@ -665,7 +687,6 @@ void UI_DisplayMenu(void)
case MENU_SCREN:
strcpy(String, gSubMenu_OFF_ON[gSubMenuSelection]);
break;
case MENU_MEM_CH:
case MENU_1_CALL:
case MENU_DEL_CH:
@ -755,6 +776,12 @@ void UI_DisplayMenu(void)
}
#endif
#ifdef ENABLE_MESSENGER
case MENU_MSG_MODULATION:
strcpy(String, gSubMenu_MSG_MODULATION[gSubMenuSelection]);
break;
#endif
case MENU_SAVE:
strcpy(String, gSubMenu_SAVE[gSubMenuSelection]);
break;

View File

@ -64,6 +64,12 @@ enum
#endif
#ifdef ENABLE_ENCRYPTION
MENU_ENC_KEY,
MENU_MSG_ENC,
#endif
#ifdef ENABLE_MESSENGER
MENU_MSG_RX,
MENU_MSG_ACK,
MENU_MSG_MODULATION,
#endif
MENU_BEEP,
#ifdef ENABLE_VOICE
@ -158,6 +164,9 @@ extern const char gSubMenu_BAT_TXT[3][8];
extern const char gSubMenu_BATTYP[2][9];
extern const char gSubMenu_SCRAMBLER[11][7];
extern const char gSubMenu_RX_AGC[3][6];
#ifdef ENABLE_MESSENGER
extern const char gSubMenu_MSG_MODULATION[3][10];
#endif
typedef struct {char* name; uint8_t id;} t_sidefunction;
extern const uint8_t gSubMenu_SIDEFUNCTIONS_size;