ble_peripheralライブラリのexampleコードを使用して,central側からBLE Writeができるように改良を試みてるのですが,以下のログが表示されwriteができません.exampleコードのhome_controller.dartのBleService get _batteryServiceの部分を変更して実行しています.コードを載せますので,修正すべき箇所をご教授お願いいたします.central側はflutter_blue_plusライブラリのexampleコードを使用してwriteしようとしています.
D/[FBP-Android]( 3111): [FBP] onMethodCall: writeCharacteristic
D/[FBP-Android]( 3111): [FBP] onMethodCall: getAdapterState
W/BluetoothGattServer( 3111): Unhandled exception in callback
W/BluetoothGattServer( 3111): java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread. Current thread: binder:3111_6
W/BluetoothGattServer( 3111): at io.flutter.embedding.engine.FlutterJNI.ensureRunningOnMainThread(FlutterJNI.java:1449)
W/BluetoothGattServer( 3111): at io.flutter.embedding.engine.FlutterJNI.dispatchPlatformMessage(FlutterJNI.java:1070)
W/BluetoothGattServer( 3111): at io.flutter.embedding.engine.dart.DartMessenger.send(DartMessenger.java:282)
W/BluetoothGattServer( 3111): at io.flutter.embedding.engine.dart.DartExecutor$DefaultBinaryMessenger.send(DartExecutor.java:470)
W/BluetoothGattServer( 3111): at io.flutter.embedding.engine.dart.DartExecutor.send(DartExecutor.java:223)
W/BluetoothGattServer( 3111): at io.flutter.plugin.common.BasicMessageChannel.send(BasicMessageChannel.java:106)
W/BluetoothGattServer( 3111): at com.rohit.ble_peripheral.BleCallback.onWriteRequest(BlePeripheral.g.kt:490)
W/BluetoothGattServer( 3111): at com.rohit.ble_peripheral.BlePeripheralPlugin$gattServerCallback$1.onCharacteristicWriteRequest(BlePeripheralPlugin.kt:405)
W/BluetoothGattServer( 3111): at android.bluetooth.BluetoothGattServer$1.onCharacteristicWriteRequest(BluetoothGattServer.java:228)
W/BluetoothGattServer( 3111): at android.bluetooth.IBluetoothGattServerCallback$Stub.onTransact(IBluetoothGattServerCallback.java:186)
W/BluetoothGattServer( 3111): at android.os.Binder.execTransactInternal(Binder.java:1285)
W/BluetoothGattServer( 3111): at android.os.Binder.execTransact(Binder.java:1244)
BleService get _batteryService {
return BleService(
uuid: serviceBattery,
primary: true,
characteristics: [
BleCharacteristic(
uuid: characteristicBatteryLevel,
properties: [
CharacteristicProperties.read.index,
CharacteristicProperties.notify.index,
CharacteristicProperties.write.index
],
value: null,
permissions: [AttributePermissions.readable.index,
AttributePermissions.writeable.index
],
),
],
);}