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

pkg/semtech-loramac: add support for sx126x/llcc68 radios #16238

Merged
merged 3 commits into from
Mar 31, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 16 additions & 0 deletions examples/lorawan/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,17 @@
#include "net/loramac.h"
#include "semtech_loramac.h"

#if IS_USED(MODULE_SX127X)
#include "sx127x.h"
#include "sx127x_netdev.h"
#include "sx127x_params.h"
#endif

#if IS_USED(MODULE_SX126X)
#include "sx126x.h"
#include "sx126x_netdev.h"
#include "sx126x_params.h"
#endif

/* Messages are sent every 20s to respect the duty cycle on each channel */
#define PERIOD (20U)
Expand Down Expand Up @@ -114,9 +122,17 @@ int main(void)
fmt_hex_bytes(appkey, CONFIG_LORAMAC_APP_KEY_DEFAULT);

/* Initialize the radio driver */
#if IS_USED(MODULE_SX127X)
sx127x_setup(&sx127x, &sx127x_params[0], 0);
loramac.netdev = (netdev_t *)&sx127x;
loramac.netdev->driver = &sx127x_driver;
#endif

#if IS_USED(MODULE_SX126X)
sx126x_setup(&sx126x, &sx126x_params[0], 0);
loramac.netdev = (netdev_t *)&sx126x;
loramac.netdev->driver = &sx126x_driver;
#endif

/* Initialize the loramac stack */
semtech_loramac_init(&loramac);
Expand Down
27 changes: 27 additions & 0 deletions sys/auto_init/loramac/auto_init_loramac.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,46 @@
*/

#include "log.h"
#include "kernel_defines.h"

#if IS_USED(MODULE_SX127X)
#include "sx127x.h"
#include "sx127x_netdev.h"
#include "sx127x_params.h"
#endif

#if IS_USED(MODULE_SX126X)
#include "sx126x.h"
#include "sx126x_netdev.h"
#include "sx126x_params.h"
#endif

#include "semtech_loramac.h"

semtech_loramac_t loramac;

#if IS_USED(MODULE_SX127X)
static sx127x_t sx127x;
#endif

#if IS_USED(MODULE_SX126X)
static sx126x_t sx126x;
#endif

void auto_init_loramac(void)
{
#if IS_USED(MODULE_SX127X)
sx127x_setup(&sx127x, &sx127x_params[0], 0);
loramac.netdev = (netdev_t *)&sx127x;
loramac.netdev->driver = &sx127x_driver;
#endif

#if IS_USED(MODULE_SX126X)
sx126x_setup(&sx126x, &sx126x_params[0], 0);
loramac.netdev = (netdev_t *)&sx126x;
loramac.netdev->driver = &sx126x_driver;
#endif

semtech_loramac_init(&loramac);
}
/** @} */
2 changes: 1 addition & 1 deletion sys/net/gnrc/netif/init_devs/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void gnrc_netif_init_devs(void)
auto_init_nrf802154();
}

if (IS_USED(MODULE_SX126X)) {
if (IS_USED(MODULE_SX126X) && !IS_USED(MODULE_SEMTECH_LORAMAC)) {
extern void auto_init_sx126x(void);
auto_init_sx126x();
}
Expand Down