async fn connect(&mut self) -> Result<()> {
        self.conn_state = ConnectionState::Connecting;

        let host_port = vec![
            self.config.server.clone(),
            ":".to_string(),
            self.config.port.to_string(),
        ]
        .join("");

        let addrs = smol::unblock(move || host_port.to_socket_addrs())
            .await?
            .collect::<Vec<_>>();
        let addr = *addrs.first().ok_or(BlynkError::Dns)?;

        info!("stream open start tp {:?}", addr);

        // opening async TcpStream connection does not work yet with esp-rs
        let blocking_stream =
            smol::unblock(move || TcpStream::connect_timeout(&addr, Duration::from_secs(3)))
                .await?;
        let stream = Async::new(blocking_stream)?;

        // once it works ;-)
        // let stream = Async::<TcpStream>::connect(addr).or(async {
        //     Timer::after(Duration::from_secs(10)).await;
        //     Err(io::ErrorKind::TimedOut.into())
        // })
        // .await.unwrap();

        self.client.set_stream(stream);

        info!("Successfully connected to blynk server");

        self.authenticate(&self.config.token.clone()).await?;
        self.set_heartbeat().await?;

        self.last_rcv_time = Instant::now();

        if let Some(hook) = &mut self.handler {
            hook.handle_connect(&mut self.client).await;
        }
        Ok(())
    }
/// Connects to Blynk servers
///
/// Performs authentication and sets up heart beat with the servers
///
/// Calls hook in event of succseful handshake
Connects to Blynk servers
Performs authentication and sets up heart beat with the servers

Calls hook in event of succseful handshake
Connects to Blynk servers Performs authentication and sets up heart beat with the servers Calls hook in event of succseful handshake
async fn connect(&mut self) -> Result<()> {
        self.conn_state = ConnectionState::Connecting;
        let host_port = vec![
            self.config.server.clone(),
            ":".to_string(),
            self.config.port.to_string(),
        ]
        .join("");
        let addrs = smol::unblock(move || host_port.to_socket_addrs())
            .await?
            .collect::<Vec<_>>();
        let addr = *addrs.first().ok_or(BlynkError::Dns)?;
        info!("stream open start tp {:?}", addr);
        // opening async TcpStream connection does not work yet with esp-rs
        let blocking_stream =
            smol::unblock(move || TcpStream::connect_timeout(&addr, Duration::from_secs(3)))
                .await?;
        let stream = Async::new(blocking_stream)?;
        // once it works ;-)
        // let stream = Async::<TcpStream>::connect(addr).or(async {
        //     Timer::after(Duration::from_secs(10)).await;
        //     Err(io::ErrorKind::TimedOut.into())
        // })
        // .await.unwrap();
        self.client.set_stream(stream);
        info!("Successfully connected to blynk server");
        self.authenticate(&self.config.token.clone()).await?;
        self.set_heartbeat().await?;
        self.last_rcv_time = Instant::now();
        if let Some(hook) = &mut self.handler {
            hook.handle_connect(&mut self.client).await;
        }
        Ok(())
    }
async fn connect ( & mut self ) -> Result < ( ) > { self . conn_state = ConnectionState :: Connecting ; let host_port = vec ! [ self config server clone ( ) " " to_string ( ) self config port to_string ( ) ] . join ( " " ) ; let addrs = smol :: unblock ( move | | host_port . to_socket_addrs ( ) ) . await ? . collect :: < Vec < _ > > ( ) ; let addr = * addrs . first ( ) . ok_or ( BlynkError :: Dns ) ? ; info ! ( " " addr ) ; // opening async TcpStream connection does not work yet with esp-rs let blocking_stream = smol :: unblock ( move | | TcpStream :: connect_timeout ( & addr , Duration :: from_secs ( 3 ) ) ) . await ? ; let stream = Async :: new ( blocking_stream ) ? ; // once it works ;-) // let stream = Async::<TcpStream>::connect(addr).or(async { //     Timer::after(Duration::from_secs(10)).await; //     Err(io::ErrorKind::TimedOut.into()) // }) // .await.unwrap(); self . client . set_stream ( stream ) ; info ! ( " " ) ; self . authenticate ( & self . config . token . clone ( ) ) . await ? ; self . set_heartbeat ( ) . await ? ; self . last_rcv_time = Instant :: now ( ) ; if let Some ( hook ) = & mut self . handler { hook . handle_connect ( & mut self . client ) . await ; } Ok ( ( ) ) }
Connects to Blynk servers
Performs authentication and sets up heart beat with the servers
Connects to Blynk servers Performs authentication and sets up heart beat with the servers
&mut self
&mut self