Skip to content

Commit

Permalink
Merge pull request #150 from mcci-catena/issue25
Browse files Browse the repository at this point in the history
TTN V3 update
  • Loading branch information
terrillmoore authored May 6, 2021
2 parents 4bc0d48 + bab0cab commit fecd8a0
Show file tree
Hide file tree
Showing 42 changed files with 935 additions and 270 deletions.
32 changes: 18 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ The classes in this library are normally intended to be used inside a class that

### Using the LMIC's pre-configured pin-maps

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

```c++
#include <Arduino_LoRaWAN_ttn.h>
Expand All @@ -138,11 +138,12 @@ public:
cMyLoRaWAN() {};

protected:
// you'll need to provide implementations for each of the following.
// you'll need to provide implementations for this.
virtual bool GetOtaaProvisioningInfo(Arduino_LoRaWAN::OtaaProvisioningInfo*) override;
virtual void NetSaveFCntUp(uint32_t uFCntUp) override;
virtual void NetSaveFCntDown(uint32_t uFCntDown) override;
// if you have persistent storage, you can provide implementations for these:
virtual void NetSaveSessionInfo(const SessionInfo &Info, const uint8_t *pExtraInfo, size_t nExtraInfo) override;
virtual void NetSaveSessionState(const SessionState &State) override;
virtual bool NetGetSessionState(SessionState &State) override;
};

// set up the data structures.
Expand All @@ -166,16 +167,6 @@ cMyLoRaWAN::GetOtaaProvisioningInfo(
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,
Expand All @@ -184,6 +175,19 @@ cMyLoRaWAN::NetSaveSessionInfo(
) {
// save Info somewhere.
}

void
cMyLoRaWAN::NetSaveSessionState(const SessionState &State) {
// save State somwwhere. Note that it's often the same;
// often only the frame counters change.
}

bool
cMyLoRaWAN::NetGetSessionState(SessionState &State) {
// either fetch SessionState from somewhere and return true or...
return false;
}

```
### Supplying a pin-map
Expand Down
31 changes: 17 additions & 14 deletions examples/simple/simple.ino
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public:
cMyLoRaWAN() {};

protected:
// you'll need to provide implementations for each of the following.
// you'll need to provide implementation for this.
virtual bool GetOtaaProvisioningInfo(Arduino_LoRaWAN::OtaaProvisioningInfo*) override;
virtual void NetSaveFCntUp(uint32_t uFCntUp) override;
virtual void NetSaveFCntDown(uint32_t uFCntDown) override;
// if you have persistent storage, you can provide implementations for these:
virtual void NetSaveSessionInfo(const SessionInfo &Info, const uint8_t *pExtraInfo, size_t nExtraInfo) override;

virtual void NetSaveSessionState(const SessionState &State) override;
virtual bool NetGetSessionState(SessionState &State) override;
};

// set up the data structures.
Expand All @@ -57,16 +57,6 @@ cMyLoRaWAN::GetOtaaProvisioningInfo(
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,
Expand All @@ -75,3 +65,16 @@ cMyLoRaWAN::NetSaveSessionInfo(
) {
// save Info somewhere.
}


void
cMyLoRaWAN::NetSaveSessionState(const SessionState &State) {
// save State somwwhere. Note that it's often the same;
// often only the frame counters change.
}

bool
cMyLoRaWAN::NetGetSessionState(SessionState &State) {
// either fetch SessionState from somewhere and return true or...
return false;
}
30 changes: 16 additions & 14 deletions examples/simple_feather/simple_feather.ino
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public:
cMyLoRaWAN() {};

protected:
// you'll need to provide implementations for each of the following.
// you'll need to provide implementation for this.
virtual bool GetOtaaProvisioningInfo(Arduino_LoRaWAN::OtaaProvisioningInfo*) override;
virtual void NetSaveFCntUp(uint32_t uFCntUp) override;
virtual void NetSaveFCntDown(uint32_t uFCntDown) override;
// if you have persistent storage, you can provide implementations for these:
virtual void NetSaveSessionInfo(const SessionInfo &Info, const uint8_t *pExtraInfo, size_t nExtraInfo) override;

virtual void NetSaveSessionState(const SessionState &State) override;
virtual bool NetGetSessionState(SessionState &State) override;
};

// set up the data structures.
Expand Down Expand Up @@ -71,16 +71,6 @@ cMyLoRaWAN::GetOtaaProvisioningInfo(
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,
Expand All @@ -89,3 +79,15 @@ cMyLoRaWAN::NetSaveSessionInfo(
) {
// save Info somewhere.
}

void
cMyLoRaWAN::NetSaveSessionState(const SessionState &State) {
// save State somwwhere. Note that it's often the same;
// often only the frame counters change.
}

bool
cMyLoRaWAN::NetGetSessionState(SessionState &State) {
// either fetch SessionState from somewhere and return true or...
return false;
}
Loading

0 comments on commit fecd8a0

Please sign in to comment.