diff --git a/src/RF95Configuration.h b/src/RF95Configuration.h index 5c525814b..f7c5751bd 100644 --- a/src/RF95Configuration.h +++ b/src/RF95Configuration.h @@ -1,6 +1,16 @@ // TODO refactor this out with better radio configuration system #ifdef USE_RF95 + +#ifndef RF95_RESET #define RF95_RESET LORA_RESET -#define RF95_IRQ LORA_DIO0 // on SX1262 version this is a no connect DIO0 +#endif + +#ifndef RF95_IRQ +#define RF95_IRQ LORA_DIO0 // on SX1262 version this is a no connect DIO0 +#endif + +#ifndef RF95_DIO1 #define RF95_DIO1 LORA_DIO1 // Note: not really used for RF95, but used for pure SX127x #endif + +#endif diff --git a/src/graphics/draw/MenuHandler.cpp b/src/graphics/draw/MenuHandler.cpp index 654796cce..45ac110bd 100644 --- a/src/graphics/draw/MenuHandler.cpp +++ b/src/graphics/draw/MenuHandler.cpp @@ -206,6 +206,9 @@ void menuHandler::LoraRegionPicker(uint32_t duration) {"KZ_863", OptionsAction::Select, meshtastic_Config_LoRaConfig_RegionCode_KZ_863}, {"NP_865", OptionsAction::Select, meshtastic_Config_LoRaConfig_RegionCode_NP_865}, {"BR_902", OptionsAction::Select, meshtastic_Config_LoRaConfig_RegionCode_BR_902}, + {"ITU1_2M (144-146)", OptionsAction::Select, meshtastic_Config_LoRaConfig_RegionCode_ITU1_2M}, + {"ITU2_2M (144-148)", OptionsAction::Select, meshtastic_Config_LoRaConfig_RegionCode_ITU2_2M}, + {"ITU3_2M (144-148)", OptionsAction::Select, meshtastic_Config_LoRaConfig_RegionCode_ITU3_2M}, }; diff --git a/src/graphics/niche/InkHUD/Applets/System/Menu/MenuAction.h b/src/graphics/niche/InkHUD/Applets/System/Menu/MenuAction.h index 9cee18533..fb1365290 100644 --- a/src/graphics/niche/InkHUD/Applets/System/Menu/MenuAction.h +++ b/src/graphics/niche/InkHUD/Applets/System/Menu/MenuAction.h @@ -66,6 +66,9 @@ enum MenuAction { SET_REGION_BR_902, SET_REGION_EU_866, SET_REGION_NARROW_868, + SET_REGION_ITU1_2M, + SET_REGION_ITU2_2M, + SET_REGION_ITU3_2M, // Device Roles SET_ROLE_CLIENT, SET_ROLE_CLIENT_MUTE, diff --git a/src/graphics/niche/InkHUD/Applets/System/Menu/MenuApplet.cpp b/src/graphics/niche/InkHUD/Applets/System/Menu/MenuApplet.cpp index ca178fb47..187381473 100644 --- a/src/graphics/niche/InkHUD/Applets/System/Menu/MenuApplet.cpp +++ b/src/graphics/niche/InkHUD/Applets/System/Menu/MenuApplet.cpp @@ -784,6 +784,18 @@ void InkHUD::MenuApplet::execute(MenuItem item) applyLoRaRegion(meshtastic_Config_LoRaConfig_RegionCode_EU_N_868); break; + case SET_REGION_ITU1_2M: + applyLoRaRegion(meshtastic_Config_LoRaConfig_RegionCode_ITU1_2M); + break; + + case SET_REGION_ITU2_2M: + applyLoRaRegion(meshtastic_Config_LoRaConfig_RegionCode_ITU2_2M); + break; + + case SET_REGION_ITU3_2M: + applyLoRaRegion(meshtastic_Config_LoRaConfig_RegionCode_ITU3_2M); + break; + // Roles case SET_ROLE_CLIENT: applyDeviceRole(meshtastic_Config_DeviceConfig_Role_CLIENT); @@ -1485,6 +1497,9 @@ void InkHUD::MenuApplet::showPage(MenuPage page) items.push_back(MenuItem("KZ 863", MenuAction::SET_REGION_KZ_863, MenuPage::EXIT)); items.push_back(MenuItem("NP 865", MenuAction::SET_REGION_NP_865, MenuPage::EXIT)); items.push_back(MenuItem("BR 902", MenuAction::SET_REGION_BR_902, MenuPage::EXIT)); + items.push_back(MenuItem("ITU1_2M (144-146)", MenuAction::SET_REGION_ITU1_2M, MenuPage::EXIT)); + items.push_back(MenuItem("ITU2_2M (144-148)", MenuAction::SET_REGION_ITU2_2M, MenuPage::EXIT)); + items.push_back(MenuItem("ITU3_2M (144-148)", MenuAction::SET_REGION_ITU3_2M, MenuPage::EXIT)); items.push_back(MenuItem("Exit", MenuPage::EXIT)); break; diff --git a/src/mesh/MeshRadio.h b/src/mesh/MeshRadio.h index 4b9d58af7..553230250 100644 --- a/src/mesh/MeshRadio.h +++ b/src/mesh/MeshRadio.h @@ -129,7 +129,7 @@ static inline float bwCodeToKHz(uint16_t bwCode) if (bwCode == 10) return 10.4f; if (bwCode == 16) - return 15.625f; + return 15.6f; if (bwCode == 21) return 20.8f; if (bwCode == 31) @@ -241,12 +241,12 @@ static inline void modemPresetToParams(meshtastic_Config_LoRaConfig_ModemPreset sf = 8; break; case PRESET(TINY_FAST): - bwKHz = 15.625f; + bwKHz = 15.6f; cr = 5; sf = 7; break; case PRESET(TINY_SLOW): - bwKHz = 15.625f; + bwKHz = 15.6f; cr = 6; sf = 8; break; diff --git a/src/mesh/RadioInterface.cpp b/src/mesh/RadioInterface.cpp index e1f1f3c97..6529dc35f 100644 --- a/src/mesh/RadioInterface.cpp +++ b/src/mesh/RadioInterface.cpp @@ -58,8 +58,8 @@ const RegionProfile PROFILE_EU868 = {PRESETS_EU_868, 0, 0, false, false, 0, 1, 1 const RegionProfile PROFILE_UNDEF = {PRESETS_UNDEF, 0, 0, true, false, 0, 1, 1}; const RegionProfile PROFILE_LITE = {PRESETS_LITE, 0.4, 0.0375f, false, false, 0, 10, 10}; const RegionProfile PROFILE_NARROW = {PRESETS_NARROW, 0, 0.0104f, true, false, 0, 1, 1}; -// Ham '20kHz' profile. 15.625kHz bandwidth coerced to 20kHz via padding. -const RegionProfile PROFILE_HAM_20KHZ = {PRESETS_TINY, 0, 0.0021875f, false, true, 0, 2, 2}; +// Ham '20kHz' profile. 15.6kHz bandwidth coerced to 20kHz via padding. +const RegionProfile PROFILE_HAM_20KHZ = {PRESETS_TINY, 0, 0.0022f, false, true, 0, 2, 2}; #define RDEF(name, freq_start, freq_end, duty_cycle, power_limit, frequency_switching, wide_lora, profile_ptr, default_preset, \ override_slot) \ @@ -230,6 +230,35 @@ const RegionInfo regions[] = { */ RDEF(BR_902, 902.0f, 907.5f, 100, 30, false, false, PROFILE_STD, PRESET(LONG_FAST), 0), + /* + ITU Region 1 (Europe, Africa, Middle East, former USSR) amateur 2m allocation: 144.000 - 146.000 MHz. + Power limit is the regulatory ceiling (1 W / 30 dBm) — individual hardware will cap below this + via its own PA curve; the field here is just the legal upper bound. + + Default slot: 26 (144.510 MHz) + https://www.iaru-r1.org/wp-content/uploads/2020/12/VHF-Bandplan.pdf + */ + RDEF(ITU1_2M, 144.0f, 146.0f, 100, 30, false, false, PROFILE_HAM_20KHZ, PRESET(TINY_FAST), 26), + + /* + ITU Region 2 (Americas) amateur 2m allocation: 144.000 - 148.000 MHz. + Typical admin rules (e.g. US FCC Part 97) allow well above 30 dBm for licensed operators. + + Default slot: 51 (145.010 MHz) + https://www.arrl.org/band-plan + */ + RDEF(ITU2_2M, 144.0f, 148.0f, 100, 30, false, false, PROFILE_HAM_20KHZ, PRESET(TINY_FAST), 51), + + /* + ITU Region 3 (Asia/Pacific) amateur 2m allocation: 144.000 - 148.000 MHz. + Typical admin rules allow well above 30 dBm for licensed operators. + + Default slot: 33 (144.650 MHz) + https://www.iaru.org/wp-content/uploads/2020/01/R3-004-IARU-Region-3-Bandplan-rev.2.pdf + https://www.wia.org.au/members/bandplans/data/documents/WIA%20Australian%20Band%20Plan%202026.pdf + */ + RDEF(ITU3_2M, 144.0f, 148.0f, 100, 30, false, false, PROFILE_HAM_20KHZ, PRESET(TINY_FAST), 33), + /* 2.4 GHZ WLAN Band equivalent. Only for SX128x chips. */ diff --git a/test/test_radio/test_main.cpp b/test/test_radio/test_main.cpp index a0ad704c4..104e6b36b 100644 --- a/test/test_radio/test_main.cpp +++ b/test/test_radio/test_main.cpp @@ -35,7 +35,7 @@ static void test_bwCodeToKHz_specialMappings() { TEST_ASSERT_FLOAT_WITHIN(0.0001f, 7.8f, bwCodeToKHz(8)); TEST_ASSERT_FLOAT_WITHIN(0.0001f, 10.4f, bwCodeToKHz(10)); - TEST_ASSERT_FLOAT_WITHIN(0.0001f, 15.625f, bwCodeToKHz(16)); + TEST_ASSERT_FLOAT_WITHIN(0.0001f, 15.6f, bwCodeToKHz(16)); TEST_ASSERT_FLOAT_WITHIN(0.0001f, 20.8f, bwCodeToKHz(21)); TEST_ASSERT_FLOAT_WITHIN(0.0001f, 31.25f, bwCodeToKHz(31)); TEST_ASSERT_FLOAT_WITHIN(0.0001f, 41.7f, bwCodeToKHz(42));