Compare commits

...

13 Commits

Author SHA1 Message Date
Alexandre Abadie
5db69b471c
Merge pull request #17570 from maribu/backport/2022.01/nucleo_f767zi_fix_adc_pin_config
boards/nucleo-f767zi: Fix adc pin config in periph_conf.h [backport 2022.01]
2022-01-25 15:25:36 +01:00
Stefan Strell
336fd75c5c
boards/nucleo-f767zi: Fix adc pin config in periph_conf.h
(cherry picked from commit ccf31eb15d49ac82369850c8f1129b91727b5bdb)
2022-01-25 14:52:49 +01:00
Emmanuel Baccelli
ec3cc227ab
Merge pull request #17562 from fjmolinas/backport/2022.01/pr_ztimer64_flag
sys/ztimer64/util.c: fix ztimer64_set_timeout_flag [backport 2022.01]
2022-01-25 10:18:29 +01:00
Francisco Molina
f052a9b621 sys/ztimer64/util.c: fix ztimer64_set_timeout_flag
(cherry picked from commit de50d557d8e9f14e0ce714755e5468cb3c014bd1)
2022-01-25 08:19:08 +01:00
Alexandre Abadie
33c360c39b
Merge pull request #17549 from fjmolinas/backport/2022.01/pr_edhoc_test_netif_multi
tests/pkg_edhoc: handle multiple interfaces [backport 2022.01]
2022-01-21 17:21:25 +01:00
Francisco Molina
c13b529482 tests/pkg_edhoc: handle multiple interfaces
(cherry picked from commit ec7926f6c4b255248a4b08ccc17c00a85d991756)
2022-01-21 15:57:45 +01:00
Alexandre Abadie
79794fd132
Merge pull request #17532 from fjmolinas/backport/2022.01/pr_rtt_rtc_utils
drivers/rtt_rtc: select rtc_utils [backport 2022.01]
2022-01-19 06:57:03 +01:00
Francisco Molina
69198a4bd3 drivers/rtt_rtc: select rtc_utils
(cherry picked from commit 8b45ed87be85d81702861c80cb85a3e35d0d3404)
2022-01-18 17:08:18 +01:00
Francisco
6a8dedf26c
Merge pull request #17529 from fjmolinas/backport/2022.01/pr_test_pkg_relic_stacksize
tests/pkg_relic: increase stacksize [backport 2022.01]
2022-01-18 15:01:33 +01:00
Francisco Molina
b8994e9961 tests/pkg_relic: increase stacksize
(cherry picked from commit 1025341ff3559a2bedf83ce0e2dafe21f7a4c5f8)
2022-01-18 13:32:09 +01:00
Alexandre Abadie
5e993749d4
Merge pull request #17527 from jia200x/backport/2022.01/pr/lora/fix_rssi_val
[treewide] lora: use int16_t for RSSI value [backport 2022.01]
2022-01-18 12:01:40 +01:00
Jose Alamos
4b3d699b62
drivers/atwinc15x0: adapt NETOPT_RSSI to int16_t
(cherry picked from commit d6899f40a7d0ce6c18c160137aa0afcd6abef9de)
2022-01-18 11:05:15 +01:00
Jose Alamos
0bef73205c
[treewide] lora: use int16_t for RSSI value
The RSSI values reported by LoRa transceiver can be less than -127.
Therefore, `int8_t` is not enough. This commit defines the RSSI of
`netdev_lora_rx_info` as `int16_t` and adapt the drivers accordingly
(sx126x, sx127x).

(cherry picked from commit 9955a35c639ca9441ad42d9b2838205bc30ed587)
2022-01-18 11:05:15 +01:00
15 changed files with 68 additions and 49 deletions

View File

@ -198,12 +198,12 @@ static const eth_conf_t eth_config = {
* @{
*/
static const adc_conf_t adc_config[] = {
{GPIO_PIN(PORT_A, 3), 0, 0},
{GPIO_PIN(PORT_C, 0), 0, 1},
{GPIO_PIN(PORT_C, 3), 0, 4},
{GPIO_PIN(PORT_F, 3), 0, 8},
{GPIO_PIN(PORT_F, 5), 0, 11},
{GPIO_PIN(PORT_F, 10), 0, 10},
{GPIO_PIN(PORT_A, 3), 2, 3},
{GPIO_PIN(PORT_C, 0), 2, 10},
{GPIO_PIN(PORT_C, 3), 2, 13},
{GPIO_PIN(PORT_F, 3), 2, 9},
{GPIO_PIN(PORT_F, 5), 2, 15},
{GPIO_PIN(PORT_F, 10), 2, 8},
};
#define ADC_NUMOF ARRAY_SIZE(adc_config)

View File

@ -372,7 +372,7 @@ static int _atwinc15x0_get(netdev_t *netdev, netopt_t opt, void *val,
return sizeof(uint16_t);
case NETOPT_RSSI:
assert(max_len == sizeof(int8_t));
assert(max_len == sizeof(int16_t));
_rssi_info_ready = false;
/* trigger the request current RSSI (asynchronous function) */
if (m2m_wifi_req_curr_rssi() != M2M_SUCCESS) {
@ -384,8 +384,8 @@ static int _atwinc15x0_get(netdev_t *netdev, netopt_t opt, void *val,
ztimer_sleep(ZTIMER_MSEC, ATWINC15X0_WAIT_TIME_MS);
}
/* return the RSSI */
*((int8_t *)val) = dev->rssi;
return sizeof(int8_t);
*((int16_t *)val) = dev->rssi;
return sizeof(int16_t);
default:
return netdev_eth_get(netdev, opt, val, max_len);

View File

@ -32,7 +32,7 @@ extern "C" {
* @brief Received LoRa packet status information
*/
typedef struct {
uint8_t rssi; /**< RSSI of a received packet */
int16_t rssi; /**< RSSI of a received packet */
int8_t snr; /**< S/N ratio */
} netdev_lora_rx_info_t;

View File

@ -10,5 +10,6 @@ config MODULE_RTT_RTC
depends on HAS_PERIPH_RTT
depends on TEST_KCONFIG
select MODULE_PERIPH_RTT
select MODULE_RTC_UTILS
help
Basic RTC implementation based on a RTT.

View File

@ -2,3 +2,5 @@
ifeq (,$(UNIT_TESTS))
FEATURES_REQUIRED += periph_rtt
endif
USEMODULE += rtc_utils

View File

@ -291,9 +291,9 @@ static int _get(netdev_t *netdev, netopt_t opt, void *val, size_t max_len)
return sizeof(netopt_enable_t);
case NETOPT_RSSI:
assert(max_len >= sizeof(int8_t));
assert(max_len >= sizeof(int16_t));
sx126x_get_rssi_inst(dev, ((int16_t *)val));
return sizeof(int8_t);
return sizeof(int16_t);
default:
break;

View File

@ -345,9 +345,9 @@ static int _get(netdev_t *netdev, netopt_t opt, void *val, size_t max_len)
return sizeof(netopt_enable_t);
case NETOPT_RSSI:
assert(max_len >= sizeof(int8_t));
*((int8_t *)val) = sx127x_read_rssi(dev);
return sizeof(int8_t);
assert(max_len >= sizeof(int16_t));
*((int16_t *)val) = sx127x_read_rssi(dev);
return sizeof(int16_t);
default:
break;

View File

@ -52,7 +52,7 @@ ifneq (,$(filter periph_%, $(USEMODULE)))
endif
# include rtc_utils if periph_rtc is used
ifneq (,$(filter periph_rtc, $(USEMODULE)))
ifneq (,$(filter periph_rtc,$(USEMODULE)))
USEMODULE += rtc_utils
endif

View File

@ -205,8 +205,8 @@ void SX127XStartCad(void)
int16_t SX127XRssi(RadioModems_t modem)
{
(void)modem;
int8_t rssi;
loramac_netdev_ptr->driver->get(loramac_netdev_ptr, NETOPT_RSSI, &rssi, sizeof(int8_t));
int16_t rssi;
loramac_netdev_ptr->driver->get(loramac_netdev_ptr, NETOPT_RSSI, &rssi, sizeof(int16_t));
return rssi;
}

View File

@ -772,7 +772,7 @@ typedef enum {
NETOPT_LINK_CHECK,
/**
* @brief (int8_t) Received Signal Strength Indicator (RSSI)
* @brief (int16_t) Received Signal Strength Indicator (RSSI)
*
* The RSSI is an indicator for the received field strength in wireless
* channels. It is often represented as the ratio of received power to

View File

@ -607,7 +607,6 @@ static void _netif_list(netif_t *iface)
uint16_t u16;
int16_t i16;
uint8_t u8;
int8_t i8;
int res;
netopt_state_t state;
unsigned line_thresh = 1;
@ -639,9 +638,9 @@ static void _netif_list(netif_t *iface)
if (res >= 0) {
printf(" NID: 0x%" PRIx16 " ", u16);
}
res = netif_get_opt(iface, NETOPT_RSSI, 0, &i8, sizeof(i8));
res = netif_get_opt(iface, NETOPT_RSSI, 0, &i16, sizeof(i16));
if (res >= 0) {
printf(" RSSI: %d ", i8);
printf(" RSSI: %d ", i16);
}
#ifdef MODULE_GNRC_NETIF_CMD_LORA
res = netif_get_opt(iface, NETOPT_BANDWIDTH, 0, &u8, sizeof(u8));

View File

@ -131,7 +131,7 @@ void ztimer64_set_timeout_flag_at(ztimer64_clock_t *clock, ztimer64_t *t,
t->callback = _set_timeout_flag_callback;
t->arg = thread_get_active();
thread_flags_clear(THREAD_FLAG_TIMEOUT);
ztimer64_set(clock, t, target);
ztimer64_set_at(clock, t, target);
}
#endif

View File

@ -59,44 +59,50 @@ struct tc_sha256_state_struct _sha_i;
static uint8_t _method;
static uint8_t _suite;
static ssize_t _send(coap_pkt_t *pkt, size_t len, char *addr_str, uint16_t port)
static int _parse_ipv6_addr(char *addr_str, ipv6_addr_t *addr, uint16_t *netif)
{
ipv6_addr_t addr;
sock_udp_ep_t remote;
remote.family = AF_INET6;
remote.port = port;
/* parse for interface */
char *iface = ipv6_addr_split_iface(addr_str);
if (!iface) {
if (gnrc_netif_numof() == 1) {
/* assign the single interface found in gnrc_netif_numof() */
remote.netif = (uint16_t)gnrc_netif_iter(NULL)->pid;
*netif = (uint16_t)gnrc_netif_iter(NULL)->pid;
}
else {
remote.netif = SOCK_ADDR_ANY_NETIF;
*netif = SOCK_ADDR_ANY_NETIF;
}
}
else {
int pid = atoi(iface);
if (gnrc_netif_get_by_pid(pid) == NULL) {
puts("[initiator]: interface not valid");
return 0;
return -1;
}
remote.netif = pid;
*netif = pid;
}
/* parse destination address */
if (ipv6_addr_from_str(&addr, addr_str) == NULL) {
if (ipv6_addr_from_str(addr, addr_str) == NULL) {
puts("[initiator]: unable to parse destination address");
return 0;
return -1;
}
if ((remote.netif == SOCK_ADDR_ANY_NETIF) && ipv6_addr_is_link_local(&addr)) {
if ((*netif == SOCK_ADDR_ANY_NETIF) && ipv6_addr_is_link_local(addr)) {
puts("[initiator]: must specify interface for link local target");
return 0;
return -1;
}
memcpy(&remote.addr.ipv6[0], &addr.u8[0], sizeof(addr.u8));
return 0;
}
static ssize_t _send(coap_pkt_t *pkt, size_t len, ipv6_addr_t *addr, uint16_t netif, uint16_t port)
{
sock_udp_ep_t remote;
remote.family = AF_INET6;
remote.port = port;
remote.netif = netif;
memcpy(&remote.addr.ipv6[0], addr->u8, sizeof(addr->u8));
return nanocoap_request(pkt, NULL, &remote, len);
}
@ -112,6 +118,7 @@ static ssize_t _build_coap_pkt(coap_pkt_t *pkt, uint8_t *buf, ssize_t buflen,
/* build header, confirmed message always post */
ssize_t hdrlen = coap_build_hdr(pkt->hdr, COAP_TYPE_CON, token,
sizeof(token), COAP_METHOD_POST, 1);
coap_pkt_init(pkt, buf, buflen, hdrlen);
coap_opt_add_string(pkt, COAP_OPT_URI_PATH, "/.well-known/edhoc", '/');
coap_opt_add_uint(pkt, COAP_OPT_CONTENT_FORMAT, COAP_FORMAT_OCTET);
@ -143,14 +150,21 @@ int _handshake_cmd(int argc, char **argv)
port = atoi(argv[2]);
}
/* parse address */
uint16_t netif;
ipv6_addr_t addr;
if (_parse_ipv6_addr(argv[1], &addr, &netif)) {
return -1;
}
/* reset state */
_ctx.state = EDHOC_WAITING;
if ((msg_len = edhoc_create_msg1(&_ctx, corr, _method, _suite, msg, sizeof(msg))) > 0) {
printf("[initiator]: sending msg1 (%d bytes):\n", (int) msg_len);
printf("[initiator]: sending msg1 (%d bytes):\n", (int)msg_len);
print_bstr(msg, msg_len);
_build_coap_pkt(&pkt, buf, sizeof(buf), msg, msg_len);
len = _send(&pkt, COAP_BUF_SIZE, argv[1], port);
len = _send(&pkt, COAP_BUF_SIZE, &addr, netif, port);
}
else {
puts("[initiator]: failed to create msg1");
@ -165,10 +179,10 @@ int _handshake_cmd(int argc, char **argv)
print_bstr(pkt.payload, pkt.payload_len);
if ((msg_len = edhoc_create_msg3(&_ctx, pkt.payload, pkt.payload_len, msg, sizeof(msg))) > 0) {
printf("[initiator]: sending msg3 (%d bytes):\n", (int) msg_len);
printf("[initiator]: sending msg3 (%d bytes):\n", (int)msg_len);
print_bstr(msg, msg_len);
_build_coap_pkt(&pkt, buf, sizeof(buf), msg, msg_len);
len = _send(&pkt, COAP_BUF_SIZE, argv[1], port);
len = _send(&pkt, COAP_BUF_SIZE, &addr, netif, port);
}
else {
puts("[initiator]: failed to create msg3");

View File

@ -48,21 +48,24 @@ LAKE_WG_EDHOC_TV_34900_OSCORE_SALT = \
"0x8e 0x44 0x92 0x10 0xe0 0x3b 0xc2 0x9d"
def get_ipv6_addr(child):
def get_ipv6_addr_and_netif(child):
child.expect_exact('>')
child.sendline('ifconfig')
# Get device local address
child.expect(r"Iface\s+(?P<netif>\d+)\s+")
netif = child.match.group("netif")
# Get device local address
child.expect(
r"inet6\s+addr:\s+(?P<lladdr>[0-9a-fA-F:]+:[A-Fa-f:0-9]+)"
" scope: link VAL"
)
return child.match.group("lladdr").lower()
addr = child.match.group("lladdr").lower()
return addr, netif
def testfunc(child):
child.sendline("init handshake {} {}".format(
get_ipv6_addr(child), COAP_PORT))
addr, netif = get_ipv6_addr_and_netif(child)
child.sendline("init handshake {}%{} {}".format(addr, netif, COAP_PORT))
child.expect_exact("[initiator]: sending msg1 (37 bytes):")
for line in LAKE_WG_EDHOC_TV_34900_MSG1.split('\n'):
child.expect_exact(line)

View File

@ -27,7 +27,7 @@ BOARD_BLACKLIST := arduino-duemilanove \
z1 \
#
CFLAGS += -DTHREAD_STACKSIZE_MAIN=\(5*THREAD_STACKSIZE_DEFAULT\)
CFLAGS += -DTHREAD_STACKSIZE_MAIN=\(6*THREAD_STACKSIZE_DEFAULT\)
USEPKG += relic
USEMODULE += embunit