55#ifdef TSCH_STATS_CONF_ON
56#define TSCH_STATS_ON TSCH_STATS_CONF_ON
58#define TSCH_STATS_ON 0
62#ifdef TSCH_STATS_CONF_SAMPLE_NOISE_RSSI
63#define TSCH_STATS_SAMPLE_NOISE_RSSI TSCH_STATS_CONF_SAMPLE_NOISE_RSSI
65#define TSCH_STATS_SAMPLE_NOISE_RSSI 0
72#ifdef TSCH_STATS_CONF_EWMA_UPDATE
73#define TSCH_STATS_EWMA_UPDATE TSCH_STATS_CONF_EWMA_UPDATE
75#define TSCH_STATS_EWMA_UPDATE(x, v) (x) = (((x) * 7 / 8) + (v) / 8)
82#ifdef TSCH_STATS_CONF_BUSY_CHANNEL_RSSI
83#define TSCH_STATS_BUSY_CHANNEL_RSSI TSCH_STATS_CONF_BUSY_CHANNEL_RSSI
85#define TSCH_STATS_BUSY_CHANNEL_RSSI -85
89#ifdef TSCH_STATS_CONF_DECAY_INTERVAL
90#define TSCH_STATS_DECAY_INTERVAL TSCH_STATS_CONF_DECAY_INTERVAL
92#define TSCH_STATS_DECAY_INTERVAL (20ul * 60 * CLOCK_SECOND)
99#ifdef TSCH_STATS_CONF_NUM_CHANNELS
100#define TSCH_STATS_NUM_CHANNELS TSCH_STATS_CONF_NUM_CHANNELS
102#define TSCH_STATS_NUM_CHANNELS 16
106#ifdef TSCH_STATS_CONF_FIRST_CHANNEL
107#define TSCH_STATS_FIRST_CHANNEL TSCH_STATS_CONF_FIRST_CHANNEL
109#define TSCH_STATS_FIRST_CHANNEL 11
113#define TSCH_STATS_RSSI_SCALING_FACTOR -16
114#define TSCH_STATS_LQI_SCALING_FACTOR 16
115#define TSCH_STATS_BINARY_SCALING_FACTOR 4096
121#define TSCH_STATS_TRANSFORM(x, factor) ((int16_t)(x) * factor)
124#define TSCH_STATS_DEFAULT_RSSI TSCH_STATS_TRANSFORM(-90, TSCH_STATS_RSSI_SCALING_FACTOR)
126#define TSCH_STATS_DEFAULT_LQI TSCH_STATS_TRANSFORM(100, TSCH_STATS_LQI_SCALING_FACTOR)
128#define TSCH_STATS_DEFAULT_P_TX (TSCH_STATS_BINARY_SCALING_FACTOR / 2)
130#define TSCH_STATS_DEFAULT_CHANNEL_FREE TSCH_STATS_BINARY_SCALING_FACTOR
139typedef uint16_t tsch_stat_t;
141struct tsch_global_stats {
143 uint32_t max_sync_error;
145 uint16_t num_disassociations;
146#if TSCH_STATS_SAMPLE_NOISE_RSSI
148 tsch_stat_t noise_rssi[TSCH_STATS_NUM_CHANNELS];
150 tsch_stat_t channel_free_ewma[TSCH_STATS_NUM_CHANNELS];
154struct tsch_channel_stats {
160 tsch_stat_t p_tx_success;
163struct tsch_neighbor_stats {
164 struct tsch_channel_stats channel_stats[TSCH_STATS_NUM_CHANNELS];
175extern struct tsch_global_stats tsch_stats;
178extern struct tsch_neighbor_stats tsch_neighbor_stats;
183void tsch_stats_init(
void);
185void tsch_stats_tx_packet(
struct tsch_neighbor *, uint8_t mac_status, uint8_t channel);
187void tsch_stats_rx_packet(
struct tsch_neighbor *, int8_t rssi, uint8_t lqi, uint8_t channel);
189void tsch_stats_on_time_synchronization(int32_t sync_error);
191void tsch_stats_sample_rssi(
void);
193struct tsch_neighbor_stats *tsch_stats_get_from_neighbor(
struct tsch_neighbor *);
195void tsch_stats_reset_neighbor_stats(
void);
199#define tsch_stats_init()
200#define tsch_stats_tx_packet(n, mac_status, channel)
201#define tsch_stats_rx_packet(n, rssi, lqi, channel)
202#define tsch_stats_on_time_synchronization(sync_error)
203#define tsch_stats_sample_rssi()
204#define tsch_stats_get_from_neighbor(neighbor) NULL
205#define tsch_stats_reset_neighbor_stats()
210tsch_stats_channel_to_index(uint8_t channel)
212 return channel - TSCH_STATS_FIRST_CHANNEL;
216tsch_stats_index_to_channel(uint8_t channel_index)
218 return channel_index + TSCH_STATS_FIRST_CHANNEL;
Header file for the link-layer address representation.
TSCH neighbor information.