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

Support for IN865_867 #233

Merged
merged 7 commits into from
May 16, 2018
Merged
Show file tree
Hide file tree
Changes from 2 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
34 changes: 34 additions & 0 deletions src/TheThingsNetwork.cpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,37 @@ void TheThingsNetwork::configureKR920_923()
}
sendMacSet(MAC_PWRIDX, TTN_PWRIDX_KR920_923);
}
void TheThingsNetwork::configureIN865_867()
{
sendMacSet(MAC_ADR, "off"); // TODO: remove when ADR is implemented for this plan
sendMacSet(MAC_RX2, "2 866550000"); // SF10
//disable three default LoRaWAN channels
sendChSet(MAC_CHANNEL_STATUS, 0, "off");
sendChSet(MAC_CHANNEL_STATUS, 1, "off");
sendChSet(MAC_CHANNEL_STATUS, 2, "off");

char buf[10];
uint32_t freq = 865062500;
uint8_t ch;
for (ch = 3; ch < 6; ch++)
{
sendChSet(MAC_CHANNEL_DCYCLE, ch, "799");
Copy link
Collaborator

Choose a reason for hiding this comment

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

For 1% duty cycle on 3 channels, this value should be 99, not 799.

The <dutyCycle> value that needs to be configured can be
obtained from the actual duty cycle X (in percentage)
using the following formula: <dutyCycle> = (100/X) – 1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I shall try the same and update you soon.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually now that I slept on this I doubt it again:

1% duty cycle over 3 channels is 0.333% per channel.
(100/0.333) - 1 = 299

So the value should be 299.

sprintf(buf, "%lu", freq);
sendChSet(MAC_CHANNEL_FREQ, ch, buf);
sendChSet(MAC_CHANNEL_DRRANGE, ch, "0 6");
sendChSet(MAC_CHANNEL_STATUS, ch, "on");
switch(ch)
{
case 4:
freq = 865402500;
break;
case 5:
freq = 865985000;
break;
}
}
sendMacSet(MAC_PWRIDX, TTN_PWRIDX_IN865_867);
}
void TheThingsNetwork::configureChannels(uint8_t fsb)
{
switch (fp)
Expand All @@ -768,6 +798,9 @@ void TheThingsNetwork::configureChannels(uint8_t fsb)
case TTN_FP_KR920_923:
configureKR920_923();
break;
case TTN_FP_IN865_867:
configureIN865_867();
break;
default:
debugPrintMessage(ERR_MESSAGE, ERR_INVALID_FP);
break;
Expand All @@ -781,6 +814,7 @@ bool TheThingsNetwork::setSF(uint8_t sf)
switch (fp)
{
case TTN_FP_EU868:
case TTN_FP_IN865_867:
case TTN_FP_AS920_923:
case TTN_FP_AS923_925:
case TTN_FP_KR920_923:
Expand Down
5 changes: 4 additions & 1 deletion src/TheThingsNetwork.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#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)
#define TTN_PWRIDX_AS923_925 "1" // TODO: should be 0
#define TTN_PWRIDX_KR920_923 "1" // TODO: should be 0
#define TTN_PWRIDX_IN865_867 "1" // TODO: should be 0

#define TTN_BUFFER_SIZE 300

Expand All @@ -36,7 +37,8 @@ enum ttn_fp_t
TTN_FP_US915,
TTN_FP_AS920_923,
TTN_FP_AS923_925,
TTN_FP_KR920_923
TTN_FP_KR920_923,
TTN_FP_IN865_867
};

class TheThingsNetwork
Expand Down Expand Up @@ -66,6 +68,7 @@ class TheThingsNetwork
void configureAS920_923();
void configureAS923_925();
void configureKR920_923();
void configureIN865_867();
void configureChannels(uint8_t fsb);
bool setSF(uint8_t sf);
bool waitForOk();
Expand Down