Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ricaun
Copy link

@ricaun ricaun commented Aug 24, 2018

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 package datr.

👍

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
Copy link

@YogoGit YogoGit left a 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) {
Copy link

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 

Copy link

@YogoGit YogoGit Feb 22, 2019

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;
Copy link

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);
Copy link

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);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the change?

Copy link
Author

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)
Copy link

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.

Copy link
Author

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)
Copy link

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
Copy link

@YogoGit YogoGit Feb 22, 2019

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 
}

@ricaun
Copy link
Author

ricaun commented Feb 22, 2019

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.
Probably was not the best solution but fixed the downlink problem.

Copy link
Author

@ricaun ricaun left a 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)
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants