Skip to content

Commit

Permalink
Added support to connect as LoRaWan node to a single channel LoRaWan …
Browse files Browse the repository at this point in the history
…gateway

Possibility to disable channel hoping in LoRaWan mode    
Possibility to define default channel and data rate for single channel mode    
Added list with channel - frequency per region
  • Loading branch information
beegee-tokyo committed Oct 11, 2019
1 parent daaaf07 commit 94c8e9e
Show file tree
Hide file tree
Showing 6 changed files with 172 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "SX126x-Arduino",
"version": "1.0.2",
"version": "1.0.3",
"keywords": [
"lora",
"Semtech",
Expand Down
135 changes: 135 additions & 0 deletions CHANNELS.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# List of channels & frequencies for different regions
Created October 11th 2019
__*Please confirm by yourself if this list is up-to-date*__

---
### Other regions using 923MHz band
### AS923

| Channel | Frequency |
| :---: | :---: |
| 0 | 923200000 |
| 1 | 923400000 |
---
### Australia
### AU915

| Channel | Frequency | Channel | Frequency | Channel | Frequency | Channel | Frequency |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| 0 | 915200000 | 18 | 918800000 | 36 | 922400000 | 54 | 926000000 |
| 1 | 915400000 | 19 | 919000000 | 37 | 922600000 | 55 | 926200000 |
| 2 | 915600000 | 20 | 919200000 | 38 | 922800000 | 56 | 926400000 |
| 3 | 915800000 | 21 | 919400000 | 39 | 923000000 | 57 | 926600000 |
| 4 | 916000000 | 22 | 919600000 | 40 | 923200000 | 58 | 926800000 |
| 5 | 916200000 | 23 | 919800000 | 41 | 923400000 | 59 | 927000000 |
| 6 | 916400000 | 24 | 920000000 | 42 | 923600000 | 60 | 927200000 |
| 7 | 916600000 | 25 | 920200000 | 43 | 923800000 | 61 | 927400000 |
| 8 | 916800000 | 26 | 920400000 | 44 | 924000000 | 62 | 927600000 |
| 9 | 917000000 | 27 | 920600000 | 45 | 924200000 | 63 | 927800000 |
| 10 | 917200000 | 28 | 920800000 | 46 | 924400000 | 64 | 915900000 |
| 11 | 917400000 | 29 | 921000000 | 47 | 924600000 | 65 | 917500000 |
| 12 | 917600000 | 30 | 921200000 | 48 | 924800000 | 66 | 919100000 |
| 13 | 917800000 | 31 | 921400000 | 49 | 925000000 | 67 | 920700000 |
| 14 | 918000000 | 32 | 921600000 | 50 | 925200000 | 68 | 922300000 |
| 15 | 918200000 | 33 | 921800000 | 51 | 925400000 | 69 | 923900000 |
| 16 | 918400000 | 34 | 922000000 | 52 | 925600000 | 70 | 925500000 |
| 17 | 918600000 | 35 | 922200000 | 53 | 925800000 | 71 | 927100000 |
---
### China 470MHz
### CN470

| Channel | Frequency | Channel | Frequency | Channel | Frequency | Channel | Frequency |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| 0 | 470300000 | 24 | 475100000 | 48 | 479900000 | 72 | 484700000 |
| 1 | 470500000 | 25 | 475300000 | 49 | 480100000 | 73 | 484900000 |
| 2 | 470700000 | 26 | 475500000 | 50 | 480300000 | 74 | 485100000 |
| 3 | 470900000 | 27 | 475700000 | 51 | 480500000 | 75 | 485300000 |
| 4 | 471100000 | 28 | 475900000 | 52 | 480700000 | 76 | 485500000 |
| 5 | 471300000 | 29 | 476100000 | 53 | 480900000 | 77 | 485700000 |
| 6 | 471500000 | 30 | 476300000 | 54 | 481100000 | 78 | 485900000 |
| 7 | 471700000 | 31 | 476500000 | 55 | 481300000 | 79 | 486100000 |
| 8 | 471900000 | 32 | 476700000 | 56 | 481500000 | 80 | 486300000 |
| 9 | 472100000 | 33 | 476900000 | 57 | 481700000 | 81 | 486500000 |
| 10 | 472300000 | 34 | 477100000 | 58 | 481900000 | 82 | 486700000 |
| 11 | 472500000 | 35 | 477300000 | 59 | 482100000 | 83 | 486900000 |
| 12 | 472700000 | 36 | 477500000 | 60 | 482300000 | 84 | 487100000 |
| 13 | 472900000 | 37 | 477700000 | 61 | 482500000 | 85 | 487300000 |
| 14 | 473100000 | 38 | 477900000 | 62 | 482700000 | 86 | 487500000 |
| 15 | 473300000 | 39 | 478100000 | 63 | 482900000 | 87 | 487700000 |
| 16 | 473500000 | 40 | 478300000 | 64 | 483100000 | 88 | 487900000 |
| 17 | 473700000 | 41 | 478500000 | 65 | 483300000 | 89 | 488100000 |
| 18 | 473900000 | 42 | 478700000 | 66 | 483500000 | 90 | 488300000 |
| 19 | 474100000 | 43 | 478900000 | 67 | 483700000 | 91 | 488500000 |
| 20 | 474300000 | 44 | 479100000 | 68 | 483900000 | 92 | 488700000 |
| 21 | 474500000 | 45 | 479300000 | 69 | 484100000 | 93 | 488900000 |
| 22 | 474700000 | 46 | 479500000 | 70 | 484300000 | 94 | 489100000 |
| 23 | 474900000 | 47 | 479700000 | 71 | 484500000 | 95 | 489300000 |
---
### China 779MHz
### CN779

| Channel | Frequency |
| :---: | :---: |
| 0 | 779500000 |
| 1 | 779700000 |
| 2 | 779900000 |
---
### Europe 433MHz
### EU433

| Channel | Frequency |
| :---: | :---: |
| 0 | 433175000 |
| 1 | 433375000 |
| 2 | 433575000 |
---
### Europe 868MHz
### EU868

| Channel | Frequency |
| :---: | :---: |
| 0 | 868100000 |
| 1 | 868300000 |
| 2 | 868500000 |
---
### India 865MHz
### IN865

| Channel | Frequency |
| :---: | :---: |
| 0 | 865062500 |
| 1 | 865402500 |
| 2 | 865985000 |
---
### South Korea 920MHz
### KR920

| Channel | Frequency |
| :---: | :---: |
| 0 | 922100000 |
| 1 | 922300000 |
| 2 | 922500000 |
---
### USA 915 MHz
### US915 & US915_HYBRID

| Channel | Frequency | Channel | Frequency | Channel | Frequency | Channel | Frequency |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| 0 | 902300000 | 18 | 905900000 | 36 | 909500000 | 54 | 913100000 |
| 1 | 902500000 | 19 | 906100000 | 37 | 909700000 | 55 | 913300000 |
| 2 | 902700000 | 20 | 906300000 | 38 | 909900000 | 56 | 913500000 |
| 3 | 902900000 | 21 | 906500000 | 39 | 910100000 | 57 | 913700000 |
| 4 | 903100000 | 22 | 906700000 | 40 | 910300000 | 58 | 913900000 |
| 5 | 903300000 | 23 | 906900000 | 41 | 910500000 | 59 | 914100000 |
| 6 | 903500000 | 24 | 907100000 | 42 | 910700000 | 60 | 914300000 |
| 7 | 903700000 | 25 | 907300000 | 43 | 910900000 | 61 | 914500000 |
| 8 | 903900000 | 26 | 907500000 | 44 | 911100000 | 62 | 914700000 |
| 9 | 904100000 | 27 | 907700000 | 45 | 911300000 | 63 | 914900000 |
| 10 | 904300000 | 28 | 907900000 | 46 | 911500000 | 64 | 903000000 |
| 11 | 904500000 | 29 | 908100000 | 47 | 911700000 | 65 | 904600000 |
| 12 | 904700000 | 30 | 908300000 | 48 | 911900000 | 66 | 906200000 |
| 13 | 904900000 | 31 | 908500000 | 49 | 912100000 | 67 | 907800000 |
| 14 | 905100000 | 32 | 908700000 | 50 | 912300000 | 68 | 909400000 |
| 15 | 905300000 | 33 | 908900000 | 51 | 912500000 | 69 | 911000000 |
| 16 | 905500000 | 34 | 909100000 | 52 | 912700000 | 70 | 912600000 |
| 17 | 905700000 | 35 | 909300000 | 53 | 912900000 | 71 | 914200000 |
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Changelog
--------
- 2019-10-11: Added support for LoRaWan connection to single channel Gateway (no frequency hopping)
- 2019-10-09:
- Tested LoRaWan with a single channel LoRaWan gateway.
- Added support for single channel gateways
Expand Down Expand Up @@ -275,6 +276,20 @@ You can find a lot of information about LoRaWan on the [LoRa Alliance](https://l
*/
#define DO_CHANNEL_SWITCH 0
/**@brief Channel to be used if we are talking to a single channel gateway
* Check the file CHANNELS.MD to find out which channel corresponds to which frequency
* in a specific region
* Defaults to channel 0
*/
#define GATEWAY_SINGLE_CHANNEL 0
/**@brief Datarate to be used if we are talking to a single channel gateway
* Check the file Region.h to find out which datarate corresponds to which SF
* and bandwidth in a specific region
* Defaults to channel DR_3
*/
#define GATEWAY_SINGLE_DATARATE DR_3
/**@brief Define activation procedure here
* More information https://www.thethingsnetwork.org/forum/t/what-is-the-difference-between-otaa-and-abp-devices/2723
* When set to 1 the application uses the Over-the-Air activation procedure
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=SX126x-Arduino
version=1.0.2
version=1.0.3
author=Bernd Giesecke <[email protected]>
maintainer=Bernd Giesecke <[email protected]>
sentence=Arduino library to use Semtech SX126x LoRa chips and modules to communicate
Expand Down
16 changes: 15 additions & 1 deletion src/mac/Commissioning.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,21 @@ extern "C"
* When set to 1 the application does randomly change channels on each transmission
* When set to 0 the application uses always the base channel
*/
#define DO_CHANNEL_SWITCH 0
#define DO_CHANNEL_SWITCH 1

/**@brief Channel to be used if we are talking to a single channel gateway
* Check the file CHANNELS.MD to find out which channel corresponds to which frequency
* in a specific region
* Defaults to channel 0
*/
#define GATEWAY_SINGLE_CHANNEL 0

/**@brief Datarate to be used if we are talking to a single channel gateway
* Check the file Region.h to find out which datarate corresponds to which SF
* and bandwidth in a specific region
* Defaults to channel DR_3
*/
#define GATEWAY_SINGLE_DATARATE DR_3

/**@brief Define activation procedure here
* More information https://www.thethingsnetwork.org/forum/t/what-is-the-difference-between-otaa-and-abp-devices/2723
Expand Down
8 changes: 5 additions & 3 deletions src/mac/LoRaMac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1922,8 +1922,6 @@ extern "C"
nextChan.Joined = IsLoRaMacNetworkJoined;
nextChan.LastAggrTx = AggregatedLastTxDoneTime;

// If we talk to a single channel gateway we should not switch channels
#if DO_CHANNEL_SWITCH == 1
// Select channel
while (RegionNextChannel(LoRaMacRegion, &nextChan, &Channel, &dutyCycleTimeOff, &AggregatedTimeOff) == false)
{
Expand All @@ -1932,7 +1930,7 @@ extern "C"
// Update datarate in the function parameters
nextChan.Datarate = LoRaMacParams.ChannelsDatarate;
}
#endif

// Compute Rx1 windows parameters
RegionComputeRxWindowParameters(LoRaMacRegion,
RegionApplyDrOffset(LoRaMacRegion, LoRaMacParams.DownlinkDwellTime, LoRaMacParams.ChannelsDatarate, LoRaMacParams.Rx1DrOffset),
Expand Down Expand Up @@ -2226,6 +2224,10 @@ extern "C"
txConfig.AntennaGain = LoRaMacParams.AntennaGain;
txConfig.PktLen = LoRaMacBufferPktLen;

#if DO_CHANNEL_SWITCH == 0
txConfig.Channel = GATEWAY_SINGLE_CHANNEL;
txConfig.Datarate = GATEWAY_SINGLE_DATARATE;
#endif
RegionTxConfig(LoRaMacRegion, &txConfig, &txPower, &TxTimeOnAir);

MlmeConfirm.Status = LORAMAC_EVENT_INFO_STATUS_ERROR;
Expand Down

0 comments on commit 94c8e9e

Please sign in to comment.