/* * \brief Starts slotted CSMA */ bool slotted_csma_start(bool perform_frame_retry) { PIN_CSMA_START(); /* debug pin to switch on: define ENABLE_DEBUG_PINS, * pal_config.h */ bool return_val = false; /* Assume error case */ if (check_beacon_reception()) { tal_state = TAL_SLOTTED_CSMA; csma_param_init(); if (perform_frame_retry) { number_of_tx_retries = 0; } else { /* Use the max value to indicate that no retries are * required. */ number_of_tx_retries = tal_pib.MaxFrameRetries; } calculate_transaction_duration(); /* Get a random backoff period duration. */ remaining_backoff_periods = (uint8_t)(rand() & ((1 << BE) - 1)); csma_backoff_calculation(); return_val = true; } return return_val; }
/** * @brief Starts slotted CSMA */ void slotted_csma_start(bool perform_frame_retry) { PIN_CSMA_START(); // debug pin to switch on: define ENABLE_DEBUG_PINS, pal_config.h tal_state = TAL_SLOTTED_CSMA; if (check_beacon_reception() == false) { tal_csma_state = NO_BEACON_TRACKING; return; } csma_param_init(); if (perform_frame_retry) { number_of_tx_retries = 0; } else { // use the max value to indicate that no retries are required number_of_tx_retries = tal_pib_MaxFrameRetries; } calculate_transaction_duration(); /* Get a random backoff period duration. */ remaining_backoff_periods = (uint8_t)(rand() & ((1 << BE) - 1)); csma_backoff_calculation(); }