-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Downlink Bandwidth Plan Frequency 915 #48
base: master
Are you sure you want to change the base?
Conversation
Add suport to bandwidth 500 and coding_rate 4/5 on function setRate. Force downlink to be bandwidth 500 and coding_rate 4/5 only if _STRICT_1CH off.
Fix uplink frequency and show web frequecy channel
Fix bandwidth only for plan 915
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The entire changed can be simplified to a few line changes in this method, since the bw_500_4_5 is never changed and is set at compile time.
#if _LFREQ==915
mc1= 0x92;
#else
mc1= 0x72;
#endif
@@ -206,9 +207,14 @@ void setRate(uint8_t sf, uint8_t crc) | |||
else { | |||
mc1= 0x72; // SX1276_MC1_BW_125==0x70 | SX1276_MC1_CR_4_5==0x02 | |||
} | |||
|
|||
if (bw500_4_5) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#if _LFREQ==915
mc1 = 0x92;
#else
mc1= 0x72; // SX1276_MC1_BW_125==0x70 | SX1276_MC1_CR_4_5==0x02
#end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All other changes in this PR can be reverted.
@@ -695,7 +701,15 @@ void txLoraModem(uint8_t *payLoad, uint8_t payLength, uint32_t tmst, uint8_t sfT | |||
} | |||
#endif | |||
_state = S_TX; | |||
|
|||
|
|||
bool bw500_4_5 = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not necessary since bw500_4_5 is a compile-time constant.
@@ -706,7 +720,7 @@ void txLoraModem(uint8_t *payLoad, uint8_t payLength, uint32_t tmst, uint8_t sfT | |||
opmode(OPMODE_STANDBY); // set 0x01 to 0x01 | |||
|
|||
// 3. Init spreading factor and other Modem setting | |||
setRate(sfTx, crc); | |||
setRate(sfTx, crc, bw500_4_5); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Un-necessary.
@@ -466,8 +466,7 @@ int buildPacket(uint32_t tmst, uint8_t *buff_up, struct LoraUp LoraUp, bool inte | |||
} | |||
#endif | |||
buff_index += j; | |||
ftoa((double)freq/1000000,cfreq,6); // XXX This can be done better | |||
j = snprintf((char *)(buff_up + buff_index), TX_BUFF_SIZE-buff_index, ",\"chan\":%1u,\"rfch\":%1u,\"freq\":%s", 0, 0, cfreq); | |||
j = snprintf((char *)(buff_up + buff_index), TX_BUFF_SIZE-buff_index, ",\"chan\":%1u,\"rfch\":%1u,\"freq\":%.2f", 0, 0, freq / 1000000.0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks nicer on the ttn console.
} pins; | ||
|
||
// For MH-ET ESP32 MiniKit | ||
#if defined (ARDUINO_ARCH_ESP32) || defined(ESP32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will break almost every other ESP32 board.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was using the Gateway for Hallard type boards on the MH-ET ESP32 MiniKit but did not want to change the _PIN_OUT number.
@@ -178,7 +178,7 @@ void writeBuffer(uint8_t addr, uint8_t *buf, uint8_t len) | |||
// CRC_ON == 0x04 | |||
// ---------------------------------------------------------------------------- | |||
|
|||
void setRate(uint8_t sf, uint8_t crc) | |||
void setRate(uint8_t sf, uint8_t crc, bool bw500_4_5 = false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not necessary
mc2= ((sf<<4) | crc) & 0xFF; // crc is 0x00 or 0x04==SX1276_MC2_RX_PAYLOAD_CRCON | ||
mc3= 0x04; // 0x04; SX1276_MC3_AGCAUTO | ||
if (sf == SF11 || sf == SF12) { mc3|= 0x08; } // 0x08 | 0x04 | ||
if ((sf == SF11 || sf == SF12) && (bw500_4_5 == false) ) { mc3|= 0x08; } // 0x08 | 0x04 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (sf == SF11 || sf == SF12) {
#if _LFREQ != 915
mc3|= 0x08; //...
#endif
}
The 915 plan has an uplink with BW125 and downlink with BW500, that's why I created the variable bw500_4_5 to use only on the txLoraModem function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The uplink and downlink need to have different BW.
} pins; | ||
|
||
// For MH-ET ESP32 MiniKit | ||
#if defined (ARDUINO_ARCH_ESP32) || defined(ESP32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was using the Gateway for Hallard type boards on the MH-ET ESP32 MiniKit but did not want to change the _PIN_OUT number.
Hello,
Based on https://www.thethingsnetwork.org/docs/lorawan/frequency-plans.html
The Bandwidth from most Frequency 915 is BW500, so I make some shenanigans to fix.
I just force downlink to change to BW500 when the frequency is 915, but I guess the right way is to create a
LoraDown.bwTx
and check the packagedatr
.👍