fengqiangboy / flutter-nordic-dfu Goto Github PK
View Code? Open in Web Editor NEWFlutter Nordic dfu
License: MIT License
Flutter Nordic dfu
License: MIT License
Hi,
Since Web Serial API is now supported in most browsers, I was wondering if you are planning to make this package also available in web.
Cheers
↳
** BUILD FAILED **
Xcode's output:
↳
Unable to run command 'PBXCp Flutterblue.pbobjc.h' - this target might include its own product.
Unable to run command 'Touch flutter_blue.framework' - this target might include its own product.
Help me!
Hi! Master branch already has support for Android embedding v2, but the latest release (v3.0.0) doesn't. Can you please push a new release with embedding v2?
Are you currently working/planning to release a null safety version for Flutter development?
I get this error when ever start DFU process
Process: com.advsolned.asnairguardadmin, PID: 10941
E/AndroidRuntime(10941): java.lang.IllegalArgumentException: com.advsolned.asnairguardadmin: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
E/AndroidRuntime(10941): Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
I am unable to get DFU to work with iOS. I believe it has to deal with the device id being different in iOS with Flutter Blue. Since iOS creates their own UUID instead of using the MAC address like Android.
The current lib is pointing to iOS lib 4.5.1, latest version is 4.9. This causes a huge problem on DFU while running on iPhone 11, iOS 13.5.1.
I've forked the repo, updated the podspec to point to 4.9 and the DFU works without a problem.
The test function has the filePath
as in the pubspec.yaml
and I also have the following directory structure
./
├── android/
│ ├── app/
│ ├── build.gradle
│ ├── gradle/
│ ├── gradle.properties
│ ├── gradlew*
│ ├── gradlew.bat
│ ├── local.properties
│ └── settings.gradle
├── assets/
│ └── sense_pir_10000_010.zip
├── build/
│ ├── app/
│ ├── app.dill
│ ├── app.dill.track.dill
│ ├── app.dill.track.dill.incremental.dill
│ ├── flutter_nordic_dfu/
│ ├── frontend_server.d
│ └── kotlin/
├── ios/
│ ├── Flutter/
│ ├── Podfile
│ ├── Runner/
│ ├── Runner.xcodeproj/
│ └── Runner.xcworkspace/
├── lib/
│ └── main.dart
├── pubspec.lock
├── pubspec.yaml
├── README.md
└── test/
└── widget_test.dart
pubspec.yaml
to Flutter.
flutter:
uses-material-design: true
assets:
- assets/sense_pir_10000_010.zip
Test function
void test() async {
var s = await FlutterNordicDfu.startDfu(
'C6:9D:C8:B6:4F:24', 'assets/sense_pir_10000_010.zip',
progressListener: ProgressListenerListener());
print(s);
}
Error
Launching lib/main.dart on devicein debug mode...
Built build/app/outputs/apk/debug/app-debug.apk.
E/CheckPermission( 4908): _bluetooth code = 1
D/AndroidRuntime( 4908): Shutting down VM
E/DfuBaseService( 4908): An exception occurred while opening file
E/DfuBaseService( 4908): java.io.FileNotFoundException: assets/sense_pir_10000_010.zip (No such file or directory)
E/DfuBaseService( 4908): at java.io.FileInputStream.open0(Native Method)
E/DfuBaseService( 4908): at java.io.FileInputStream.open(FileInputStream.java:200)
E/DfuBaseService( 4908): at java.io.FileInputStream.<init>(FileInputStream.java:150)
E/DfuBaseService( 4908): at java.io.FileInputStream.<init>(FileInputStream.java:103)
E/DfuBaseService( 4908): at no.nordicsemi.android.dfu.DfuBaseService.openInputStream(DfuBaseService.java:1418)
E/DfuBaseService( 4908): at no.nordicsemi.android.dfu.DfuBaseService.onHandleIntent(DfuBaseService.java:1160)
E/DfuBaseService( 4908): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:76)
E/DfuBaseService( 4908): at android.os.Handler.dispatchMessage(Handler.java:106)
E/DfuBaseService( 4908): at android.os.Looper.loop(Looper.java:197)
E/DfuBaseService( 4908): at android.os.HandlerThread.run(HandlerThread.java:65)
E/AndroidRuntime( 4908): FATAL EXCEPTION: main
E/AndroidRuntime( 4908): Process: com.timeyaa.flutternordicdfuexample, PID: 4908
E/AndroidRuntime( 4908): android.app.RemoteServiceException: Bad notification for startForeground: java.lang.RuntimeException: invalid channel for service notification: Notification(channel=dfu pri=-1 contentView=null vibrate=null sound=null defaults=0x0 flags=0x42 color=0xff888888 vis=PRIVATE)
Currently the readme states that the library supports Android and iOS. In the pubspec.yaml file, there is a comment that states that iOS is not supported.
I assume the comment in pubspec.yaml is incorrect, but I leave that up to maintainers to decide / correct.
is there any example code for updating different combinations ? Is it support?
BL: Bootloader
SD: SoftDevice
APP: Application
when i build this example for iphone 6 simulater, I received the following error:
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
Unable to run command 'PBXCp Flutterblue.pbobjc.h' - this target might include its own product.
Unable to run command 'Touch flutter_blue.framework' - this target might include its own product.
Unable to run command 'CodeSign flutter_blue.framework' - this target might include its own product.
Could not build the application for the simulator.
Error launching application on iPhone 6s.
What I had to do because some hardware needed this setting to be false instead of the default true value from the Nordic Libraries was to hardcode alternativeAdvertisingNameEnabled = false to make things work on IOS. This parameter is forwarded from DFUServiceInitiator to the DfuPeripheral later on in their libraries where I actually needed this. It is a public member so I think it can be set after instantiating the DFUServiceInitiator:
Would it be possible to provide this as an additional boolean parameter (maybe with default to true) in your plugin's call to startDFU()
and then on the swift side of things in SwiftFlutterNordicDfuPlugin.swift after
let dfuInitiator = DFUServiceInitiator(queue: nil)
set:
dfuInitiator.alternativeAdvertisingNameEnabled = (false or true according to the parameter)
so further down in the chain the DfuPeripheral Object would inhabit this parameter's setting?
As discussed in the Android-DFU-Library github page issue 315, there was an issue with the library on Android 12, which by now is fixed and the fix is released. This flutter library does not have the fix and thus it cannot be used on Android 12. The required changes are minimal, only needing to update the Flutter library with the new releases from the Nordic Semiconductors.
Hi All,
Great work on getting this done. I have been having an issue where using flutter run i have no issues or errors with the zip file in the assets folder or downloading a url and making it into a file and passing it to startDfu.
However, I have been experiencing an issue when installing it as an apk or putting the app bundle on the play store. I have tried using the example you have provided as well and I have the same issue. I have narrowed it down to a try catch error at stratDfu.
I am using flutter 1.10.7, flutter-nordic-dfu v 2.3.0, and flutter-blue v 0.6.2.
Any help would be great.
Thanks
I'm using the Companion Device Pairing method to connect to my BLE device. This allows the app not to ask for the location permissions.
I noticed that this lib requests for ACCESS_COARSE_LOCATION in its manifest. However, I can't find any call to ActivityCompat.requestPermissions()
in the plugin code nor in the Nordic DFU library.
Is this really required ? I guessed that since we need to provide the device address, a location request shouldn't be necessary.
Any plans to update the library to support null safety?
The plugin flutter_nordic_dfu
uses a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to see if this plugin supports the Android V2 embedding. Otherwise, consider removing it since a future release of Flutter will remove these deprecated APIs.
If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.
environment:
sdk: ">=2.16.1 <3.0.0"
flutter: ">=2.10.1"
dependencies:
flutter:
sdk: flutter
In the Flutter, it seems that only few events are fired during DFU, in my case, they are onDfuProcessStarting
, onProgressChanged
and onDfuCompleted
.
onError
gets called in the native layer, but looks like the channel method call arguments is not in correct format, this event expects
progressListener?.onError(
call.arguments['deviceAddress'],
call.arguments['error'],
call.arguments['errorType'],
call.arguments['message'],
);
But the actual arguments the Flutter part receives is just the deviceAddress
in String, not even in Map.
It would be good to fix the issues and get all events work. Thanks.
Crashes as soon as you hit start dfu on Android 9. Same effect with version 2.2.1 and 2.3.0
We are actively using this package. Can you please update? Thanks
Log:
To avoid unexpected runtime failures, or future build failures, try to see if these plugins support the Android V2 embedding. Otherwise, consider removing them since a future release of Flutter will remove these deprecated APIs.
I am attempting to download both a boot loader and new firmware package. I can pass the firmware update to the dfuStart() module and it succeeds and reconnects with the new firmware. When I try the boot loader and then follow up after the boot loader completes with the firmware module, I see connect errors being generated. Should I be sending the separate files in separate dfuStart() calls or should all files be contained in a single zip file download?
Seeing the following errors after the second download.
D/BluetoothGatt(18048): onClientRegistered() - status=0 clientIf=25
D/ViewRootImpl@7da5ab5MainActivity: ViewPostIme pointer 0
D/ViewRootImpl@7da5ab5MainActivity: ViewPostIme pointer 1
D/BluetoothGatt(18048): onClientConnectionState() - status=133 clientIf=25 device=DD:ED:34:E0:BF:D3
E/DfuBaseService(18048): Connection state change error: 133 newState: 0
E/DfuBaseService(18048): An error occurred while connecting to the device:133
is there abort function?
When running a simple DFU using a Firmware homemade.
The firmware DFU is working fine with NRF Connect, but I need to turn Alternative Advertising Mode off.
5E5B33DD-07EC-020F-639B-4FCB80E3763A onDfuProcessStarting
5E5B33DD-07EC-020F-639B-4FCB80E3763A onEnablingDfuMode
5E5B33DD-07EC-020F-639B-4FCB80E3763A onDeviceConnecting
5E5B33DD-07EC-020F-639B-4FCB80E3763A onDfuProcessStarting
5E5B33DD-07EC-020F-639B-4FCB80E3763A onEnablingDfuMode
5E5B33DD-07EC-020F-639B-4FCB80E3763A onDeviceConnecting
5E5B33DD-07EC-020F-639B-4FCB80E3763A onDfuProcessStarting
5E5B33DD-07EC-020F-639B-4FCB80E3763A onEnablingDfuMode
5E5B33DD-07EC-020F-639B-4FCB80E3763A onDeviceConnecting
5E5B33DD-07EC-020F-639B-4FCB80E3763A onDfuProcessStarting
5E5B33DD-07EC-020F-639B-4FCB80E3763A onEnablingDfuMode
For an unknown reason it's just looping on this. Any idea why ?
Often, when attempting a DFU on iOS, the progress gets to 4% and then I'll get the string "DFU FAILED" as the return from FlutterNordicDfu.startDfu(). Is there a way to get more informative error messages from the underlying DFU library?
Hello, thx for pkg !
We upgraded our flutter version to 2.5.0 and now build or pkg get cmds are printing this msg:
The plugin `flutter_nordic_dfu` uses a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to see if this plugin supports the Android V2 embedding. Otherwise, consider removing it since a future release of Flutter will remove these deprecated APIs.
If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.
Do you have time to implement the necessary changes ? For now it should still work properly but may break in the future...
Regards,
R0m4in
Fantastic Library!
I have Android working great for my application, but when I compile for ios, I'm getting this error:
=== BUILD TARGET flutter_nordic_dfu OF PROJECT Pods WITH CONFIGURATION Release ===
/Users/zwells/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_nordic_dfu-2.2.1/ios/Classes/FlutterNordicDfuPlugin.m:2:9: fatal error: 'flutter_nordic_dfu/flutter_nordic_dfu-Swift.h' file not found
#import <flutter_nordic_dfu/flutter_nordic_dfu-Swift.h>
^~~~~~~~~~~~~~~~~~~~~~~
Do I need to relocate the .h file or is something wrong with my pub get?
When building I get this error:
/Users/mike/dev/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_nordic_dfu-2.4.0/ios/Classes/FlutterNordicDfuPlugin.m:2:9: fatal error: 'flutter_nordic_dfu/flutter_nordic_dfu-Swift.h' file not found
#import <flutter_nordic_dfu/flutter_nordic_dfu-Swift.h>
下载的文件后缀为.bin,可以直接传输.bin文件吗?我压缩为zip,也是提示 DFU_FIRMWARE_NOT_FOUND。
mac 环境
I wonder can this issue ("#3" ) slove in Xcode, not in Flutter.
hope to repair ios.
Hi
I'm following your instructions to use the dfu feature. But no matter what i do, i'm getting the same exception:
PlatformException(2, DFU FAILED, device address: DC:3E:41:AC:F3:75, null)
Any hints on why this is happening?
I've also seen the log entry:
W/DfuBaseService(15862): DFU Service not found.
maybe that helps. I'd suspect the service to be declared in the Manifest of your library, isn't it?
Future<void> _updateFirmware() async {
print("START DFU HERE");
try {
await FlutterNordicDfu.startDfu(
widget.request.gadget.getDeviceAddress(),
// _firmwarePath,
'assets/file.zip',
fileInAsset: true,
progressListener:
DefaultDfuProgressListenerAdapter(onProgressChangedHandle: (
deviceAddress,
percent,
speed,
avgSpeed,
currentPart,
partsTotal,
) {
print('deviceAddress: $deviceAddress, percent: $percent');
}),
);
} catch (exception) {
print("Firmware Update Failed: $exception");
}
}
I'm getting the following log:
I/flutter (15862): START DFU HERE
D/BluetoothAdapter(15862): STATE_ON
D/BluetoothGatt(15862): connect() - device: DC:3E:41:AC:F3:75, auto: false
D/BluetoothAdapter(15862): isSecureModeEnabled
D/BluetoothGatt(15862): registerApp()
D/BluetoothGatt(15862): registerApp() - UUID=648c2f50-01a1-4427-a54d-25e04930fae5
D/BluetoothGatt(15862): onClientRegistered() - status=0 clientIf=13
D/BluetoothGatt(15862): onClientConnectionState() - status=0 clientIf=13 device=DC:3E:41:AC:F3:75
D/BluetoothGatt(15862): discoverServices() - device: DC:3E:41:AC:F3:75
D/BluetoothGatt(15862): onConnectionUpdated() - Device=DC:3E:41:AC:F3:75 interval=6 latency=0 timeout=500 status=0
D/BluetoothGatt(15862): onSearchComplete() = Device=DC:3E:41:AC:F3:75 Status=0
W/DfuBaseService(15862): DFU Service not found.
D/BluetoothGatt(15862): cancelOpen() - device: DC:3E:41:AC:F3:75
D/BluetoothGatt(15862): onClientConnectionState() - status=0 clientIf=13 device=DC:3E:41:AC:F3:75
D/BluetoothGatt(15862): refresh() - device: DC:3E:41:AC:F3:75
D/BluetoothGatt(15862): close()
D/BluetoothGatt(15862): unregisterApp() - mClientIf=13
I/flutter (15862): Firmware Update Failed: PlatformException(2, DFU FAILED, device address: DC:3E:41:AC:F3:75, null)
Suddenly started getting the following build error today:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkDevReleaseAarMetadata'.
> Could not resolve all files for configuration ':app:devReleaseRuntimeClasspath'.
> Could not resolve no.nordicsemi.android:dfu:1.11.0.
Required by:
project :app > project :flutter_nordic_dfu
Checking on Maven Repository, it appears no.nordicsemi.android:dfu:1.11.0 is no longer available:
https://mvnrepository.com/artifact/no.nordicsemi.android/dfu
The latest stable version as of now is 1.12.0, or the prior one 1.11.1
I have run the example project (which is flutter_blue ^0.5.0), and it works perfectly.
I try to integrate into my project (with plug-in flutter_blue 0.6.2), and it do not work.
Error message is:
E/DfuBaseService(20455): Connection state change error: 133 newState: 0
E/DfuBaseService(20455): Device not reachable. Check if the device with address xx:xx:xx:xx:xx:xx is in range, is advertising and is connectable
I/flutter (20455): PlatformException(2, DFU FAILED, device address: xx:xx:xx:xx:xx:xx)
I tried to change the example project to flutter_blue 0.6.2, and it will not work. So, I suppose this package will work on flutter_blue ^0.5.0 only.
May you update the package to fit flutter_blue 0.6.2?
The stack trace of the app:
I/DfuBaseService(12097): DFU service created. Version: 1.10.1
I/DfuBaseService(12097): Starting DFU service in foreground
I/DfuBaseService(12097): Connecting to the device...
D/BluetoothGatt(12097): connect() - device: FF:86:28:CB:AA:04, auto: false
D/BluetoothGatt(12097): registerApp()
D/BluetoothGatt(12097): registerApp() - UUID=b7bb7287-1d57-4902-bc66-9e8d952bf87e
D/BluetoothGatt(12097): onClientRegistered() - status=0 clientIf=9
I/zygote64(12097): Do partial code cache collection, code=123KB, data=76KB
I/zygote64(12097): After code cache collection, code=123KB, data=76KB
I/zygote64(12097): Increasing code cache capacity to 512KB
D/BluetoothGatt(12097): onClientConnectionState() - status=133 clientIf=9 device=FF:86:28:CB:AA:04
E/DfuBaseService(12097): Connection state change error: 133 newState: 0
E/DfuBaseService(12097): An error occurred while connecting to the device:133
D/BluetoothGatt(12097): refresh() - device: FF:86:28:CB:AA:04
I/DfuBaseService(12097): Refreshing result: true
I/DfuBaseService(12097): Cleaning up...
D/BluetoothGatt(12097): close()
D/BluetoothGatt(12097): unregisterApp() - mClientIf=9
I/DfuBaseService(12097): Restarting the service
I/DfuBaseService(12097): Starting DFU service in foreground
I/DfuBaseService(12097): Connecting to the device...
D/BluetoothGatt(12097): connect() - device: FF:86:28:CB:AA:04, auto: false
D/BluetoothGatt(12097): registerApp()
D/BluetoothGatt(12097): registerApp() - UUID=f42fba60-2872-4ab3-bd5e-36d5948d57de
D/BluetoothGatt(12097): onClientRegistered() - status=0 clientIf=9
D/BluetoothGatt(12097): onClientConnectionState() - status=133 clientIf=9 device=FF:86:28:CB:AA:04
E/DfuBaseService(12097): Connection state change error: 133 newState: 0
E/DfuBaseService(12097): Device not reachable. Check if the device with address FF:86:28:CB:AA:04 is in range, is advertising and is connectable
D/BluetoothGatt(12097): refresh() - device: FF:86:28:CB:AA:04
I/DfuBaseService(12097): Refreshing result: true
I/DfuBaseService(12097): Cleaning up...
D/BluetoothGatt(12097): close()
D/BluetoothGatt(12097): unregisterApp() - mClientIf=9
I/DfuBaseService(12097): Restarting the service
I/DfuBaseService(12097): Starting DFU service in foreground
I/DfuBaseService(12097): Connecting to the device...
D/BluetoothGatt(12097): connect() - device: FF:86:28:CB:AA:04, auto: false
D/BluetoothGatt(12097): registerApp()
D/BluetoothGatt(12097): registerApp() - UUID=98b70f5a-daad-4c2d-97ca-8a9c3cc2f46c
D/BluetoothGatt(12097): onClientRegistered() - status=0 clientIf=9
D/BluetoothGatt(12097): onClientConnectionState() - status=133 clientIf=9 device=FF:86:28:CB:AA:04
E/DfuBaseService(12097): Connection state change error: 133 newState: 0
E/DfuBaseService(12097): Device not reachable. Check if the device with address FF:86:28:CB:AA:04 is in range, is advertising and is connectable
D/BluetoothGatt(12097): refresh() - device: FF:86:28:CB:AA:04
I/DfuBaseService(12097): Refreshing result: true
I/DfuBaseService(12097): Cleaning up...
D/BluetoothGatt(12097): close()
D/BluetoothGatt(12097): unregisterApp() - mClientIf=9
W/FlutterJNI(12097): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: com.timeyaa.flutter_nordic_dfu/method. Response ID: 0
W/FlutterJNI(12097): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: com.timeyaa.flutter_nordic_dfu/method. Response ID: 0
I/DfuBaseService(12097): DFU service destroyed
D/AndroidRuntime(12097): Shutting down VM
E/AndroidRuntime(12097): FATAL EXCEPTION: main
E/AndroidRuntime(12097): Process: com.dersalis.dersalis_support, PID: 12097
E/AndroidRuntime(12097): java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.app.Activity.getSystemService(java.lang.String)' on a null object reference
E/AndroidRuntime(12097): at com.timeyaa.flutternordicdfu.FlutterNordicDfuPlugin$2.run(FlutterNordicDfuPlugin.java:280)
E/AndroidRuntime(12097): at android.os.Handler.handleCallback(Unknown Source:2)
E/AndroidRuntime(12097): at android.os.Handler.dispatchMessage(Unknown Source:4)
E/AndroidRuntime(12097): at android.os.Looper.loop(Unknown Source:155)
E/AndroidRuntime(12097): at android.app.ActivityThread.main(Unknown Source:65)
E/AndroidRuntime(12097): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(12097): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(Unknown Source:11)
E/AndroidRuntime(12097): at com.android.internal.os.ZygoteInit.main(Unknown Source:345)
W/FlutterEngine(13882): Tried to automatically register plugins with FlutterEngine (io.flutter.embedding.engine.FlutterEngine@97042d0) but could not find and invoke the GeneratedPluginRegistrant.
Using flutter_blue 0.7.2
What can be done to resolve?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.