Skip to content

Commit 13c8759

Browse files
committed
Fix #726: adopt semantic versions completely
1 parent 37b8e6c commit 13c8759

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

src/lmic/lmic.h

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,35 @@ extern "C"{
120120
#define ARDUINO_LMIC_VERSION_GET_LOCAL(v) \
121121
((v) & 0xFFu)
122122

123+
/// \brief convert a semantic version to an ordinal integer.
124+
#define ARDUINO_LMIC_VERSION_TO_ORDINAL(v) \
125+
(((v) & 0xFFFFFF00u) | (((v) - 1) & 0xFFu))
126+
127+
/// \brief compare two semantic versions
128+
/// \return \c true if \p a is less than \p b (as a semantic version).
129+
#define ARDUINO_LMIC_VERSION_COMPARE_LT(a, b) \
130+
(ARDUINO_LMIC_VERSION_TO_ORDINAL(a) < ARDUINO_LMIC_VERSION_TO_ORDINAL(b))
131+
132+
/// \brief compare two semantic versions
133+
/// \return \c true if \p a is less than or equal to \p b (as a semantic version).
134+
#define ARDUINO_LMIC_VERSION_COMPARE_LE(a, b) \
135+
(ARDUINO_LMIC_VERSION_TO_ORDINAL(a) <= ARDUINO_LMIC_VERSION_TO_ORDINAL(b))
136+
137+
/// \brief compare two semantic versions
138+
/// \return \c true if \p a is greater than \p b (as a semantic version).
139+
#define ARDUINO_LMIC_VERSION_COMPARE_GT(a, b) \
140+
(ARDUINO_LMIC_VERSION_TO_ORDINAL(a) > ARDUINO_LMIC_VERSION_TO_ORDINAL(b))
141+
142+
/// \brief compare two semantic versions
143+
/// \return \c true if \p a is greater than or equal to \p b (as a semantic version).
144+
#define ARDUINO_LMIC_VERSION_COMPARE_GE(a, b) \
145+
(ARDUINO_LMIC_VERSION_TO_ORDINAL(a) >= ARDUINO_LMIC_VERSION_TO_ORDINAL(b))
146+
147+
123148
//! Only For Antenna Tuning Tests !
124149
//#define CFG_TxContinuousMode 1
125150

126-
// since this was annouunced as the API variable, we keep it. But it's not used,
151+
// since this was announced as the API variable, we keep it. But it's not used,
127152
// MAX_LEN_FRAME is what the code uses.
128153
enum { MAX_FRAME_LEN = MAX_LEN_FRAME }; //!< Library cap on max frame length
129154

@@ -132,10 +157,10 @@ enum { MAX_MISSED_BCNS = (2 * 60 * 60 + 127) / 128 }; //!< threshold for d
132157
// note that we need 100 ppm timing accuracy for
133158
// this, to keep the timing error to +/- 700ms.
134159
enum { MAX_RXSYMS = 350 }; // Stop tracking beacon if sync error grows beyond this. A 0.4% clock error
135-
// at SF9.125k means 512 ms; one sybol is 4.096 ms,
160+
// at SF9.125k means 512 ms; one symbol is 4.096 ms,
136161
// so this needs to be at least 125 for an STM32L0.
137162
// And for 100ppm clocks and 2 hours of beacon misses,
138-
// this needs to accomodate 1.4 seconds of error at
163+
// this needs to accommodate 1.4 seconds of error at
139164
// 4.096 ms/sym or at least 342 symbols.
140165

141166
enum { LINK_CHECK_CONT = 0 , // continue with this after reported dead link

0 commit comments

Comments
 (0)