From 77162b8c6f32d39fdae78f6e76fe47bb495bbed5 Mon Sep 17 00:00:00 2001 From: Jose Alamos Date: Thu, 7 Mar 2019 16:35:18 +0100 Subject: [PATCH] drivers/sx127x: add NETOPT_SYNCWORD option handling --- drivers/sx127x/sx127x_netdev.c | 10 ++++++++++ sys/include/net/netopt.h | 5 +++++ sys/net/crosslayer/netopt/netopt.c | 1 + 3 files changed, 16 insertions(+) diff --git a/drivers/sx127x/sx127x_netdev.c b/drivers/sx127x/sx127x_netdev.c index a08df8e877..9d86ad1b68 100644 --- a/drivers/sx127x/sx127x_netdev.c +++ b/drivers/sx127x/sx127x_netdev.c @@ -351,6 +351,11 @@ static int _get(netdev_t *netdev, netopt_t opt, void *val, size_t max_len) *((int16_t*) val) = (int16_t)sx127x_get_tx_power(dev); return sizeof(int16_t); + case NETOPT_SYNCWORD: + assert(max_len >= sizeof(uint8_t)); + *((uint8_t*) val) = (uint8_t) sx127x_get_syncword(dev); + return sizeof(uint8_t); + case NETOPT_IQ_INVERT: assert(max_len >= sizeof(uint8_t)); *((netopt_enable_t*) val) = sx127x_get_iq_invert(dev) ? NETOPT_ENABLE : NETOPT_DISABLE; @@ -480,6 +485,11 @@ static int _set(netdev_t *netdev, netopt_t opt, const void *val, size_t len) sx127x_set_preamble_length(dev, *((const uint16_t*) val)); return sizeof(uint16_t); + case NETOPT_SYNCWORD: + assert(len <= sizeof(uint8_t)); + sx127x_set_syncword(dev, *((uint8_t*) val)); + return sizeof(uint8_t); + case NETOPT_IQ_INVERT: assert(len <= sizeof(netopt_enable_t)); sx127x_set_iq_invert(dev, *((const netopt_enable_t*) val) ? true : false); diff --git a/sys/include/net/netopt.h b/sys/include/net/netopt.h index d48841118e..1bac19606b 100644 --- a/sys/include/net/netopt.h +++ b/sys/include/net/netopt.h @@ -645,6 +645,11 @@ typedef enum { */ NETOPT_LORAWAN_MIN_RX_SYMBOL, + /** + * @brief (uint8_t*) phy layer syncword + */ + NETOPT_SYNCWORD, + /* add more options if needed */ /** diff --git a/sys/net/crosslayer/netopt/netopt.c b/sys/net/crosslayer/netopt/netopt.c index 76922c1e3a..930c8ac344 100644 --- a/sys/net/crosslayer/netopt/netopt.c +++ b/sys/net/crosslayer/netopt/netopt.c @@ -106,6 +106,7 @@ static const char *_netopt_strmap[] = { [NETOPT_LORAWAN_RX2_FREQ] = "NETOPT_LORAWAN_RX2_FREQ", [NETOPT_LORAWAN_MAX_RX_ERROR] = "NETOPT_LORAWAN_MAX_RX_ERROR", [NETOPT_LORAWAN_MIN_RX_SYMBOL] = "NETOPT_LORAWAN_MIN_RX_SYMBOL", + [NETOPT_SYNCWORD] = "NETOPT_SYNCWORD", [NETOPT_NUMOF] = "NETOPT_NUMOF", };