Add support for the new RegionCodes of meshtastic
This commit is contained in:
parent
71f52ba2ca
commit
52c96ae949
|
@ -1,6 +1,6 @@
|
||||||
#include "mesh.pb.h"
|
#include "mesh.pb.h"
|
||||||
// CONFIGURATION HERE:
|
// CONFIGURATION HERE:
|
||||||
uint8_t REGION = RegionCode_EU865 ; // define your region here. For US, RegionCode_US, CN RegionCode_Cn etc.
|
#define REGION RegionCode_EU865 // define your region here. For US, RegionCode_US, CN RegionCode_Cn etc.
|
||||||
char MESHTASTIC_NAME[12] = {"Default"}; // Channel Name, but without "-Xy" suffix , e.g. use "Test" instead of "Test-A"
|
char MESHTASTIC_NAME[12] = {"Default"}; // Channel Name, but without "-Xy" suffix , e.g. use "Test" instead of "Test-A"
|
||||||
#define MESHTASTIC_SPEED 3 // 0 = short range, 1 = medium range, 2 = long range, 3 = very long range
|
#define MESHTASTIC_SPEED 3 // 0 = short range, 1 = medium range, 2 = long range, 3 = very long range
|
||||||
|
|
||||||
|
@ -59,6 +59,7 @@ struct RegionInfo {
|
||||||
};
|
};
|
||||||
|
|
||||||
const RegionInfo regions[] = {
|
const RegionInfo regions[] = {
|
||||||
|
RDEF(Unset, 903.08f, 2.16f, 13, 0), // Assume US freqs if unset
|
||||||
RDEF(US, 903.08f, 2.16f, 13, 0),
|
RDEF(US, 903.08f, 2.16f, 13, 0),
|
||||||
RDEF(EU433, 433.175f, 0.2f, 8, 0),
|
RDEF(EU433, 433.175f, 0.2f, 8, 0),
|
||||||
RDEF(EU865, 865.2f, 0.3f, 10, 0),
|
RDEF(EU865, 865.2f, 0.3f, 10, 0),
|
||||||
|
@ -67,8 +68,7 @@ const RegionInfo regions[] = {
|
||||||
RDEF(ANZ, 916.0f, 0.5f, 20, 0), // AU/NZ channel settings 915-928MHz
|
RDEF(ANZ, 916.0f, 0.5f, 20, 0), // AU/NZ channel settings 915-928MHz
|
||||||
RDEF(KR, 921.9f, 0.2f, 8, 0), // KR channel settings (KR920-923) Start from TTN download channel
|
RDEF(KR, 921.9f, 0.2f, 8, 0), // KR channel settings (KR920-923) Start from TTN download channel
|
||||||
// freq. (921.9f is for download, others are for uplink)
|
// freq. (921.9f is for download, others are for uplink)
|
||||||
RDEF(TW, 923.0f, 0.2f, 10, 0), // TW channel settings (AS2 bandplan 923-925MHz)
|
RDEF(TW, 923.0f, 0.2f, 10, 0) // TW channel settings (AS2 bandplan 923-925MHz)
|
||||||
RDEF(Unset, 903.08f, 2.16f, 13, 0) // Assume US freqs if unset, Must be last
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const RegionInfo *myRegion;
|
//static const RegionInfo *myRegion;
|
||||||
|
|
16
src/main.cpp
16
src/main.cpp
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
// CONFIGURATION: change values in config.h !
|
// CONFIGURATION: change values in config.h !
|
||||||
#define VERBOSE // define to SILENT to turn off serial messages
|
#define VERBOSE // define to SILENT to turn off serial messages
|
||||||
#define NOBLINK // define to NOBLINK to turn off LED signaling
|
#define BLINK // define to NOBLINK to turn off LED signaling
|
||||||
|
|
||||||
MeshPacket thePacket;
|
MeshPacket thePacket;
|
||||||
ChannelSettings ChanSet;
|
ChannelSettings ChanSet;
|
||||||
|
@ -33,10 +33,9 @@ void setup() {
|
||||||
Radio.Init( &RadioEvents );
|
Radio.Init( &RadioEvents );
|
||||||
Radio.Sleep();
|
Radio.Sleep();
|
||||||
memcpy(ChanSet.name, MESHTASTIC_NAME, 12);
|
memcpy(ChanSet.name, MESHTASTIC_NAME, 12);
|
||||||
REGION -= 1;
|
//myRegion = ®ions[REGION];
|
||||||
ChanSet.channel_num = hash( MESHTASTIC_NAME ) % regions[REGION].numChannels; // see config.h
|
ChanSet.channel_num = hash( MESHTASTIC_NAME ) % regions[REGION].numChannels; // see config.h
|
||||||
ChanSet.tx_power = (regions[REGION].powerLimit == 0) ? TX_MAX_POWER : regions[REGION].powerLimit ;
|
ChanSet.tx_power = (regions[REGION].powerLimit == 0) ? TX_MAX_POWER : MAX(regions[REGION].powerLimit, TX_MAX_POWER) ;
|
||||||
if (ChanSet.tx_power > TX_MAX_POWER) ChanSet.tx_power = TX_MAX_POWER;
|
|
||||||
ChanSet.psk = MESHTASTIC_PSK;
|
ChanSet.psk = MESHTASTIC_PSK;
|
||||||
/* FYI:
|
/* FYI:
|
||||||
"bandwidth":
|
"bandwidth":
|
||||||
|
@ -183,9 +182,12 @@ unsigned long hash(char *str)
|
||||||
|
|
||||||
void ConfigureRadio( ChannelSettings ChanSet )
|
void ConfigureRadio( ChannelSettings ChanSet )
|
||||||
{
|
{
|
||||||
|
//uint32_t freq = (myRegion->freq + myRegion->spacing * ChanSet.channel_num)*1E6;
|
||||||
uint32_t freq = (regions[REGION].freq + regions[REGION].spacing * ChanSet.channel_num)*1E6;
|
uint32_t freq = (regions[REGION].freq + regions[REGION].spacing * ChanSet.channel_num)*1E6;
|
||||||
|
|
||||||
#ifndef SILENT
|
#ifndef SILENT
|
||||||
MSG("\nRegion is: %s\n",regions[REGION].name);
|
MSG("\nRegion is: %s", regions[REGION].name);
|
||||||
|
MSG(" TX power: %i\n", ChanSet.tx_power);
|
||||||
MSG("Setting frequency to %i Hz (meshtastic channel %i) .. \n",freq,ChanSet.channel_num );
|
MSG("Setting frequency to %i Hz (meshtastic channel %i) .. \n",freq,ChanSet.channel_num );
|
||||||
MSG("Channel name is: %s .. \n", ChanSet.name );
|
MSG("Channel name is: %s .. \n", ChanSet.name );
|
||||||
MSG("Setting bandwidth to index %i ..\n",ChanSet.bandwidth);
|
MSG("Setting bandwidth to index %i ..\n",ChanSet.bandwidth);
|
||||||
|
@ -195,8 +197,6 @@ void ConfigureRadio( ChannelSettings ChanSet )
|
||||||
Radio.SetChannel( freq );
|
Radio.SetChannel( freq );
|
||||||
Radio.SetTxConfig( MODEM_LORA, ChanSet.tx_power ,0 , ChanSet.bandwidth, ChanSet.spread_factor, ChanSet.coding_rate,
|
Radio.SetTxConfig( MODEM_LORA, ChanSet.tx_power ,0 , ChanSet.bandwidth, ChanSet.spread_factor, ChanSet.coding_rate,
|
||||||
LORA_PREAMBLE_LENGTH, false, true, false, 0, false, 20000 );
|
LORA_PREAMBLE_LENGTH, false, true, false, 0, false, 20000 );
|
||||||
|
|
||||||
Radio.SetRxConfig( MODEM_LORA, ChanSet.bandwidth, ChanSet.spread_factor, ChanSet.coding_rate, 0, LORA_PREAMBLE_LENGTH,
|
Radio.SetRxConfig( MODEM_LORA, ChanSet.bandwidth, ChanSet.spread_factor, ChanSet.coding_rate, 0, LORA_PREAMBLE_LENGTH,
|
||||||
LORA_SYMBOL_TIMEOUT, false , 0, true, false, 0, false, true );
|
LORA_SYMBOL_TIMEOUT, false , 0, true, false, 0, false, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue