Skip to content

Commit aa70f68

Browse files
authored
Merge pull request #13550 from artokin/nanostack_release_v12_5_0_feature_wisun
[feature-wisun] Nanostack release v12.5.0
2 parents 85f2537 + a43934c commit aa70f68

File tree

31 files changed

+804
-95
lines changed

31 files changed

+804
-95
lines changed

components/802.15.4_RF/atmel-rf-driver/atmel-rf-driver/NanostackRfPhyAtmel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include "at24mac.h"
2121
#include "PinNames.h"
2222

23-
#if defined(MBED_CONF_NANOSTACK_CONFIGURATION) && DEVICE_SPI && DEVICE_I2C && defined(MBED_CONF_RTOS_PRESENT)
23+
#if defined(MBED_CONF_NANOSTACK_CONFIGURATION) && DEVICE_SPI && DEVICE_I2C && DEVICE_INTERRUPTIN && defined(MBED_CONF_RTOS_PRESENT)
2424

2525
#include "NanostackRfPhy.h"
2626

components/802.15.4_RF/atmel-rf-driver/source/NanostackRfPhyAT86RF215.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
#include <string.h>
1818

19-
#if defined(MBED_CONF_NANOSTACK_CONFIGURATION) && DEVICE_SPI && DEVICE_INTERRUPTIN && defined(MBED_CONF_RTOS_PRESENT)
19+
#if defined(MBED_CONF_NANOSTACK_CONFIGURATION) && DEVICE_SPI && DEVICE_I2C && DEVICE_INTERRUPTIN && defined(MBED_CONF_RTOS_PRESENT)
2020

2121
#include "ns_types.h"
2222
#include "platform/arm_hal_interrupt.h"

components/802.15.4_RF/atmel-rf-driver/source/NanostackRfPhyAtmel.cpp

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,21 @@
3434
#include "inttypes.h"
3535
#include "Timeout.h"
3636
#include "platform/mbed_error.h"
37+
#include "platform/mbed_version.h"
38+
39+
#if (MBED_VERSION > MBED_ENCODE_VERSION(6, 0, 0))
40+
/* Mbed OS 6.0 introduces support for chrono time management */
41+
using namespace std::chrono;
42+
#define ATMEL_RF_TIME_50US 50us
43+
#define ATMEL_RF_TIME_2MS 2ms
44+
#define ATMEL_RF_TIME_10MS 10ms
45+
#define ATMEL_RF_ATTACH(timer_ref, signal_ref, timeout_ref) timer_ref.attach(signal_ref, timeout_ref)
46+
#else
47+
#define ATMEL_RF_TIME_50US 50
48+
#define ATMEL_RF_TIME_2MS 2
49+
#define ATMEL_RF_TIME_10MS 10
50+
#define ATMEL_RF_ATTACH(timer_ref, signal_ref, timeout_ref) timer_ref.attach_us(signal_ref, timeout_ref)
51+
#endif
3752

3853
#define TRACE_GROUP "AtRF"
3954

@@ -345,7 +360,6 @@ static rf_trx_part_e rf_radio_type_read(void)
345360
return ret_val;
346361
}
347362

348-
349363
/*
350364
* \brief Function starts the ACK wait timeout.
351365
*
@@ -356,9 +370,9 @@ static rf_trx_part_e rf_radio_type_read(void)
356370
static void rf_if_ack_wait_timer_start(uint16_t slots)
357371
{
358372
#ifdef MBED_CONF_RTOS_PRESENT
359-
rf->ack_timer.attach_us(rf_if_ack_timer_signal, slots * 50);
373+
ATMEL_RF_ATTACH(rf->ack_timer, rf_if_ack_timer_signal, slots * ATMEL_RF_TIME_50US);
360374
#else
361-
rf->ack_timer.attach_us(rf_ack_wait_timer_interrupt, slots * 50);
375+
ATMEL_RF_ATTACH(rf->ack_timer, rf_ack_wait_timer_interrupt, slots * ATMEL_RF_TIME_50US);
362376
#endif
363377
}
364378

@@ -372,9 +386,9 @@ static void rf_if_ack_wait_timer_start(uint16_t slots)
372386
static void rf_if_calibration_timer_start(uint32_t slots)
373387
{
374388
#ifdef MBED_CONF_RTOS_PRESENT
375-
rf->cal_timer.attach_us(rf_if_cal_timer_signal, slots * 50);
389+
ATMEL_RF_ATTACH(rf->cal_timer, rf_if_cal_timer_signal, slots * ATMEL_RF_TIME_50US);
376390
#else
377-
rf->cal_timer.attach_us(rf_calibration_timer_interrupt, slots * 50);
391+
ATMEL_RF_ATTACH(rf->cal_timer, rf_calibration_timer_interrupt, slots * ATMEL_RF_TIME_50US);
378392
#endif
379393
}
380394

@@ -388,9 +402,9 @@ static void rf_if_calibration_timer_start(uint32_t slots)
388402
static void rf_if_cca_timer_start(uint32_t slots)
389403
{
390404
#ifdef MBED_CONF_RTOS_PRESENT
391-
rf->cca_timer.attach_us(rf_if_cca_timer_signal, slots * 50);
405+
ATMEL_RF_ATTACH(rf->cca_timer, rf_if_cca_timer_signal, slots * ATMEL_RF_TIME_50US);
392406
#else
393-
rf->cca_timer.attach_us(rf_cca_timer_interrupt, slots * 50);
407+
ATMEL_RF_ATTACH(rf->cca_timer, rf_cca_timer_interrupt, slots * ATMEL_RF_TIME_50US);
394408
#endif
395409
}
396410

@@ -519,14 +533,14 @@ static void rf_if_reset_radio(void)
519533
#endif
520534
rf->IRQ.rise(nullptr);
521535
rf->RST = 1;
522-
ThisThread::sleep_for(2);
536+
ThisThread::sleep_for(ATMEL_RF_TIME_2MS);
523537
rf->RST = 0;
524-
ThisThread::sleep_for(10);
538+
ThisThread::sleep_for(ATMEL_RF_TIME_10MS);
525539
CS_RELEASE();
526540
rf->SLP_TR = 0;
527-
ThisThread::sleep_for(10);
541+
ThisThread::sleep_for(ATMEL_RF_TIME_10MS);
528542
rf->RST = 1;
529-
ThisThread::sleep_for(10);
543+
ThisThread::sleep_for(ATMEL_RF_TIME_10MS);
530544

531545
rf->IRQ.rise(&rf_if_interrupt_handler);
532546
}

components/802.15.4_RF/atmel-rf-driver/source/rfbits.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#ifndef RFBITS_H_
1818
#define RFBITS_H_
1919

20+
#if DEVICE_SPI
21+
2022
#include "DigitalIn.h"
2123
#include "DigitalOut.h"
2224
#include "InterruptIn.h"
@@ -78,4 +80,5 @@ class Se2435Pins {
7880
DigitalOut ANT_SEL;
7981
};
8082

83+
#endif /* DEVICE_SPI */
8184
#endif /* RFBITS_H_ */

components/802.15.4_RF/stm-s2lp-rf-driver/source/NanostackRfPhys2lp.cpp

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
#include <string.h>
1717
#if defined(MBED_CONF_NANOSTACK_CONFIGURATION) && DEVICE_SPI && DEVICE_INTERRUPTIN && defined(MBED_CONF_RTOS_PRESENT)
18+
1819
#include "platform/arm_hal_interrupt.h"
1920
#include "nanostack/platform/arm_hal_phy.h"
2021
#include "ns_types.h"
@@ -30,6 +31,17 @@
3031
#include "Thread.h"
3132
#include "mbed_wait_api.h"
3233
#include "platform/mbed_error.h"
34+
#include "platform/mbed_version.h"
35+
36+
#if (MBED_VERSION > MBED_ENCODE_VERSION(6, 0, 0))
37+
/* Mbed OS 6.0 introduces support for chrono time management */
38+
using namespace std::chrono;
39+
#define S2LP_USE_CHRONO
40+
#define S2LP_TIME_50US 50us
41+
#define S2LP_TIME_10MS 10ms
42+
#else
43+
#define S2LP_TIME_10MS 10
44+
#endif
3345

3446
using namespace mbed;
3547
using namespace rtos;
@@ -276,7 +288,11 @@ static void rf_calculate_symbol_rate(uint32_t baudrate, phy_modulation_e modulat
276288

277289
static uint32_t rf_get_timestamp(void)
278290
{
291+
#ifdef S2LP_USE_CHRONO
292+
return (uint32_t)rf->tx_timer.elapsed_time().count();
293+
#else
279294
return (uint32_t)rf->tx_timer.read_us();
295+
#endif
280296
}
281297

282298
static void rf_update_tx_active_time(void)
@@ -866,7 +882,11 @@ static void rf_cca_timer_stop(void)
866882

867883
static void rf_cca_timer_start(uint32_t slots)
868884
{
885+
#ifdef S2LP_USE_CHRONO
886+
rf->cca_timer.attach(rf_cca_timer_signal, microseconds(slots));
887+
#else
869888
rf->cca_timer.attach_us(rf_cca_timer_signal, slots);
889+
#endif
870890
TEST_CSMA_STARTED
871891
}
872892

@@ -903,7 +923,11 @@ static void rf_backup_timer_stop(void)
903923

904924
static void rf_backup_timer_start(uint32_t slots)
905925
{
926+
#ifdef S2LP_USE_CHRONO
927+
rf->backup_timer.attach(rf_backup_timer_signal, microseconds(slots));
928+
#else
906929
rf->backup_timer.attach_us(rf_backup_timer_signal, slots);
930+
#endif
907931
}
908932

909933
static int8_t rf_start_cca(uint8_t *data_ptr, uint16_t data_length, uint8_t tx_handle, data_protocol_e data_protocol)
@@ -1177,10 +1201,10 @@ static void rf_reset(void)
11771201
{
11781202
// Shutdown
11791203
rf->SDN = 1;
1180-
ThisThread::sleep_for(10);
1204+
ThisThread::sleep_for(S2LP_TIME_10MS);
11811205
// Wake up
11821206
rf->SDN = 0;
1183-
ThisThread::sleep_for(10);
1207+
ThisThread::sleep_for(S2LP_TIME_10MS);
11841208
}
11851209

11861210
static void rf_init(void)

features/nanostack/sal-stack-nanostack/nanostack/ws_bbr_api.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,8 @@ int ws_bbr_radius_timing_validate(int8_t interface_id, bbr_radius_timing_t *timi
490490
*
491491
* This function can be called multiple times.
492492
* if domain name matches a existing entry address is updated.
493-
* If address and domain name is set to NULL entire list is cleared
493+
* If domain name is set to NULL entire list is cleared
494+
* if address is set to NULL the Domain name is removed from the list.
494495
*
495496
* \param interface_id Network interface ID.
496497
* \param address The address of the DNS query result.

features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_bbr_api.c

Lines changed: 101 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "nsconfig.h"
2020
#include "ns_types.h"
2121
#include "ns_trace.h"
22+
#include "nsdynmemLIB.h"
2223
#include "net_interface.h"
2324
#include "socket_api.h"
2425
#include "eventOS_event.h"
@@ -41,6 +42,7 @@
4142
#include "6LoWPAN/ws/ws_pae_controller.h"
4243
#include "DHCPv6_Server/DHCPv6_server_service.h"
4344
#include "DHCPv6_client/dhcpv6_client_api.h"
45+
#include "libDHCPv6/libDHCPv6_vendordata.h"
4446
#include "libNET/src/net_dns_internal.h"
4547

4648

@@ -93,6 +95,17 @@ static rpl_dodag_conf_t rpl_conf = {
9395
.dio_redundancy_constant = WS_RPL_DIO_REDUNDANCY_SMALL
9496
};
9597

98+
typedef struct dns_resolution {
99+
/** Resolved address for the domain*/
100+
uint8_t address[16];
101+
/** Domain name string */
102+
char *domain_name;
103+
} dns_resolution_t;
104+
105+
#define MAX_DNS_RESOLUTIONS 4
106+
107+
static dns_resolution_t pre_resolved_dns_queries[MAX_DNS_RESOLUTIONS] = {0};
108+
96109
static void ws_bbr_rpl_version_timer_start(protocol_interface_info_entry_t *cur, uint8_t version)
97110
{
98111
// Set the next timeout value for version update
@@ -368,7 +381,8 @@ static bool wisun_dhcp_address_add_cb(int8_t interfaceId, dhcp_address_cache_upd
368381
wisun_bbr_na_send(backbone_interface_id, address_info->allocatedAddress);
369382
return true;
370383
}
371-
static void ws_bbr_dhcp_server_dns_info_update(protocol_interface_info_entry_t *cur)
384+
385+
static void ws_bbr_dhcp_server_dns_info_update(protocol_interface_info_entry_t *cur, uint8_t *global_id)
372386
{
373387
//add DNS server information to DHCP server that is learned from the backbone interface.
374388
uint8_t dns_server_address[16];
@@ -377,13 +391,37 @@ static void ws_bbr_dhcp_server_dns_info_update(protocol_interface_info_entry_t *
377391
(void)cur;
378392
if (net_dns_server_get(backbone_interface_id, dns_server_address, &dns_search_list_ptr, &dns_search_list_len, 0) == 0) {
379393
/*Only supporting one DNS server address*/
380-
//DHCPv6_server_service_set_dns_server(cur->id, dns_server_address, dns_search_list_ptr, dns_search_list_len);
394+
DHCPv6_server_service_set_dns_server(cur->id, global_id, dns_server_address, dns_search_list_ptr, dns_search_list_len);
381395
}
382396

383397
//TODO Generate vendor data in Wi-SUN network include the cached DNS query results in some sort of TLV format
384-
(void)dhcp_vendor_data_ptr;
385-
(void)dhcp_vendor_data_len;
386-
//DHCPv6_server_service_set_vendor_data(cur->id, dhcp_vendor_data_ptr, dhcp_vendor_data_len);
398+
int vendor_data_len = 0;
399+
for (int n = 0; n < MAX_DNS_RESOLUTIONS; n++) {
400+
if (pre_resolved_dns_queries[n].domain_name != NULL) {
401+
vendor_data_len += net_dns_option_vendor_option_data_dns_query_length(pre_resolved_dns_queries[n].domain_name);
402+
}
403+
}
404+
if (vendor_data_len) {
405+
ns_dyn_mem_free(dhcp_vendor_data_ptr);
406+
dhcp_vendor_data_ptr = ns_dyn_mem_alloc(vendor_data_len);
407+
if (!dhcp_vendor_data_ptr) {
408+
tr_warn("Vendor info set fail");
409+
return;
410+
}
411+
dhcp_vendor_data_len = vendor_data_len;
412+
}
413+
if (dhcp_vendor_data_ptr) {
414+
// Write vendor data
415+
uint8_t *ptr = dhcp_vendor_data_ptr;
416+
for (int n = 0; n < MAX_DNS_RESOLUTIONS; n++) {
417+
if (pre_resolved_dns_queries[n].domain_name != NULL) {
418+
ptr = net_dns_option_vendor_option_data_dns_query_write(ptr, pre_resolved_dns_queries[n].address, pre_resolved_dns_queries[n].domain_name);
419+
tr_info("set DNS query result for %s, addr: %s", pre_resolved_dns_queries[n].domain_name, tr_ipv6(pre_resolved_dns_queries[n].address));
420+
}
421+
}
422+
}
423+
424+
DHCPv6_server_service_set_vendor_data(cur->id, global_id, ARM_ENTERPRISE_NUMBER, dhcp_vendor_data_ptr, dhcp_vendor_data_len);
387425
}
388426

389427
static void ws_bbr_dhcp_server_start(protocol_interface_info_entry_t *cur, uint8_t *global_id, uint32_t dhcp_address_lifetime)
@@ -406,7 +444,7 @@ static void ws_bbr_dhcp_server_start(protocol_interface_info_entry_t *cur, uint8
406444
//SEt max value for not limiting address allocation
407445
DHCPv6_server_service_set_max_clients_accepts_count(cur->id, global_id, MAX_SUPPORTED_ADDRESS_LIST_SIZE);
408446

409-
ws_bbr_dhcp_server_dns_info_update(cur);
447+
ws_bbr_dhcp_server_dns_info_update(cur, global_id);
410448

411449
ws_dhcp_client_address_request(cur, global_id, ll);
412450
}
@@ -594,7 +632,7 @@ static void ws_bbr_rpl_status_check(protocol_interface_info_entry_t *cur)
594632
// Add also global prefix and route to RPL
595633
rpl_control_update_dodag_route(protocol_6lowpan_rpl_root_dodag, current_global_prefix, 64, 0, WS_ROUTE_LIFETIME, false);
596634
}
597-
ws_bbr_dhcp_server_dns_info_update(cur);
635+
ws_bbr_dhcp_server_dns_info_update(cur, current_global_prefix);
598636
}
599637
}
600638
void ws_bbr_pan_version_increase(protocol_interface_info_entry_t *cur)
@@ -1200,7 +1238,7 @@ int ws_bbr_dns_query_result_set(int8_t interface_id, const uint8_t address[16],
12001238
{
12011239
#ifdef HAVE_WS_BORDER_ROUTER
12021240
protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(interface_id);
1203-
if (!cur || !address || !domain_name_ptr) {
1241+
if (!cur) {
12041242
return -1;
12051243
}
12061244

@@ -1210,10 +1248,62 @@ int ws_bbr_dns_query_result_set(int8_t interface_id, const uint8_t address[16],
12101248
*
12111249
* This is included in the vendor extension where the format is decided by the vendor
12121250
*/
1213-
// TODO search if entry exists replace if address is NULL delete the entry
1214-
// TODO This information should expire if not updated by client
12151251

1216-
ws_bbr_dhcp_server_dns_info_update(cur);
1252+
// Delete all entries
1253+
if (!domain_name_ptr) {
1254+
for (int n = 0; n < MAX_DNS_RESOLUTIONS; n++) {
1255+
// Delete all entries
1256+
memset(pre_resolved_dns_queries[n].address, 0, 16);
1257+
ns_dyn_mem_free(pre_resolved_dns_queries[n].domain_name);
1258+
pre_resolved_dns_queries[n].domain_name = NULL;
1259+
}
1260+
goto update_information;
1261+
}
1262+
1263+
// Update existing entries or delete
1264+
for (int n = 0; n < MAX_DNS_RESOLUTIONS; n++) {
1265+
if (pre_resolved_dns_queries[n].domain_name != NULL &&
1266+
strcasecmp(pre_resolved_dns_queries[n].domain_name, domain_name_ptr) == 0) {
1267+
// Matching query updated
1268+
if (address) {
1269+
// Update address
1270+
memcpy(pre_resolved_dns_queries[n].address, address, 16);
1271+
} else {
1272+
// delete entry
1273+
memset(pre_resolved_dns_queries[n].address, 0, 16);
1274+
ns_dyn_mem_free(pre_resolved_dns_queries[n].domain_name);
1275+
pre_resolved_dns_queries[n].domain_name = NULL;
1276+
}
1277+
goto update_information;
1278+
}
1279+
}
1280+
1281+
if (address && domain_name_ptr) {
1282+
// Store new entry to the list
1283+
for (int n = 0; n < MAX_DNS_RESOLUTIONS; n++) {
1284+
if (pre_resolved_dns_queries[n].domain_name == NULL) {
1285+
// Free entry found
1286+
pre_resolved_dns_queries[n].domain_name = ns_dyn_mem_alloc(strlen(domain_name_ptr) + 1);
1287+
if (!pre_resolved_dns_queries[n].domain_name) {
1288+
// Out of memory
1289+
return -2;
1290+
}
1291+
memcpy(pre_resolved_dns_queries[n].address, address, 16);
1292+
strcpy(pre_resolved_dns_queries[n].domain_name, domain_name_ptr);
1293+
goto update_information;
1294+
}
1295+
}
1296+
// No room to store new field
1297+
return -3;
1298+
}
1299+
1300+
update_information:
1301+
if (memcmp(current_global_prefix, ADDR_UNSPECIFIED, 8) == 0) {
1302+
// Not in active state so changes are activated after start
1303+
return 0;
1304+
}
1305+
1306+
ws_bbr_dhcp_server_dns_info_update(cur, current_global_prefix);
12171307
return 0;
12181308
#else
12191309
(void) interface_id;

0 commit comments

Comments
 (0)