Skip to content

Commit d5b4f42

Browse files
authored
Merge pull request #13894 from noonfom/fix_compilation_warnings
Fix compilation warnings
2 parents a937a43 + 3e6cf78 commit d5b4f42

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

connectivity/drivers/802.15.4_RF/atmel-rf-driver/source/NanostackRfPhyAT86RF215.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ static const phy_device_channel_page_s phy_channel_pages[] = {
164164
{ CHANNEL_PAGE_0, NULL}
165165
};
166166

167+
using namespace std::chrono_literals;
168+
167169
using namespace mbed;
168170
using namespace rtos;
169171

@@ -196,7 +198,7 @@ static Se2435Pins *se2435_pa_pins = NULL;
196198

197199
static uint32_t rf_get_timestamp(void)
198200
{
199-
return (uint32_t)rf->tx_timer.read_us();
201+
return (uint32_t)rf->tx_timer.elapsed_time().count();
200202
}
201203

202204
static void rf_lock(void)
@@ -564,17 +566,17 @@ static int8_t rf_start_csma_ca(uint8_t *data_ptr, uint16_t data_length, uint8_t
564566
mac_tx_handle = tx_handle;
565567

566568
if (tx_time) {
567-
uint32_t backoff_time = tx_time - rf_get_timestamp();
569+
std::chrono::microseconds backoff_time(tx_time - rf_get_timestamp());
568570
// Max. time to TX can be 65ms, otherwise time has passed already -> send immediately
569-
if (backoff_time <= 65000) {
570-
rf->cca_timer.attach_us(rf_csma_ca_timer_signal, backoff_time);
571+
if (backoff_time <= 65ms) {
572+
rf->cca_timer.attach(rf_csma_ca_timer_signal, backoff_time);
571573
TEST_CSMA_STARTED
572574
rf_unlock();
573575
return 0;
574576
}
575577
}
576578
// Short timeout to start CCA immediately.
577-
rf->cca_timer.attach_us(rf_csma_ca_timer_signal, 1);
579+
rf->cca_timer.attach(rf_csma_ca_timer_signal, 1us);
578580
TEST_CSMA_STARTED
579581
rf_unlock();
580582
return 0;
@@ -607,12 +609,12 @@ static void rf_handle_cca_ed_done(void)
607609
if (cca_prepare_status == PHY_RESTART_CSMA) {
608610
device_driver.phy_tx_done_cb(rf_radio_driver_id, mac_tx_handle, PHY_LINK_CCA_OK, 0, 0);
609611
if (tx_time) {
610-
uint32_t backoff_time = tx_time - rf_get_timestamp();
612+
std::chrono::microseconds backoff_time(tx_time - rf_get_timestamp());
611613
// Max. time to TX can be 65ms, otherwise time has passed already -> send immediately
612-
if (backoff_time > 65000) {
613-
backoff_time = 1;
614+
if (backoff_time > 65ms) {
615+
backoff_time = 1us;
614616
}
615-
rf->cca_timer.attach_us(rf_csma_ca_timer_signal, backoff_time);
617+
rf->cca_timer.attach(rf_csma_ca_timer_signal, backoff_time);
616618
TEST_CSMA_STARTED
617619
}
618620
return;
@@ -994,7 +996,7 @@ static uint32_t rf_backup_timer_start(uint16_t bytes, uint32_t time_us)
994996
time_us = (uint32_t)(8000000 / phy_current_config.datarate) * bytes + PACKET_PROCESSING_TIME;
995997
}
996998
// Using cal_timer as backup timer
997-
rf->cal_timer.attach_us(rf_backup_timer_signal, time_us);
999+
rf->cal_timer.attach(rf_backup_timer_signal, std::chrono::microseconds(time_us));
9981000

9991001
return (rf_get_timestamp() + time_us);
10001002
}

connectivity/nanostack/coap-service/source/coap_connection_handler.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,13 @@ typedef struct secure_session {
102102
} secure_session_t;
103103

104104
static NS_LIST_DEFINE(secure_session_list, secure_session_t, link);
105+
106+
#ifdef COAP_SECURITY_AVAILABLE
105107
static int secure_session_sendto(int8_t socket_id, void *handle, const void *buf, size_t len);
106108
static int secure_session_recvfrom(int8_t socket_id, unsigned char *buf, size_t len);
107109
static void start_timer(int8_t timer_id, uint32_t int_ms, uint32_t fin_ms);
108110
static int timer_status(int8_t timer_id);
111+
#endif //COAP_SECURITY_AVAILABLE
109112

110113
static secure_session_t *secure_session_find_by_timer_id(int8_t timer_id)
111114
{
@@ -237,7 +240,9 @@ static void clear_secure_sessions(internal_socket_t *this)
237240
if (this) {
238241
ns_list_foreach_safe(secure_session_t, cur_ptr, &secure_session_list) {
239242
if (cur_ptr->parent == this) {
243+
#ifdef COAP_SECURITY_AVAILABLE
240244
coap_security_send_close_alert(cur_ptr->sec_handler);
245+
#endif //COAP_SECURITY_AVAILABLE
241246
secure_session_delete(cur_ptr);
242247
}
243248
}
@@ -430,6 +435,7 @@ static int send_to_real_socket(int8_t socket_id, const ns_address_t *address, co
430435
return socket_sendmsg(socket_id, &msghdr, 0);
431436
}
432437

438+
#ifdef COAP_SECURITY_AVAILABLE
433439
static int secure_session_sendto(int8_t socket_id, void *handle, const void *buf, size_t len)
434440
{
435441
secure_session_t *session = handle;
@@ -462,7 +468,9 @@ static int secure_session_sendto(int8_t socket_id, void *handle, const void *buf
462468
}
463469
return len;
464470
}
471+
#endif //COAP_SECURITY_AVAILABLE
465472

473+
#ifdef COAP_SECURITY_AVAILABLE
466474
static int secure_session_recvfrom(int8_t socket_id, unsigned char *buf, size_t len)
467475
{
468476
(void)len;
@@ -477,6 +485,7 @@ static int secure_session_recvfrom(int8_t socket_id, unsigned char *buf, size_t
477485
}
478486
return MBEDTLS_ERR_SSL_WANT_READ;
479487
}
488+
#endif //COAP_SECURITY_AVAILABLE
480489

481490
/**
482491
* Callback timer. Maybe called in interrupt context
@@ -516,6 +525,7 @@ static void timer_cb(void *param)
516525
}
517526
}
518527

528+
#ifdef COAP_SECURITY_AVAILABLE
519529
static void start_timer(int8_t timer_id, uint32_t int_ms, uint32_t fin_ms)
520530
{
521531
secure_session_t *sec = secure_session_find_by_timer_id(timer_id);
@@ -538,7 +548,9 @@ static void start_timer(int8_t timer_id, uint32_t int_ms, uint32_t fin_ms)
538548
}
539549
}
540550
}
551+
#endif //COAP_SECURITY_AVAILABLE
541552

553+
#ifdef COAP_SECURITY_AVAILABLE
542554
static int timer_status(int8_t timer_id)
543555
{
544556
secure_session_t *sec = secure_session_find_by_timer_id(timer_id);
@@ -547,6 +559,7 @@ static int timer_status(int8_t timer_id)
547559
}
548560
return TIMER_STATE_CANCELLED;
549561
}
562+
#endif //COAP_SECURITY_AVAILABLE
550563

551564
static int read_data(socket_callback_t *sckt_data, internal_socket_t *sock, ns_address_t *src_address, uint8_t dst_address[static 16])
552565
{
@@ -872,7 +885,9 @@ void connection_handler_close_secure_connection(coap_conn_handler_t *handler, ui
872885
if (handler->socket && handler->socket->is_secure) {
873886
secure_session_t *session = secure_session_find(handler->socket, destination_addr_ptr, port);
874887
if (session) {
888+
#ifdef COAP_SECURITY_AVAILABLE
875889
coap_security_send_close_alert(session->sec_handler);
890+
#endif //COAP_SECURITY_AVAILABLE
876891
session->session_state = SECURE_SESSION_CLOSED;
877892
session->last_contact_time = coap_service_get_internal_timer_ticks();
878893
}

0 commit comments

Comments
 (0)