Телефон Android прослушивает соединение Bluetooth, но устройство Bluetooth не может подключиться
Устройство Omron Bluetooth для измерения артериального давления 708-BT здесь.
Устройство работоспособности уже подключено к моему HTC Sensation под управлением Android 4.0.3.
Устройство исправности устанавливает соединение, и мое приложение Android должно его принять. Приложение настроено на целевой уровень API 16 с минимальным уровнем API 11.
Вчера все работало нормально, а потом вдруг перестало работать.
Мой поток, чтобы принимать входящие соединения от устройства здоровья, является стандартным, взятым из образца BluetoothChat Google. Код включен ниже. Не исключение - выбросить, и журнал cat показывает, что мой телефон просто отлично прослушивает входящие соединения.
Где я могу начать тестировать такого рода проблемы?
AcceptThread:
private class AcceptThread extends Thread {
// The local server socket
private final BluetoothServerSocket mmServerSocket;
private String mSocketType;
public AcceptThread(boolean secure) {
BluetoothServerSocket tmp = null;
mSocketType = secure ? "Secure":"Insecure";
// Create a new listening server socket
try {
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(NAME_HEALTH_MON, MY_UUID);
} catch (IOException e) {
Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
}
mmServerSocket = tmp;
}
public void run() {
if (D) Log.d(TAG, "Socket Type: " + mSocketType +
"BEGIN mAcceptThread" + this);
setName("AcceptThread" + mSocketType);
BluetoothSocket socket = null;
// Listen to the server socket if we're not connected
while (mState != STATE_CONNECTED) {
try {
// This is a blocking call and will only return on a
// successful connection or an exception
socket = mmServerSocket.accept();
} catch (IOException e) {
Log.e(TAG, "Socket Type: " + mSocketType + "accept() failed", e);
break;
}
// If a connection was accepted
if (socket != null) {
synchronized (BluetoothSPPService.this) {
switch (mState) {
case STATE_LISTEN:
case STATE_CONNECTING:
// Situation normal. Start the connected thread.
connected(socket, socket.getRemoteDevice(),
mSocketType);
break;
case STATE_NONE:
case STATE_CONNECTED:
// Either not ready or already connected. Terminate new socket.
try {
socket.close();
} catch (IOException e) {
Log.e(TAG, "Could not close unwanted socket", e);
}
break;
}
}
}
}
if (D) Log.i(TAG, "END mAcceptThread, socket Type: " + mSocketType);
}
public void cancel() {
if (D) Log.d(TAG, "Socket Type" + mSocketType + "cancel " + this);
try {
mmServerSocket.close();
} catch (IOException e) {
Log.e(TAG, "Socket Type" + mSocketType + "close() of server failed", e);
}
}
}
LogCat:
08-02 17:44:41.055: D/BluetoothSPPService(2956): start
08-02 17:44:41.055: D/BluetoothSPPService(2956): setState() 0 -> 1
08-02 17:45:49.491: D/BluetoothSPPService(2956): Socket Type: SecureBEGIN mAcceptThreadThread[Thread-6798,5,main]
08-02 17:46:07.159: D/BluetoothSPPService(2956): Socket Type: InsecureBEGIN mAcceptThreadThread[Thread-6799,5,main]
08-02 17:48:29.938: D/BluetoothSPPService(3388): start
08-02 17:48:29.938: D/BluetoothSPPService(3388): setState() 0 -> 1
08-02 17:48:41.049: D/BluetoothSPPService(3388): Socket Type: SecureBEGIN mAcceptThreadThread[Thread-6837,5,main]
08-02 17:48:42.730: D/BluetoothSPPService(3388): Socket Type: InsecureBEGIN mAcceptThreadThread[Thread-6838,5,main]