diff --git a/lib/src/main/java/quevedo/soares/leandro/blemadeeasy/models/BLEDevice.kt b/lib/src/main/java/quevedo/soares/leandro/blemadeeasy/models/BLEDevice.kt index 6c5cf0d..9f61b4d 100644 --- a/lib/src/main/java/quevedo/soares/leandro/blemadeeasy/models/BLEDevice.kt +++ b/lib/src/main/java/quevedo/soares/leandro/blemadeeasy/models/BLEDevice.kt @@ -1,10 +1,13 @@ package quevedo.soares.leandro.blemadeeasy.models +import android.annotation.SuppressLint import android.bluetooth.BluetoothDevice class BLEDevice(var device: BluetoothDevice, var rsii: Int = 0, val advertisingId: Int = -1) { - val name: String get () = device.name ?: "" + @get:SuppressLint("MissingPermission") + val name: String + get() = device.name ?: "" val macAddress: String get () = device.address diff --git a/lib/src/main/java/quevedo/soares/leandro/blemadeeasy/models/BluetoothCharacteristic.kt b/lib/src/main/java/quevedo/soares/leandro/blemadeeasy/models/BluetoothCharacteristic.kt index 52e28fb..70a8668 100644 --- a/lib/src/main/java/quevedo/soares/leandro/blemadeeasy/models/BluetoothCharacteristic.kt +++ b/lib/src/main/java/quevedo/soares/leandro/blemadeeasy/models/BluetoothCharacteristic.kt @@ -1,8 +1,11 @@ package quevedo.soares.leandro.blemadeeasy.models +import android.Manifest +import android.annotation.SuppressLint import android.bluetooth.BluetoothGatt import android.bluetooth.BluetoothGattCharacteristic import android.bluetooth.BluetoothGattDescriptor +import androidx.annotation.RequiresPermission import quevedo.soares.leandro.blemadeeasy.exceptions.PeripheralNotObservableException import java.util.* @@ -20,13 +23,16 @@ data class BluetoothCharacteristic( return this.characteristic.descriptors.find { it.uuid == c } } + @SuppressLint("MissingPermission") fun read(gatt: BluetoothGatt): Boolean = gatt.readCharacteristic(this.characteristic) + @SuppressLint("MissingPermission") fun write(gatt: BluetoothGatt, value: ByteArray): Boolean { this.characteristic.value = value return gatt.writeCharacteristic(this.characteristic) } + @SuppressLint("MissingPermission") fun enableNotify(gatt: BluetoothGatt) { // If the characteristic does not export the NOTIFY property, throw an exception if (!this.isNotifiable) throw PeripheralNotObservableException(gatt.device.address, this.uuid.toString().lowercase()) @@ -39,6 +45,7 @@ data class BluetoothCharacteristic( gatt.setCharacteristicNotification(this.characteristic, true) } + @SuppressLint("MissingPermission") fun disableNotify(gatt: BluetoothGatt) { // If the characteristic does not export the NOTIFY property, throw an exception if (!this.isNotifiable) throw PeripheralNotObservableException(gatt.device.address, this.uuid.toString().lowercase())