I have a sample application which transfers 30 char length data through Bluetooth.Data transfer was proper for four days,and then disconnected.Then after,when ever connection is established after few minutes Bluetooth connection is lost.adding adb logs and code.
Why i am getting disconnect from platform due to device property change ? when will the device property change ? is the device property change is the reason to loose Bluetooth connection?
private static final UUID MY_UUID_SECURE = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
private class ConnectThread extends Thread {
private final BluetoothSocket mmSocket;
private final BluetoothDevice mmDevice;
private String mSocketType;
public ConnectThread(BluetoothDevice device, boolean secure) {
mmDevice = device;
BluetoothSocket tmp = null;
mSocketType = secure ? "Secure" : "Insecure";
// Get a BluetoothSocket for a connection with the
// given BluetoothDevice
try {
tmp = device.createRfcommSocketToServiceRecord(MY_UUID_SECURE);
} catch (IOException e) {
Log.e(TAG, "Socket Type: " + mSocketType + "create() failed", e);
}
mmSocket = tmp;
Log.i("12345", "Socket set");
}
public void run() {
Log.i("12345", "BEGIN mConnectThread SocketType:" + mSocketType);
setName("ConnectThread" + mSocketType);
// Always cancel discovery because it will slow down a connection
mAdapter.cancelDiscovery();
// Make a connection to the BluetoothSocket
try {
// This is a blocking call and will only return on a
// successful connection or an exception
mmSocket.connect();
} catch (IOException e) {
// Close the socket
try {
mmSocket.close();
Log.i(TAG, "Closing Socket 3");
} catch (IOException e2) {
Log.e(TAG, "unable to close() " + mSocketType + " socket during connection failure", e2);
}
connectionFailed();
return;
}
// Reset the ConnectThread because we're done
synchronized (BluetoothChatService.this) {
mConnectThread = null;
}
// Start the connected thread
connected(mmSocket, mmDevice, mSocketType);
}
Logs :
09-12 11:16:36.230 V/BluetoothEventLoop.cpp( 2255): event_filter: Received signal org.bluez.Device:PropertyChanged from /org/bluez/3179/hci0/dev_22_89_8E_A9_50_1C
09-12 11:16:36.230 D/BluetoothEventLoop( 2255): Device property changed
09-12 11:16:36.240 D/BluetoothA2DPStateReceiver(20246): BluetoothA2DPStateReceiver constructor call()
09-12 11:16:36.245 D/BluetoothA2DPStateReceiver(20246): onReceive(): action = android.bluetooth.device.action.ACL_DISCONNECTED
09-12 11:16:36.245 D/BluetoothA2DPStateReceiver(20246): ACTION_ACL_DISCONNECTED
09-12 11:16:36.245 D/BluetoothA2DPSinkInfo(20246): checkBlackListCarkit() : isBlackListCarkit false
09-12 11:16:36.660 D/KeyguardViewMediator( 2255): setHidden false
May be due to the link loss, BT adapter had initiated the property changed command to report link disconnected to the upper layers. Please check in multitple devices.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.