Skip to content

Salt-PepperEngineering/react-native-nordic-dfu

 
 

Repository files navigation

react-native-nordic-dfu npm version CircleCI Known Vulnerabilities

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

For more info about the DFU process, see: Resources

This is a fork from the main library!

  • Please keep in mind the our availability to maintain this fork is limited and is based on our project needs.
  • If need the main documentation you can find it here.
  • This fork contains the latest verisons of iOSDFULibrary & Android-BLE-Library.

Installation

Install and link the NPM package per usual with

npm install --save https://github.com/Salt-PepperEngineering/react-native-nordic-dfu

or

yarn add https://github.com/Salt-PepperEngineering/react-native-nordic-dfu

For React Native below 60.0 version

react-native link react-native-nordic-dfu

Project Setup

Unfortunately, the ios project is written in Objective-C so you will need to use use_frameworks! :linkage => :static. Note: We are considering rewriting the ios module on Swift, but it depends very much on how much free time we have and how much we needed right now.

Podfile:

  • Flipper Disabled
target "YourApp" do

  ...
  pod "react-native-nordic-dfu", path: "../node_modules/react-native-nordic-dfu"
  ...
  use_frameworks! :linkage => :static
  ...
  :flipper_configuration => FlipperConfiguration.disabled,
  ...

end
  • Flipper enabled
static_frameworks = ['iOSDFULibrary']
pre_install do |installer|
  installer.pod_targets.each do |pod|
    if static_frameworks.include?(pod.name)
      puts "Overriding the static_frameworks? method for #{pod.name}"
      def pod.build_type;
        Pod::BuildType.new(:linkage => :static, :packaging => :framework)
      end
    end
  end
end

target "YourApp" do

  ...
  pod "react-native-nordic-dfu", path: "../node_modules/react-native-nordic-dfu"
  ...
  :flipper_configuration => FlipperConfiguration.enabled,
  ...

end

AppDelegate.mm:

...
#import "RNNordicDfu.h"
...

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  ...

  [RNNordicDfu setCentralManagerGetter:^() {
           return [[CBCentralManager alloc] initWithDelegate:nil queue:dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0)];
       }];

         // Reset manager delegate since the Nordic DFU lib "steals" control over it
             [RNNordicDfu setOnDFUComplete:^() {
                 NSLog(@"onDFUComplete");
             }];
             [RNNordicDfu setOnDFUError:^() {
                 NSLog(@"onDFUError");
             }];
  ...

}

New Example

  1. cd newExample
  2. yarn setup
  3. Go to newExample/App.tsx
  4. Update the filePath variable with the link to the firmware file
  5. Update the BleManagerService.init('', ''); function with the DFU Service & the device name
  6. Press Connect to Device in Area button
  7. When you see some small info about the device on the screen Press the Start Update
  8. If you have any problems connecting to the Device pleas consult the react-native-ble-manager

Issues

  • For configuration issues please also check this (Pilloxa#171)

Resources

About

Nordic Device Firmware Update for React Native

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 35.0%
  • Objective-C 27.3%
  • JavaScript 15.9%
  • TypeScript 9.4%
  • Ruby 7.4%
  • Starlark 2.9%
  • Objective-C++ 2.1%