Skip to content

Commit

Permalink
Merge pull request #52 from mcci-catena/issue49
Browse files Browse the repository at this point in the history
Fix #49: add compilable example, update README, add to travis
  • Loading branch information
terrillmoore authored Nov 12, 2018
2 parents 105df62 + 9bbd087 commit 0ba36ff
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 10 deletions.
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ matrix:
- arduino --verify --board $(_samdopts '' as923jp) $THISLIB/examples/header_test_ttn/header_test_ttn.ino
- arduino --verify --board $(_samdopts '' in866) $THISLIB/examples/header_test_ttn/header_test_ttn.ino

- arduino --verify --board $(_samdopts '' us915) $THISLIB/examples/simple_feather/simple_feather.ino
- arduino --verify --board $(_samdopts '' eu868) $THISLIB/examples/simple_feather/simple_feather.ino
# V1.1.0 of the samd bsp doesn't support au921 correctly -- test with projcfg
# - arduino --verify --board $(_samdopts '' au921) $THISLIB/examples/simple_feather/simple_feather.ino
- _projcfg CFG_au921 CFG_sx1276_radio && arduino --verify --board $(_samdopts '' projcfg) $THISLIB/examples/simple_feather/simple_feather.ino
- arduino --verify --board $(_samdopts '' as923) $THISLIB/examples/simple_feather/simple_feather.ino
- arduino --verify --board $(_samdopts '' as923jp) $THISLIB/examples/simple_feather/simple_feather.ino
- arduino --verify --board $(_samdopts '' in866) $THISLIB/examples/simple_feather/simple_feather.ino

#
# *** TESTS FOR STM32L0 / Catena 4551 ****
- arduino --verify --board $(_stm32l0opts '' us915 ) $MCCI_STM32_OPTS $THISLIB/examples/header_test/header_test.ino
Expand Down
48 changes: 38 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,15 @@ MCCI tends to use the this library wrapped by the [Catena Arduino Platform](http

The classes in this library are normally intended to be used inside a class that overrides one or more of the virtual methods.

The stand-alone use pattern is as follows, targeting The Things Network V2.
The stand-alone use pattern is as follows, targeting The Things Network V2. This code can be found in the `example/simple_feather/simple_feather.ino` sketch. Note that this isn't complete, as you have to add code in the indicated places.

```c++
#include <Arduino_LoRaWAN_ttn.h>

class cMyLoRaWAN : public Arduino_LoRaWAN_ttn {
// ... see below for typical contents
publc:
myLoRaWAN() {};
myLoRaWAN(const lmic_pinmap& pinmap) Arduino_LoRaWAN_ttn(pinmap) {};
public:
cMyLoRaWAN() {};
cMyLoRaWAN(const lmic_pinmap& pinmap) : Arduino_LoRaWAN_ttn(pinmap) {};
protected:
// you'll need to provide implementations for each of the following.
virtual bool GetOtaaProvisioningInfo(Arduino_LoRaWAN::OtaaProvisioningInfo*) override;
Expand All @@ -79,14 +78,14 @@ protected:
virtual void NetSaveSessionInfo(const SessionInfo &Info, const uint8_t *pExtraInfo, size_t nExtraInfo) override;
};

// example pinmap - this is for Feather M0 LoRa
const lmic_pinmap myPinmap = {
// pinmap - this is for Feather M0 LoRa
const cMyLoRaWAN::lmic_pinmap myPinMap = {
.nss = 8,
.nss = 8,
.rxtx = LMIC_UNUSED_PIN,
.rxtx = cMyLoRaWAN::lmic_pinmap::LMIC_UNUSED_PIN,
.rst = 4,
.dio = { 3, 6, LMIC_UNUSED_PIN },
.dio = { 3, 6, cMyLoRaWAN::lmic_pinmap::LMIC_UNUSED_PIN },
.rxtx_rx_active = 0,
.rssi_cal = 0,
.spi_freq = 8000000,
};

Expand All @@ -100,6 +99,35 @@ void setup() {
void loop() {
myLoRaWAN.loop();
}

// this method is called when the LMIC needs OTAA info.
// return false to indicate "no provisioning", otherwise
// fill in the data and return true.
bool
cMyLoRaWAN::GetOtaaProvisioningInfo(
OtaaProvisioningInfo *pInfo
) {
return false;
}

void
cMyLoRaWAN::NetSaveFCntDown(uint32_t uFCntDown) {
// save uFcntDown somwwhere
}

void
cMyLoRaWAN::NetSaveFCntUp(uint32_t uFCntUp) {
// save uFCntUp somewhere
}

void
cMyLoRaWAN::NetSaveSessionInfo(
const SessionInfo &Info,
const uint8_t *pExtraInfo,
size_t nExtraInfo
) {
// save Info somewhere.
}
```
## Release History
Expand Down
85 changes: 85 additions & 0 deletions examples/simple_feather/simple_feather.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
Module: simple_feather.ino
Function:
Example app matching the documentation in the project
README.md.
Copyright notice and License:
See LICENSE file accompanying this project.
Author:
Terry Moore, MCCI Corporation November 2018
Notes:
This app is not complete -- it only presents skeleton
code for the methods you must provide in order to
use this library. However, it compiles!
*/

#include <Arduino_LoRaWAN_ttn.h>

class cMyLoRaWAN : public Arduino_LoRaWAN_ttn {
public:
cMyLoRaWAN() {};
cMyLoRaWAN(const lmic_pinmap& pinmap) : Arduino_LoRaWAN_ttn(pinmap) {};
protected:
// you'll need to provide implementations for each of the following.
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;
};

// pinmap - this is for Feather M0 LoRa
const cMyLoRaWAN::lmic_pinmap myPinMap = {
.nss = 8,
.rxtx = cMyLoRaWAN::lmic_pinmap::LMIC_UNUSED_PIN,
.rst = 4,
.dio = { 3, 6, cMyLoRaWAN::lmic_pinmap::LMIC_UNUSED_PIN },
.rxtx_rx_active = 0,
.rssi_cal = 0,
.spi_freq = 8000000,
};

// set up the data structures.
cMyLoRaWAN myLoRaWAN(myPinMap);

void setup() {
myLoRaWAN.begin();
}

void loop() {
myLoRaWAN.loop();
}

// this method is called when the LMIC needs OTAA info.
// return false to indicate "no provisioning", otherwise
// fill in the data and return true.
bool
cMyLoRaWAN::GetOtaaProvisioningInfo(
OtaaProvisioningInfo *pInfo
) {
return false;
}

void
cMyLoRaWAN::NetSaveFCntDown(uint32_t uFCntDown) {
// save uFcntDown somwwhere
}

void
cMyLoRaWAN::NetSaveFCntUp(uint32_t uFCntUp) {
// save uFCntUp somewhere
}

void
cMyLoRaWAN::NetSaveSessionInfo(
const SessionInfo &Info,
const uint8_t *pExtraInfo,
size_t nExtraInfo
) {
// save Info somewhere.
}

2 comments on commit 0ba36ff

@chipmc
Copy link

@chipmc chipmc commented on 0ba36ff Nov 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@terrillmoore
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're welcome.

Please sign in to comment.