Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AU915 bandwidth and Adafruit Feather LoRa Boards #174

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ For more info, see https://www.arduino.cc/en/Guide/Libraries
Features
--------
The LMIC library provides a fairly complete LoRaWAN Class A and Class B
implementation, supporting the EU-868 and US-915 bands. Only a limited
implementation, supporting the EU-868, US-915 and AU-915 bands. Only a limited
number of features was tested using this port on Arduino hardware, so be
careful when using any of the untested features.

Expand Down Expand Up @@ -236,6 +236,36 @@ This board uses the following pin mapping:
.dio = {4, 5, 7},
};

#### Adafruit Feather

##### Feather 32u4 RFM95W LoRa Radio 900MHz
This board uses the following pin mapping:

const lmic_pinmap lmic_pins = {
.nss = 8,
.rxtx = LMIC_UNUSED_PIN,
.rst = 4,
.dio = {7, 6, LMIC_UNUSED_PIN},
};

##### Feather M0 RFM95W loRa Radio 900MHz
This board uses the following pin mapping:

const lmic_pinmap lmic_pins = {
.nss = 8,
.rxtx = LMIC_UNUSED_PIN,
.rst = 4,
.dio = {3, 6, LMIC_UNUSED_PIN},
};

**PIN6** and **IO1** from the Adafruit board need to be connected before uploading the code.

A suitable length [antenna](https://learn.adafruit.com/adafruit-feather-32u4-radio-with-lora-radio-module/antenna-options) is also required to ensure good connection qualities.

- 433 MHz - 6.5 inches, or 16.5 cm
- 868 MHz - 3.25 inches or 8.2 cm
- 915 MHz - 3 inches or 7.8 cm

Examples
--------
This library currently provides three examples:
Expand Down
5 changes: 5 additions & 0 deletions src/lmic/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@

#define CFG_eu868 1
//#define CFG_us915 1
//#define CFG_au915 1

#if defined(CFG_au915)
#define CFG_us915 1
#endif
// This is the SX1272/SX1273 radio, which is also used on the HopeRF
// RFM92 boards.
//#define CFG_sx1272_radio 1
Expand Down
43 changes: 43 additions & 0 deletions src/lmic/lmic.c
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,11 @@ static void initDefaultChannels (void) {

static u4_t convFreq (xref2u1_t ptr) {
u4_t freq = (os_rlsbf4(ptr-1) >> 8) * 100;
#if defined(CFG_au915)
if( freq < AU915_FREQ_MIN || freq > AU915_FREQ_MAX )
#else
if( freq < US915_FREQ_MIN || freq > US915_FREQ_MAX )
#endif
freq = 0;
return freq;
}
Expand Down Expand Up @@ -821,6 +825,29 @@ static u1_t mapChannels (u1_t chpage, u2_t chmap) {
return 1;
}

#if defined(CFG_au915)
static void updateTx (ostime_t txbeg) {
u1_t chnl = LMIC.txChnl;
if( chnl < 64 ) {
LMIC.freq = AU915_125kHz_UPFBASE + (chnl % 8) * AU915_125kHz_UPFSTEP;
LMIC.txpow = 30;
return;
}
LMIC.txpow = 26;
if( chnl < 64+8 ) {
LMIC.freq = AU915_500kHz_UPFBASE;
} else {
ASSERT(chnl < 64+8+MAX_XCHANNELS);
LMIC.freq = LMIC.xchFreq[chnl-72];
}

// Update global duty cycle stats
if( LMIC.globalDutyRate != 0 ) {
ostime_t airtime = calcAirTime(LMIC.rps, LMIC.dataLen);
LMIC.globalDutyAvail = txbeg + (airtime<<LMIC.globalDutyRate);
}
}
#else
static void updateTx (ostime_t txbeg) {
u1_t chnl = LMIC.txChnl;
if( chnl < 64 ) {
Expand All @@ -842,6 +869,7 @@ static void updateTx (ostime_t txbeg) {
LMIC.globalDutyAvail = txbeg + (airtime<<LMIC.globalDutyRate);
}
}
#endif

// US does not have duty cycling - return now as earliest TX time
#define nextTx(now) (_nextTx(),(now))
Expand Down Expand Up @@ -871,11 +899,25 @@ static void _nextTx (void) {
#if !defined(DISABLE_BEACONS)
static void setBcnRxParams (void) {
LMIC.dataLen = 0;
#if defined(CFG_au915)
LMIC.freq = AU915_500kHz_DNFBASE + LMIC.bcnChnl * AU915_500kHz_DNFSTEP;
#else
LMIC.freq = US915_500kHz_DNFBASE + LMIC.bcnChnl * US915_500kHz_DNFSTEP;
#endif
LMIC.rps = setIh(setNocrc(dndr2rps((dr_t)DR_BCN),1),LEN_BCN);
}
#endif // !DISABLE_BEACONS

#if defined(CFG_au915)
#define setRx1Params() { \
LMIC.freq = AU915_500kHz_DNFBASE + (LMIC.txChnl & 0x7) * AU915_500kHz_DNFSTEP; \
if( /* TX datarate */LMIC.dndr < DR_SF8C ) \
LMIC.dndr += DR_SF10CR - DR_SF10; \
else if( LMIC.dndr == DR_SF8C ) \
LMIC.dndr = DR_SF7CR; \
LMIC.rps = dndr2rps(LMIC.dndr); \
}
#else
#define setRx1Params() { \
LMIC.freq = US915_500kHz_DNFBASE + (LMIC.txChnl & 0x7) * US915_500kHz_DNFSTEP; \
if( /* TX datarate */LMIC.dndr < DR_SF8C ) \
Expand All @@ -884,6 +926,7 @@ static void setBcnRxParams (void) {
LMIC.dndr = DR_SF7CR; \
LMIC.rps = dndr2rps(LMIC.dndr); \
}
#endif

#if !defined(DISABLE_JOIN)
static void initJoinLoop (void) {
Expand Down
25 changes: 25 additions & 0 deletions src/lmic/lorabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,30 @@ enum _dr_us915_t { DR_SF10=0, DR_SF9, DR_SF8, DR_SF7, DR_SF8C, DR_NONE,
enum { DR_DFLTMIN = DR_SF8C };
enum { DR_PAGE = DR_PAGE_US915 };

#if defined(CFG_au915)

// Default frequency plan for AU 915MHz
enum { AU915_125kHz_UPFBASE = 916800000,
AU915_125kHz_UPFSTEP = 200000,
AU915_500kHz_UPFBASE = 917500000,
//AU915_500kHz_UPFSTEP = 0,
AU915_500kHz_DNFBASE = 923300000,
AU915_500kHz_DNFSTEP = 600000
};
enum { AU915_FREQ_MIN = 915000000,
AU915_FREQ_MAX = 928000000 };

enum { CHNL_PING = 0 }; // used only for default init of state (follows beacon - rotating)
enum { FREQ_PING = AU915_125kHz_UPFBASE + CHNL_PING*AU915_125kHz_UPFSTEP }; // default ping freq
enum { DR_PING = DR_SF10CR }; // default ping DR
enum { CHNL_DNW2 = 0 };
enum { FREQ_DNW2 = AU915_500kHz_DNFBASE + CHNL_DNW2*AU915_500kHz_DNFSTEP };
enum { DR_DNW2 = DR_SF12CR };
enum { CHNL_BCN = 0 }; // used only for default init of state (rotating beacon scheme)
enum { FREQ_BCN = AU915_500kHz_UPFBASE };
enum { DR_BCN = DR_SF8C };
enum { AIRTIME_BCN = 72192 }; // micros
#else
// Default frequency plan for US 915MHz
enum { US915_125kHz_UPFBASE = 902300000,
US915_125kHz_UPFSTEP = 200000,
Expand All @@ -134,6 +158,7 @@ enum { DR_DNW2 = DR_SF12CR };
enum { CHNL_BCN = 0 }; // used only for default init of state (rotating beacon scheme)
enum { DR_BCN = DR_SF10CR };
enum { AIRTIME_BCN = 72192 }; // micros
#endif

enum {
// Beacon frame format US SF10
Expand Down