/* * @brief Timer function at start of the inactive portion at an end device. * * This function is a callback from the superframe beacon timer for an * end deviceand implements the functionality required for entering the * inactive portion for an end device. * * @param callback_parameter Callback parameter of the superframe timer */ void mac_t_start_inactive_device_cb(void *callback_parameter) { /* * Go to sleep (independent of the value of macRxOnWhenIdle) * because we enter the incative portion now. * Note: Do not use mac_sleep_trans() here, because this would check * macRxOnWhenIdle first. */ mac_trx_init_sleep(); callback_parameter = callback_parameter; /* Keep compiler happy. */ }
/** * @brief Puts the radio to sleep if this is allowed */ void mac_sleep_trans(void) { /* Go to sleep? */ #ifdef BEACON_SUPPORT if ((NON_BEACON_NWK > tal_pib.BeaconOrder && MAC_INACTIVE == mac_superframe_state && (!mac_rx_enabled)) || (NON_BEACON_NWK == tal_pib.BeaconOrder && (!mac_pib.mac_RxOnWhenIdle) && (!mac_rx_enabled))) { #else /* BEACON_SUPPORT */ if ((!mac_pib.mac_RxOnWhenIdle) && (!mac_rx_enabled)) { #endif /* BEACON_SUPPORT */ #if (MAC_SYNC_REQUEST == 1) /* * In case we are currently synced with our parent, and the * tracking beacon timer it NOT running (i.e. the timer is * expired and not started again yet), we need to stay awake, * until we receive a new beacon frame form our parent. */ if ((MAC_SYNC_NEVER != mac_sync_state) && (!pal_is_timer_running(T_Beacon_Tracking_Period))) { /* Stays awake */ } else { mac_trx_init_sleep(); } #else mac_trx_init_sleep(); #endif /* (MAC_SYNC_REQUEST == 1) */ } } /* * @brief Flushes all queues */ static void flush_queues(void) { /* Flush NHLE MAC queue */ qmm_queue_flush(&nhle_mac_q); /* Flush TAL_MAC queue */ qmm_queue_flush(&tal_mac_q); #if (HIGHEST_STACK_LAYER == MAC) /* Flush MAC-NHLE queue */ qmm_queue_flush(&mac_nhle_q); #endif #ifdef GTS_SUPPORT /* Flush MAC GTS queue */ flush_gts_queues(); #endif /* GTS_SUPPORT */ #if (MAC_INDIRECT_DATA_FFD == 1) /* Flush MAC indirect queue */ qmm_queue_flush(&indirect_data_q); #endif /* (MAC_INDIRECT_DATA_FFD == 1) */ #if (MAC_START_REQUEST_CONFIRM == 1) #ifdef BEACON_SUPPORT /* Flush MAC broadcast queue */ qmm_queue_flush(&broadcast_q); #endif /* BEACON_SUPPORT */ #endif /* (MAC_START_REQUEST_CONFIRM == 1) */ }