Compare commits
13 Commits
master
...
2022.01-RC
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5db69b471c | ||
|
|
336fd75c5c | ||
|
|
ec3cc227ab | ||
|
|
f052a9b621 | ||
|
|
33c360c39b | ||
|
|
c13b529482 | ||
|
|
79794fd132 | ||
|
|
69198a4bd3 | ||
|
|
6a8dedf26c | ||
|
|
b8994e9961 | ||
|
|
5e993749d4 | ||
|
|
4b3d699b62 | ||
|
|
0bef73205c |
@ -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)
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -2,3 +2,5 @@
|
||||
ifeq (,$(UNIT_TESTS))
|
||||
FEATURES_REQUIRED += periph_rtt
|
||||
endif
|
||||
|
||||
USEMODULE += rtc_utils
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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));
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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");
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user