From 97b4ead8481d669a51f358355ce5206acc00418b Mon Sep 17 00:00:00 2001 From: Martijn van Welie Date: Sun, 26 Mar 2023 11:03:42 +0200 Subject: [PATCH] Fix NPE --- .../java/com/welie/blessed/BluetoothPeripheralManager.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/blessed/src/main/java/com/welie/blessed/BluetoothPeripheralManager.kt b/blessed/src/main/java/com/welie/blessed/BluetoothPeripheralManager.kt index f823c0c..bfb284a 100644 --- a/blessed/src/main/java/com/welie/blessed/BluetoothPeripheralManager.kt +++ b/blessed/src/main/java/com/welie/blessed/BluetoothPeripheralManager.kt @@ -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) } } @@ -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) }