MCPcopy Create free account
hub / github.com/XCSoar/XCSoar / onConnectionStateChange

Method onConnectionStateChange

android/src/HM10Port.java:102–130  ·  view source on GitHub ↗
(BluetoothGatt gatt,
      int status,
      int newState)

Source from the content-addressed store, hash-verified

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,

Callers

nothing calls this directly

Calls 4

errorMethod · 0.95
stateChangedMethod · 0.95
connectMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected