Update main.cpp

This commit is contained in:
tuxphone 2020-09-27 19:33:25 +02:00 committed by GitHub
parent 5548789c19
commit 22c580fad6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 6 deletions

View File

@ -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 BLINK // define to NOBLINK to turn off LED signaling #define NOBLINK // define to NOBLINK to turn off LED signaling
MeshPacket thePacket; MeshPacket thePacket;
ChannelSettings ChanSet; ChannelSettings ChanSet;
@ -33,8 +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);
ChanSet.channel_num = hash( MESHTASTIC_NAME ) % myRegion[REGION].numChannels; // see config.h REGION -= 1;
ChanSet.tx_power = (myRegion[REGION].powerLimit == 0) ? TX_MAX_POWER : myRegion[REGION].powerLimit; 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 ;
if (ChanSet.tx_power > TX_MAX_POWER) ChanSet.tx_power = 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:
@ -182,9 +183,9 @@ unsigned long hash(char *str)
void ConfigureRadio( ChannelSettings ChanSet ) void ConfigureRadio( ChannelSettings ChanSet )
{ {
uint32_t freq = (uint32_t)(myRegion[REGION].freq + myRegion[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",myRegion[REGION].code); MSG("\nRegion is: %s\n",regions[REGION].name);
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);
@ -192,9 +193,10 @@ void ConfigureRadio( ChannelSettings ChanSet )
MSG("Setting SpreadingFactor to %i ..\n",ChanSet.spread_factor); MSG("Setting SpreadingFactor to %i ..\n",ChanSet.spread_factor);
#endif #endif
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 );
} }