Last active
January 4, 2020 00:33
-
-
Save wybiral/8426b8aa2c86fb8919e0d96a63ca9d29 to your computer and use it in GitHub Desktop.
Makes it easier to customize the LoRa parameters for RadioHead with RFM95 modules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// After calling these methods you can write them | |
// to the LoRa module using: [RH_RF95 instance].setModemRegisters(&modem) | |
// Defaults: | |
// Bw = 125 kHz | |
// Cr = 4/5 | |
// Sf = 128chips/symbol | |
// CRC on | |
RH_RF95::ModemConfig modem = {0x72, 0x74, 0x00}; | |
void setBandwidth(uint32_t bw) { | |
uint8_t index; | |
uint32_t bandwidths[] = { | |
7800, | |
10400, | |
15600, | |
20800, | |
31250, | |
41700, | |
62500, | |
125000, | |
250000, | |
500000 | |
}; | |
for (index = 0x00; index < 9; index++) { | |
if (bw <= bandwidths[index]) { | |
break; | |
} | |
} | |
modem.reg_1d = (modem.reg_1d & 0x0f) | (index << 4); | |
} | |
void setSpreadingFactor(uint8_t sf) { | |
if (sf < 6 || sf > 12) { | |
return; | |
} | |
modem.reg_1e = (modem.reg_1e & 0x0f) | (sf << 4); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment