Skip to content

Conversation

jia200x
Copy link
Member

@jia200x jia200x commented Feb 23, 2017

Hi.

This is the WIP of GNRC LoRaWAN. Provides a full implementation of the LoRaWAN protocol (class A and C).

It's based on the original Semtech LoRaMAC implementation. Includes #6002 driver made by @Cr0s with netdev2 adoption. (I will split the PR in multiple parts later, but I think this way is easier for testing).

What has been tested so far:

  • Over The Air Activation
  • Activation By Personalization
  • Class A and class C
  • 915 MHz band

What has been partially tested:

  • ADR

To be done:

  • Remove GNRC dependencies at netdev level
  • Better UI for sending messages
  • Code refactor
  • Timers with RTC
  • Test all bands

Cheers!

bandwidth = 1;
symbTimeout = 14;
}
_rx_window_setup(loradev, channels[Channel].Frequency, datarate, bandwidth, symbTimeout, false );
Copy link

@Cr0s Cr0s Feb 25, 2017

Choose a reason for hiding this comment

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

Compile error on that line in case USE_BAND_868 is defined.
error: 'Channel' undeclared (first use in this function)

It's better to test your implementation for compilation errors for other than 915MHz bands as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

Channel should be loradev->Channel.
Check if that fixes the issue.

Anyway, I will fix this on monday.
Cheers!

return -1;
}

kernel_pid_t pid = atoi(argv[1]);
Copy link

Choose a reason for hiding this comment

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

Why we should pass netdev's thread's PID into command explicitly? The description of command doesn't implies that.

I think the PID returned from gnrc_lorawan_init function called during auto-init procedure should be saved somewhere to be accessible from application code.

Copy link
Member Author

Choose a reason for hiding this comment

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

I forgot to fix the description. This change was added 3 days ago.

Cheers!

@jia200x
Copy link
Member Author

jia200x commented Feb 26, 2017 via email

@@ -0,0 +1,45 @@
APPLICATION = loramac

FEATURES_REQUIRED = periph_spi periph_gpio periph_adc
Copy link
Member

Choose a reason for hiding this comment

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

Why periph_adc is needed here ?

Copy link
Member Author

Choose a reason for hiding this comment

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

In fact adc is not needed. I forgot to remove that line ;)

@emmanuelsearch
Copy link
Member

@dylad @Cr0s Do you have the hardware setup to test this on your side? Does it work? Would be useful to know.

Copy link
Contributor

@kaspar030 kaspar030 left a comment

Choose a reason for hiding this comment

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

It looks like lorawan as is ties in gnrc at the netdev level. That's a no-go. Either remove the gnrc dependency, split it up or move it into sys/net/gnrc.

NETDEV2_EVENT_TX_TIMEOUT,
NETDEV2_EVENT_RX_TIMEOUT,
NETDEV2_EVENT_CRC_ERROR,
NETDEV2_EVENT_FHSS_CHANGE_CHANNEL,
Copy link
Contributor

Choose a reason for hiding this comment

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

At least this and the next need doc...

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup. To be done

@@ -90,6 +96,7 @@ typedef enum {
struct netdev2_radio_rx_info {
uint8_t rssi; /**< RSSI of a received packet */
uint8_t lqi; /**< LQI of a received packet */
uint8_t snr;
Copy link
Contributor

Choose a reason for hiding this comment

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

  • /**< SNR of a received packet. */. For friendly OS, consistency is king.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup. To be done

* @author José Ignacio Alamos <jose.alamos@inria.cl>
*/

#ifndef NETDEV2_ETH_H
Copy link
Contributor

Choose a reason for hiding this comment

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

copy&pasta

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops


#include "net/netdev2.h"
#include "net/netopt.h"
#include "net/gnrc/lorawan/timer.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

If this includes gnrc headers at netdev2 level, you've messed up the layering.

extern "C" {
#endif

#define KEY_SIZE 16
Copy link
Contributor

Choose a reason for hiding this comment

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

indent is all off (here and below). Please use type specifiers ((16U) where they might make a difference.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok

int8_t Min : 4;
int8_t Max : 4;
}Fields;
}DrRange_t;
Copy link
Contributor

Choose a reason for hiding this comment

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

  • space after }

Are these definitions imported from somewhere?
If not, please don't use CamelCase, don't use type specifiers (sFields), and please use lower case variable/field names.

Copy link
Member Author

Choose a reason for hiding this comment

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

ditto, imported from original code. I will remove them later


typedef struct sLoRaMacParams
{
int8_t ChannelsTxPower;
Copy link
Contributor

Choose a reason for hiding this comment

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

if possible, reorder fields so they don't waste space through alignment constraints.

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, I will do it

bool b_rx;
bool link_check;
bool join_req;
gnrc_pktsnip_t *pkt;
Copy link
Contributor

Choose a reason for hiding this comment

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

No gnrc specific stuff allowed in netdev2...

Copy link
Member Author

Choose a reason for hiding this comment

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

The GNRC LoRaWAN code lives in the sys/net/gnrc folder, but all variables are handled in this netdev2_lorawan_t.
Indeed it's GNRC dependent.

In this case, where should these variables live? (E.g a gnrc_netdev2_lorawan_t object?)

{
assert(value_len == sizeof(uint32_t));
uint32_t dev_addr = *((uint32_t *)value);
assert(dev_addr <= UINT32_MAX);
Copy link
Contributor

Choose a reason for hiding this comment

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

assert always true

Copy link
Member Author

Choose a reason for hiding this comment

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

yep, you're right. This shouldn't be here.

{
assert(value_len == sizeof(uint32_t));
uint32_t net_id = *((uint32_t *)value);
assert(net_id <= UINT32_MAX);
Copy link
Contributor

Choose a reason for hiding this comment

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

assert always true

Copy link
Member Author

Choose a reason for hiding this comment

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

yep, you're right. This shouldn't be here.

@dylad
Copy link
Member

dylad commented Mar 1, 2017

@emmanuelsearch I will test this PR in a few days on my hardware and I'll let you know the result.

@jia200x
Copy link
Member Author

jia200x commented Mar 1, 2017

@kaspar030 There are some common variables that might still live in the netdev2_lorawan_t object (e.g dev_eui, dev_addr, etc). Exactly the same as the netdev2_ieee802154_t object.

Do you think is ok to add a gnrc_netdev2_lorawan_t with all internal variables?

Cheers

@jia200x
Copy link
Member Author

jia200x commented Mar 1, 2017

@Cr0s now the 868mhz band is compiling.
Cheers

@dylad dylad mentioned this pull request Mar 2, 2017
Copy link
Member

@dylad dylad left a comment

Choose a reason for hiding this comment

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

tests/driver_sx1276 won't compile so I cannot test it.
tests/loramac sx1276 seems to be initialized but I still cannot send any data (I used a spectrum analyzer but I cannot see anything around 868MHz)
I will investigate further.

# include the selected driver
USEMODULE += $(DRIVER)

CFLAGS += -DDEVELHELP
Copy link
Member

Choose a reason for hiding this comment

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

Missing CFLAGS USE_BAND, compiler complains.

#include "shell_commands.h"
#include "thread.h"
#include "xtimer.h"
#include "lpm.h"
Copy link
Member

Choose a reason for hiding this comment

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

Did you mean periph/pm.h ? Is it useful ?

int rx_test(int argc, char **argv)
{
nd->driver->set(nd, NETOPT_LORA_SINGLE_RECEIVE, false, sizeof(uint8_t));
sx1276_set_rx(&sx1276, 0);
Copy link
Member

Choose a reason for hiding this comment

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

This function only has one argument, please remove 0


static const sx1276_params_t sx1276_params[] =
{
#ifdef SX1276_PARAMS_BOARD
Copy link
Member

Choose a reason for hiding this comment

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

SX1276_PARAMS_DEFAULT seems to "prevail" on SX1276_PARAMS_BOARD
I made change on tests/loramac/common.h to adapt to my hardware for testing but it doesn't work. I had to change SX1276_PARAMS_DEFAULT to see change on my hardware.

@jia200x
Copy link
Member Author

jia200x commented Mar 3, 2017 via email

@jia200x
Copy link
Member Author

jia200x commented Mar 3, 2017 via email

@jia200x
Copy link
Member Author

jia200x commented Mar 3, 2017

@dylad please try the just committed sx1276 driver. I don't have any sx1276 board atm.

@dylad
Copy link
Member

dylad commented Mar 7, 2017

I've tested #6002 It seems to work so far(only tested with a spectrum analyzer atm)
But I cannot reproduce the same behaviour with tests/driver_sx1276 and tests/loramac
I'm still trying to figured out what is going on.

Hardware used :

  • Nucleo-L1 board
  • SX1276MB1MAS from mbed

Also try the MB1MAS shield with a SAML21-xpro but I'm facing issues which I think are not related to this PR.
Can anyone give it a try and share results ?

@dylad
Copy link
Member

dylad commented Mar 7, 2017

Okay tests/sx1276_driver is working
I didn't pay attention to the channel and its default value was 915000000 in drivers/include/sx1276.h Maybe you should move it to either specific .h file in the app or in makefile ?
Once I set the channel to 868900000 or 868000000, It emits.

I'm now working on loramac but there are some kind of "black magic" to me.
how can I check channel or lora specific stuff ? everything seems to be handle by netdev2 and I'm unfamiliar with it. For now, I'm unable to emit anything using tests/loramac

@aabadie aabadie modified the milestone: Release 2017.07 Jun 26, 2017
miri64 added a commit that referenced this pull request Jun 30, 2017
drivers/sx127x: rework of implementations from #6645 and #6002
@aabadie
Copy link
Contributor

aabadie commented Jun 30, 2017

Let's keep this one opened.

#6797 is now merged and there are 2 possibilities:

  • rebase this one
  • open a new PR

@aabadie aabadie removed this from the Release 2017.07 milestone Jun 30, 2017
@jia200x
Copy link
Member Author

jia200x commented Jul 3, 2017

@aabadie Hi.

We can rebase this one and continue the development. In case #6165 gets merged, it will be the same as opening a new PR :)

@jia200x
Copy link
Member Author

jia200x commented Jul 3, 2017

Also, we will focus now in make this PR work with the upstream sx127x driver

@jia200x jia200x mentioned this pull request Jul 7, 2017
@aabadie aabadie added the Area: LoRa Area: LoRa radio support label Oct 13, 2017
@kYc0o kYc0o mentioned this pull request Oct 29, 2017
23 tasks
@kYc0o kYc0o removed this from the Release 2017.10 milestone Oct 30, 2017
@miri64
Copy link
Member

miri64 commented Dec 18, 2017

@jia200x, with #8264 opened: can this be closed?

@miri64
Copy link
Member

miri64 commented Dec 18, 2017

(or @aabadie maybe)

@aabadie
Copy link
Contributor

aabadie commented Dec 18, 2017

I won't close this before we get @jia200x 's opinion. Maybe we can just close with the memo label ?

@jia200x
Copy link
Member Author

jia200x commented Dec 18, 2017 via email

@miri64
Copy link
Member

miri64 commented Dec 18, 2017

Alright then. Closing in favor of #8264

1 similar comment
@miri64
Copy link
Member

miri64 commented Dec 18, 2017

Alright then. Closing in favor of #8264

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: LoRa Area: LoRa radio support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants