From 9fb7e8bfed6bab8d7543c95ef4192fd83c6c9b83 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Fri, 28 Sep 2018 16:12:28 +0200 Subject: [PATCH] TSCH: cleanup flags for CCA configuration --- os/net/mac/tsch/tsch-conf.h | 10 ++++++++++ os/net/mac/tsch/tsch-slot-operation.c | 8 ++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/os/net/mac/tsch/tsch-conf.h b/os/net/mac/tsch/tsch-conf.h index 8613eb0e3..a6e1bc768 100644 --- a/os/net/mac/tsch/tsch-conf.h +++ b/os/net/mac/tsch/tsch-conf.h @@ -365,18 +365,21 @@ /******** Configuration: CSMA *******/ /* TSCH CSMA-CA parameters, see IEEE 802.15.4e-2012 */ + /* Min backoff exponent */ #ifdef TSCH_CONF_MAC_MIN_BE #define TSCH_MAC_MIN_BE TSCH_CONF_MAC_MIN_BE #else #define TSCH_MAC_MIN_BE 1 #endif + /* Max backoff exponent */ #ifdef TSCH_CONF_MAC_MAX_BE #define TSCH_MAC_MAX_BE TSCH_CONF_MAC_MAX_BE #else #define TSCH_MAC_MAX_BE 5 #endif + /* Max number of re-transmissions */ #ifdef TSCH_CONF_MAC_MAX_FRAME_RETRIES #define TSCH_MAC_MAX_FRAME_RETRIES TSCH_CONF_MAC_MAX_FRAME_RETRIES @@ -391,6 +394,13 @@ #define TSCH_PACKET_EACK_WITH_SRC_ADDR 0 #endif +/* Perform CCA before sending? */ +#ifdef TSCH_CONF_CCA_ENABLED +#define TSCH_CCA_ENABLED TSCH_CONF_CCA_ENABLED +#else +#define TSCH_CCA_ENABLED 0 +#endif + /* Include destination address in ACK? */ #ifdef TSCH_PACKET_CONF_EACK_WITH_DEST_ADDR #define TSCH_PACKET_EACK_WITH_DEST_ADDR TSCH_PACKET_CONF_EACK_WITH_DEST_ADDR diff --git a/os/net/mac/tsch/tsch-slot-operation.c b/os/net/mac/tsch/tsch-slot-operation.c index 843b79f42..74ab6b46e 100644 --- a/os/net/mac/tsch/tsch-slot-operation.c +++ b/os/net/mac/tsch/tsch-slot-operation.c @@ -464,9 +464,9 @@ PT_THREAD(tsch_tx_slot(struct pt *pt, struct rtimer *t)) /* Did we set the frame pending bit to request an extra burst link? */ static int burst_link_requested; -#if CCA_ENABLED +#if TSCH_CCA_ENABLED static uint8_t cca_status; -#endif +#endif /* TSCH_CCA_ENABLED */ /* get payload */ packet = queuebuf_dataptr(current_packet->qb); @@ -507,7 +507,7 @@ PT_THREAD(tsch_tx_slot(struct pt *pt, struct rtimer *t)) if(packet_ready && NETSTACK_RADIO.prepare(packet, packet_len) == 0) { /* 0 means success */ static rtimer_clock_t tx_duration; -#if CCA_ENABLED +#if TSCH_CCA_ENABLED cca_status = 1; /* delay before CCA */ TSCH_SCHEDULE_AND_YIELD(pt, t, current_slot_start, TS_CCA_OFFSET, "cca"); @@ -522,7 +522,7 @@ PT_THREAD(tsch_tx_slot(struct pt *pt, struct rtimer *t)) if(cca_status == 0) { mac_tx_status = MAC_TX_COLLISION; } else -#endif /* CCA_ENABLED */ +#endif /* TSCH_CCA_ENABLED */ { /* delay before TX */ TSCH_SCHEDULE_AND_YIELD(pt, t, current_slot_start, tsch_timing[tsch_ts_tx_offset] - RADIO_DELAY_BEFORE_TX, "TxBeforeTx");