-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
{ | ||
uint8_t mc1=0, mc2=0, mc3=0; | ||
#if DUSB>=2 | ||
|
@@ -190,6 +190,7 @@ void setRate(uint8_t sf, uint8_t crc) | |
return; | ||
} | ||
#endif | ||
|
||
ricaun marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// Set rate based on Spreading Factor etc | ||
if (sx1272) { | ||
mc1= 0x0A; // SX1276_MC1_BW_250 0x80 | SX1276_MC1_CR_4_5 0x02 | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All other changes in this PR can be reverted. |
||
mc1 = 0x92; | ||
} | ||
|
||
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 commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
|
||
// Implicit Header (IH), for class b beacons (&& SF6) | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Not necessary since bw500_4_5 is a compile-time constant. |
||
|
||
#if _STRICT_1CH | ||
bw500_4_5 = false; | ||
#elif _LFREQ==915 | ||
bw500_4_5 = true; | ||
#endif | ||
|
||
// 1. Select LoRa modem from sleep mode | ||
//opmode(OPMODE_LORA); // set register 0x01 to 0x80 | ||
|
||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Un-necessary. |
||
|
||
// Frquency hopping | ||
//writeRegister(REG_HOP_PERIOD, (uint8_t) 0x00); // set 0x24 to 0x00 only for receivers | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Looks nicer on the ttn console. |
||
buff_index += j; | ||
memcpy((void *)(buff_up + buff_index), (void *)",\"stat\":1", 9); | ||
buff_index += 9; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,16 +148,28 @@ unsigned long detTime=0; | |
// ---------------------------------------------------------------------------- | ||
// Definition of the GPIO pins used by the Gateway for Hallard type boards | ||
// | ||
struct pins { | ||
uint8_t dio0=15; // GPIO15 / D8. For the Hallard board shared between DIO0/DIO1/DIO2 | ||
uint8_t dio1=15; // GPIO15 / D8. Used for CAD, may or not be shared with DIO0 | ||
uint8_t dio2=15; // GPIO15 / D8. Used for frequency hopping, don't care | ||
uint8_t ss=16; // GPIO16 / D0. Select pin connected to GPIO16 / D0 | ||
uint8_t rst=0; // GPIO 0 / D3. Reset pin not used | ||
// MISO 12 / D6 | ||
// MOSI 13 / D7 | ||
// CLK 14 / D5 | ||
} 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 commentThe 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 commentThe 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. |
||
struct pins { | ||
uint8_t dio0=5; // GPIO5 | ||
uint8_t dio1=5; // GPIO5 | ||
uint8_t dio2=5; // GPIO5 | ||
uint8_t ss=26; // GPIO26 | ||
uint8_t rst=0; // Reset pin not used | ||
} pins; | ||
#else | ||
struct pins { | ||
uint8_t dio0=15; // GPIO15 / D8. For the Hallard board shared between DIO0/DIO1/DIO2 | ||
uint8_t dio1=15; // GPIO15 / D8. Used for CAD, may or not be shared with DIO0 | ||
uint8_t dio2=15; // GPIO15 / D8. Used for frequency hopping, don't care | ||
uint8_t ss=16; // GPIO16 / D0. Select pin connected to GPIO16 / D0 | ||
uint8_t rst=0; // GPIO 0 / D3. Reset pin not used | ||
// MISO 12 / D6 | ||
// MOSI 13 / D7 | ||
// CLK 14 / D5 | ||
} pins; | ||
#endif | ||
|
||
#elif _PIN_OUT==2 | ||
// ---------------------------------------------------------------------------- | ||
|
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