Android 平台开发 (#1)

* 修复 UUID 创建失败的问题

* 移除 scanning 属性

* 临时提交

* CentralManager 开发 & 示例项目开发

* CentralManager 开发 & 示例项目开发

* android 插件生命周期监听

* 修改 API

* 示例程序开发

* 修改字体,添加 API,解决后台问题

* Central#connect API

* 蓝牙连接部分开发

* 蓝牙连接部分开发

* 解决一些问题

* 解决一些问题

* Connect API 优化

* 添加 API

* example 开发

* API 基本完成

* 消息重命名

* API 修改,Android 实现

* 删除多余代码

* 删除多余文件

* 解决 descriptor 自动生成报错的问题

* 还原 Kotlin 版本,广播处理代码迁移至 dart 端

* Kotlin 版本升至 1.5.20

* 解决特征值通知没有在主线程触发的问题,优化代码

* 引入哈希值,避免对象销毁后继续使用

* 使用下拉刷新代替搜索按钮

* 解决由于热重载和蓝牙关闭产生的问题

* 更新插件信息

* 更新 README 和 CHANGELOG

* 更新许可证

* 添加注释

* 添加注释,central 拆分
This commit is contained in:
iAMD
2021-07-01 17:35:54 +08:00
committed by GitHub
parent f138b8e11e
commit 6bc1a364fb
59 changed files with 20524 additions and 443 deletions

View File

@ -2,10 +2,11 @@ group 'dev.yanshouwang.bluetooth_low_energy'
version '1.0-SNAPSHOT'
buildscript {
ext.kotlin_version = '1.3.50'
ext.kotlin_version = '1.5.20'
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://mirrors.cloud.tencent.com/nexus/repository/maven-public/' }
}
dependencies {
@ -17,7 +18,8 @@ buildscript {
rootProject.allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://mirrors.cloud.tencent.com/nexus/repository/maven-public/' }
}
}
@ -31,10 +33,11 @@ android {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
minSdkVersion 16
minSdkVersion 21
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.protobuf:protobuf-kotlin:3.17.3'
}

View File

@ -1,3 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="dev.yanshouwang.bluetooth_low_energy">
package="dev.yanshouwang.bluetooth_low_energy">
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
</manifest>

File diff suppressed because it is too large Load Diff

View File

@ -1,35 +1,687 @@
package dev.yanshouwang.bluetooth_low_energy
import android.Manifest
import android.bluetooth.*
import android.bluetooth.le.*
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.content.pm.PackageManager
import android.os.Build
import android.os.DeadObjectException
import android.os.Handler
import android.os.ParcelUuid
import android.util.Log
import androidx.annotation.NonNull
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import com.google.protobuf.ByteString
import dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.*
import dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.MessageCategory.*
import io.flutter.embedding.engine.plugins.FlutterPlugin
import io.flutter.embedding.engine.plugins.activity.ActivityAware
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding
import io.flutter.plugin.common.EventChannel
import io.flutter.plugin.common.EventChannel.EventSink
import io.flutter.plugin.common.EventChannel.StreamHandler
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel
import io.flutter.plugin.common.MethodChannel.MethodCallHandler
import io.flutter.plugin.common.MethodChannel.Result
import io.flutter.plugin.common.PluginRegistry.RequestPermissionsResultListener
import java.util.*
const val NAMESPACE = "yanshouwang.dev/bluetooth_low_energy"
typealias StartScanHandler = (code: Int) -> Unit
typealias RequestPermissionsHandler = (granted: Boolean) -> Unit
/** BluetoothLowEnergyPlugin */
class BluetoothLowEnergyPlugin: FlutterPlugin, MethodCallHandler {
/// The MethodChannel that will the communication between Flutter and native Android
///
/// This local reference serves to register the plugin with the Flutter Engine and unregister it
/// when the Flutter Engine is detached from the Activity
private lateinit var channel : MethodChannel
override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
channel = MethodChannel(flutterPluginBinding.binaryMessenger, "bluetooth_low_energy")
channel.setMethodCallHandler(this)
}
override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) {
if (call.method == "getPlatformVersion") {
result.success("Android ${android.os.Build.VERSION.RELEASE}")
} else {
result.notImplemented()
class BluetoothLowEnergyPlugin : FlutterPlugin, MethodCallHandler, StreamHandler, ActivityAware, RequestPermissionsResultListener {
companion object {
private const val CLIENT_CHARACTERISTIC_CONFIG = "00002902-0000-1000-8000-00805f9b34fb"
private const val BLUETOOTH_ADAPTER_STATE_UNKNOWN = -1
private const val NO_ERROR = 0
private const val INVALID_REQUEST = 1
private const val REQUEST_PERMISSION_FAILED = 2
private const val REQUEST_MTU_FAILED = 3
private const val DISCOVER_SERVICES_FAILED = 4
private const val READ_CHARACTERISTIC_FAILED = 5
private const val WRITE_CHARACTERISTIC_FAILED = 6
private const val NOTIFY_CHARACTERISTIC_FAILED = 7
private const val READ_DESCRIPTOR_FAILED = 8
private const val WRITE_DESCRIPTOR_FAILED = 9
private const val REQUEST_CODE = 443
}
}
override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) {
channel.setMethodCallHandler(null)
}
private lateinit var method: MethodChannel
private lateinit var event: EventChannel
private lateinit var context: Context
private var binding: ActivityPluginBinding? = null
private var sink: EventSink? = null
private val bluetoothAvailable by lazy { context.packageManager.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE) }
private val bluetoothManager by lazy { context.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager }
private val bluetoothAdapter by lazy { bluetoothManager.adapter }
private val handler by lazy { Handler(context.mainLooper) }
private val bluetoothStateReceiver by lazy {
object : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) {
val oldState = intent!!.getIntExtra(BluetoothAdapter.EXTRA_PREVIOUS_STATE, BLUETOOTH_ADAPTER_STATE_UNKNOWN).opened
val newState = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BLUETOOTH_ADAPTER_STATE_UNKNOWN).opened
// TODO: clear status when bluetooth closed.
if (newState == oldState) return
val closed = !newState
if (closed && scanning) scanning = false
val event = Message.newBuilder()
.setCategory(BLUETOOTH_STATE)
.setState(newState)
.build()
.toByteArray()
sink?.success(event)
}
}
}
private val hasPermission
get() = ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
private var requestPermissionsHandler: RequestPermissionsHandler? = null
private var scanCode = NO_ERROR
private var scanning = false
private val scanCallback by lazy {
object : ScanCallback() {
override fun onScanFailed(errorCode: Int) {
super.onScanFailed(errorCode)
scanCode = errorCode
}
override fun onScanResult(callbackType: Int, result: ScanResult?) {
super.onScanResult(callbackType, result)
if (result == null) return
val address = result.device.address
val rssi = result.rssi
val record = result.scanRecord
val advertisements =
if (record == null) ByteString.EMPTY
else ByteString.copyFrom(record.bytes)
val builder = Discovery.newBuilder()
.setAddress(address)
.setRssi(rssi)
.setAdvertisements(advertisements)
val discovery = builder.build()
val event = Message.newBuilder()
.setCategory(CENTRAL_DISCOVERED)
.setDiscovery(discovery)
.build()
.toByteArray()
sink?.success(event)
}
override fun onBatchScanResults(results: MutableList<ScanResult>?) {
super.onBatchScanResults(results)
if (results == null) return
for (result in results) {
val address = result.device.address
val rssi = result.rssi
val record = result.scanRecord
val advertisements =
if (record == null) ByteString.EMPTY
else ByteString.copyFrom(record.bytes)
val builder = Discovery.newBuilder()
.setAddress(address)
.setRssi(rssi)
.setAdvertisements(advertisements)
val discovery = builder.build()
val event = Message.newBuilder()
.setCategory(CENTRAL_DISCOVERED)
.setDiscovery(discovery)
.build()
.toByteArray()
sink?.success(event)
}
}
}
}
private val gatts by lazy { mutableMapOf<String, BluetoothGatt>() }
private val connects by lazy { mutableMapOf<String, Result>() }
private val mtus by lazy { mutableMapOf<String, Int>() }
private val disconnects by lazy { mutableMapOf<String, Result>() }
private val characteristicReads by lazy { mutableMapOf<Int, Result>() }
private val characteristicWrites by lazy { mutableMapOf<Int, Result>() }
private val descriptorReads by lazy { mutableMapOf<Int, Result>() }
private val descriptorWrites by lazy { mutableMapOf<Int, Result>() }
private val bluetoothGattCallback by lazy {
object : BluetoothGattCallback() {
override fun onConnectionStateChange(gatt: BluetoothGatt?, status: Int, newState: Int) {
super.onConnectionStateChange(gatt, status, newState)
val address = gatt!!.device.address
when (status) {
BluetoothGatt.GATT_SUCCESS -> {
when (newState) {
BluetoothProfile.STATE_DISCONNECTED -> {
gatts.remove(address)!!.close()
val disconnect = disconnects.remove(address)
if (disconnect != null) handler.post { disconnect.success() }
else {
// An adapter closed event
val id = gatt.hashCode()
val connectionLost = ConnectionLost.newBuilder()
.setId(id)
.setErrorCode(status)
.build()
val event = Message.newBuilder()
.setCategory(GATT_CONNECTION_LOST)
.setConnectionLost(connectionLost)
.build()
.toByteArray()
handler.post { sink?.success(event) }
}
}
BluetoothProfile.STATE_CONNECTED -> {
val code = when {
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP -> {
// TODO: how to get exact MTU size of this device here?
if (gatt.requestMtu(512)) NO_ERROR
else REQUEST_MTU_FAILED
}
else -> {
if (gatt.discoverServices()) {
// Just use 23 as MTU before LOLLIPOP.
mtus[address] = 23
NO_ERROR
} else DISCOVER_SERVICES_FAILED
}
}
if (code != NO_ERROR) {
gatts.remove(address)!!.close()
val connect = connects.remove(address)!!
handler.post { connect.error(code) }
}
}
else -> throw NotImplementedError() // should never be called.
}
}
else -> {
gatts.remove(address)!!.close()
val connect = connects.remove(address)
val disconnect = disconnects.remove(address)
when {
connect != null -> handler.post { connect.error(status) }
disconnect != null -> handler.post { disconnect.error(status) }
else -> {
val id = gatt.hashCode()
val connectionLost = ConnectionLost.newBuilder()
.setId(id)
.setErrorCode(status)
.build()
val event = Message.newBuilder()
.setCategory(GATT_CONNECTION_LOST)
.setConnectionLost(connectionLost)
.build()
.toByteArray()
handler.post { sink?.success(event) }
}
}
}
}
}
override fun onMtuChanged(gatt: BluetoothGatt?, mtu: Int, status: Int) {
super.onMtuChanged(gatt, mtu, status)
val address = gatt!!.device.address
val code = when (status) {
BluetoothGatt.GATT_SUCCESS -> {
if (gatt.discoverServices()) {
mtus[address] = mtu
NO_ERROR
} else DISCOVER_SERVICES_FAILED
}
else -> status
}
if (code != NO_ERROR) {
gatts.remove(address)!!.close()
val connect = connects.remove(address)!!
handler.post { connect.error(code) }
}
}
override fun onServicesDiscovered(gatt: BluetoothGatt?, status: Int) {
super.onServicesDiscovered(gatt, status)
val address = gatt!!.device.address
val connect = connects.remove(address)!!
val mtu = mtus.remove(address)!!
when (status) {
BluetoothGatt.GATT_SUCCESS -> {
val id = gatt.hashCode()
val services = gatt.services.map { service ->
val serviceId = service.hashCode()
val serviceUUID = service.uuid.toString()
val characteristics = service.characteristics.map { characteristic ->
val characteristicId = characteristic.hashCode()
val characteristicUUID = characteristic.uuid.toString()
val properties = characteristic.properties
val canRead = properties and BluetoothGattCharacteristic.PROPERTY_READ != 0
val canWrite = properties and BluetoothGattCharacteristic.PROPERTY_WRITE != 0
val canWriteWithoutResponse = properties and BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE != 0
val canNotify = properties and BluetoothGattCharacteristic.PROPERTY_NOTIFY != 0
val descriptors = characteristic.descriptors.map { descriptor ->
val descriptorId = descriptor.hashCode()
val descriptorUUID = descriptor.uuid.toString()
GattDescriptor.newBuilder()
.setId(descriptorId)
.setUuid(descriptorUUID)
.build()
}
GattCharacteristic.newBuilder()
.setId(characteristicId)
.setUuid(characteristicUUID)
.setCanRead(canRead)
.setCanWrite(canWrite)
.setCanWriteWithoutResponse(canWriteWithoutResponse)
.setCanNotify(canNotify)
.addAllDescriptors(descriptors)
.build()
}
GattService.newBuilder()
.setId(serviceId)
.setUuid(serviceUUID)
.addAllCharacteristics(characteristics).build()
}
val reply = GATT.newBuilder()
.setId(id)
.setMtu(mtu)
.addAllServices(services)
.build()
.toByteArray()
handler.post { connect.success(reply) }
}
else -> {
gatts.remove(address)!!.close()
handler.post { connect.error(status) }
}
}
}
override fun onCharacteristicRead(gatt: BluetoothGatt?, characteristic: BluetoothGattCharacteristic?, status: Int) {
super.onCharacteristicRead(gatt, characteristic, status)
val key = characteristic!!.hashCode()
val read = characteristicReads.remove(key)!!
when (status) {
BluetoothGatt.GATT_SUCCESS -> handler.post { read.success(characteristic.value) }
else -> handler.post { read.error(status) }
}
}
override fun onCharacteristicWrite(gatt: BluetoothGatt?, characteristic: BluetoothGattCharacteristic?, status: Int) {
super.onCharacteristicWrite(gatt, characteristic, status)
val key = characteristic!!.hashCode()
val write = characteristicWrites.remove(key)!!
when (status) {
BluetoothGatt.GATT_SUCCESS -> handler.post { write.success() }
else -> handler.post { write.error(status) }
}
}
override fun onCharacteristicChanged(gatt: BluetoothGatt?, characteristic: BluetoothGattCharacteristic?) {
super.onCharacteristicChanged(gatt, characteristic)
val id = characteristic!!.hashCode()
val value = ByteString.copyFrom(characteristic.value)
val characteristicValue = GattCharacteristicValue.newBuilder()
.setId(id)
.setValue(value)
.build()
val event = Message.newBuilder()
.setCategory(GATT_CHARACTERISTIC_NOTIFY)
.setCharacteristicValue(characteristicValue)
.build()
.toByteArray()
handler.post { sink?.success(event) }
}
override fun onDescriptorRead(gatt: BluetoothGatt?, descriptor: BluetoothGattDescriptor?, status: Int) {
super.onDescriptorRead(gatt, descriptor, status)
val key = descriptor!!.hashCode()
val read = descriptorReads.remove(key)!!
when (status) {
BluetoothGatt.GATT_SUCCESS -> handler.post { read.success(descriptor.value) }
else -> handler.post { read.error(status) }
}
}
override fun onDescriptorWrite(gatt: BluetoothGatt?, descriptor: BluetoothGattDescriptor?, status: Int) {
super.onDescriptorWrite(gatt, descriptor, status)
val key = descriptor!!.hashCode()
val write = descriptorWrites.remove(key)!!
when (status) {
BluetoothGatt.GATT_SUCCESS -> handler.post { write.success() }
else -> handler.post { write.error(status) }
}
}
}
}
private fun startScan(services: List<String>, startScanHandler: StartScanHandler) {
val filters = services.map { service ->
val serviceUUID = ParcelUuid.fromString(service)
ScanFilter.Builder()
.setServiceUuid(serviceUUID)
.build()
}
val settings = ScanSettings.Builder()
.setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
.build()
bluetoothAdapter.bluetoothLeScanner.startScan(filters, settings, scanCallback)
// use handler.post to delay until #onScanFailed executed.
handler.post {
val code = scanCode
when (code) {
NO_ERROR -> scanning = true
else -> scanCode = NO_ERROR
}
startScanHandler.invoke(code)
}
}
private fun stopScan() {
bluetoothAdapter.bluetoothLeScanner.stopScan(scanCallback)
scanning = false
}
override fun onAttachedToEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) {
method = MethodChannel(binding.binaryMessenger, "$NAMESPACE/method")
method.setMethodCallHandler(this)
event = EventChannel(binding.binaryMessenger, "$NAMESPACE/event")
event.setStreamHandler(this)
context = binding.applicationContext
// Register bluetooth adapter state receiver.
val adapterStateFilter = IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED)
context.registerReceiver(bluetoothStateReceiver, adapterStateFilter)
}
override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) {
// Clear connections.
for (gatt in gatts.values) gatt.close()
gatts.clear()
// Stop scan.
if (scanning) stopScan()
// Unregister bluetooth adapter state receiver.
context.unregisterReceiver(bluetoothStateReceiver)
event.setStreamHandler(null)
method.setMethodCallHandler(null)
}
override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) {
val category = call.category
if (category != BLUETOOTH_AVAILABLE && category != BLUETOOTH_STATE && !bluetoothAdapter.state.opened) result.error(INVALID_REQUEST)
else when (category) {
BLUETOOTH_AVAILABLE -> result.success(bluetoothAvailable)
BLUETOOTH_STATE -> result.success(bluetoothAdapter.state.opened)
CENTRAL_START_DISCOVERY -> {
when {
requestPermissionsHandler != null -> result.error(INVALID_REQUEST)
else -> {
val startDiscovery = Runnable {
val data = call.arguments<ByteArray>()
val arguments = StartDiscoveryArguments.parseFrom(data)
val startScanHandler: StartScanHandler = { code ->
when (code) {
NO_ERROR -> result.success()
else -> result.error(code)
}
}
startScan(arguments.servicesList, startScanHandler)
}
when {
hasPermission -> startDiscovery.run()
else -> {
requestPermissionsHandler = { granted ->
if (granted) startDiscovery.run()
else result.error(REQUEST_PERMISSION_FAILED)
}
val permissions = arrayOf(Manifest.permission.ACCESS_FINE_LOCATION)
ActivityCompat.requestPermissions(binding!!.activity, permissions, REQUEST_CODE)
}
}
}
}
}
CENTRAL_STOP_DISCOVERY -> {
stopScan()
result.success()
}
CENTRAL_DISCOVERED -> result.notImplemented()
CENTRAL_CONNECT -> {
val data = call.arguments<ByteArray>()
val arguments = ConnectArguments.parseFrom(data)
val address = arguments.address
val connect = connects[address]
var gatt = gatts[address]
if (connect != null || gatt != null) {
result.error(INVALID_REQUEST)
} else {
val device = bluetoothAdapter.getRemoteDevice(address)
gatt = when {
// Use TRANSPORT_LE to avoid none flag device on Android 23 or later.
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M -> device.connectGatt(context, false, bluetoothGattCallback, BluetoothDevice.TRANSPORT_LE)
else -> device.connectGatt(context, false, bluetoothGattCallback)
}
connects[address] = result
gatts[address] = gatt
}
}
GATT_DISCONNECT -> {
val data = call.arguments<ByteArray>()
val arguments = GattDisconnectArguments.parseFrom(data)
val address = arguments.address
val disconnect = disconnects[address]
val gatt = gatts[address]
if (disconnect != null || gatt == null || gatt.hashCode() != arguments.id) {
result.error(INVALID_REQUEST)
} else {
disconnects[address] = result
gatt.disconnect()
}
}
GATT_CONNECTION_LOST -> result.notImplemented()
GATT_CHARACTERISTIC_READ -> {
val data = call.arguments<ByteArray>()
val arguments = GattCharacteristicReadArguments.parseFrom(data)
val gatt = gatts[arguments.address]
if (gatt == null) result.error(INVALID_REQUEST)
else {
val serviceUUID = UUID.fromString(arguments.serviceUuid)
val service = gatt.getService(serviceUUID)
val uuid = UUID.fromString(arguments.uuid)
val characteristic = service.getCharacteristic(uuid)
val id = characteristic.hashCode()
val characteristicRead = characteristicReads[id]
if (characteristicRead != null || id != arguments.id) result.error(INVALID_REQUEST)
else {
val failed = !gatt.readCharacteristic(characteristic)
if (failed) result.error(READ_CHARACTERISTIC_FAILED)
else characteristicReads[id] = result
}
}
}
GATT_CHARACTERISTIC_WRITE -> {
val data = call.arguments<ByteArray>()
val arguments = GattCharacteristicWriteArguments.parseFrom(data)
val gatt = gatts[arguments.address]
if (gatt == null) result.error(INVALID_REQUEST)
else {
val serviceUUID = UUID.fromString(arguments.serviceUuid)
val service = gatt.getService(serviceUUID)
val uuid = UUID.fromString(arguments.uuid)
val characteristic = service.getCharacteristic(uuid)
val id = characteristic.hashCode()
val characteristicWrite = characteristicWrites[id]
if (characteristicWrite != null || id != arguments.id) result.error(INVALID_REQUEST)
else {
characteristic.value = arguments.value.toByteArray()
characteristic.writeType =
if (arguments.withoutResponse) BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE
else BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT
val failed = !gatt.writeCharacteristic(characteristic)
if (failed) result.error(WRITE_CHARACTERISTIC_FAILED)
else characteristicWrites[id] = result
}
}
}
GATT_CHARACTERISTIC_NOTIFY -> {
val data = call.arguments<ByteArray>()
val arguments = GattCharacteristicNotifyArguments.parseFrom(data)
val gatt = gatts[arguments.address]
if (gatt == null) result.error(INVALID_REQUEST)
else {
val serviceUUID = UUID.fromString(arguments.serviceUuid)
val service = gatt.getService(serviceUUID)
val uuid = UUID.fromString(arguments.uuid)
val characteristic = service.getCharacteristic(uuid)
val id = characteristic.hashCode()
val descriptorUUID = UUID.fromString(CLIENT_CHARACTERISTIC_CONFIG)
val descriptor = characteristic.getDescriptor(descriptorUUID)
val descriptorId = descriptor.hashCode()
val descriptorWrite = descriptorWrites[descriptorId]
if (descriptorWrite != null || id != arguments.id) result.error(INVALID_REQUEST)
else {
var failed = !gatt.setCharacteristicNotification(characteristic, arguments.state)
if (failed) result.error(NOTIFY_CHARACTERISTIC_FAILED)
else {
descriptor.value =
if (arguments.state) BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE
else BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE
failed = !gatt.writeDescriptor(descriptor)
if (failed) result.error(WRITE_DESCRIPTOR_FAILED)
else descriptorWrites[descriptorId] = result
}
}
}
}
GATT_DESCRIPTOR_READ -> {
val data = call.arguments<ByteArray>()
val arguments = GattDescriptorReadArguments.parseFrom(data)
val gatt = gatts[arguments.address]
if (gatt == null) result.error(INVALID_REQUEST)
else {
val serviceUUID = UUID.fromString(arguments.serviceUuid)
val service = gatt.getService(serviceUUID)
val characteristicUUID = UUID.fromString(arguments.characteristicUuid)
val characteristic = service.getCharacteristic(characteristicUUID)
val uuid = UUID.fromString(arguments.uuid)
val descriptor = characteristic.getDescriptor(uuid)
val id = descriptor.hashCode()
val descriptorRead = descriptorReads[id]
if (descriptorRead != null || id != arguments.id) result.error(INVALID_REQUEST)
else {
val failed = !gatt.readDescriptor(descriptor)
if (failed) result.error(READ_DESCRIPTOR_FAILED)
else descriptorReads[id] = result
}
}
}
GATT_DESCRIPTOR_WRITE -> {
val data = call.arguments<ByteArray>()
val arguments = GattDescriptorWriteArguments.parseFrom(data)
val gatt = gatts[arguments.address]
if (gatt == null) result.error(INVALID_REQUEST)
else {
val serviceUUID = UUID.fromString(arguments.serviceUuid)
val service = gatt.getService(serviceUUID)
val characteristicUUID = UUID.fromString(arguments.characteristicUuid)
val characteristic = service.getCharacteristic(characteristicUUID)
val uuid = UUID.fromString(arguments.uuid)
val descriptor = characteristic.getDescriptor(uuid)
val id = descriptor.hashCode()
val descriptorWrite = descriptorWrites[id]
if (descriptorWrite != null || id != arguments.id) result.error(INVALID_REQUEST)
else {
val failed = !gatt.writeDescriptor(descriptor)
if (failed) result.error(WRITE_DESCRIPTOR_FAILED)
else descriptorWrites[id] = result
}
}
}
UNRECOGNIZED -> result.notImplemented()
}
}
override fun onListen(arguments: Any?, sink: EventSink?) {
Log.d(TAG, "onListen")
this.sink = sink
}
override fun onCancel(arguments: Any?) {
Log.d(TAG, "onCancel")
// This must be a hot reload for now, clear all status here.
// Clear connections.
for (gatt in gatts.values) gatt.close()
gatts.clear()
// Stop scan.
if (scanning) stopScan()
sink = null
}
override fun onAttachedToActivity(binding: ActivityPluginBinding) {
this.binding = binding
this.binding!!.addRequestPermissionsResultListener(this)
}
override fun onDetachedFromActivity() {
binding!!.removeRequestPermissionsResultListener(this)
binding = null
}
override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) {
onAttachedToActivity(binding)
}
override fun onDetachedFromActivityForConfigChanges() {
onDetachedFromActivity()
}
override fun onRequestPermissionsResult(
requestCode: Int,
permissions: Array<out String>?,
grantResults: IntArray?
): Boolean {
return when {
requestCode != REQUEST_CODE || requestPermissionsHandler == null -> false
else -> {
val granted =
grantResults != null && grantResults.all { result -> result == PackageManager.PERMISSION_GRANTED }
requestPermissionsHandler!!.invoke(granted)
requestPermissionsHandler = null
true
}
}
}
}
fun Result.success() {
success(null)
}
fun Result.error(code: Int, message: String? = null, details: String? = null) {
error("$code", message, details)
}
val Any.TAG: String
get() = this::class.java.simpleName
val MethodCall.category: MessageCategory
get() = valueOf(method)
val Int.opened: Boolean
get() = when (this) {
BluetoothAdapter.STATE_OFF -> false
BluetoothAdapter.STATE_TURNING_ON -> false
BluetoothAdapter.STATE_ON -> true
BluetoothAdapter.STATE_TURNING_OFF -> true
else -> false
}

View File

@ -0,0 +1,45 @@
//Generated by the protocol buffer compiler. DO NOT EDIT!
// source: message.proto
package dev.yanshouwang.bluetooth_low_energy;
@kotlin.jvm.JvmSynthetic
inline fun connectArguments(block: dev.yanshouwang.bluetooth_low_energy.ConnectArgumentsKt.Dsl.() -> Unit): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.ConnectArguments =
dev.yanshouwang.bluetooth_low_energy.ConnectArgumentsKt.Dsl._create(dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.ConnectArguments.newBuilder()).apply { block() }._build()
object ConnectArgumentsKt {
@kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)
@com.google.protobuf.kotlin.ProtoDslMarker
class Dsl private constructor(
@kotlin.jvm.JvmField private val _builder: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.ConnectArguments.Builder
) {
companion object {
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _create(builder: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.ConnectArguments.Builder): Dsl = Dsl(builder)
}
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _build(): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.ConnectArguments = _builder.build()
/**
* <code>string address = 1;</code>
*/
var address: kotlin.String
@JvmName("getAddress")
get() = _builder.getAddress()
@JvmName("setAddress")
set(value) {
_builder.setAddress(value)
}
/**
* <code>string address = 1;</code>
*/
fun clearAddress() {
_builder.clearAddress()
}
}
}
@kotlin.jvm.JvmSynthetic
inline fun dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.ConnectArguments.copy(block: dev.yanshouwang.bluetooth_low_energy.ConnectArgumentsKt.Dsl.() -> Unit): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.ConnectArguments =
dev.yanshouwang.bluetooth_low_energy.ConnectArgumentsKt.Dsl._create(this.toBuilder()).apply { block() }._build()

View File

@ -0,0 +1,62 @@
//Generated by the protocol buffer compiler. DO NOT EDIT!
// source: message.proto
package dev.yanshouwang.bluetooth_low_energy;
@kotlin.jvm.JvmSynthetic
inline fun connectionLost(block: dev.yanshouwang.bluetooth_low_energy.ConnectionLostKt.Dsl.() -> Unit): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.ConnectionLost =
dev.yanshouwang.bluetooth_low_energy.ConnectionLostKt.Dsl._create(dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.ConnectionLost.newBuilder()).apply { block() }._build()
object ConnectionLostKt {
@kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)
@com.google.protobuf.kotlin.ProtoDslMarker
class Dsl private constructor(
@kotlin.jvm.JvmField private val _builder: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.ConnectionLost.Builder
) {
companion object {
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _create(builder: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.ConnectionLost.Builder): Dsl = Dsl(builder)
}
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _build(): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.ConnectionLost = _builder.build()
/**
* <code>int32 id = 1;</code>
*/
var id: kotlin.Int
@JvmName("getId")
get() = _builder.getId()
@JvmName("setId")
set(value) {
_builder.setId(value)
}
/**
* <code>int32 id = 1;</code>
*/
fun clearId() {
_builder.clearId()
}
/**
* <code>int32 error_code = 2;</code>
*/
var errorCode: kotlin.Int
@JvmName("getErrorCode")
get() = _builder.getErrorCode()
@JvmName("setErrorCode")
set(value) {
_builder.setErrorCode(value)
}
/**
* <code>int32 error_code = 2;</code>
*/
fun clearErrorCode() {
_builder.clearErrorCode()
}
}
}
@kotlin.jvm.JvmSynthetic
inline fun dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.ConnectionLost.copy(block: dev.yanshouwang.bluetooth_low_energy.ConnectionLostKt.Dsl.() -> Unit): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.ConnectionLost =
dev.yanshouwang.bluetooth_low_energy.ConnectionLostKt.Dsl._create(this.toBuilder()).apply { block() }._build()

View File

@ -0,0 +1,79 @@
//Generated by the protocol buffer compiler. DO NOT EDIT!
// source: message.proto
package dev.yanshouwang.bluetooth_low_energy;
@kotlin.jvm.JvmSynthetic
inline fun discovery(block: dev.yanshouwang.bluetooth_low_energy.DiscoveryKt.Dsl.() -> Unit): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.Discovery =
dev.yanshouwang.bluetooth_low_energy.DiscoveryKt.Dsl._create(dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.Discovery.newBuilder()).apply { block() }._build()
object DiscoveryKt {
@kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)
@com.google.protobuf.kotlin.ProtoDslMarker
class Dsl private constructor(
@kotlin.jvm.JvmField private val _builder: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.Discovery.Builder
) {
companion object {
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _create(builder: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.Discovery.Builder): Dsl = Dsl(builder)
}
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _build(): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.Discovery = _builder.build()
/**
* <code>string address = 1;</code>
*/
var address: kotlin.String
@JvmName("getAddress")
get() = _builder.getAddress()
@JvmName("setAddress")
set(value) {
_builder.setAddress(value)
}
/**
* <code>string address = 1;</code>
*/
fun clearAddress() {
_builder.clearAddress()
}
/**
* <code>sint32 rssi = 2;</code>
*/
var rssi: kotlin.Int
@JvmName("getRssi")
get() = _builder.getRssi()
@JvmName("setRssi")
set(value) {
_builder.setRssi(value)
}
/**
* <code>sint32 rssi = 2;</code>
*/
fun clearRssi() {
_builder.clearRssi()
}
/**
* <code>bytes advertisements = 3;</code>
*/
var advertisements: com.google.protobuf.ByteString
@JvmName("getAdvertisements")
get() = _builder.getAdvertisements()
@JvmName("setAdvertisements")
set(value) {
_builder.setAdvertisements(value)
}
/**
* <code>bytes advertisements = 3;</code>
*/
fun clearAdvertisements() {
_builder.clearAdvertisements()
}
}
}
@kotlin.jvm.JvmSynthetic
inline fun dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.Discovery.copy(block: dev.yanshouwang.bluetooth_low_energy.DiscoveryKt.Dsl.() -> Unit): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.Discovery =
dev.yanshouwang.bluetooth_low_energy.DiscoveryKt.Dsl._create(this.toBuilder()).apply { block() }._build()

View File

@ -0,0 +1,125 @@
//Generated by the protocol buffer compiler. DO NOT EDIT!
// source: message.proto
package dev.yanshouwang.bluetooth_low_energy;
@kotlin.jvm.JvmSynthetic
inline fun gATT(block: dev.yanshouwang.bluetooth_low_energy.GATTKt.Dsl.() -> Unit): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GATT =
dev.yanshouwang.bluetooth_low_energy.GATTKt.Dsl._create(dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GATT.newBuilder()).apply { block() }._build()
object GATTKt {
@kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)
@com.google.protobuf.kotlin.ProtoDslMarker
class Dsl private constructor(
@kotlin.jvm.JvmField private val _builder: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GATT.Builder
) {
companion object {
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _create(builder: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GATT.Builder): Dsl = Dsl(builder)
}
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _build(): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GATT = _builder.build()
/**
* <code>int32 id = 1;</code>
*/
var id: kotlin.Int
@JvmName("getId")
get() = _builder.getId()
@JvmName("setId")
set(value) {
_builder.setId(value)
}
/**
* <code>int32 id = 1;</code>
*/
fun clearId() {
_builder.clearId()
}
/**
* <code>int32 mtu = 2;</code>
*/
var mtu: kotlin.Int
@JvmName("getMtu")
get() = _builder.getMtu()
@JvmName("setMtu")
set(value) {
_builder.setMtu(value)
}
/**
* <code>int32 mtu = 2;</code>
*/
fun clearMtu() {
_builder.clearMtu()
}
/**
* An uninstantiable, behaviorless type to represent the field in
* generics.
*/
@kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)
class ServicesProxy private constructor() : com.google.protobuf.kotlin.DslProxy()
/**
* <code>repeated .dev.yanshouwang.bluetooth_low_energy.GattService services = 3;</code>
*/
val services: com.google.protobuf.kotlin.DslList<dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattService, ServicesProxy>
@kotlin.jvm.JvmSynthetic
get() = com.google.protobuf.kotlin.DslList(
_builder.getServicesList()
)
/**
* <code>repeated .dev.yanshouwang.bluetooth_low_energy.GattService services = 3;</code>
* @param value The services to add.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("addServices")
fun com.google.protobuf.kotlin.DslList<dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattService, ServicesProxy>.add(value: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattService) {
_builder.addServices(value)
}/**
* <code>repeated .dev.yanshouwang.bluetooth_low_energy.GattService services = 3;</code>
* @param value The services to add.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("plusAssignServices")
inline operator fun com.google.protobuf.kotlin.DslList<dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattService, ServicesProxy>.plusAssign(value: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattService) {
add(value)
}/**
* <code>repeated .dev.yanshouwang.bluetooth_low_energy.GattService services = 3;</code>
* @param values The services to add.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("addAllServices")
fun com.google.protobuf.kotlin.DslList<dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattService, ServicesProxy>.addAll(values: kotlin.collections.Iterable<dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattService>) {
_builder.addAllServices(values)
}/**
* <code>repeated .dev.yanshouwang.bluetooth_low_energy.GattService services = 3;</code>
* @param values The services to add.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("plusAssignAllServices")
inline operator fun com.google.protobuf.kotlin.DslList<dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattService, ServicesProxy>.plusAssign(values: kotlin.collections.Iterable<dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattService>) {
addAll(values)
}/**
* <code>repeated .dev.yanshouwang.bluetooth_low_energy.GattService services = 3;</code>
* @param index The index to set the value at.
* @param value The services to set.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("setServices")
operator fun com.google.protobuf.kotlin.DslList<dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattService, ServicesProxy>.set(index: kotlin.Int, value: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattService) {
_builder.setServices(index, value)
}/**
* <code>repeated .dev.yanshouwang.bluetooth_low_energy.GattService services = 3;</code>
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("clearServices")
fun com.google.protobuf.kotlin.DslList<dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattService, ServicesProxy>.clear() {
_builder.clearServices()
}}
}
@kotlin.jvm.JvmSynthetic
inline fun dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GATT.copy(block: dev.yanshouwang.bluetooth_low_energy.GATTKt.Dsl.() -> Unit): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GATT =
dev.yanshouwang.bluetooth_low_energy.GATTKt.Dsl._create(this.toBuilder()).apply { block() }._build()

View File

@ -0,0 +1,193 @@
//Generated by the protocol buffer compiler. DO NOT EDIT!
// source: message.proto
package dev.yanshouwang.bluetooth_low_energy;
@kotlin.jvm.JvmSynthetic
inline fun gattCharacteristic(block: dev.yanshouwang.bluetooth_low_energy.GattCharacteristicKt.Dsl.() -> Unit): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristic =
dev.yanshouwang.bluetooth_low_energy.GattCharacteristicKt.Dsl._create(dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristic.newBuilder()).apply { block() }._build()
object GattCharacteristicKt {
@kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)
@com.google.protobuf.kotlin.ProtoDslMarker
class Dsl private constructor(
@kotlin.jvm.JvmField private val _builder: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristic.Builder
) {
companion object {
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _create(builder: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristic.Builder): Dsl = Dsl(builder)
}
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _build(): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristic = _builder.build()
/**
* <code>int32 id = 1;</code>
*/
var id: kotlin.Int
@JvmName("getId")
get() = _builder.getId()
@JvmName("setId")
set(value) {
_builder.setId(value)
}
/**
* <code>int32 id = 1;</code>
*/
fun clearId() {
_builder.clearId()
}
/**
* <code>string uuid = 2;</code>
*/
var uuid: kotlin.String
@JvmName("getUuid")
get() = _builder.getUuid()
@JvmName("setUuid")
set(value) {
_builder.setUuid(value)
}
/**
* <code>string uuid = 2;</code>
*/
fun clearUuid() {
_builder.clearUuid()
}
/**
* An uninstantiable, behaviorless type to represent the field in
* generics.
*/
@kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)
class DescriptorsProxy private constructor() : com.google.protobuf.kotlin.DslProxy()
/**
* <code>repeated .dev.yanshouwang.bluetooth_low_energy.GattDescriptor descriptors = 3;</code>
*/
val descriptors: com.google.protobuf.kotlin.DslList<dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDescriptor, DescriptorsProxy>
@kotlin.jvm.JvmSynthetic
get() = com.google.protobuf.kotlin.DslList(
_builder.getDescriptorsList()
)
/**
* <code>repeated .dev.yanshouwang.bluetooth_low_energy.GattDescriptor descriptors = 3;</code>
* @param value The descriptors to add.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("addDescriptors")
fun com.google.protobuf.kotlin.DslList<dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDescriptor, DescriptorsProxy>.add(value: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDescriptor) {
_builder.addDescriptors(value)
}/**
* <code>repeated .dev.yanshouwang.bluetooth_low_energy.GattDescriptor descriptors = 3;</code>
* @param value The descriptors to add.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("plusAssignDescriptors")
inline operator fun com.google.protobuf.kotlin.DslList<dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDescriptor, DescriptorsProxy>.plusAssign(value: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDescriptor) {
add(value)
}/**
* <code>repeated .dev.yanshouwang.bluetooth_low_energy.GattDescriptor descriptors = 3;</code>
* @param values The descriptors to add.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("addAllDescriptors")
fun com.google.protobuf.kotlin.DslList<dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDescriptor, DescriptorsProxy>.addAll(values: kotlin.collections.Iterable<dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDescriptor>) {
_builder.addAllDescriptors(values)
}/**
* <code>repeated .dev.yanshouwang.bluetooth_low_energy.GattDescriptor descriptors = 3;</code>
* @param values The descriptors to add.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("plusAssignAllDescriptors")
inline operator fun com.google.protobuf.kotlin.DslList<dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDescriptor, DescriptorsProxy>.plusAssign(values: kotlin.collections.Iterable<dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDescriptor>) {
addAll(values)
}/**
* <code>repeated .dev.yanshouwang.bluetooth_low_energy.GattDescriptor descriptors = 3;</code>
* @param index The index to set the value at.
* @param value The descriptors to set.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("setDescriptors")
operator fun com.google.protobuf.kotlin.DslList<dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDescriptor, DescriptorsProxy>.set(index: kotlin.Int, value: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDescriptor) {
_builder.setDescriptors(index, value)
}/**
* <code>repeated .dev.yanshouwang.bluetooth_low_energy.GattDescriptor descriptors = 3;</code>
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("clearDescriptors")
fun com.google.protobuf.kotlin.DslList<dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDescriptor, DescriptorsProxy>.clear() {
_builder.clearDescriptors()
}
/**
* <code>bool canRead = 4;</code>
*/
var canRead: kotlin.Boolean
@JvmName("getCanRead")
get() = _builder.getCanRead()
@JvmName("setCanRead")
set(value) {
_builder.setCanRead(value)
}
/**
* <code>bool canRead = 4;</code>
*/
fun clearCanRead() {
_builder.clearCanRead()
}
/**
* <code>bool canWrite = 5;</code>
*/
var canWrite: kotlin.Boolean
@JvmName("getCanWrite")
get() = _builder.getCanWrite()
@JvmName("setCanWrite")
set(value) {
_builder.setCanWrite(value)
}
/**
* <code>bool canWrite = 5;</code>
*/
fun clearCanWrite() {
_builder.clearCanWrite()
}
/**
* <code>bool canWriteWithoutResponse = 6;</code>
*/
var canWriteWithoutResponse: kotlin.Boolean
@JvmName("getCanWriteWithoutResponse")
get() = _builder.getCanWriteWithoutResponse()
@JvmName("setCanWriteWithoutResponse")
set(value) {
_builder.setCanWriteWithoutResponse(value)
}
/**
* <code>bool canWriteWithoutResponse = 6;</code>
*/
fun clearCanWriteWithoutResponse() {
_builder.clearCanWriteWithoutResponse()
}
/**
* <code>bool canNotify = 7;</code>
*/
var canNotify: kotlin.Boolean
@JvmName("getCanNotify")
get() = _builder.getCanNotify()
@JvmName("setCanNotify")
set(value) {
_builder.setCanNotify(value)
}
/**
* <code>bool canNotify = 7;</code>
*/
fun clearCanNotify() {
_builder.clearCanNotify()
}
}
}
@kotlin.jvm.JvmSynthetic
inline fun dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristic.copy(block: dev.yanshouwang.bluetooth_low_energy.GattCharacteristicKt.Dsl.() -> Unit): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristic =
dev.yanshouwang.bluetooth_low_energy.GattCharacteristicKt.Dsl._create(this.toBuilder()).apply { block() }._build()

View File

@ -0,0 +1,113 @@
//Generated by the protocol buffer compiler. DO NOT EDIT!
// source: message.proto
package dev.yanshouwang.bluetooth_low_energy;
@kotlin.jvm.JvmSynthetic
inline fun gattCharacteristicNotifyArguments(block: dev.yanshouwang.bluetooth_low_energy.GattCharacteristicNotifyArgumentsKt.Dsl.() -> Unit): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristicNotifyArguments =
dev.yanshouwang.bluetooth_low_energy.GattCharacteristicNotifyArgumentsKt.Dsl._create(dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristicNotifyArguments.newBuilder()).apply { block() }._build()
object GattCharacteristicNotifyArgumentsKt {
@kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)
@com.google.protobuf.kotlin.ProtoDslMarker
class Dsl private constructor(
@kotlin.jvm.JvmField private val _builder: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristicNotifyArguments.Builder
) {
companion object {
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _create(builder: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristicNotifyArguments.Builder): Dsl = Dsl(builder)
}
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _build(): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristicNotifyArguments = _builder.build()
/**
* <code>string address = 1;</code>
*/
var address: kotlin.String
@JvmName("getAddress")
get() = _builder.getAddress()
@JvmName("setAddress")
set(value) {
_builder.setAddress(value)
}
/**
* <code>string address = 1;</code>
*/
fun clearAddress() {
_builder.clearAddress()
}
/**
* <code>string service_uuid = 2;</code>
*/
var serviceUuid: kotlin.String
@JvmName("getServiceUuid")
get() = _builder.getServiceUuid()
@JvmName("setServiceUuid")
set(value) {
_builder.setServiceUuid(value)
}
/**
* <code>string service_uuid = 2;</code>
*/
fun clearServiceUuid() {
_builder.clearServiceUuid()
}
/**
* <code>string uuid = 3;</code>
*/
var uuid: kotlin.String
@JvmName("getUuid")
get() = _builder.getUuid()
@JvmName("setUuid")
set(value) {
_builder.setUuid(value)
}
/**
* <code>string uuid = 3;</code>
*/
fun clearUuid() {
_builder.clearUuid()
}
/**
* <code>int32 id = 4;</code>
*/
var id: kotlin.Int
@JvmName("getId")
get() = _builder.getId()
@JvmName("setId")
set(value) {
_builder.setId(value)
}
/**
* <code>int32 id = 4;</code>
*/
fun clearId() {
_builder.clearId()
}
/**
* <code>bool state = 5;</code>
*/
var state: kotlin.Boolean
@JvmName("getState")
get() = _builder.getState()
@JvmName("setState")
set(value) {
_builder.setState(value)
}
/**
* <code>bool state = 5;</code>
*/
fun clearState() {
_builder.clearState()
}
}
}
@kotlin.jvm.JvmSynthetic
inline fun dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristicNotifyArguments.copy(block: dev.yanshouwang.bluetooth_low_energy.GattCharacteristicNotifyArgumentsKt.Dsl.() -> Unit): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristicNotifyArguments =
dev.yanshouwang.bluetooth_low_energy.GattCharacteristicNotifyArgumentsKt.Dsl._create(this.toBuilder()).apply { block() }._build()

View File

@ -0,0 +1,96 @@
//Generated by the protocol buffer compiler. DO NOT EDIT!
// source: message.proto
package dev.yanshouwang.bluetooth_low_energy;
@kotlin.jvm.JvmSynthetic
inline fun gattCharacteristicReadArguments(block: dev.yanshouwang.bluetooth_low_energy.GattCharacteristicReadArgumentsKt.Dsl.() -> Unit): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristicReadArguments =
dev.yanshouwang.bluetooth_low_energy.GattCharacteristicReadArgumentsKt.Dsl._create(dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristicReadArguments.newBuilder()).apply { block() }._build()
object GattCharacteristicReadArgumentsKt {
@kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)
@com.google.protobuf.kotlin.ProtoDslMarker
class Dsl private constructor(
@kotlin.jvm.JvmField private val _builder: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristicReadArguments.Builder
) {
companion object {
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _create(builder: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristicReadArguments.Builder): Dsl = Dsl(builder)
}
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _build(): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristicReadArguments = _builder.build()
/**
* <code>string address = 1;</code>
*/
var address: kotlin.String
@JvmName("getAddress")
get() = _builder.getAddress()
@JvmName("setAddress")
set(value) {
_builder.setAddress(value)
}
/**
* <code>string address = 1;</code>
*/
fun clearAddress() {
_builder.clearAddress()
}
/**
* <code>string service_uuid = 2;</code>
*/
var serviceUuid: kotlin.String
@JvmName("getServiceUuid")
get() = _builder.getServiceUuid()
@JvmName("setServiceUuid")
set(value) {
_builder.setServiceUuid(value)
}
/**
* <code>string service_uuid = 2;</code>
*/
fun clearServiceUuid() {
_builder.clearServiceUuid()
}
/**
* <code>string uuid = 3;</code>
*/
var uuid: kotlin.String
@JvmName("getUuid")
get() = _builder.getUuid()
@JvmName("setUuid")
set(value) {
_builder.setUuid(value)
}
/**
* <code>string uuid = 3;</code>
*/
fun clearUuid() {
_builder.clearUuid()
}
/**
* <code>int32 id = 4;</code>
*/
var id: kotlin.Int
@JvmName("getId")
get() = _builder.getId()
@JvmName("setId")
set(value) {
_builder.setId(value)
}
/**
* <code>int32 id = 4;</code>
*/
fun clearId() {
_builder.clearId()
}
}
}
@kotlin.jvm.JvmSynthetic
inline fun dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristicReadArguments.copy(block: dev.yanshouwang.bluetooth_low_energy.GattCharacteristicReadArgumentsKt.Dsl.() -> Unit): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristicReadArguments =
dev.yanshouwang.bluetooth_low_energy.GattCharacteristicReadArgumentsKt.Dsl._create(this.toBuilder()).apply { block() }._build()

View File

@ -0,0 +1,62 @@
//Generated by the protocol buffer compiler. DO NOT EDIT!
// source: message.proto
package dev.yanshouwang.bluetooth_low_energy;
@kotlin.jvm.JvmSynthetic
inline fun gattCharacteristicValue(block: dev.yanshouwang.bluetooth_low_energy.GattCharacteristicValueKt.Dsl.() -> Unit): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristicValue =
dev.yanshouwang.bluetooth_low_energy.GattCharacteristicValueKt.Dsl._create(dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristicValue.newBuilder()).apply { block() }._build()
object GattCharacteristicValueKt {
@kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)
@com.google.protobuf.kotlin.ProtoDslMarker
class Dsl private constructor(
@kotlin.jvm.JvmField private val _builder: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristicValue.Builder
) {
companion object {
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _create(builder: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristicValue.Builder): Dsl = Dsl(builder)
}
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _build(): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristicValue = _builder.build()
/**
* <code>int32 id = 3;</code>
*/
var id: kotlin.Int
@JvmName("getId")
get() = _builder.getId()
@JvmName("setId")
set(value) {
_builder.setId(value)
}
/**
* <code>int32 id = 3;</code>
*/
fun clearId() {
_builder.clearId()
}
/**
* <code>bytes value = 4;</code>
*/
var value: com.google.protobuf.ByteString
@JvmName("getValue")
get() = _builder.getValue()
@JvmName("setValue")
set(value) {
_builder.setValue(value)
}
/**
* <code>bytes value = 4;</code>
*/
fun clearValue() {
_builder.clearValue()
}
}
}
@kotlin.jvm.JvmSynthetic
inline fun dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristicValue.copy(block: dev.yanshouwang.bluetooth_low_energy.GattCharacteristicValueKt.Dsl.() -> Unit): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristicValue =
dev.yanshouwang.bluetooth_low_energy.GattCharacteristicValueKt.Dsl._create(this.toBuilder()).apply { block() }._build()

View File

@ -0,0 +1,130 @@
//Generated by the protocol buffer compiler. DO NOT EDIT!
// source: message.proto
package dev.yanshouwang.bluetooth_low_energy;
@kotlin.jvm.JvmSynthetic
inline fun gattCharacteristicWriteArguments(block: dev.yanshouwang.bluetooth_low_energy.GattCharacteristicWriteArgumentsKt.Dsl.() -> Unit): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristicWriteArguments =
dev.yanshouwang.bluetooth_low_energy.GattCharacteristicWriteArgumentsKt.Dsl._create(dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristicWriteArguments.newBuilder()).apply { block() }._build()
object GattCharacteristicWriteArgumentsKt {
@kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)
@com.google.protobuf.kotlin.ProtoDslMarker
class Dsl private constructor(
@kotlin.jvm.JvmField private val _builder: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristicWriteArguments.Builder
) {
companion object {
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _create(builder: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristicWriteArguments.Builder): Dsl = Dsl(builder)
}
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _build(): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristicWriteArguments = _builder.build()
/**
* <code>string address = 1;</code>
*/
var address: kotlin.String
@JvmName("getAddress")
get() = _builder.getAddress()
@JvmName("setAddress")
set(value) {
_builder.setAddress(value)
}
/**
* <code>string address = 1;</code>
*/
fun clearAddress() {
_builder.clearAddress()
}
/**
* <code>string service_uuid = 2;</code>
*/
var serviceUuid: kotlin.String
@JvmName("getServiceUuid")
get() = _builder.getServiceUuid()
@JvmName("setServiceUuid")
set(value) {
_builder.setServiceUuid(value)
}
/**
* <code>string service_uuid = 2;</code>
*/
fun clearServiceUuid() {
_builder.clearServiceUuid()
}
/**
* <code>string uuid = 3;</code>
*/
var uuid: kotlin.String
@JvmName("getUuid")
get() = _builder.getUuid()
@JvmName("setUuid")
set(value) {
_builder.setUuid(value)
}
/**
* <code>string uuid = 3;</code>
*/
fun clearUuid() {
_builder.clearUuid()
}
/**
* <code>int32 id = 4;</code>
*/
var id: kotlin.Int
@JvmName("getId")
get() = _builder.getId()
@JvmName("setId")
set(value) {
_builder.setId(value)
}
/**
* <code>int32 id = 4;</code>
*/
fun clearId() {
_builder.clearId()
}
/**
* <code>bytes value = 5;</code>
*/
var value: com.google.protobuf.ByteString
@JvmName("getValue")
get() = _builder.getValue()
@JvmName("setValue")
set(value) {
_builder.setValue(value)
}
/**
* <code>bytes value = 5;</code>
*/
fun clearValue() {
_builder.clearValue()
}
/**
* <code>bool withoutResponse = 6;</code>
*/
var withoutResponse: kotlin.Boolean
@JvmName("getWithoutResponse")
get() = _builder.getWithoutResponse()
@JvmName("setWithoutResponse")
set(value) {
_builder.setWithoutResponse(value)
}
/**
* <code>bool withoutResponse = 6;</code>
*/
fun clearWithoutResponse() {
_builder.clearWithoutResponse()
}
}
}
@kotlin.jvm.JvmSynthetic
inline fun dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristicWriteArguments.copy(block: dev.yanshouwang.bluetooth_low_energy.GattCharacteristicWriteArgumentsKt.Dsl.() -> Unit): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristicWriteArguments =
dev.yanshouwang.bluetooth_low_energy.GattCharacteristicWriteArgumentsKt.Dsl._create(this.toBuilder()).apply { block() }._build()

View File

@ -0,0 +1,62 @@
//Generated by the protocol buffer compiler. DO NOT EDIT!
// source: message.proto
package dev.yanshouwang.bluetooth_low_energy;
@kotlin.jvm.JvmSynthetic
inline fun gattDescriptor(block: dev.yanshouwang.bluetooth_low_energy.GattDescriptorKt.Dsl.() -> Unit): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDescriptor =
dev.yanshouwang.bluetooth_low_energy.GattDescriptorKt.Dsl._create(dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDescriptor.newBuilder()).apply { block() }._build()
object GattDescriptorKt {
@kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)
@com.google.protobuf.kotlin.ProtoDslMarker
class Dsl private constructor(
@kotlin.jvm.JvmField private val _builder: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDescriptor.Builder
) {
companion object {
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _create(builder: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDescriptor.Builder): Dsl = Dsl(builder)
}
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _build(): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDescriptor = _builder.build()
/**
* <code>int32 id = 1;</code>
*/
var id: kotlin.Int
@JvmName("getId")
get() = _builder.getId()
@JvmName("setId")
set(value) {
_builder.setId(value)
}
/**
* <code>int32 id = 1;</code>
*/
fun clearId() {
_builder.clearId()
}
/**
* <code>string uuid = 2;</code>
*/
var uuid: kotlin.String
@JvmName("getUuid")
get() = _builder.getUuid()
@JvmName("setUuid")
set(value) {
_builder.setUuid(value)
}
/**
* <code>string uuid = 2;</code>
*/
fun clearUuid() {
_builder.clearUuid()
}
}
}
@kotlin.jvm.JvmSynthetic
inline fun dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDescriptor.copy(block: dev.yanshouwang.bluetooth_low_energy.GattDescriptorKt.Dsl.() -> Unit): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDescriptor =
dev.yanshouwang.bluetooth_low_energy.GattDescriptorKt.Dsl._create(this.toBuilder()).apply { block() }._build()

View File

@ -0,0 +1,113 @@
//Generated by the protocol buffer compiler. DO NOT EDIT!
// source: message.proto
package dev.yanshouwang.bluetooth_low_energy;
@kotlin.jvm.JvmSynthetic
inline fun gattDescriptorReadArguments(block: dev.yanshouwang.bluetooth_low_energy.GattDescriptorReadArgumentsKt.Dsl.() -> Unit): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDescriptorReadArguments =
dev.yanshouwang.bluetooth_low_energy.GattDescriptorReadArgumentsKt.Dsl._create(dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDescriptorReadArguments.newBuilder()).apply { block() }._build()
object GattDescriptorReadArgumentsKt {
@kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)
@com.google.protobuf.kotlin.ProtoDslMarker
class Dsl private constructor(
@kotlin.jvm.JvmField private val _builder: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDescriptorReadArguments.Builder
) {
companion object {
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _create(builder: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDescriptorReadArguments.Builder): Dsl = Dsl(builder)
}
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _build(): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDescriptorReadArguments = _builder.build()
/**
* <code>string address = 1;</code>
*/
var address: kotlin.String
@JvmName("getAddress")
get() = _builder.getAddress()
@JvmName("setAddress")
set(value) {
_builder.setAddress(value)
}
/**
* <code>string address = 1;</code>
*/
fun clearAddress() {
_builder.clearAddress()
}
/**
* <code>string service_uuid = 2;</code>
*/
var serviceUuid: kotlin.String
@JvmName("getServiceUuid")
get() = _builder.getServiceUuid()
@JvmName("setServiceUuid")
set(value) {
_builder.setServiceUuid(value)
}
/**
* <code>string service_uuid = 2;</code>
*/
fun clearServiceUuid() {
_builder.clearServiceUuid()
}
/**
* <code>string characteristic_uuid = 3;</code>
*/
var characteristicUuid: kotlin.String
@JvmName("getCharacteristicUuid")
get() = _builder.getCharacteristicUuid()
@JvmName("setCharacteristicUuid")
set(value) {
_builder.setCharacteristicUuid(value)
}
/**
* <code>string characteristic_uuid = 3;</code>
*/
fun clearCharacteristicUuid() {
_builder.clearCharacteristicUuid()
}
/**
* <code>string uuid = 4;</code>
*/
var uuid: kotlin.String
@JvmName("getUuid")
get() = _builder.getUuid()
@JvmName("setUuid")
set(value) {
_builder.setUuid(value)
}
/**
* <code>string uuid = 4;</code>
*/
fun clearUuid() {
_builder.clearUuid()
}
/**
* <code>int32 id = 5;</code>
*/
var id: kotlin.Int
@JvmName("getId")
get() = _builder.getId()
@JvmName("setId")
set(value) {
_builder.setId(value)
}
/**
* <code>int32 id = 5;</code>
*/
fun clearId() {
_builder.clearId()
}
}
}
@kotlin.jvm.JvmSynthetic
inline fun dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDescriptorReadArguments.copy(block: dev.yanshouwang.bluetooth_low_energy.GattDescriptorReadArgumentsKt.Dsl.() -> Unit): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDescriptorReadArguments =
dev.yanshouwang.bluetooth_low_energy.GattDescriptorReadArgumentsKt.Dsl._create(this.toBuilder()).apply { block() }._build()

View File

@ -0,0 +1,130 @@
//Generated by the protocol buffer compiler. DO NOT EDIT!
// source: message.proto
package dev.yanshouwang.bluetooth_low_energy;
@kotlin.jvm.JvmSynthetic
inline fun gattDescriptorWriteArguments(block: dev.yanshouwang.bluetooth_low_energy.GattDescriptorWriteArgumentsKt.Dsl.() -> Unit): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDescriptorWriteArguments =
dev.yanshouwang.bluetooth_low_energy.GattDescriptorWriteArgumentsKt.Dsl._create(dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDescriptorWriteArguments.newBuilder()).apply { block() }._build()
object GattDescriptorWriteArgumentsKt {
@kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)
@com.google.protobuf.kotlin.ProtoDslMarker
class Dsl private constructor(
@kotlin.jvm.JvmField private val _builder: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDescriptorWriteArguments.Builder
) {
companion object {
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _create(builder: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDescriptorWriteArguments.Builder): Dsl = Dsl(builder)
}
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _build(): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDescriptorWriteArguments = _builder.build()
/**
* <code>string address = 1;</code>
*/
var address: kotlin.String
@JvmName("getAddress")
get() = _builder.getAddress()
@JvmName("setAddress")
set(value) {
_builder.setAddress(value)
}
/**
* <code>string address = 1;</code>
*/
fun clearAddress() {
_builder.clearAddress()
}
/**
* <code>string service_uuid = 2;</code>
*/
var serviceUuid: kotlin.String
@JvmName("getServiceUuid")
get() = _builder.getServiceUuid()
@JvmName("setServiceUuid")
set(value) {
_builder.setServiceUuid(value)
}
/**
* <code>string service_uuid = 2;</code>
*/
fun clearServiceUuid() {
_builder.clearServiceUuid()
}
/**
* <code>string characteristic_uuid = 3;</code>
*/
var characteristicUuid: kotlin.String
@JvmName("getCharacteristicUuid")
get() = _builder.getCharacteristicUuid()
@JvmName("setCharacteristicUuid")
set(value) {
_builder.setCharacteristicUuid(value)
}
/**
* <code>string characteristic_uuid = 3;</code>
*/
fun clearCharacteristicUuid() {
_builder.clearCharacteristicUuid()
}
/**
* <code>string uuid = 4;</code>
*/
var uuid: kotlin.String
@JvmName("getUuid")
get() = _builder.getUuid()
@JvmName("setUuid")
set(value) {
_builder.setUuid(value)
}
/**
* <code>string uuid = 4;</code>
*/
fun clearUuid() {
_builder.clearUuid()
}
/**
* <code>int32 id = 5;</code>
*/
var id: kotlin.Int
@JvmName("getId")
get() = _builder.getId()
@JvmName("setId")
set(value) {
_builder.setId(value)
}
/**
* <code>int32 id = 5;</code>
*/
fun clearId() {
_builder.clearId()
}
/**
* <code>bytes value = 6;</code>
*/
var value: com.google.protobuf.ByteString
@JvmName("getValue")
get() = _builder.getValue()
@JvmName("setValue")
set(value) {
_builder.setValue(value)
}
/**
* <code>bytes value = 6;</code>
*/
fun clearValue() {
_builder.clearValue()
}
}
}
@kotlin.jvm.JvmSynthetic
inline fun dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDescriptorWriteArguments.copy(block: dev.yanshouwang.bluetooth_low_energy.GattDescriptorWriteArgumentsKt.Dsl.() -> Unit): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDescriptorWriteArguments =
dev.yanshouwang.bluetooth_low_energy.GattDescriptorWriteArgumentsKt.Dsl._create(this.toBuilder()).apply { block() }._build()

View File

@ -0,0 +1,62 @@
//Generated by the protocol buffer compiler. DO NOT EDIT!
// source: message.proto
package dev.yanshouwang.bluetooth_low_energy;
@kotlin.jvm.JvmSynthetic
inline fun gattDisconnectArguments(block: dev.yanshouwang.bluetooth_low_energy.GattDisconnectArgumentsKt.Dsl.() -> Unit): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDisconnectArguments =
dev.yanshouwang.bluetooth_low_energy.GattDisconnectArgumentsKt.Dsl._create(dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDisconnectArguments.newBuilder()).apply { block() }._build()
object GattDisconnectArgumentsKt {
@kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)
@com.google.protobuf.kotlin.ProtoDslMarker
class Dsl private constructor(
@kotlin.jvm.JvmField private val _builder: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDisconnectArguments.Builder
) {
companion object {
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _create(builder: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDisconnectArguments.Builder): Dsl = Dsl(builder)
}
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _build(): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDisconnectArguments = _builder.build()
/**
* <code>string address = 1;</code>
*/
var address: kotlin.String
@JvmName("getAddress")
get() = _builder.getAddress()
@JvmName("setAddress")
set(value) {
_builder.setAddress(value)
}
/**
* <code>string address = 1;</code>
*/
fun clearAddress() {
_builder.clearAddress()
}
/**
* <code>int32 id = 2;</code>
*/
var id: kotlin.Int
@JvmName("getId")
get() = _builder.getId()
@JvmName("setId")
set(value) {
_builder.setId(value)
}
/**
* <code>int32 id = 2;</code>
*/
fun clearId() {
_builder.clearId()
}
}
}
@kotlin.jvm.JvmSynthetic
inline fun dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDisconnectArguments.copy(block: dev.yanshouwang.bluetooth_low_energy.GattDisconnectArgumentsKt.Dsl.() -> Unit): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattDisconnectArguments =
dev.yanshouwang.bluetooth_low_energy.GattDisconnectArgumentsKt.Dsl._create(this.toBuilder()).apply { block() }._build()

View File

@ -0,0 +1,125 @@
//Generated by the protocol buffer compiler. DO NOT EDIT!
// source: message.proto
package dev.yanshouwang.bluetooth_low_energy;
@kotlin.jvm.JvmSynthetic
inline fun gattService(block: dev.yanshouwang.bluetooth_low_energy.GattServiceKt.Dsl.() -> Unit): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattService =
dev.yanshouwang.bluetooth_low_energy.GattServiceKt.Dsl._create(dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattService.newBuilder()).apply { block() }._build()
object GattServiceKt {
@kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)
@com.google.protobuf.kotlin.ProtoDslMarker
class Dsl private constructor(
@kotlin.jvm.JvmField private val _builder: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattService.Builder
) {
companion object {
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _create(builder: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattService.Builder): Dsl = Dsl(builder)
}
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _build(): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattService = _builder.build()
/**
* <code>int32 id = 1;</code>
*/
var id: kotlin.Int
@JvmName("getId")
get() = _builder.getId()
@JvmName("setId")
set(value) {
_builder.setId(value)
}
/**
* <code>int32 id = 1;</code>
*/
fun clearId() {
_builder.clearId()
}
/**
* <code>string uuid = 2;</code>
*/
var uuid: kotlin.String
@JvmName("getUuid")
get() = _builder.getUuid()
@JvmName("setUuid")
set(value) {
_builder.setUuid(value)
}
/**
* <code>string uuid = 2;</code>
*/
fun clearUuid() {
_builder.clearUuid()
}
/**
* An uninstantiable, behaviorless type to represent the field in
* generics.
*/
@kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)
class CharacteristicsProxy private constructor() : com.google.protobuf.kotlin.DslProxy()
/**
* <code>repeated .dev.yanshouwang.bluetooth_low_energy.GattCharacteristic characteristics = 3;</code>
*/
val characteristics: com.google.protobuf.kotlin.DslList<dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristic, CharacteristicsProxy>
@kotlin.jvm.JvmSynthetic
get() = com.google.protobuf.kotlin.DslList(
_builder.getCharacteristicsList()
)
/**
* <code>repeated .dev.yanshouwang.bluetooth_low_energy.GattCharacteristic characteristics = 3;</code>
* @param value The characteristics to add.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("addCharacteristics")
fun com.google.protobuf.kotlin.DslList<dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristic, CharacteristicsProxy>.add(value: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristic) {
_builder.addCharacteristics(value)
}/**
* <code>repeated .dev.yanshouwang.bluetooth_low_energy.GattCharacteristic characteristics = 3;</code>
* @param value The characteristics to add.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("plusAssignCharacteristics")
inline operator fun com.google.protobuf.kotlin.DslList<dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristic, CharacteristicsProxy>.plusAssign(value: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristic) {
add(value)
}/**
* <code>repeated .dev.yanshouwang.bluetooth_low_energy.GattCharacteristic characteristics = 3;</code>
* @param values The characteristics to add.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("addAllCharacteristics")
fun com.google.protobuf.kotlin.DslList<dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristic, CharacteristicsProxy>.addAll(values: kotlin.collections.Iterable<dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristic>) {
_builder.addAllCharacteristics(values)
}/**
* <code>repeated .dev.yanshouwang.bluetooth_low_energy.GattCharacteristic characteristics = 3;</code>
* @param values The characteristics to add.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("plusAssignAllCharacteristics")
inline operator fun com.google.protobuf.kotlin.DslList<dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristic, CharacteristicsProxy>.plusAssign(values: kotlin.collections.Iterable<dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristic>) {
addAll(values)
}/**
* <code>repeated .dev.yanshouwang.bluetooth_low_energy.GattCharacteristic characteristics = 3;</code>
* @param index The index to set the value at.
* @param value The characteristics to set.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("setCharacteristics")
operator fun com.google.protobuf.kotlin.DslList<dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristic, CharacteristicsProxy>.set(index: kotlin.Int, value: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristic) {
_builder.setCharacteristics(index, value)
}/**
* <code>repeated .dev.yanshouwang.bluetooth_low_energy.GattCharacteristic characteristics = 3;</code>
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("clearCharacteristics")
fun com.google.protobuf.kotlin.DslList<dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristic, CharacteristicsProxy>.clear() {
_builder.clearCharacteristics()
}}
}
@kotlin.jvm.JvmSynthetic
inline fun dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattService.copy(block: dev.yanshouwang.bluetooth_low_energy.GattServiceKt.Dsl.() -> Unit): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattService =
dev.yanshouwang.bluetooth_low_energy.GattServiceKt.Dsl._create(this.toBuilder()).apply { block() }._build()

View File

@ -0,0 +1,172 @@
//Generated by the protocol buffer compiler. DO NOT EDIT!
// source: message.proto
package dev.yanshouwang.bluetooth_low_energy;
@kotlin.jvm.JvmSynthetic
inline fun message(block: dev.yanshouwang.bluetooth_low_energy.MessageKt.Dsl.() -> Unit): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.Message =
dev.yanshouwang.bluetooth_low_energy.MessageKt.Dsl._create(dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.Message.newBuilder()).apply { block() }._build()
object MessageKt {
@kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)
@com.google.protobuf.kotlin.ProtoDslMarker
class Dsl private constructor(
@kotlin.jvm.JvmField private val _builder: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.Message.Builder
) {
companion object {
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _create(builder: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.Message.Builder): Dsl = Dsl(builder)
}
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _build(): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.Message = _builder.build()
/**
* <code>.dev.yanshouwang.bluetooth_low_energy.MessageCategory category = 1;</code>
*/
var category: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.MessageCategory
@JvmName("getCategory")
get() = _builder.getCategory()
@JvmName("setCategory")
set(value) {
_builder.setCategory(value)
}
/**
* <code>.dev.yanshouwang.bluetooth_low_energy.MessageCategory category = 1;</code>
*/
fun clearCategory() {
_builder.clearCategory()
}
/**
* <code>bool state = 2;</code>
*/
var state: kotlin.Boolean
@JvmName("getState")
get() = _builder.getState()
@JvmName("setState")
set(value) {
_builder.setState(value)
}
/**
* <code>bool state = 2;</code>
*/
fun clearState() {
_builder.clearState()
}
/**
* <code>bool state = 2;</code>
* @return Whether the state field is set.
*/
fun hasState(): kotlin.Boolean {
return _builder.hasState()
}
/**
* <code>.dev.yanshouwang.bluetooth_low_energy.Discovery discovery = 3;</code>
*/
var discovery: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.Discovery
@JvmName("getDiscovery")
get() = _builder.getDiscovery()
@JvmName("setDiscovery")
set(value) {
_builder.setDiscovery(value)
}
/**
* <code>.dev.yanshouwang.bluetooth_low_energy.Discovery discovery = 3;</code>
*/
fun clearDiscovery() {
_builder.clearDiscovery()
}
/**
* <code>.dev.yanshouwang.bluetooth_low_energy.Discovery discovery = 3;</code>
* @return Whether the discovery field is set.
*/
fun hasDiscovery(): kotlin.Boolean {
return _builder.hasDiscovery()
}
/**
* <code>bool scanning = 4;</code>
*/
var scanning: kotlin.Boolean
@JvmName("getScanning")
get() = _builder.getScanning()
@JvmName("setScanning")
set(value) {
_builder.setScanning(value)
}
/**
* <code>bool scanning = 4;</code>
*/
fun clearScanning() {
_builder.clearScanning()
}
/**
* <code>bool scanning = 4;</code>
* @return Whether the scanning field is set.
*/
fun hasScanning(): kotlin.Boolean {
return _builder.hasScanning()
}
/**
* <code>.dev.yanshouwang.bluetooth_low_energy.ConnectionLost connectionLost = 5;</code>
*/
var connectionLost: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.ConnectionLost
@JvmName("getConnectionLost")
get() = _builder.getConnectionLost()
@JvmName("setConnectionLost")
set(value) {
_builder.setConnectionLost(value)
}
/**
* <code>.dev.yanshouwang.bluetooth_low_energy.ConnectionLost connectionLost = 5;</code>
*/
fun clearConnectionLost() {
_builder.clearConnectionLost()
}
/**
* <code>.dev.yanshouwang.bluetooth_low_energy.ConnectionLost connectionLost = 5;</code>
* @return Whether the connectionLost field is set.
*/
fun hasConnectionLost(): kotlin.Boolean {
return _builder.hasConnectionLost()
}
/**
* <code>.dev.yanshouwang.bluetooth_low_energy.GattCharacteristicValue characteristicValue = 6;</code>
*/
var characteristicValue: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.GattCharacteristicValue
@JvmName("getCharacteristicValue")
get() = _builder.getCharacteristicValue()
@JvmName("setCharacteristicValue")
set(value) {
_builder.setCharacteristicValue(value)
}
/**
* <code>.dev.yanshouwang.bluetooth_low_energy.GattCharacteristicValue characteristicValue = 6;</code>
*/
fun clearCharacteristicValue() {
_builder.clearCharacteristicValue()
}
/**
* <code>.dev.yanshouwang.bluetooth_low_energy.GattCharacteristicValue characteristicValue = 6;</code>
* @return Whether the characteristicValue field is set.
*/
fun hasCharacteristicValue(): kotlin.Boolean {
return _builder.hasCharacteristicValue()
}
val valueCase: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.Message.ValueCase
@JvmName("getValueCase")
get() = _builder.getValueCase()
fun clearValue() {
_builder.clearValue()
}
}
}
@kotlin.jvm.JvmSynthetic
inline fun dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.Message.copy(block: dev.yanshouwang.bluetooth_low_energy.MessageKt.Dsl.() -> Unit): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.Message =
dev.yanshouwang.bluetooth_low_energy.MessageKt.Dsl._create(this.toBuilder()).apply { block() }._build()

View File

@ -0,0 +1,96 @@
//Generated by the protocol buffer compiler. DO NOT EDIT!
// source: message.proto
package dev.yanshouwang.bluetooth_low_energy;
@kotlin.jvm.JvmSynthetic
inline fun startDiscoveryArguments(block: dev.yanshouwang.bluetooth_low_energy.StartDiscoveryArgumentsKt.Dsl.() -> Unit): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.StartDiscoveryArguments =
dev.yanshouwang.bluetooth_low_energy.StartDiscoveryArgumentsKt.Dsl._create(dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.StartDiscoveryArguments.newBuilder()).apply { block() }._build()
object StartDiscoveryArgumentsKt {
@kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)
@com.google.protobuf.kotlin.ProtoDslMarker
class Dsl private constructor(
@kotlin.jvm.JvmField private val _builder: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.StartDiscoveryArguments.Builder
) {
companion object {
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _create(builder: dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.StartDiscoveryArguments.Builder): Dsl = Dsl(builder)
}
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _build(): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.StartDiscoveryArguments = _builder.build()
/**
* An uninstantiable, behaviorless type to represent the field in
* generics.
*/
@kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)
class ServicesProxy private constructor() : com.google.protobuf.kotlin.DslProxy()
/**
* <code>repeated string services = 1;</code>
* @return A list containing the services.
*/
val services: com.google.protobuf.kotlin.DslList<kotlin.String, ServicesProxy>
@kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)
get() = com.google.protobuf.kotlin.DslList(
_builder.getServicesList()
)
/**
* <code>repeated string services = 1;</code>
* @param value The services to add.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("addServices")
fun com.google.protobuf.kotlin.DslList<kotlin.String, ServicesProxy>.add(value: kotlin.String) {
_builder.addServices(value)
}
/**
* <code>repeated string services = 1;</code>
* @param value The services to add.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("plusAssignServices")
operator fun com.google.protobuf.kotlin.DslList<kotlin.String, ServicesProxy>.plusAssign(value: kotlin.String) {
_builder.addServices(value)
}
/**
* <code>repeated string services = 1;</code>
* @param values The services to add.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("addAllServices")
fun com.google.protobuf.kotlin.DslList<kotlin.String, ServicesProxy>.addAll(values: kotlin.collections.Iterable<kotlin.String>) {
_builder.addAllServices(values)
}
/**
* <code>repeated string services = 1;</code>
* @param values The services to add.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("plusAssignAllServices")
operator fun com.google.protobuf.kotlin.DslList<kotlin.String, ServicesProxy>.plusAssign(values: kotlin.collections.Iterable<kotlin.String>) {
_builder.addAllServices(values)
}
/**
* <code>repeated string services = 1;</code>
* @param index The index to set the value at.
* @param value The services to set.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("setServices")
operator fun com.google.protobuf.kotlin.DslList<kotlin.String, ServicesProxy>.set(index: kotlin.Int, value: kotlin.String) {
_builder.setServices(index, value)
}/**
* <code>repeated string services = 1;</code>
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("clearServices")
fun com.google.protobuf.kotlin.DslList<kotlin.String, ServicesProxy>.clear() {
_builder.clearServices()
}}
}
@kotlin.jvm.JvmSynthetic
inline fun dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.StartDiscoveryArguments.copy(block: dev.yanshouwang.bluetooth_low_energy.StartDiscoveryArgumentsKt.Dsl.() -> Unit): dev.yanshouwang.bluetooth_low_energy.MessageOuterClass.StartDiscoveryArguments =
dev.yanshouwang.bluetooth_low_energy.StartDiscoveryArgumentsKt.Dsl._create(this.toBuilder()).apply { block() }._build()