gnrc_lwmac: enable duty-cycle printing.
This commit is contained in:
parent
d3f8739a1e
commit
4a4e552cca
@ -90,14 +90,6 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
#define GNRC_LWMAC_RADIO_IS_ON (0x04)
|
#define GNRC_LWMAC_RADIO_IS_ON (0x04)
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enable/disable duty-cycle record and print out.
|
|
||||||
* Set "1" to enable, set "0" to disable.
|
|
||||||
*/
|
|
||||||
#ifndef GNRC_LWMAC_ENABLE_DUTYCYLE_RECORD
|
|
||||||
#define GNRC_LWMAC_ENABLE_DUTYCYLE_RECORD (0U)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The default largest number of parallel timeouts in LWMAC
|
* @brief The default largest number of parallel timeouts in LWMAC
|
||||||
*/
|
*/
|
||||||
@ -204,7 +196,7 @@ typedef struct lwmac {
|
|||||||
uint8_t lwmac_info; /**< LWMAC's internal informations (flags) */
|
uint8_t lwmac_info; /**< LWMAC's internal informations (flags) */
|
||||||
gnrc_lwmac_timeout_t timeouts[GNRC_LWMAC_TIMEOUT_COUNT]; /**< Store timeouts used for protocol */
|
gnrc_lwmac_timeout_t timeouts[GNRC_LWMAC_TIMEOUT_COUNT]; /**< Store timeouts used for protocol */
|
||||||
|
|
||||||
#if (GNRC_LWMAC_ENABLE_DUTYCYLE_RECORD == 1)
|
#if (GNRC_MAC_ENABLE_DUTYCYCLE_RECORD == 1)
|
||||||
/* Parameters for recording duty-cycle */
|
/* Parameters for recording duty-cycle */
|
||||||
uint32_t last_radio_on_time_ticks; /**< The last time in ticks when radio is on */
|
uint32_t last_radio_on_time_ticks; /**< The last time in ticks when radio is on */
|
||||||
uint32_t radio_off_time_ticks; /**< The time in ticks when radio is off */
|
uint32_t radio_off_time_ticks; /**< The time in ticks when radio is off */
|
||||||
|
|||||||
@ -266,14 +266,6 @@ void lwmac_set_state(gnrc_netif_t *netif, gnrc_lwmac_state_t newstate)
|
|||||||
case GNRC_LWMAC_TRANSMITTING: {
|
case GNRC_LWMAC_TRANSMITTING: {
|
||||||
/* Enable duty cycling again */
|
/* Enable duty cycling again */
|
||||||
rtt_handler(GNRC_LWMAC_EVENT_RTT_RESUME, netif);
|
rtt_handler(GNRC_LWMAC_EVENT_RTT_RESUME, netif);
|
||||||
#if (GNRC_LWMAC_ENABLE_DUTYCYLE_RECORD == 1)
|
|
||||||
/* Output duty-cycle ratio */
|
|
||||||
uint64_t duty;
|
|
||||||
duty = (uint64_t) rtt_get_counter();
|
|
||||||
duty = ((uint64_t) netif->mac.prot.lwmac.awake_duration_sum_ticks) * 100 /
|
|
||||||
(duty - (uint64_t)netif->mac.prot.lwmac.system_start_time_ticks);
|
|
||||||
printf("[LWMAC]: achieved duty-cycle: %lu %% \n", (uint32_t)duty);
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GNRC_LWMAC_SLEEPING: {
|
case GNRC_LWMAC_SLEEPING: {
|
||||||
@ -880,7 +872,16 @@ static void _lwmac_msg_handler(gnrc_netif_t *netif, msg_t *msg)
|
|||||||
lwmac_schedule_update(netif);
|
lwmac_schedule_update(netif);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#if (GNRC_MAC_ENABLE_DUTYCYCLE_RECORD == 1)
|
||||||
|
case GNRC_MAC_TYPE_GET_DUTYCYCLE: {
|
||||||
|
/* Output LWMAC's radio duty-cycle ratio */
|
||||||
|
uint64_t duty = (uint64_t) rtt_get_counter();
|
||||||
|
duty = ((uint64_t) netif->mac.prot.lwmac.awake_duration_sum_ticks) * 100 /
|
||||||
|
(duty - (uint64_t)netif->mac.prot.lwmac.system_start_time_ticks);
|
||||||
|
printf("[LWMAC]: achieved radio duty-cycle: %u %% \n", (unsigned) duty);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
default: {
|
default: {
|
||||||
#if ENABLE_DEBUG
|
#if ENABLE_DEBUG
|
||||||
DEBUG("[LWMAC]: unknown message type 0x%04x"
|
DEBUG("[LWMAC]: unknown message type 0x%04x"
|
||||||
@ -933,7 +934,7 @@ static void _lwmac_init(gnrc_netif_t *netif)
|
|||||||
/* Start duty cycling */
|
/* Start duty cycling */
|
||||||
lwmac_set_state(netif, GNRC_LWMAC_START);
|
lwmac_set_state(netif, GNRC_LWMAC_START);
|
||||||
|
|
||||||
#if (GNRC_LWMAC_ENABLE_DUTYCYLE_RECORD == 1)
|
#if (GNRC_MAC_ENABLE_DUTYCYCLE_RECORD == 1)
|
||||||
/* Start duty cycle recording */
|
/* Start duty cycle recording */
|
||||||
netif->mac.prot.lwmac.system_start_time_ticks = rtt_get_counter();
|
netif->mac.prot.lwmac.system_start_time_ticks = rtt_get_counter();
|
||||||
netif->mac.prot.lwmac.last_radio_on_time_ticks = netif->mac.prot.lwmac.system_start_time_ticks;
|
netif->mac.prot.lwmac.last_radio_on_time_ticks = netif->mac.prot.lwmac.system_start_time_ticks;
|
||||||
|
|||||||
@ -191,7 +191,7 @@ void _gnrc_lwmac_set_netdev_state(gnrc_netif_t *netif, netopt_state_t devstate)
|
|||||||
&devstate,
|
&devstate,
|
||||||
sizeof(devstate));
|
sizeof(devstate));
|
||||||
|
|
||||||
#if (GNRC_LWMAC_ENABLE_DUTYCYLE_RECORD == 1)
|
#if (GNRC_MAC_ENABLE_DUTYCYCLE_RECORD == 1)
|
||||||
if (devstate == NETOPT_STATE_IDLE) {
|
if (devstate == NETOPT_STATE_IDLE) {
|
||||||
if (!(netif->mac.prot.lwmac.lwmac_info & GNRC_LWMAC_RADIO_IS_ON)) {
|
if (!(netif->mac.prot.lwmac.lwmac_info & GNRC_LWMAC_RADIO_IS_ON)) {
|
||||||
netif->mac.prot.lwmac.last_radio_on_time_ticks = rtt_get_counter();
|
netif->mac.prot.lwmac.last_radio_on_time_ticks = rtt_get_counter();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user