pub async fn report_telemetry_periodically(ifaces_map: Arc<IfaceMap>, mut sender: CobaltSender) {
    // TODO(NET-1386): Make this module resilient to Wlanstack2 downtime.

    let mut last_reported_stats: HashMap<u16, StatsRef> = HashMap::new();
    let mut interval_stream = fasync::Interval::new(REPORT_PERIOD_MINUTES.minutes());
    while let Some(_) = await!(interval_stream.next()) {
        let mut futures = FuturesUnordered::new();
        for (id, iface) in ifaces_map.get_snapshot().iter() {
            let id = *id;
            let iface = Arc::clone(iface);
            let fut = iface.stats_sched.get_stats().map(move |r| (id, iface, r));
            futures.push(fut);
        }

        while let Some((id, iface, stats_result)) = await!(futures.next()) {
            match stats_result {
                Ok(current_stats) => {
                    let last_stats_opt = last_reported_stats.get(&id);
                    if let Some(last_stats) = last_stats_opt {
                        let last_stats = last_stats.lock();
                        let current_stats = current_stats.lock();
                        report_stats(&last_stats, &current_stats, &mut sender);
                    }

                    last_reported_stats.insert(id, current_stats);
                }
                Err(e) => {
                    last_reported_stats.remove(&id);
                    error!(
                        "Failed to get the stats for iface '{:?}': {}",
                        match &iface.device {
                            Some(device) => device.path().to_string_lossy().into_owned(),
                            None => "TODO(WLAN-927)".to_string(),
                        },
                        e
                    );
                }
            };
        }
    }
}
// Export MLME stats to Cobalt every REPORT_PERIOD_MINUTES.
Export MLME stats to Cobalt every REPORT_PERIOD_MINUTES.
Export MLME stats to Cobalt every REPORT_PERIOD_MINUTES .
pub async fn report_telemetry_periodically(ifaces_map: Arc<IfaceMap>, mut sender: CobaltSender) {
    // TODO(NET-1386): Make this module resilient to Wlanstack2 downtime.
    let mut last_reported_stats: HashMap<u16, StatsRef> = HashMap::new();
    let mut interval_stream = fasync::Interval::new(REPORT_PERIOD_MINUTES.minutes());
    while let Some(_) = await!(interval_stream.next()) {
        let mut futures = FuturesUnordered::new();
        for (id, iface) in ifaces_map.get_snapshot().iter() {
            let id = *id;
            let iface = Arc::clone(iface);
            let fut = iface.stats_sched.get_stats().map(move |r| (id, iface, r));
            futures.push(fut);
        }
        while let Some((id, iface, stats_result)) = await!(futures.next()) {
            match stats_result {
                Ok(current_stats) => {
                    let last_stats_opt = last_reported_stats.get(&id);
                    if let Some(last_stats) = last_stats_opt {
                        let last_stats = last_stats.lock();
                        let current_stats = current_stats.lock();
                        report_stats(&last_stats, &current_stats, &mut sender);
                    }
                    last_reported_stats.insert(id, current_stats);
                }
                Err(e) => {
                    last_reported_stats.remove(&id);
                    error!(
                        "Failed to get the stats for iface '{:?}': {}",
                        match &iface.device {
                            Some(device) => device.path().to_string_lossy().into_owned(),
                            None => "TODO(WLAN-927)".to_string(),
                        },
                        e
                    );
                }
            };
        }
    }
}
pub async fn report_telemetry_periodically ( ifaces_map : Arc < IfaceMap > , mut sender : CobaltSender ) { // TODO(NET-1386): Make this module resilient to Wlanstack2 downtime. let mut last_reported_stats : HashMap < u16 , StatsRef > = HashMap :: new ( ) ; let mut interval_stream = fasync :: Interval :: new ( REPORT_PERIOD_MINUTES . minutes ( ) ) ; while let Some ( _ ) = await ! ( interval_stream next ( ) ) { let mut futures = FuturesUnordered :: new ( ) ; for ( id , iface ) in ifaces_map . get_snapshot ( ) . iter ( ) { let id = * id ; let iface = Arc :: clone ( iface ) ; let fut = iface . stats_sched . get_stats ( ) . map ( move | r | ( id , iface , r ) ) ; futures . push ( fut ) ; } while let Some ( ( id , iface , stats_result ) ) = await ! ( futures next ( ) ) { match stats_result { Ok ( current_stats ) => { let last_stats_opt = last_reported_stats . get ( & id ) ; if let Some ( last_stats ) = last_stats_opt { let last_stats = last_stats . lock ( ) ; let current_stats = current_stats . lock ( ) ; report_stats ( & last_stats , & current_stats , & mut sender ) ; } last_reported_stats . insert ( id , current_stats ) ; } Err ( e ) => { last_reported_stats . remove ( & id ) ; error ! ( " " match iface device { Some ( device ) device path ( ) to_string_lossy ( ) into_owned ( ) None " " to_string ( ) } e ) ; } } ; } } }
Export MLME stats to Cobalt every REPORT_PERIOD_MINUTES.
Export MLME stats to Cobalt every REPORT_PERIOD_MINUTES .
ifaces_map
Arc<IfaceMap>
sender
CobaltSender
ifaces_map
Arc<IfaceMap>
sender
CobaltSender