(BluetoothGatt gatt,
int status,
int newState)
| 100 | } |
| 101 | |
| 102 | @Override |
| 103 | public void onConnectionStateChange(BluetoothGatt gatt, |
| 104 | int status, |
| 105 | int newState) { |
| 106 | try { |
| 107 | if (BluetoothProfile.STATE_CONNECTED == newState) { |
| 108 | if (!gatt.discoverServices()) |
| 109 | throw new Error("Discovering GATT services request failed"); |
| 110 | } else { |
| 111 | dataCharacteristic = null; |
| 112 | deviceNameCharacteristic = null; |
| 113 | |
| 114 | if ((BluetoothProfile.STATE_DISCONNECTED == newState) && !shutdown && |
| 115 | !gatt.connect()) |
| 116 | throw new Error("Received GATT disconnected event, and reconnect attempt failed"); |
| 117 | } |
| 118 | |
| 119 | portState = STATE_LIMBO; |
| 120 | } catch (Error e) { |
| 121 | error(e.getMessage()); |
| 122 | } |
| 123 | |
| 124 | writeBuffer.clear(); |
| 125 | stateChanged(); |
| 126 | synchronized (gattStateSync) { |
| 127 | gattState = newState; |
| 128 | gattStateSync.notifyAll(); |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | @Override |
| 133 | public void onServicesDiscovered(BluetoothGatt gatt, |
nothing calls this directly
no test coverage detected