Skip to content

Commit

Permalink
Modify RadioLib library to allow using illegal syncword 0x0F0F (to be…
Browse files Browse the repository at this point in the history
… able to communicate with Fossasat1
  • Loading branch information
4m1g0 committed Jan 6, 2020
1 parent dc3debf commit f8208b2
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion FossaGroundStation/src/ConfigManager/htmlOptions.h

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion FossaGroundStation/src/Radio/Radio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ bool eInterrupt = true;
#define LORA_CURRENT_LIMIT_7X 120 // mA
#define LORA_CURRENT_LIMIT_6X 120.0f // mA
#define SYNC_WORD_7X 0xFF // sync word when using SX127x
#define SYNC_WORD_6X 0xFF // SX126x
#define SYNC_WORD_6X 0x0F0F // SX126x
#define LORA_PREAMBLE_LENGTH 8U

Radio::Radio(ConfigManager& x, MQTT_Client& mqtt)
Expand Down
2 changes: 1 addition & 1 deletion FossaGroundStation/src/Status.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct PacketInfo {
};

struct Status {
const uint32_t version = 2001063; // version year month day release
const uint32_t version = 2001064; // version year month day release
bool mqtt_connected = false;
SysInfo sysInfo;
PacketInfo lastPacketInfo;
Expand Down
2 changes: 1 addition & 1 deletion lib/RadioLib/src/modules/SX126x/SX1268.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SX1268::SX1268(Module* mod) : SX126x(mod) {

}

int16_t SX1268::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, float currentLimit, uint16_t preambleLength, float tcxoVoltage) {
int16_t SX1268::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint16_t syncWord, int8_t power, float currentLimit, uint16_t preambleLength, float tcxoVoltage) {
// execute common part
int16_t state = SX126x::begin(bw, sf, cr, syncWord, currentLimit, preambleLength, tcxoVoltage);
if(state != ERR_NONE) {
Expand Down
2 changes: 1 addition & 1 deletion lib/RadioLib/src/modules/SX126x/SX1268.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class SX1268: public SX126x {
\returns \ref status_codes
*/
int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX126X_SYNC_WORD_PRIVATE, int8_t power = 14, float currentLimit = 60.0, uint16_t preambleLength = 8, float tcxoVoltage = 1.6);
int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint16_t syncWord = SX126X_SYNC_WORD_PRIVATE, int8_t power = 14, float currentLimit = 60.0, uint16_t preambleLength = 8, float tcxoVoltage = 1.6);

/*!
\brief Initialization method for FSK modem.
Expand Down
9 changes: 4 additions & 5 deletions lib/RadioLib/src/modules/SX126x/SX126x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SX126x::SX126x(Module* mod) : PhysicalLayer(SX126X_CRYSTAL_FREQ, SX126X_DIV_EXPO
_mod = mod;
}

int16_t SX126x::begin(float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, float currentLimit, uint16_t preambleLength, float tcxoVoltage) {
int16_t SX126x::begin(float bw, uint8_t sf, uint8_t cr, uint16_t syncWord, float currentLimit, uint16_t preambleLength, float tcxoVoltage) {
// set module properties
_mod->init(RADIOLIB_USE_SPI);
Module::pinMode(_mod->getIrq(), INPUT);
Expand Down Expand Up @@ -678,16 +678,15 @@ int16_t SX126x::setCodingRate(uint8_t cr) {
return(setModulationParams(_sf, _bw, _cr));
}

int16_t SX126x::setSyncWord(uint8_t syncWord) {
int16_t SX126x::setSyncWord(uint16_t syncWord) {
// check active modem
if(getPacketType() != SX126X_PACKET_TYPE_LORA) {
return(ERR_WRONG_MODEM);
}

// update register
uint8_t data[2] = {(uint8_t)((syncWord & 0xF0) | 0x04), (uint8_t)(((syncWord & 0x0F) << 4) | 0x04)};
Serial.println(data[0], HEX);
Serial.println(data[1], HEX);
//uint8_t data[2] = {(uint8_t)((syncWord & 0xF0) | 0x04), (uint8_t)(((syncWord & 0x0F) << 4) | 0x04)};
uint8_t data[2] = {(uint8_t)((syncWord >> 8) & 0xFF), (uint8_t)(syncWord & 0xFF)};
return(writeRegister(SX126X_REG_LORA_SYNC_WORD_MSB, data, 2));
}

Expand Down
4 changes: 2 additions & 2 deletions lib/RadioLib/src/modules/SX126x/SX126x.h
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ class SX126x: public PhysicalLayer {
\returns \ref status_codes
*/
int16_t begin(float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, float currentLimit, uint16_t preambleLength, float tcxoVoltage);
int16_t begin(float bw, uint8_t sf, uint8_t cr, uint16_t syncWord, float currentLimit, uint16_t preambleLength, float tcxoVoltage);

/*!
\brief Initialization method for FSK modem.
Expand Down Expand Up @@ -576,7 +576,7 @@ class SX126x: public PhysicalLayer {
\returns \ref status_codes
*/
int16_t setSyncWord(uint8_t syncWord);
int16_t setSyncWord(uint16_t syncWord);

/*!
\brief Sets current protection limit. Can be set in 0.25 mA steps.
Expand Down

0 comments on commit f8208b2

Please sign in to comment.