Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when setting value for serviceData #94

Open
ONLYstcm opened this issue Aug 28, 2022 · 2 comments
Open

Error when setting value for serviceData #94

ONLYstcm opened this issue Aug 28, 2022 · 2 comments

Comments

@ONLYstcm
Copy link

When trying to use serviceData in AdvertiseData, for example:
serviceData: [7,8,9,10]

I get the following error at the beginning of a advertisment function:

E/MethodChannel#dev.steenbakker.flutter_ble_peripheral/ble_state( 8553): Failed to handle method call
E/MethodChannel#dev.steenbakker.flutter_ble_peripheral/ble_state( 8553): java.lang.ClassCastException: java.util.ArrayList cannot be cast to byte[]
E/MethodChannel#dev.steenbakker.flutter_ble_peripheral/ble_state( 8553): 	at dev.steenbakker.flutter_ble_peripheral.FlutterBlePeripheralPlugin.startPeripheral(FlutterBlePeripheralPlugin.kt:167)
E/MethodChannel#dev.steenbakker.flutter_ble_peripheral/ble_state( 8553): 	at dev.steenbakker.flutter_ble_peripheral.FlutterBlePeripheralPlugin.onMethodCall(FlutterBlePeripheralPlugin.kt:123)
E/MethodChannel#dev.steenbakker.flutter_ble_peripheral/ble_state( 8553): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
E/MethodChannel#dev.steenbakker.flutter_ble_peripheral/ble_state( 8553): 	at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
E/MethodChannel#dev.steenbakker.flutter_ble_peripheral/ble_state( 8553): 	at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
E/MethodChannel#dev.steenbakker.flutter_ble_peripheral/ble_state( 8553): 	at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/MethodChannel#dev.steenbakker.flutter_ble_peripheral/ble_state( 8553): 	at android.os.Handler.handleCallback(Handler.java:938)
E/MethodChannel#dev.steenbakker.flutter_ble_peripheral/ble_state( 8553): 	at android.os.Handler.dispatchMessage(Handler.java:99)
E/MethodChannel#dev.steenbakker.flutter_ble_peripheral/ble_state( 8553): 	at android.os.Looper.loopOnce(Looper.java:226)
E/MethodChannel#dev.steenbakker.flutter_ble_peripheral/ble_state( 8553): 	at android.os.Looper.loop(Looper.java:313)
E/MethodChannel#dev.steenbakker.flutter_ble_peripheral/ble_state( 8553): 	at android.app.ActivityThread.main(ActivityThread.java:8751)
E/MethodChannel#dev.steenbakker.flutter_ble_peripheral/ble_state( 8553): 	at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#dev.steenbakker.flutter_ble_peripheral/ble_state( 8553): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
E/MethodChannel#dev.steenbakker.flutter_ble_peripheral/ble_state( 8553): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
@ahmdsdk
Copy link

ahmdsdk commented Aug 21, 2023

Hello @ONLYstcm have you been able to solve this?

I realized that when you set serviceData: Uint8List.fromList([0x41, 0x42, 0x43, 0x44]) and includeDeviceName: false it works, otherwise you get PlatformException (PlatformException(1, ADVERTISE_FAILED_DATA_TOO_LARGE, startAdvertising, null)). I guess it could be related to device name being too long or something. Is there a work around for this to keep the device name short since on android we cannot set the localName?

@khanhnmbk
Copy link

I got the same error. Anyone resolves it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants