/// Attempts to make an outbound RFCOMM connection to the peer specified in `args`.
Attempts to make an outbound RFCOMM connection to the peer specified in `args`.
Attempts to make an outbound RFCOMM connection to the peer specified in ` args ` .
async fn connect_rfcomm(
    profile_svc: &ProfileProxy,
    state: Arc<RwLock<ProfileState>>,
    args: &Vec<String>,
) -> Result<(), Error> {
    if args.len() != 2 {
        return Err(anyhow!("Invalid number of arguments"));
    }
    let peer_id: PeerId = args[0].parse()?;
    let server_channel =
        args[1].parse::<u8>().map_err(|_| anyhow!("Server channel must be a u8"))?;
    let server_channel = ServerChannelNumber::try_from(server_channel)?;
    let res = profile_svc
        .connect(
            &mut peer_id.into(),
            &mut ConnectParameters::Rfcomm(RfcommParameters {
                channel: Some(server_channel.0),
                ..RfcommParameters::EMPTY
            }),
        )
        .await?;
    let channel = res.map_err(|e| anyhow!("Error establishing channel: {:?}", e))?;
    let channel = Channel::try_from(channel).unwrap();
    let receiver = state.write().rfcomm.create_channel(server_channel);
    fasync::Task::spawn(rfcomm_channel_task(server_channel, state.clone(), channel, receiver))
        .detach();
    println!("Established outbound Rfcomm channel: {}", server_channel.0);
    Ok(())
}
async fn connect_rfcomm ( profile_svc : & ProfileProxy , state : Arc < RwLock < ProfileState > > , args : & Vec < String > , ) -> Result < ( ) , Error > { if args . len ( ) != 2 { return Err ( anyhow ! ( " " ) ) ; } let peer_id : PeerId = args [ 0 ] . parse ( ) ? ; let server_channel = args [ 1 ] . parse :: < u8 > ( ) . map_err ( | _ | anyhow ! ( " " ) ) ? ; let server_channel = ServerChannelNumber :: try_from ( server_channel ) ? ; let res = profile_svc . connect ( & mut peer_id . into ( ) , & mut ConnectParameters :: Rfcomm ( RfcommParameters { channel : Some ( server_channel . 0 ) , .. RfcommParameters :: EMPTY } ) , ) . await ? ; let channel = res . map_err ( | e | anyhow ! ( " " e ) ) ? ; let channel = Channel :: try_from ( channel ) . unwrap ( ) ; let receiver = state . write ( ) . rfcomm . create_channel ( server_channel ) ; fasync :: Task :: spawn ( rfcomm_channel_task ( server_channel , state . clone ( ) , channel , receiver ) ) . detach ( ) ; println ! ( " " server_channel 0 ) ; Ok ( ( ) ) }
Attempts to make an outbound RFCOMM connection to the peer specified in `args`.
Attempts to make an outbound RFCOMM connection to the peer specified in ` args ` .
profile_svc
&ProfileProxy
state
Arc<RwLock<ProfileState>>
args
&Vec<String>