fn init_protocol(&self) -> Result<Option<MessageHeader>, MeshSimError> {
        //Random startup delay to avoid high collisions
        let mut rng = self.rng.lock().expect("Failed to lock rng");
        let startup_delay: u64 = rng.gen_range(0..50);
        std::thread::sleep(Duration::from_millis(startup_delay));

        let wifi_tx_queue = self.wifi_tx_queue.clone();
        let self_peer = self.get_self_peer();
        let logger = self.logger.clone();
        let link = String::from("wifi");
        let _wifi_beacon_handle = thread::spawn(move || {
            let _ = LoraWifiBeacon::beacon_loop(
                wifi_tx_queue,
                WIFI_BEACON_TIMEOUT,
                self_peer,
                link,
                logger,
            );
        });

        let lora_tx_queue = self.lora_tx_queue.clone();
        let self_peer = self.get_self_peer();
        let logger = self.logger.clone();
        let link = String::from("lora");
        let _lora_beacon_handle = thread::spawn(move || {
            // let initial_offset: u64 = thread_rng().next_u64() % 3_000u64;
            // thread::sleep(Duration::from_millis(initial_offset));
            let _ = LoraWifiBeacon::beacon_loop(
                lora_tx_queue,
                LORA_BEACON_TIMEOUT,
                self_peer,
                link,
                logger,
            );
        });
        Ok(None)
    }
/// Function to initialize the protocol.
Function to initialize the protocol.
Function to initialize the protocol .
fn init_protocol(&self) -> Result<Option<MessageHeader>, MeshSimError> {
        //Random startup delay to avoid high collisions
        let mut rng = self.rng.lock().expect("Failed to lock rng");
        let startup_delay: u64 = rng.gen_range(0..50);
        std::thread::sleep(Duration::from_millis(startup_delay));
        let wifi_tx_queue = self.wifi_tx_queue.clone();
        let self_peer = self.get_self_peer();
        let logger = self.logger.clone();
        let link = String::from("wifi");
        let _wifi_beacon_handle = thread::spawn(move || {
            let _ = LoraWifiBeacon::beacon_loop(
                wifi_tx_queue,
                WIFI_BEACON_TIMEOUT,
                self_peer,
                link,
                logger,
            );
        });
        let lora_tx_queue = self.lora_tx_queue.clone();
        let self_peer = self.get_self_peer();
        let logger = self.logger.clone();
        let link = String::from("lora");
        let _lora_beacon_handle = thread::spawn(move || {
            // let initial_offset: u64 = thread_rng().next_u64() % 3_000u64;
            // thread::sleep(Duration::from_millis(initial_offset));
            let _ = LoraWifiBeacon::beacon_loop(
                lora_tx_queue,
                LORA_BEACON_TIMEOUT,
                self_peer,
                link,
                logger,
            );
        });
        Ok(None)
    }
fn init_protocol ( & self ) -> Result < Option < MessageHeader > , MeshSimError > { //Random startup delay to avoid high collisions let mut rng = self . rng . lock ( ) . expect ( " " ) ; let startup_delay : u64 = rng . gen_range ( 0 .. 50 ) ; std :: thread :: sleep ( Duration :: from_millis ( startup_delay ) ) ; let wifi_tx_queue = self . wifi_tx_queue . clone ( ) ; let self_peer = self . get_self_peer ( ) ; let logger = self . logger . clone ( ) ; let link = String :: from ( " " ) ; let _wifi_beacon_handle = thread :: spawn ( move | | { let _ = LoraWifiBeacon :: beacon_loop ( wifi_tx_queue , WIFI_BEACON_TIMEOUT , self_peer , link , logger , ) ; } ) ; let lora_tx_queue = self . lora_tx_queue . clone ( ) ; let self_peer = self . get_self_peer ( ) ; let logger = self . logger . clone ( ) ; let link = String :: from ( " " ) ; let _lora_beacon_handle = thread :: spawn ( move | | { // let initial_offset: u64 = thread_rng().next_u64() % 3_000u64; // thread::sleep(Duration::from_millis(initial_offset)); let _ = LoraWifiBeacon :: beacon_loop ( lora_tx_queue , LORA_BEACON_TIMEOUT , self_peer , link , logger , ) ; } ) ; Ok ( None ) }
Function to initialize the protocol.
Function to initialize the protocol .
&self