1 Star 0 Fork 0

三也 / flutter_nordic_dfu

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.md 3.21 KB
一键复制 编辑 原始数据 按行查看 历史
Ivan Herrera 提交于 2020-09-18 14:32 . Fix typo in README.md

flutter-nordic-dfu pub package

This library allows you to do a Device Firmware Update (DFU) of your nrf51 or nrf52 chip from Nordic Semiconductor. It works for Android and iOS fine.

This is the implementation of the reference "react-native-nordic-dfu"

For more info about the DFU process, see: Resources

Run Example

  1. Add you dfu zip file to example/assets/file.zip

  2. Run example project

  3. Scan device

  4. Start dfu

Usage

startDFU

Examples

You can pass a absolute file path or asset file to FlutterNordicDfu

Use absolute file path
/// You can define your ProgressListenerListener
await FlutterNordicDfu.startDfu(
            'EB:75:AD:E3:CA:CF', '/file/to/zip/path/file.zip',
            progressListener: ProgressListenerListener(),
         );


class ProgressListenerListener extends DfuProgressListenerAdapter {
  @override
  void onProgressChanged(String deviceAddress, int percent, double speed,
      double avgSpeed, int currentPart, int partsTotal) {
    super.onProgressChanged(
        deviceAddress, percent, speed, avgSpeed, currentPart, partsTotal);
    print('deviceAddress: $deviceAddress, percent: $percent');
  }
}

/// Or you can use DefaultDfuProgressListenerAdapter
await FlutterNordicDfu.startDfu(
      'EB:75:AD:E3:CA:CF',
      'assets/file.zip',
      fileInAsset: true,
      progressListener:
          DefaultDfuProgressListenerAdapter(onProgressChangedHandle: (
        deviceAddress,
        percent,
        speed,
        avgSpeed,
        currentPart,
        partsTotal,
      ) {
        print('deviceAddress: $deviceAddress, percent: $percent');
      }),
    );
Use asset file path
/// just set [fileInAsset] true
await FlutterNordicDfu.startDfu(
            'EB:75:AD:E3:CA:CF', 'assets/file.zip',
            progressListener: ProgressListenerListener(),
            fileInAsset: true,
         );

class ProgressListenerListener extends DfuProgressListenerAdapter {
  @override
  void onProgressChanged(String deviceAddress, int percent, double speed,
      double avgSpeed, int currentPart, int partsTotal) {
    super.onProgressChanged(
        deviceAddress, percent, speed, avgSpeed, currentPart, partsTotal);
    print('deviceAddress: $deviceAddress, percent: $percent');
  }
}

Resources

1
https://gitee.com/philos/flutter_nordic_dfu.git
git@gitee.com:philos/flutter_nordic_dfu.git
philos
flutter_nordic_dfu
flutter_nordic_dfu
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891