Skip to content

Commit

Permalink
fix channel_num variable
Browse files Browse the repository at this point in the history
  • Loading branch information
andrekir committed Mar 16, 2023
1 parent b398f31 commit af4e8df
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/mesh/RadioInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,13 +454,13 @@ void RadioInterface::applyModemConfig()

// If user has manually specified a channel num, then use that, otherwise generate one by hashing the name
const char *channelName = channels.getName(channels.getPrimaryIndex());
int channel_num = (loraConfig.channel_num ? loraConfig.channel_num - 1 : hash(channelName)) % numChannels;
int channel_num = (loraConfig.channel_num ? loraConfig.channel_num : hash(channelName)) % numChannels;

// Old frequency selection formula
// float freq = myRegion->freqStart + ((((myRegion->freqEnd - myRegion->freqStart) / numChannels) / 2) * channel_num);

// New frequency selection formula
float freq = myRegion->freqStart + (bw / 2000) + (channel_num * (bw / 1000));
float freq = myRegion->freqStart + (bw / 2000) + ((channel_num - 1) * (bw / 1000));

// override if we have a verbatim frequency
if (loraConfig.override_frequency) {
Expand Down

0 comments on commit af4e8df

Please sign in to comment.