diff --git a/examples/SX127x/SX127x_FSK_Modem/SX127x_FSK_Modem.ino b/examples/SX127x/SX127x_FSK_Modem/SX127x_FSK_Modem.ino index 184008e8..d6294889 100644 --- a/examples/SX127x/SX127x_FSK_Modem/SX127x_FSK_Modem.ino +++ b/examples/SX127x/SX127x_FSK_Modem/SX127x_FSK_Modem.ino @@ -57,7 +57,7 @@ void setup() { state = radio.setRxBandwidth(250.0); state = radio.setOutputPower(10.0); state = radio.setCurrentLimit(100); - state = radio.setDataShaping(0.5); + state = radio.setDataShaping(RADIOLIB_SHAPING_0_5); uint8_t syncWord[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; state = radio.setSyncWord(syncWord, 8); diff --git a/src/modules/SX127x/SX1272.cpp b/src/modules/SX127x/SX1272.cpp index 411c3ab3..503923e9 100644 --- a/src/modules/SX127x/SX1272.cpp +++ b/src/modules/SX127x/SX1272.cpp @@ -36,13 +36,14 @@ int16_t SX1272::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync RADIOLIB_ASSERT(state); state = setGain(gain); + RADIOLIB_ASSERT(state); return(state); } -int16_t SX1272::beginFSK(float freq, float br, float rxBw, float freqDev, int8_t power, uint8_t currentLimit, uint16_t preambleLength, bool enableOOK) { +int16_t SX1272::beginFSK(float freq, float br, float rxBw, float freqDev, int8_t power, uint16_t preambleLength, bool enableOOK) { // execute common part - int16_t state = SX127x::beginFSK(SX1272_CHIP_VERSION, br, rxBw, freqDev, currentLimit, preambleLength, enableOOK); + int16_t state = SX127x::beginFSK(SX1272_CHIP_VERSION, br, rxBw, freqDev, preambleLength, enableOOK); RADIOLIB_ASSERT(state); // configure settings not accessible by API @@ -53,7 +54,11 @@ int16_t SX1272::beginFSK(float freq, float br, float rxBw, float freqDev, int8_t state = setFrequency(freq); RADIOLIB_ASSERT(state); + state = setDataShaping(RADIOLIB_SHAPING_NONE); + RADIOLIB_ASSERT(state); + state = setOutputPower(power); + RADIOLIB_ASSERT(state); return(state); } diff --git a/src/modules/SX127x/SX1272.h b/src/modules/SX127x/SX1272.h index 6aba8259..f65539f2 100644 --- a/src/modules/SX127x/SX1272.h +++ b/src/modules/SX127x/SX1272.h @@ -148,16 +148,13 @@ class SX1272: public SX127x { \param power Transmission output power in dBm. Allowed values range from 2 to 17 dBm. - \param currentLimit Trim value for OCP (over current protection) in mA. Can be set to multiplies of 5 in range 45 to 120 mA and to multiples of 10 in range 120 to 240 mA. - Set to 0 to disable OCP (not recommended). - \param preambleLength Length of FSK preamble in bits. \param enableOOK Use OOK modulation instead of FSK. \returns \ref status_codes */ - int16_t beginFSK(float freq = 915.0, float br = 48.0, float rxBw = 125.0, float freqDev = 50.0, int8_t power = 13, uint8_t currentLimit = 100, uint16_t preambleLength = 16, bool enableOOK = false); + int16_t beginFSK(float freq = 915.0, float br = 48.0, float rxBw = 125.0, float freqDev = 50.0, int8_t power = 10, uint16_t preambleLength = 16, bool enableOOK = false); /*! \brief Reset method. Will reset the chip to the default state using RST pin. diff --git a/src/modules/SX127x/SX1278.cpp b/src/modules/SX127x/SX1278.cpp index ae2933a5..b4c37576 100644 --- a/src/modules/SX127x/SX1278.cpp +++ b/src/modules/SX127x/SX1278.cpp @@ -31,13 +31,14 @@ int16_t SX1278::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync RADIOLIB_ASSERT(state); state = setGain(gain); + RADIOLIB_ASSERT(state); return(state); } -int16_t SX1278::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t power, uint8_t currentLimit, uint16_t preambleLength, bool enableOOK) { +int16_t SX1278::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t power, uint16_t preambleLength, bool enableOOK) { // execute common part - int16_t state = SX127x::beginFSK(SX1278_CHIP_VERSION, br, freqDev, rxBw, currentLimit, preambleLength, enableOOK); + int16_t state = SX127x::beginFSK(SX1278_CHIP_VERSION, br, freqDev, rxBw, preambleLength, enableOOK); RADIOLIB_ASSERT(state); // configure settings not accessible by API @@ -49,6 +50,10 @@ int16_t SX1278::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t RADIOLIB_ASSERT(state); state = setOutputPower(power); + RADIOLIB_ASSERT(state); + + state = setDataShaping(RADIOLIB_SHAPING_NONE); + RADIOLIB_ASSERT(state); return(state); } diff --git a/src/modules/SX127x/SX1278.h b/src/modules/SX127x/SX1278.h index 5ee20cc8..fe136361 100644 --- a/src/modules/SX127x/SX1278.h +++ b/src/modules/SX127x/SX1278.h @@ -157,16 +157,13 @@ class SX1278: public SX127x { \param power Transmission output power in dBm. Allowed values range from 2 to 17 dBm. - \param currentLimit Trim value for OCP (over current protection) in mA. Can be set to multiplies of 5 in range 45 to 120 mA and to multiples of 10 in range 120 to 240 mA. - Set to 0 to disable OCP (not recommended). - \param preambleLength Length of FSK preamble in bits. \param enableOOK Use OOK modulation instead of FSK. \returns \ref status_codes */ - int16_t beginFSK(float freq = 434.0, float br = 48.0, float freqDev = 50.0, float rxBw = 125.0, int8_t power = 13, uint8_t currentLimit = 100, uint16_t preambleLength = 16, bool enableOOK = false); + int16_t beginFSK(float freq = 434.0, float br = 48.0, float freqDev = 50.0, float rxBw = 125.0, int8_t power = 10, uint16_t preambleLength = 16, bool enableOOK = false); /*! \brief Reset method. Will reset the chip to the default state using RST pin. diff --git a/src/modules/SX127x/SX127x.cpp b/src/modules/SX127x/SX127x.cpp index 9f1f4ad0..557035d8 100644 --- a/src/modules/SX127x/SX127x.cpp +++ b/src/modules/SX127x/SX127x.cpp @@ -49,7 +49,7 @@ int16_t SX127x::begin(uint8_t chipVersion, uint8_t syncWord, uint8_t currentLimi return(state); } -int16_t SX127x::beginFSK(uint8_t chipVersion, float br, float freqDev, float rxBw, uint8_t currentLimit, uint16_t preambleLength, bool enableOOK) { +int16_t SX127x::beginFSK(uint8_t chipVersion, float br, float freqDev, float rxBw, uint16_t preambleLength, bool enableOOK) { // set module properties _mod->init(RADIOLIB_USE_SPI); Module::pinMode(_mod->getIrq(), INPUT); @@ -88,15 +88,15 @@ int16_t SX127x::beginFSK(uint8_t chipVersion, float br, float freqDev, float rxB RADIOLIB_ASSERT(state); // set over current protection - state = SX127x::setCurrentLimit(currentLimit); + state = SX127x::setCurrentLimit(60); RADIOLIB_ASSERT(state); // set preamble length state = SX127x::setPreambleLength(preambleLength); RADIOLIB_ASSERT(state); - // default sync word value 0x2D01 is the same as the default in LowPowerLab RFM69 library - uint8_t syncWord[] = {0x2D, 0x01}; + // set default sync word + uint8_t syncWord[] = {0x12, 0xAD}; state = setSyncWord(syncWord, 2); RADIOLIB_ASSERT(state); @@ -109,7 +109,7 @@ int16_t SX127x::beginFSK(uint8_t chipVersion, float br, float freqDev, float rxB RADIOLIB_ASSERT(state); // set default encoding - state = setEncoding(0); + state = setEncoding(RADIOLIB_ENCODING_NRZ); RADIOLIB_ASSERT(state); // set default packet length mode diff --git a/src/modules/SX127x/SX127x.h b/src/modules/SX127x/SX127x.h index efc5eb50..04a28bc5 100644 --- a/src/modules/SX127x/SX127x.h +++ b/src/modules/SX127x/SX127x.h @@ -583,15 +583,13 @@ class SX127x: public PhysicalLayer { \param rxBw Receiver bandwidth in kHz. - \param currentLimit Trim value for OCP (over current protection) in mA. - \param preambleLength Length of FSK preamble in bits. \param enableOOK Flag to specify OOK mode. This modulation is similar to FSK. \returns \ref status_codes */ - int16_t beginFSK(uint8_t chipVersion, float br, float freqDev, float rxBw, uint8_t currentLimit, uint16_t preambleLength, bool enableOOK); + int16_t beginFSK(uint8_t chipVersion, float br, float freqDev, float rxBw, uint16_t preambleLength, bool enableOOK); /*! \brief Binary transmit method. Will transmit arbitrary binary data up to 255 bytes long using %LoRa or up to 63 bytes using FSK modem.