Skip to content

Commit

Permalink
Merge pull request #290 from mcci-catena/issue286
Browse files Browse the repository at this point in the history
TTN V3 compatibility patch
  • Loading branch information
terrillmoore authored May 6, 2021
2 parents 3f23add + aabf80a commit 8e7234d
Show file tree
Hide file tree
Showing 93 changed files with 2,311 additions and 507 deletions.
8 changes: 4 additions & 4 deletions README.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions assets/CatenaBase.plantuml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ abstract class CatenaBase {
+ProvisioningStyle GetProvisioningStyle();
+bool GetAbpProvisioningInfo();
+bool GetOtaaProvisioningInfo();
+void NetSaveFCntUp();
+void NetSaveFCntDown();
+void NetSaveSessionInfo();
+void NetSaveSessionState();
+bool NetGetSessionInfo();
+bool addLoRaWanCommands();
+{static}CatenaBase *pCatenaBase;
#{abstract}void registerCommands();
Expand Down
2 changes: 1 addition & 1 deletion examples/catena_fsm/catena_fsm.ino
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public:
};

// the begin method initializes the fsm
void begin()
void begin()
{
if (! this->m_fRunning)
this->m_fsm.init(*this, &Turnstile::fsmDispatch);
Expand Down
2 changes: 1 addition & 1 deletion examples/catena_hello/catena_hello.ino
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Function:
Copyright notice and License:
See LICENSE file accompanying this project.
Author:
Terry Moore, MCCI Corporation April 2018
Expand Down
2 changes: 1 addition & 1 deletion examples/catena_hello_lora/catena_hello_lora.ino
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Function:
Copyright notice and License:
See LICENSE file accompanying this project.
Author:
Terry Moore, MCCI Corporation April 2018
Expand Down
4 changes: 2 additions & 2 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ MCCIADK_STRINGVAL KEYWORD2
MCCIADK_UNREFERENCED_PARAMETER KEYWORD1
MCCIADK_UNREFERENCED_VARIABLE KEYWORD1
MCCIHWINFO_KEY KEYWORD1
NetSaveFCntDown KEYWORD2
NetSaveFCntUp KEYWORD2
NetSaveSessionInfo KEYWORD2
NetSaveSessionState KEYWORD2
NetGetSessionState KEYWORD2
OPERATING_FLAGS KEYWORD1
PAGE_BASE KEYWORD2
PIN_ONE_WIRE KEYWORD2
Expand Down
10 changes: 5 additions & 5 deletions src/Catena4410.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ Copyright notice:
Ithaca, NY 14850
An unpublished work. All rights reserved.
This file is proprietary information, and may not be disclosed or
copied without the prior permission of MCCI Corporation.
Author:
Terry Moore, MCCI Corporation October 2016
Expand Down Expand Up @@ -63,7 +63,7 @@ class Catena4410 : public CatenaFeatherM0
PIN_SHT10_CLK = 11,
PIN_SHT10_DATA = 10
};

/*
|| Methods
*/
Expand Down Expand Up @@ -107,11 +107,11 @@ class Catena4410::LoRaWAN : public CatenaFeatherM0::LoRaWAN
|| the constructor.
*/
LoRaWAN() {};

/*
|| the begin function loads data from the local
|| platform's stable storage and initializes
|| the connection.
|| the connection.
*/
// bool begin(Catena4410 *pCatena4410);

Expand Down
4 changes: 2 additions & 2 deletions src/Catena4410_project_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ Copyright notice:
Ithaca, NY 14850
An unpublished work. All rights reserved.
This file is proprietary information, and may not be disclosed or
copied without the prior permission of MCCI Corporation.
Author:
Terry Moore, MCCI Corporation November 2016
Expand Down
4 changes: 2 additions & 2 deletions src/Catena4420_project_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ Copyright notice:
Ithaca, NY 14850
An unpublished work. All rights reserved.
This file is proprietary information, and may not be disclosed or
copied without the prior permission of MCCI Corporation.
Author:
Terry Moore, MCCI Corporation November 2016
Expand Down
4 changes: 2 additions & 2 deletions src/Catena4450.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ Copyright notice:
Ithaca, NY 14850
An unpublished work. All rights reserved.
This file is proprietary information, and may not be disclosed or
copied without the prior permission of MCCI Corporation.
Author:
Terry Moore, MCCI Corporation March 2017
Expand Down
4 changes: 2 additions & 2 deletions src/Catena4460.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ Copyright notice:
Ithaca, NY 14850
An unpublished work. All rights reserved.
This file is proprietary information, and may not be disclosed or
copied without the prior permission of MCCI Corporation.
Author:
Terry Moore, MCCI Corporation March 2018
Expand Down
4 changes: 2 additions & 2 deletions src/Catena4470.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ Copyright notice:
Ithaca, NY 14850
An unpublished work. All rights reserved.
This file is proprietary information, and may not be disclosed or
copied without the prior permission of MCCI Corporation.
Author:
Terry Moore, MCCI Corporation March 2018
Expand Down
52 changes: 44 additions & 8 deletions src/CatenaBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,17 @@ Copyright notice:

#include <Arduino_LoRaWAN.h>

#if ! (defined(ARDUINO_LORAWAN_VERSION) && ARDUINO_LORAWAN_VERSION >= ARDUINO_LORAWAN_VERSION_CALC(0,6,0,20))
#if ! (defined(ARDUINO_LORAWAN_VERSION_COMPARE_LT) && \
! ARDUINO_LORAWAN_VERSION_COMPARE_LT(ARDUINO_LORAWAN_VERSION, ARDUINO_LORAWAN_VERSION_CALC(0,9,0,2)))
# error Arduino_LoRaWAN library is out of date. Check ARDUINO_LORAWAN_VERSION.
#endif

// Catena-Arduino-Platform Version
// Catena-Arduino-Platform Version: uses semantic version for local (so local == 0 is > non-zero)
#define CATENA_ARDUINO_PLATFORM_VERSION_CALC(major, minor, patch, local) \
(((major) << 24u) | ((minor) << 16u) | ((patch) << 8u) | (local))

#define CATENA_ARDUINO_PLATFORM_VERSION CATENA_ARDUINO_PLATFORM_VERSION_CALC(0, 20, 1, 0) /* v0.20.1.0 */
#define CATENA_ARDUINO_PLATFORM_VERSION \
CATENA_ARDUINO_PLATFORM_VERSION_CALC(0, 21, 0, 5) /* v0.21.0-5 */

#define CATENA_ARDUINO_PLATFORM_VERSION_GET_MAJOR(v) \
(((v) >> 24u) & 0xFFu)
Expand All @@ -69,6 +71,29 @@ Copyright notice:
#define CATENA_ARDUINO_PLATFORM_VERSION_GET_LOCAL(v) \
((v) & 0xFFu)

/// \brief convert a semantic version to an integer.
#define CATENA_ARDUINO_PLATFORM_VERSION_TO_INT(v) \
(((v) & 0xFFFFFF00u) | (((v) - 1) & 0xFFu))

/// \brief compare two semantic versions
/// \return \c true if \b a is less than \b b (as a semantic version).
#define CATENA_ARDUINO_PLATFORM_VERSION_COMPARE_LT(a, b) \
(CATENA_ARDUINO_PLATFORM_VERSION_TO_INT(a) < CATENA_ARDUINO_PLATFORM_VERSION_TO_INT(b))

/// \brief compare two semantic versions
/// \return \c true if \b a is greater than or equal to \b b (as a semantic version).
#define CATENA_ARDUINO_PLATFORM_VERSION_COMPARE_GE(a, b) \
(CATENA_ARDUINO_PLATFORM_VERSION_TO_INT(a) >= CATENA_ARDUINO_PLATFORM_VERSION_TO_INT(b))

/// \brief compare two semantic versions
/// \return \c true if \b a is greater than \b b (as a semantic version).
#define CATENA_ARDUINO_PLATFORM_VERSION_COMPARE_GT(a, b) \
(CATENA_ARDUINO_PLATFORM_VERSION_TO_INT(a) > CATENA_ARDUINO_PLATFORM_VERSION_TO_INT(b))

/// \brief compare two semantic versions
/// \return \c true if \b a is less than or equal to \b b (as a semantic version).
#define CATENA_ARDUINO_PLATFORM_VERSION_COMPARE_LE(a, b) \
(CATENA_ARDUINO_PLATFORM_VERSION_TO_INT(a) <= CATENA_ARDUINO_PLATFORM_VERSION_TO_INT(b))

namespace McciCatena {

Expand All @@ -90,6 +115,11 @@ class CatenaBase
static constexpr uint32_t kMcciArduinoVersion = _mcci_arduino_version;
#else
static constexpr uint32_t kMcciArduinoVersion = 0;
#endif
#if defined(_mcci_arduino_version_is_semantic)
static constexpr bool kMcciArduinoVersionIsSemantic = true;
#else
static constexpr bool kMcciArduinoVersionIsSemantic = false;
#endif
static constexpr uint32_t versionCalc(uint8_t major, uint8_t minor, uint8_t patch, uint8_t local)
{
Expand Down Expand Up @@ -276,13 +306,17 @@ class CatenaBase
bool GetAbpProvisioningInfo(Arduino_LoRaWAN::AbpProvisioningInfo *);
bool GetOtaaProvisioningInfo(Arduino_LoRaWAN::OtaaProvisioningInfo *);

void NetSaveFCntUp(uint32_t uFCntUp);
void NetSaveFCntDown(uint32_t uFCntDown);
void NetSaveSessionInfo(
const Arduino_LoRaWAN::SessionInfo &Info,
const uint8_t *pExtraInfo,
size_t nExtraInfo
);
void NetSaveSessionState(
const Arduino_LoRaWAN::SessionState &State
);
bool NetGetSessionState(
Arduino_LoRaWAN::SessionState &State
);

bool addLoRaWanCommands(void);

Expand All @@ -299,6 +333,11 @@ class CatenaBase
return &this->m_CommandStream;
}

/// \brief return the command line collector
cStreamLineCollector *getCommandCollector()
{
return &this->m_Collector;
}

/****************************************************************************\
|
Expand Down Expand Up @@ -565,9 +604,6 @@ Index: Function: CatenaBase::PlatformFlags_IsModded();
*/
// actual function is above.

// global for finding the base from anywhere.
extern CatenaBase *gpCatenaBase;

}; // end namespace McciCatena


Expand Down
4 changes: 2 additions & 2 deletions src/CatenaBase_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ Copyright notice:
Ithaca, NY 14850
An unpublished work. All rights reserved.
This file is proprietary information, and may not be disclosed or
copied without the prior permission of MCCI Corporation.
Author:
Terry Moore, MCCI Corporation March 2017
Expand Down
4 changes: 2 additions & 2 deletions src/CatenaFeatherM0.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ class CatenaFeatherM0::LoRaWAN : public Arduino_LoRaWAN_network,
|| the constructor.
*/
LoRaWAN() {};

/*
|| the begin function loads data from the local
|| platform's stable storage and initializes
|| the connection.
|| the connection.
*/
virtual bool begin(CatenaFeatherM0 *pCatena);

Expand Down
6 changes: 3 additions & 3 deletions src/CatenaRTC.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ Copyright notice:
Ithaca, NY 14850
An unpublished work. All rights reserved.
This file is proprietary information, and may not be disclosed or
copied without the prior permission of MCCI Corporation.
Author:
Terry Moore, MCCI Corporation November 2016
Expand Down Expand Up @@ -87,7 +87,7 @@ class CatenaRTC

void SetAlarm(const CalendarTime *pNow);

void SleepForAlarm(Alarm_Match how = MATCH_HHMMSS,
void SleepForAlarm(Alarm_Match how = MATCH_HHMMSS,
SleepMode howSleep = SleepMode::IdleCpu
);

Expand Down
4 changes: 2 additions & 2 deletions src/CatenaSamd21.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Copyright notice:
Ithaca, NY 14850
An unpublished work. All rights reserved.
This file is proprietary information, and may not be disclosed or
copied without the prior permission of MCCI Corporation.
Expand Down Expand Up @@ -65,7 +65,7 @@ namespace McciCatena {
/* the class for Samd21-based Catenas */
class CatenaSamd21 : public CatenaBase
{
public:
public:
using Super = CatenaBase;

/*
Expand Down
18 changes: 15 additions & 3 deletions src/CatenaStm32L0.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ Copyright notice:

#include <Arduino_LoRaWAN_network.h>

static_assert(
! ARDUINO_LORAWAN_VERSION_COMPARE_LT(
ARDUINO_LORAWAN_VERSION,
ARDUINO_LORAWAN_VERSION_CALC(0, 9, 0, 1)
),
"ARDUINO_LORAWAN_VERSION must be at least 0.9.0-1"
);

namespace McciCatena {

class CatenaStm32L0 : public CatenaStm32
Expand Down Expand Up @@ -94,7 +102,7 @@ class CatenaStm32L0 : public CatenaStm32
// In future versions, this might change; some STM32L0 implementations
// might not have a crystal so LSE won't work. But for now, we assume
// that there's a crystal for LSE.
#if defined(_mcci_arduino_version)
#if defined(_mcci_arduino_version)
# if _mcci_arduino_version >= _mcci_arduino_version_calc(2,4,0,90)
static constexpr bool kUsesLSE = true; // _mcci_arduino_version indicates that LSE clock is used.
# else
Expand Down Expand Up @@ -146,13 +154,17 @@ class CatenaStm32L0::LoRaWAN : public Arduino_LoRaWAN_network,
virtual bool GetOtaaProvisioningInfo(
Arduino_LoRaWAN::OtaaProvisioningInfo *
) override;
virtual void NetSaveFCntUp(uint32_t uFCntUp) override;
virtual void NetSaveFCntDown(uint32_t uFCntDown) override;
virtual void NetSaveSessionInfo(
const SessionInfo &Info,
const uint8_t *pExtraInfo,
size_t nExtraInfo
) override;
virtual void NetSaveSessionState(
Arduino_LoRaWAN::SessionState const &State
) override;
virtual bool NetGetSessionState(
Arduino_LoRaWAN::SessionState &State
) override;

//
// TODO([email protected]) -- the following are not used but are always
Expand Down
Loading

0 comments on commit 8e7234d

Please sign in to comment.