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

Conversation

akshaim
Copy link
Contributor

@akshaim akshaim commented Mar 31, 2018

No description provided.

@CLAassistant
Copy link

CLAassistant commented Mar 31, 2018

CLA assistant check
All committers have signed the CLA.

{
sendMacSet(MAC_ADR, "off"); // TODO: remove when ADR is implemented for this plan
sendMacSet(MAC_RX2, "2 866550000"); // SF10
//disable two default LoRaWAN channels
Copy link
Collaborator

Choose a reason for hiding this comment

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

two => three

sendChSet(MAC_CHANNEL_DRRANGE, ch, "0 6");
sendChSet(MAC_CHANNEL_STATUS, ch, "on");
switch(ch)
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

The indentation is a bit strange here.

Copy link
Collaborator

@jpmeijers jpmeijers left a comment

Choose a reason for hiding this comment

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

Might need a test by a 3rd party, but just looking at the code it looks good to me.

@akshaim
Copy link
Contributor Author

akshaim commented Apr 3, 2018

865_867 addition was tested to work on two channels but 865985000 is showing a few issues. I shall debug and update soon.

@johanstokking
Copy link
Member

@akshaim thanks! Should we wait for your debugging and test results?

@akshaim
Copy link
Contributor Author

akshaim commented Apr 4, 2018

Sure. I am waiting for an SDR to arrive to see exactly what is going on.

@akshaim
Copy link
Contributor Author

akshaim commented Apr 13, 2018

Works now. Uplink and Downlink tested.

Copy link
Collaborator

@jpmeijers jpmeijers left a comment

Choose a reason for hiding this comment

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

lgtm

@jpmeijers
Copy link
Collaborator

It is fine as it is, but I would have written this function differently as there is no need for the loop and switch - they just complicate the algorithm without saving any memory.

void TheThingsNetwork::configureIN865_867()
{
  sendMacSet(MAC_ADR, "off"); // TODO: remove when ADR is implemented for this plan
  sendMacSet(MAC_RX2, "2 866550000"); // SF10  
  
  // Disable the three default LoRaWAN channels
  sendChSet(MAC_CHANNEL_STATUS, 0, "off");
  sendChSet(MAC_CHANNEL_STATUS, 1, "off");
  sendChSet(MAC_CHANNEL_STATUS, 2, "off");

  // Channel 3
  sendChSet(MAC_CHANNEL_DCYCLE, 3, "799");
  sendChSet(MAC_CHANNEL_FREQ, 3, "865062500");
  sendChSet(MAC_CHANNEL_DRRANGE, 3, "0 5");
  sendChSet(MAC_CHANNEL_STATUS, 3, "on");

  // Channel 4
  sendChSet(MAC_CHANNEL_DCYCLE, 4, "799");
  sendChSet(MAC_CHANNEL_FREQ, 4, "865402500");
  sendChSet(MAC_CHANNEL_DRRANGE, 4, "0 5");
  sendChSet(MAC_CHANNEL_STATUS, 4, "on");

  // Channel 5
  sendChSet(MAC_CHANNEL_DCYCLE, 5, "799");
  sendChSet(MAC_CHANNEL_FREQ, 5, "865985000");
  sendChSet(MAC_CHANNEL_DRRANGE, 5, "0 5");
  sendChSet(MAC_CHANNEL_STATUS, 5, "on");
  
  sendMacSet(MAC_PWRIDX, TTN_PWRIDX_IN865_867);
}

Copy link
Collaborator

@jpmeijers jpmeijers left a comment

Choose a reason for hiding this comment

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

Duty cycle value is incorrect according to my calculations.

uint8_t ch;
for (ch = 3; ch < 7; 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.

Copy link
Contributor Author

@akshaim akshaim left a comment

Choose a reason for hiding this comment

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

Thanks. The command reference manual states the same.

@akshaim
Copy link
Contributor Author

akshaim commented Apr 24, 2018

Thanks. I have updated the code as per your recommendations and it works! Can you help me implement ADR on the channel?

Copy link
Collaborator

@jpmeijers jpmeijers left a comment

Choose a reason for hiding this comment

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

LGTM

ADR needs to be done on the core TTN infrastructure, so it is out of our hands. This library is good as it is now. Let's merge.

@johanstokking
Copy link
Member

What is the reason to disable the three default LoRaWAN channels?

Regarding the loop; this is consistent with other frequency plans (and it may reduce flash memory).

@johanstokking
Copy link
Member

Any news @akshaim @jpmeijers ?

@jpmeijers
Copy link
Collaborator

  1. On the RN module with european firmware one can not change the frequency of the three default channels. For India we therefore have to disable these three channels to not use them, and rather use another three to configure the three default Indian channels.

  2. Even though the original loop method is consistent with the other frequency plans, it complicates the code and in this case do not save any space. In this case there is no constant step between 8 channel, so using a loop to add the constant step doesn't make sense. Configuring the three channels one by one by hand is much clearer and does not really use much more program space than the loop. In fact, I believe it will use less instructions as we are not using the loop. For-loops are notorious to be compiled to a lot of instructions and are quite often unrolled by the compiler.

@jpmeijers
Copy link
Collaborator

Also note that we plan to rewrite the frequency plan logic to save program space. So let's not worry too much about it now as we will rethink and re-implement it later.
See branch:
https://github.com/TheThingsNetwork/arduino-device-lib/tree/feature/use-less-program-space

@akshaim
Copy link
Contributor Author

akshaim commented May 14, 2018

@johanstokking Please see the following snap from the RN2483 command reference manual. Channel 0-2 can be used only on default channels.
https://imgur.com/a/sSO9SMp

@johanstokking johanstokking merged commit 3a01327 into TheThingsNetwork:master May 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants