Skip to content

Commit fdf6355

Browse files
committed
fix(android): prevent errors
1 parent 016085c commit fdf6355

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/bluetooth.android.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,7 @@ function initBluetoothGattCallback() {
783783
* @param characteristic [android.bluetooth.BluetoothGattCharacteristic] - Characteristic that has been updated as a result of a remote notification event.
784784
*/
785785
onCharacteristicChanged(gatt: android.bluetooth.BluetoothGatt, characteristic: android.bluetooth.BluetoothGattCharacteristic) {
786+
786787
const device = gatt.getDevice();
787788
let pUUID: string = null;
788789
if (device == null) {
@@ -799,8 +800,13 @@ function initBluetoothGattCallback() {
799800
d.onCharacteristicChanged(gatt, characteristic);
800801
}
801802
});
803+
804+
const owner = this.owner.get();
805+
if (!owner) {
806+
return;
807+
}
802808

803-
const stateObject = this.owner.get().connections[pUUID];
809+
const stateObject = owner.connections[pUUID];
804810
if (stateObject) {
805811
const cUUID = uuidToString(characteristic.getUuid());
806812
const sUUID = uuidToString(characteristic.getService().getUuid());

0 commit comments

Comments
 (0)