Skip to content

Commit

Permalink
Fix NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
weliem committed Mar 26, 2023
1 parent 678b4eb commit 97b4ead
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ class BluetoothPeripheralManager(private val context: Context, private val bluet
handleDeviceDisconnected(device)
}
} else {
Logger.i(TAG, "Device '%s' disconnected with status %d", device.name, status)
Logger.i(TAG, "Device '%s' disconnected with status %d", device.name ?: "null", status)
handleDeviceDisconnected(device)
}
}

private fun handleDeviceConnected(device: BluetoothDevice) {
Logger.i(TAG, "Central '%s' (%s) connected", device.name, device.address)
val bluetoothCentral = BluetoothCentral(device.address, device.name)
val bluetoothCentral = BluetoothCentral(device.address, device.name ?: "null")
connectedCentralsMap[bluetoothCentral.address] = bluetoothCentral
mainHandler.post { callback.onCentralConnected(bluetoothCentral) }
}
Expand Down Expand Up @@ -476,7 +476,7 @@ class BluetoothPeripheralManager(private val context: Context, private val bluet

private fun cancelConnection(bluetoothDevice: BluetoothDevice) {
Objects.requireNonNull(bluetoothDevice, DEVICE_IS_NULL)
Logger.i(TAG, "cancelConnection with '%s' (%s)", bluetoothDevice.name, bluetoothDevice.address)
Logger.i(TAG, "cancelConnection with '%s' (%s)", bluetoothDevice.name ?: "null", bluetoothDevice.address)
bluetoothGattServer.cancelConnection(bluetoothDevice)
}

Expand Down

0 comments on commit 97b4ead

Please sign in to comment.