Skip to content

Commit ffbc988

Browse files
committed
Add Asia-high and Korea frequency plans - Untested.
1 parent 11370c2 commit ffbc988

File tree

5 files changed

+80
-8
lines changed

5 files changed

+80
-8
lines changed

docs/TheThingsNetwork.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ TheThingsNetwork ttn(Stream& modemStream, Stream& debugStream, fp_ttn_t fp, uint
1414
1515
- `Stream& modemStream`: Stream for the LoRa modem (for The Things Node/Uno use `Serial1` and data rate `57600`).
1616
- `Stream& debugStream`: Stream to write debug logs to (for The Things Node/Uno use `Serial` and data rate `9600`).
17-
- `fp_ttn_fp fp`: The frequency plan: `TTN_FP_EU868` or `TTN_FP_US915` depending on the region you deploy in.
18-
- `uint8_t sf = 7`: Optional custom spreading factor. Can be `7` to `12` for `TTN_FP_EU868` and `7` to `10` for `TTN_FP_US915`. Defaults to `7`.
17+
- `fp_ttn_fp fp`: The frequency plan: `TTN_FP_EU868`, `TTN_FP_US915`, `TTN_FP_AS920_923`, `TTN_FP_AS923_925` or `TTN_FP_KR920_923` depending on the region you deploy in. See [the wiki](https://www.thethingsnetwork.org/wiki/LoRaWAN/Frequencies/Frequency-Plans).
18+
- `uint8_t sf = 7`: Optional custom spreading factor. Can be `7` to `10` for `TTN_FP_US915` and `7` to `12` for other frequency plans. Defaults to `7`.
1919
- `uint8_t fsb = 2`: Optional custom frequency subband. Can be `1` to `8`. Defaults to `2` (for US915).
2020
2121
## Method: `reset`

keywords.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ TTN_ERROR_UNEXPECTED_RESPONSE LITERAL1
7474
TTN_SUCCESSFUL_TRANSMISSION LITERAL1
7575
TTN_SUCCESSFUL_RECEIVE LITERAL1
7676
TTN_FP_EU868 LITERAL1
77-
TTN_FP_EU915 LITERAL1
77+
TTN_FP_US915 LITERAL1
78+
TTN_FP_AS920_923 LITERAL1
79+
TTN_FP_AS923_925 LITERAL1
80+
TTN_FP_KR920_923 LITERAL1
7881

7982
TTN_PIN_LED LITERAL1
8083

@@ -86,4 +89,4 @@ TTN_YELLOW LITERAL1
8689
TTN_CYAN LITERAL1
8790
TTN_MAGENTA LITERAL1
8891
TTN_WHITE LITERAL1
89-
TTN_BLACK LITERAL1
92+
TTN_BLACK LITERAL1

src/TheThingsNetwork.cpp

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,8 @@ bool TheThingsNetwork::provision(const char *appEui, const char *appKey)
488488
switch (fp)
489489
{
490490
case TTN_FP_AS920_923:
491+
case TTN_FP_AS923_925:
492+
case TTN_FP_KR920_923:
491493
// TODO: temporarily removed 'mac save' because RN2903AS crashes on this command!
492494
break;
493495
default:
@@ -678,10 +680,62 @@ void TheThingsNetwork::configureAS920_923()
678680
//sendChSet(MAC_CHANNEL_FREQ, 8, "922100000");
679681
//sendChSet(MAC_CHANNEL_DRRANGE, 8, "6 6");
680682
//sendChSet(MAC_CHANNEL_STATUS, 8, "on");
681-
// TODO: Add FSK channel
683+
// TODO: Add FSK channel on 921800000
682684
sendMacSet(MAC_PWRIDX, TTN_PWRIDX_AS920_923);
683685
}
684686

687+
void TheThingsNetwork::configureAS923_925()
688+
{
689+
sendMacSet(MAC_ADR, "off"); // TODO: remove when ADR is implemented for this plan
690+
sendMacSet(MAC_RX2, "2 923200000");
691+
692+
char buf[10];
693+
uint32_t freq = 923200000;
694+
uint8_t ch;
695+
for (ch = 0; ch < 8; ch++)
696+
{
697+
sendChSet(MAC_CHANNEL_DCYCLE, ch, "799");
698+
if (ch > 1)
699+
{
700+
sprintf(buf, "%lu", freq);
701+
sendChSet(MAC_CHANNEL_FREQ, ch, buf);
702+
sendChSet(MAC_CHANNEL_DRRANGE, ch, "0 5");
703+
sendChSet(MAC_CHANNEL_STATUS, ch, "on");
704+
freq = freq + 200000;
705+
}
706+
}
707+
// TODO: SF7BW250/DR6 channel, not properly supported by RN2903AS yet
708+
//sendChSet(MAC_CHANNEL_DCYCLE, 8, "799");
709+
//sendChSet(MAC_CHANNEL_FREQ, 8, "924500000");
710+
//sendChSet(MAC_CHANNEL_DRRANGE, 8, "6 6");
711+
//sendChSet(MAC_CHANNEL_STATUS, 8, "on");
712+
// TODO: Add FSK channel on 924800000
713+
sendMacSet(MAC_PWRIDX, TTN_PWRIDX_AS923_925);
714+
}
715+
716+
void TheThingsNetwork::configureKR920_923()
717+
{
718+
sendMacSet(MAC_ADR, "off"); // TODO: remove when ADR is implemented for this plan
719+
sendMacSet(MAC_RX2, "0 921900000"); // KR still uses SF12 for now. Might change to SF9 later.
720+
721+
char buf[10];
722+
uint32_t freq = 922100000;
723+
uint8_t ch;
724+
for (ch = 0; ch < 8; ch++)
725+
{
726+
sendChSet(MAC_CHANNEL_DCYCLE, ch, "799");
727+
if (ch > 1)
728+
{
729+
sprintf(buf, "%lu", freq);
730+
sendChSet(MAC_CHANNEL_FREQ, ch, buf);
731+
sendChSet(MAC_CHANNEL_DRRANGE, ch, "0 5");
732+
sendChSet(MAC_CHANNEL_STATUS, ch, "on");
733+
freq = freq + 200000;
734+
}
735+
}
736+
sendMacSet(MAC_PWRIDX, TTN_PWRIDX_KR920_923);
737+
}
738+
685739
void TheThingsNetwork::configureChannels(uint8_t fsb)
686740
{
687741
switch (fp)
@@ -695,6 +749,12 @@ void TheThingsNetwork::configureChannels(uint8_t fsb)
695749
case TTN_FP_AS920_923:
696750
configureAS920_923();
697751
break;
752+
case TTN_FP_AS923_925:
753+
configureAS923_925();
754+
break;
755+
case TTN_FP_KR920_923:
756+
configureKR920_923();
757+
break;
698758
default:
699759
debugPrintMessage(ERR_MESSAGE, ERR_INVALID_FP);
700760
break;
@@ -709,6 +769,8 @@ bool TheThingsNetwork::setSF(uint8_t sf)
709769
{
710770
case TTN_FP_EU868:
711771
case TTN_FP_AS920_923:
772+
case TTN_FP_AS923_925:
773+
case TTN_FP_KR920_923:
712774
dr = 12 - sf;
713775
break;
714776
case TTN_FP_US915:

src/TheThingsNetwork.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#define TTN_PWRIDX_EU868 "1"
1616
#define TTN_PWRIDX_US915 "5"
1717
#define TTN_PWRIDX_AS920_923 "1" // TODO: should be 0, but the current RN2903AS firmware doesn't accept that value (probably still using EU868: 1=14dBm)
18+
#define TTN_PWRIDX_AS923_925 "1" // TODO: should be 0
19+
#define TTN_PWRIDX_KR920_923 "1" // TODO: should be 0
1820

1921
#define TTN_BUFFER_SIZE 300
2022

@@ -32,7 +34,9 @@ enum ttn_fp_t
3234
{
3335
TTN_FP_EU868,
3436
TTN_FP_US915,
35-
TTN_FP_AS920_923
37+
TTN_FP_AS920_923,
38+
TTN_FP_AS923_925,
39+
TTN_FP_KR920_923
3640
};
3741

3842
class TheThingsNetwork
@@ -60,6 +64,8 @@ class TheThingsNetwork
6064
void configureEU868();
6165
void configureUS915(uint8_t fsb);
6266
void configureAS920_923();
67+
void configureAS923_925();
68+
void configureKR920_923();
6369
void configureChannels(uint8_t fsb);
6470
bool setSF(uint8_t sf);
6571
bool waitForOk();

test/TheThingsNetwork/TheThingsNetwork.ino

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ const char *appSKey = "00000000000000000000000000000000";
1212

1313
TheThingsNetwork ttn(loraSerial, debugSerial, TTN_FP_EU868);
1414

15-
TheThingsNetwork ttn2(loraSerial, debugSerial, TTN_FP_EU868, 10);
15+
TheThingsNetwork ttn2(loraSerial, debugSerial, TTN_FP_US915, 10);
16+
17+
TheThingsNetwork ttn3(loraSerial, debugSerial, TTN_FP_AS923_925, 10, 4);
1618

17-
TheThingsNetwork ttn3(loraSerial, debugSerial, TTN_FP_EU868, 10, 4);
1819

1920
void setup()
2021
{

0 commit comments

Comments
 (0)