android 蓝牙设备超出范围[已关闭]

问题描述 投票:0回答:1

我有以下 android 代码,它创建与远程设备的蓝牙连接。有什么办法可以发现远程设备已经超出范围了?

private void connectToRobot(BluetoothDevice bd){            
    try{
        Method m = bd.getClass().getMethod("createRfcommSocket", 
            new Class[] {int.class});
        socket = (BluetoothSocket) m.invoke(bd, 1);

        socket.connect();               
        Toast.makeText(AndroidBluetooth.this,"CONNECTED ", 
            Toast.LENGTH_LONG).show();

        os = socket.getOutputStream();
    }catch (Exception e){        
        Log.e(tag,"Error interacting with remote device [" + 
            e.getMessage() +"]");               
    }        
}

我现在能得到的唯一信息就是BluetoothSocket是否成功。有没有办法确定连接的强度?

android bluetooth
1个回答
0
投票

我不知道有任何功能可以确定设备是否超出范围或者用户是否刚刚断开连接,但是您可以做的一件事是监视 RSSI 以及它在断开连接之前是否减少,称之为超出范围。如果断开时有字符串信号,则称其为用户断开。

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.