Skip to content

Commit 6ba4c9a

Browse files
authored
Merge pull request #12515 from artokin/nanostack_for_feature_wisun
[feature-wisun] Nanostack release to feature_wisun branch
2 parents e642a7d + dedc380 commit 6ba4c9a

File tree

100 files changed

+2363
-833
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+2363
-833
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ static void rf_if_reset_radio(void)
524524
#else
525525
rf->spi.frequency(MBED_CONF_ATMEL_RF_LOW_SPI_SPEED);
526526
#endif
527-
rf->IRQ.rise(0);
527+
rf->IRQ.rise(nullptr);
528528
rf->RST = 1;
529529
ThisThread::sleep_for(2);
530530
rf->RST = 0;

components/802.15.4_RF/mcr20a-rf-driver/source/MCR20Drv.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#if defined(MBED_CONF_NANOSTACK_CONFIGURATION) && DEVICE_SPI && DEVICE_INTERRUPTIN && defined(MBED_CONF_RTOS_PRESENT)
4646

4747
#include "platform/mbed_critical.h"
48+
#include <string.h>
4849

4950
/*****************************************************************************
5051
* PRIVATE VARIABLES *
@@ -165,7 +166,7 @@ void MCR20Drv_DirectAccessSPIMultiByteWrite
165166
{
166167
uint8_t txData;
167168

168-
if ((numOfBytes == 0) || (byteArray == 0)) {
169+
if ((numOfBytes == 0) || (byteArray == NULL)) {
169170
return;
170171
}
171172

@@ -230,7 +231,7 @@ void MCR20Drv_PB_SPIBurstWrite
230231
{
231232
uint8_t txData;
232233

233-
if ((numOfBytes == 0) || (byteArray == 0)) {
234+
if ((numOfBytes == 0) || (byteArray == NULL)) {
234235
return;
235236
}
236237

@@ -301,7 +302,7 @@ uint8_t MCR20Drv_DirectAccessSPIMultiByteRead
301302
uint8_t txData;
302303
uint8_t phyIRQSTS1;
303304

304-
if ((numOfBytes == 0) || (byteArray == 0)) {
305+
if ((numOfBytes == 0) || (byteArray == NULL)) {
305306
return 0;
306307
}
307308

@@ -338,7 +339,7 @@ uint8_t MCR20Drv_PB_SPIBurstRead
338339
uint8_t txData;
339340
uint8_t phyIRQSTS1;
340341

341-
if ((numOfBytes == 0) || (byteArray == 0)) {
342+
if ((numOfBytes == 0) || (byteArray == NULL)) {
342343
return 0;
343344
}
344345

@@ -406,7 +407,7 @@ void MCR20Drv_IndirectAccessSPIMultiByteWrite
406407
{
407408
uint16_t txData;
408409

409-
if ((numOfBytes == 0) || (byteArray == 0)) {
410+
if ((numOfBytes == 0) || (byteArray == NULL)) {
410411
return;
411412
}
412413

@@ -473,7 +474,7 @@ void MCR20Drv_IndirectAccessSPIMultiByteRead
473474
{
474475
uint16_t txData;
475476

476-
if ((numOfBytes == 0) || (byteArray == 0)) {
477+
if ((numOfBytes == 0) || (byteArray == NULL)) {
477478
return;
478479
}
479480

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

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ static rf_mode_e rf_mode = RF_MODE_NORMAL;
209209
static bool rf_update_config = false;
210210
static uint16_t cur_packet_len = 0xffff;
211211
static uint32_t receiver_ready_timestamp;
212-
213212
static int16_t rssi_threshold = RSSI_THRESHOLD;
213+
static uint32_t tx_start_time = 0;
214214

215215
/* Channel configurations for sub-GHz */
216216
static phy_rf_channel_configuration_s phy_subghz = {
@@ -276,6 +276,20 @@ static uint32_t rf_get_timestamp(void)
276276
return (uint32_t)rf->tx_timer.read_us();
277277
}
278278

279+
static void rf_update_tx_active_time(void)
280+
{
281+
if (device_driver.phy_rf_statistics) {
282+
device_driver.phy_rf_statistics->tx_active_time += rf_get_timestamp() - tx_start_time;
283+
}
284+
}
285+
286+
static void rf_update_rx_active_time(void)
287+
{
288+
if (device_driver.phy_rf_statistics) {
289+
device_driver.phy_rf_statistics->rx_active_time += rf_get_timestamp() - rx_time;
290+
}
291+
}
292+
279293
static void rf_lock(void)
280294
{
281295
platform_enter_critical();
@@ -739,6 +753,7 @@ static void rf_tx_sent_handler(void)
739753
rf_disable_interrupt(TX_DATA_SENT);
740754
if (rf_state != RF_TX_ACK) {
741755
tx_finnish_time = rf_get_timestamp();
756+
rf_update_tx_active_time();
742757
TEST_TX_DONE
743758
rf_state = RF_IDLE;
744759
rf_receive(rf_rx_channel);
@@ -771,6 +786,7 @@ static void rf_start_tx(void)
771786
rf_disable_all_interrupts();
772787
rf_poll_state_change(S2LP_STATE_READY);
773788
rf_state_change(S2LP_STATE_TX, false);
789+
tx_start_time = rf_get_timestamp();
774790
// More TX data to be written in FIFO when TX threshold interrupt occurs
775791
if (tx_data_ptr) {
776792
rf_enable_interrupt(TX_FIFO_ALMOST_EMPTY);
@@ -805,6 +821,7 @@ static void rf_cca_timer_interrupt(void)
805821
}
806822
rf_flush_tx_fifo();
807823
tx_finnish_time = rf_get_timestamp();
824+
rf_update_tx_active_time();
808825
if (device_driver.phy_tx_done_cb) {
809826
device_driver.phy_tx_done_cb(rf_radio_driver_id, mac_tx_handle, PHY_LINK_CCA_FAIL, 0, 0);
810827
}
@@ -825,6 +842,9 @@ static void rf_cca_timer_interrupt(void)
825842
rf_start_tx();
826843
rf_state = RF_TX_STARTED;
827844
TEST_TX_STARTED
845+
if (device_driver.phy_rf_statistics) {
846+
device_driver.phy_rf_statistics->tx_bytes += tx_data_length;
847+
}
828848
}
829849
}
830850
}
@@ -843,10 +863,12 @@ static void rf_backup_timer_interrupt(void)
843863
{
844864
tx_finnish_time = rf_get_timestamp();
845865
if (rf_state == RF_RX_STARTED) {
866+
rf_update_rx_active_time();
846867
if (device_driver.phy_rf_statistics) {
847868
device_driver.phy_rf_statistics->rx_timeouts++;
848869
}
849870
} else {
871+
rf_update_tx_active_time();
850872
if (device_driver.phy_rf_statistics) {
851873
device_driver.phy_rf_statistics->tx_timeouts++;
852874
}
@@ -921,13 +943,17 @@ static void rf_send_ack(uint8_t seq)
921943
rf_start_tx();
922944
TEST_ACK_TX_STARTED
923945
rf_backup_timer_start(ACK_SENDING_TIME);
946+
if (device_driver.phy_rf_statistics) {
947+
device_driver.phy_rf_statistics->tx_bytes += sizeof(ack_frame);
948+
}
924949
}
925950

926951
static void rf_handle_ack(uint8_t seq_number, uint8_t pending)
927952
{
928953
phy_link_tx_status_e phy_status;
929954
if (tx_sequence == (uint16_t)seq_number) {
930955
tx_finnish_time = rf_get_timestamp();
956+
rf_update_tx_active_time();
931957
if (pending) {
932958
phy_status = PHY_LINK_TX_DONE_PENDING;
933959
} else {
@@ -966,6 +992,9 @@ static void rf_rx_ready_handler(void)
966992
rf_send_ack(rx_buffer[2]);
967993
}
968994
}
995+
if (device_driver.phy_rf_statistics) {
996+
device_driver.phy_rf_statistics->rx_bytes += rx_data_length;
997+
}
969998
} else {
970999
rf_state = RF_IDLE;
9711000
int8_t rssi = (rf_read_register(RSSI_LEVEL) - RSSI_OFFSET);
@@ -1072,6 +1101,7 @@ static void rf_irq_task_process_irq(void)
10721101
if ((irq_status & (1 << TX_FIFO_UNF_OVF)) && (enabled_interrupts & (1 << TX_FIFO_UNF_OVF))) {
10731102
rf_backup_timer_stop();
10741103
tx_finnish_time = rf_get_timestamp();
1104+
rf_update_tx_active_time();
10751105
TEST_TX_DONE
10761106
device_driver.phy_tx_done_cb(rf_radio_driver_id, mac_tx_handle, PHY_LINK_CCA_FAIL, 1, 0);
10771107
rf_send_command(S2LP_CMD_SABORT);
@@ -1087,6 +1117,7 @@ static void rf_irq_task_process_irq(void)
10871117
}
10881118
} else if (rf_state == RF_RX_STARTED) {
10891119
if ((irq_status & (1 << RX_DATA_READY)) && (enabled_interrupts & (1 << RX_DATA_READY))) {
1120+
rf_update_rx_active_time();
10901121
if (!(irq_status & (1 << CRC_ERROR))) {
10911122
rf_rx_ready_handler();
10921123
} else {
@@ -1112,6 +1143,7 @@ static void rf_irq_task_process_irq(void)
11121143
}
11131144
}
11141145
if ((irq_status & (1 << RX_FIFO_UNF_OVF)) && (enabled_interrupts & (1 << RX_FIFO_UNF_OVF))) {
1146+
rf_update_rx_active_time();
11151147
TEST_RX_DONE
11161148
rf_backup_timer_stop();
11171149
rf_send_command(S2LP_CMD_SABORT);

features/frameworks/nanostack-libservice/mbed-client-libservice/ip6string.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ uint_fast8_t ip6_prefix_tos(const void *prefix, uint_fast8_t prefix_len, char *p
5757
* IPv4 tunneling addresses are not covered.
5858
*
5959
* \param ip6addr IPv6 address in string format.
60-
* \param len Lenght of ipv6 string, maximum of 41.
60+
* \param len Length of ipv6 string, maximum of 41.
6161
* \param dest buffer for address. MUST be 16 bytes. Filled with 0 on error.
6262
* \return boolean set to true if conversion succeed, false if it didn't
6363
*/

features/nanostack/coap-service/coap-service/coap_service_api.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ extern void coap_service_close_secure_connection(int8_t service_id, uint8_t dest
184184
* \param destination_addr_ptr Receiver IPv6 address.
185185
* \param port Receiver port number.
186186
* \param *data_ptr Pointer to the data.
187-
* \param data_len Lenght of the data.
187+
* \param data_len Length of the data.
188188
*
189189
* \return 0 for success / -1 for failure
190190
*/
@@ -199,7 +199,7 @@ typedef int coap_service_virtual_socket_send_cb(int8_t service_id, uint8_t desti
199199
* \param source_addr_ptr Receiver IPv6 address.
200200
* \param port Receiver port number.
201201
* \param *data_ptr Pointer to the data
202-
* \param data_len Lenght of the data
202+
* \param data_len Length of the data
203203
*
204204
* \return 0 for success / -1 for failure
205205
*/
@@ -257,7 +257,7 @@ extern int8_t coap_service_unregister_uri(int8_t service_id, const char *uri);
257257
* \param *uri Uri address.
258258
* \param cont_type Content type can be found from sn_coap_header.
259259
* \param payload_ptr Pointer to message content.
260-
* \param payload_len Lenght of the message.
260+
* \param payload_len Length of the message.
261261
* \param *request_response_cb Callback to inform result of the request.
262262
*
263263
* \return msg_id Id number of the current message.
@@ -276,7 +276,7 @@ extern uint16_t coap_service_request_send(int8_t service_id, uint8_t options, co
276276
* \param message_code Message code can be found from sn_coap_header.
277277
* \param content_type Content type can be found from sn_coap_header.
278278
* \param payload_ptr Pointer to message content.
279-
* \param payload_len Lenght of the message.
279+
* \param payload_len Length of the message.
280280
*
281281
* \return -1 For failure
282282
*- 0 For success
@@ -295,7 +295,7 @@ extern int8_t coap_service_response_send(int8_t service_id, uint8_t options, sn_
295295
* \param message_code Message code can be found from sn_coap_header.
296296
* \param content_type Content type can be found from sn_coap_header.
297297
* \param payload_ptr Pointer to message content.
298-
* \param payload_len Lenght of the message.
298+
* \param payload_len Length of the message.
299299
*
300300
* \return -1 For failure
301301
*- 0 For success

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,10 @@ typedef void fhss_data_tx_done(const fhss_api_t *api, bool waiting_ack, bool tx_
122122
* @param api FHSS instance.
123123
* @param handle Handle of the data request.
124124
* @param frame_type Frame type of packet (Frames types are defined by FHSS api).
125+
* @param channel Channel wanted to black list temporarily.
125126
* @return true if frame has to be queued for retransmission, false otherwise.
126127
*/
127-
typedef bool fhss_data_tx_fail(const fhss_api_t *api, uint8_t handle, int frame_type);
128+
typedef bool fhss_data_tx_fail(const fhss_api_t *api, uint8_t handle, int frame_type, uint8_t channel);
128129

129130
/**
130131
* @brief Change synchronization state.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright (c) 2020, Arm Limited and affiliates.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/**
19+
* \file fhss_test_api.h
20+
* \brief
21+
*/
22+
23+
#ifndef FHSS_TEST_API_H
24+
#define FHSS_TEST_API_H
25+
26+
27+
#ifdef __cplusplus
28+
extern "C" {
29+
#endif
30+
31+
/**
32+
* \brief Set optimal packet length
33+
*
34+
* \param fhss_api FHSS instance.
35+
* \param packet_length Optimal packet length
36+
*
37+
* \return 0 Success
38+
* \return -1 Failure
39+
*/
40+
int8_t fhss_set_optimal_packet_length(const fhss_api_t *fhss_api, uint16_t packet_length);
41+
42+
#ifdef __cplusplus
43+
}
44+
#endif
45+
46+
#endif // FHSS_TEST_API_H

features/nanostack/sal-stack-nanostack/nanostack/platform/arm_hal_phy.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ typedef enum {
161161
CHANNEL_PAGE_5 = 5, ///< Page 5
162162
CHANNEL_PAGE_6 = 6, ///< Page 6
163163
CHANNEL_PAGE_9 = 9, ///< Page 9
164-
CHANNEL_PAGE_10 = 10 ///< Page 10
164+
CHANNEL_PAGE_10 = 10, ///< Page 10
165+
CHANNEL_PAGE_UNDEFINED ///< Undefined
165166
} channel_page_e;
166167

167168
/** Modulation index */
@@ -192,6 +193,10 @@ typedef struct phy_rf_statistics_s {
192193
uint32_t crc_fails; ///< CRC failures
193194
uint32_t tx_timeouts; ///< transmission timeouts
194195
uint32_t rx_timeouts; ///< reception timeouts
196+
uint64_t tx_active_time; ///< transmission active time
197+
uint64_t rx_active_time; ///< reception active time
198+
uint32_t tx_bytes; ///< transmitted bytes
199+
uint32_t rx_bytes; ///< received bytes
195200
} phy_rf_statistics_s;
196201

197202
/** Virtual data request */

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ extern int8_t ns_sw_mac_virtual_client_unregister(struct mac_api_s *api);
6767
*/
6868
extern int ns_sw_mac_fhss_register(struct mac_api_s *mac_api, struct fhss_api *fhss_api);
6969

70+
/**
71+
* @brief Unregister FHSS API instance from given software MAC instance.
72+
* @param mac_api MAC instance.
73+
* @return 0 on success, -1 on fail.
74+
*/
75+
extern int ns_sw_mac_fhss_unregister(struct mac_api_s *mac_api);
76+
7077
/**
7178
* @brief Request registered FHSS API instance from software MAC instance.
7279
* @param mac_api MAC instance.

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,10 @@ int ws_bbr_start(int8_t interface_id, int8_t backbone_interface_id);
4848
/**
4949
* Border router configuration options
5050
*/
51-
#define BBR_ULA_C 0x0001 /**< Static ULA prefix created automatically */
52-
#define BBR_GUA_ROUTE 0x0002 /**< More specific route is added for GUA prefix */
53-
#define BBR_BB_WAIT 0x0004 /**< Wait backbone availability before starting Wi-SUN network */
54-
55-
/*Deprecated configuration values */
56-
#define BBR_GUA_C 0x0000 /**< Routable prefix is learned from the backbone */
57-
#define BBR_GUA_SLAAC 0x0000 /**< Use SLAAC addressing in routable prefix */
58-
#define BBR_GUA_WAIT 0x0000 /**< Wait backbone availability before startingRPL dodag */
51+
#define BBR_ULA_C 0x0001 /**< Static ULA prefix created automatically */
52+
#define BBR_GUA_ROUTE 0x0002 /**< More specific route is added for GUA prefix */
53+
#define BBR_BB_WAIT 0x0004 /**< Wait backbone availability before starting Wi-SUN network */
54+
#define BBR_DEFAULT_ROUTE 0x0008 /**< Add default route parameter to DIO */
5955

6056
/**
6157
* Configure border router features.

features/nanostack/sal-stack-nanostack/source/6LoWPAN/Bootstraps/Generic/protocol_6lowpan_bootstrap.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1379,6 +1379,8 @@ static int8_t arm_6lowpan_bootstrap_down(protocol_interface_info_entry_t *cur)
13791379
}
13801380
cur->if_lowpan_security_params->mle_security_frame_counter = mle_service_security_get_frame_counter(cur->id);
13811381
mle_service_interface_receiver_handler_update(cur->id, mle_6lowpan_message_handler);
1382+
// Reset MAC for safe upper layer memory free
1383+
protocol_mac_reset(cur);
13821384
return nwk_6lowpan_down(cur);
13831385
}
13841386
#ifdef HAVE_6LOWPAN_ND
@@ -1593,7 +1595,7 @@ static void lowpan_neighbor_entry_remove_notify(mac_neighbor_table_entry_t *entr
15931595
{
15941596

15951597
protocol_interface_info_entry_t *cur_interface = user_data;
1596-
lowpan_adaptation_remove_free_indirect_table(cur_interface, entry_ptr);
1598+
lowpan_adaptation_neigh_remove_free_tx_tables(cur_interface, entry_ptr);
15971599
// Sleepy host
15981600
if (cur_interface->lowpan_info & INTERFACE_NWK_CONF_MAC_RX_OFF_IDLE) {
15991601
mac_data_poll_protocol_poll_mode_decrement(cur_interface);

0 commit comments

Comments
 (0)