mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #13894 from noonfom/fix_compilation_warnings
Fix compilation warningspull/13904/head
commit
d5b4f42fcd
|
@ -164,6 +164,8 @@ static const phy_device_channel_page_s phy_channel_pages[] = {
|
||||||
{ CHANNEL_PAGE_0, NULL}
|
{ CHANNEL_PAGE_0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
using namespace mbed;
|
using namespace mbed;
|
||||||
using namespace rtos;
|
using namespace rtos;
|
||||||
|
|
||||||
|
@ -196,7 +198,7 @@ static Se2435Pins *se2435_pa_pins = NULL;
|
||||||
|
|
||||||
static uint32_t rf_get_timestamp(void)
|
static uint32_t rf_get_timestamp(void)
|
||||||
{
|
{
|
||||||
return (uint32_t)rf->tx_timer.read_us();
|
return (uint32_t)rf->tx_timer.elapsed_time().count();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rf_lock(void)
|
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
|
||||||
mac_tx_handle = tx_handle;
|
mac_tx_handle = tx_handle;
|
||||||
|
|
||||||
if (tx_time) {
|
if (tx_time) {
|
||||||
uint32_t backoff_time = tx_time - rf_get_timestamp();
|
std::chrono::microseconds backoff_time(tx_time - rf_get_timestamp());
|
||||||
// Max. time to TX can be 65ms, otherwise time has passed already -> send immediately
|
// Max. time to TX can be 65ms, otherwise time has passed already -> send immediately
|
||||||
if (backoff_time <= 65000) {
|
if (backoff_time <= 65ms) {
|
||||||
rf->cca_timer.attach_us(rf_csma_ca_timer_signal, backoff_time);
|
rf->cca_timer.attach(rf_csma_ca_timer_signal, backoff_time);
|
||||||
TEST_CSMA_STARTED
|
TEST_CSMA_STARTED
|
||||||
rf_unlock();
|
rf_unlock();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Short timeout to start CCA immediately.
|
// Short timeout to start CCA immediately.
|
||||||
rf->cca_timer.attach_us(rf_csma_ca_timer_signal, 1);
|
rf->cca_timer.attach(rf_csma_ca_timer_signal, 1us);
|
||||||
TEST_CSMA_STARTED
|
TEST_CSMA_STARTED
|
||||||
rf_unlock();
|
rf_unlock();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -607,12 +609,12 @@ static void rf_handle_cca_ed_done(void)
|
||||||
if (cca_prepare_status == PHY_RESTART_CSMA) {
|
if (cca_prepare_status == PHY_RESTART_CSMA) {
|
||||||
device_driver.phy_tx_done_cb(rf_radio_driver_id, mac_tx_handle, PHY_LINK_CCA_OK, 0, 0);
|
device_driver.phy_tx_done_cb(rf_radio_driver_id, mac_tx_handle, PHY_LINK_CCA_OK, 0, 0);
|
||||||
if (tx_time) {
|
if (tx_time) {
|
||||||
uint32_t backoff_time = tx_time - rf_get_timestamp();
|
std::chrono::microseconds backoff_time(tx_time - rf_get_timestamp());
|
||||||
// Max. time to TX can be 65ms, otherwise time has passed already -> send immediately
|
// Max. time to TX can be 65ms, otherwise time has passed already -> send immediately
|
||||||
if (backoff_time > 65000) {
|
if (backoff_time > 65ms) {
|
||||||
backoff_time = 1;
|
backoff_time = 1us;
|
||||||
}
|
}
|
||||||
rf->cca_timer.attach_us(rf_csma_ca_timer_signal, backoff_time);
|
rf->cca_timer.attach(rf_csma_ca_timer_signal, backoff_time);
|
||||||
TEST_CSMA_STARTED
|
TEST_CSMA_STARTED
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -994,7 +996,7 @@ static uint32_t rf_backup_timer_start(uint16_t bytes, uint32_t time_us)
|
||||||
time_us = (uint32_t)(8000000 / phy_current_config.datarate) * bytes + PACKET_PROCESSING_TIME;
|
time_us = (uint32_t)(8000000 / phy_current_config.datarate) * bytes + PACKET_PROCESSING_TIME;
|
||||||
}
|
}
|
||||||
// Using cal_timer as backup timer
|
// Using cal_timer as backup timer
|
||||||
rf->cal_timer.attach_us(rf_backup_timer_signal, time_us);
|
rf->cal_timer.attach(rf_backup_timer_signal, std::chrono::microseconds(time_us));
|
||||||
|
|
||||||
return (rf_get_timestamp() + time_us);
|
return (rf_get_timestamp() + time_us);
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,10 +102,13 @@ typedef struct secure_session {
|
||||||
} secure_session_t;
|
} secure_session_t;
|
||||||
|
|
||||||
static NS_LIST_DEFINE(secure_session_list, secure_session_t, link);
|
static NS_LIST_DEFINE(secure_session_list, secure_session_t, link);
|
||||||
|
|
||||||
|
#ifdef COAP_SECURITY_AVAILABLE
|
||||||
static int secure_session_sendto(int8_t socket_id, void *handle, const void *buf, size_t len);
|
static int secure_session_sendto(int8_t socket_id, void *handle, const void *buf, size_t len);
|
||||||
static int secure_session_recvfrom(int8_t socket_id, unsigned char *buf, size_t len);
|
static int secure_session_recvfrom(int8_t socket_id, unsigned char *buf, size_t len);
|
||||||
static void start_timer(int8_t timer_id, uint32_t int_ms, uint32_t fin_ms);
|
static void start_timer(int8_t timer_id, uint32_t int_ms, uint32_t fin_ms);
|
||||||
static int timer_status(int8_t timer_id);
|
static int timer_status(int8_t timer_id);
|
||||||
|
#endif //COAP_SECURITY_AVAILABLE
|
||||||
|
|
||||||
static secure_session_t *secure_session_find_by_timer_id(int8_t timer_id)
|
static secure_session_t *secure_session_find_by_timer_id(int8_t timer_id)
|
||||||
{
|
{
|
||||||
|
@ -237,7 +240,9 @@ static void clear_secure_sessions(internal_socket_t *this)
|
||||||
if (this) {
|
if (this) {
|
||||||
ns_list_foreach_safe(secure_session_t, cur_ptr, &secure_session_list) {
|
ns_list_foreach_safe(secure_session_t, cur_ptr, &secure_session_list) {
|
||||||
if (cur_ptr->parent == this) {
|
if (cur_ptr->parent == this) {
|
||||||
|
#ifdef COAP_SECURITY_AVAILABLE
|
||||||
coap_security_send_close_alert(cur_ptr->sec_handler);
|
coap_security_send_close_alert(cur_ptr->sec_handler);
|
||||||
|
#endif //COAP_SECURITY_AVAILABLE
|
||||||
secure_session_delete(cur_ptr);
|
secure_session_delete(cur_ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -430,6 +435,7 @@ static int send_to_real_socket(int8_t socket_id, const ns_address_t *address, co
|
||||||
return socket_sendmsg(socket_id, &msghdr, 0);
|
return socket_sendmsg(socket_id, &msghdr, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef COAP_SECURITY_AVAILABLE
|
||||||
static int secure_session_sendto(int8_t socket_id, void *handle, const void *buf, size_t len)
|
static int secure_session_sendto(int8_t socket_id, void *handle, const void *buf, size_t len)
|
||||||
{
|
{
|
||||||
secure_session_t *session = handle;
|
secure_session_t *session = handle;
|
||||||
|
@ -462,7 +468,9 @@ static int secure_session_sendto(int8_t socket_id, void *handle, const void *buf
|
||||||
}
|
}
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
#endif //COAP_SECURITY_AVAILABLE
|
||||||
|
|
||||||
|
#ifdef COAP_SECURITY_AVAILABLE
|
||||||
static int secure_session_recvfrom(int8_t socket_id, unsigned char *buf, size_t len)
|
static int secure_session_recvfrom(int8_t socket_id, unsigned char *buf, size_t len)
|
||||||
{
|
{
|
||||||
(void)len;
|
(void)len;
|
||||||
|
@ -477,6 +485,7 @@ static int secure_session_recvfrom(int8_t socket_id, unsigned char *buf, size_t
|
||||||
}
|
}
|
||||||
return MBEDTLS_ERR_SSL_WANT_READ;
|
return MBEDTLS_ERR_SSL_WANT_READ;
|
||||||
}
|
}
|
||||||
|
#endif //COAP_SECURITY_AVAILABLE
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback timer. Maybe called in interrupt context
|
* Callback timer. Maybe called in interrupt context
|
||||||
|
@ -516,6 +525,7 @@ static void timer_cb(void *param)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef COAP_SECURITY_AVAILABLE
|
||||||
static void start_timer(int8_t timer_id, uint32_t int_ms, uint32_t fin_ms)
|
static void start_timer(int8_t timer_id, uint32_t int_ms, uint32_t fin_ms)
|
||||||
{
|
{
|
||||||
secure_session_t *sec = secure_session_find_by_timer_id(timer_id);
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif //COAP_SECURITY_AVAILABLE
|
||||||
|
|
||||||
|
#ifdef COAP_SECURITY_AVAILABLE
|
||||||
static int timer_status(int8_t timer_id)
|
static int timer_status(int8_t timer_id)
|
||||||
{
|
{
|
||||||
secure_session_t *sec = secure_session_find_by_timer_id(timer_id);
|
secure_session_t *sec = secure_session_find_by_timer_id(timer_id);
|
||||||
|
@ -547,6 +559,7 @@ static int timer_status(int8_t timer_id)
|
||||||
}
|
}
|
||||||
return TIMER_STATE_CANCELLED;
|
return TIMER_STATE_CANCELLED;
|
||||||
}
|
}
|
||||||
|
#endif //COAP_SECURITY_AVAILABLE
|
||||||
|
|
||||||
static int read_data(socket_callback_t *sckt_data, internal_socket_t *sock, ns_address_t *src_address, uint8_t dst_address[static 16])
|
static int read_data(socket_callback_t *sckt_data, internal_socket_t *sock, ns_address_t *src_address, uint8_t dst_address[static 16])
|
||||||
{
|
{
|
||||||
|
@ -872,7 +885,9 @@ void connection_handler_close_secure_connection(coap_conn_handler_t *handler, ui
|
||||||
if (handler->socket && handler->socket->is_secure) {
|
if (handler->socket && handler->socket->is_secure) {
|
||||||
secure_session_t *session = secure_session_find(handler->socket, destination_addr_ptr, port);
|
secure_session_t *session = secure_session_find(handler->socket, destination_addr_ptr, port);
|
||||||
if (session) {
|
if (session) {
|
||||||
|
#ifdef COAP_SECURITY_AVAILABLE
|
||||||
coap_security_send_close_alert(session->sec_handler);
|
coap_security_send_close_alert(session->sec_handler);
|
||||||
|
#endif //COAP_SECURITY_AVAILABLE
|
||||||
session->session_state = SECURE_SESSION_CLOSED;
|
session->session_state = SECURE_SESSION_CLOSED;
|
||||||
session->last_contact_time = coap_service_get_internal_timer_ticks();
|
session->last_contact_time = coap_service_get_internal_timer_ticks();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue