You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -5,7 +5,11 @@ nrf52 chip from Nordic Semiconductor. It works for both iOS and Android.
5
5
6
6
For more info about the DFU process, see: [Resources](#resources)
7
7
8
-
## Installation
8
+
This is a fork from the main library!
9
+
If need the main documentation you can find it [here](https://github.com/Pilloxa/react-native-nordic-dfu).
10
+
This fork contains the latest verisons of `iOSDFULibrary` & `Android-BLE-Library`.
11
+
12
+
### Installation
9
13
10
14
Install and link the NPM package per usual with
11
15
@@ -25,251 +29,58 @@ For React Native below 60.0 version
25
29
react-native link react-native-nordic-dfu
26
30
```
27
31
28
-
### Minimum requirements
29
-
30
-
This project has been verified to work with the following dependencies, though other versions may work as well.
31
-
32
-
| Dependency | Version |
33
-
| ------------ | ------- |
34
-
| React Native | 0.59.4 |
35
-
| XCode | 10.2 |
36
-
| Swift | 5.0 |
37
-
| CocoaPods | 1.6.1 |
38
-
| Gradle | 5.3.1 |
39
-
40
-
### iOS
41
-
42
-
The iOS version of this library has native dependencies that need to be installed via `CocoaPods`, which is currently the only supported method for installing this library. (PR's for alternative installation methods are welcome!)
43
-
44
-
Previous versions supported manual linking, but this was prone to errors every time a new version of XCode and/or Swift was released, which is why this support was dropped. If you've previously installed this library manually, you'll want to remove the old installation and replace it with CocoaPods.
32
+
### Project Setup
45
33
46
-
#### CocoaPods
34
+
Unfortunately, the ios project is written in Objective-C so you will need to use `use_frameworks! :linkage => :static`.
35
+
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.
47
36
48
-
On your project directory;
49
-
50
-
```bash
51
-
cd ios && pod install
52
-
```
53
-
54
-
If your React Native version below 0.60 or any problem occures on pod command, you can try these steps;
55
-
56
-
Add the following to your `Podfile`
37
+
`Podfile`:
57
38
58
39
```ruby
59
40
target "YourApp"do
60
41
61
42
...
62
43
pod "react-native-nordic-dfu", path:"../node_modules/react-native-nordic-dfu"
63
44
...
45
+
use_frameworks! :linkage => :static
46
+
...
64
47
65
48
end
66
49
```
67
50
68
-
and in the same folder as the Podfile run
51
+
`AppDelegate.mm`:
69
52
70
-
```bash
71
-
pod install
72
53
```
73
-
74
-
Since there's native Swift dependencies you need to set which Swift version your project complies with. If you haven't already done this, open up your project with XCode and add a User-Defined setting under Build Settings: `SWIFT_VERSION = <your-swift-version>`.
75
-
76
-
If your React Native version is higher than 0.60, probably it's already there.
77
-
78
-
#### Bluetooth integration
79
-
80
-
This library needs access to an instance of `CBCentralManager`, which you most likely will have instantiated already if you're using Bluetooth for other purposes than DFU in your project.
81
-
82
-
To integrate with your existing Bluetooth setup, call `[RNNordicDfu setCentralManagerGetter:<...>]` with a block argument that returns your `CBCentralManager` instance.
83
-
84
-
If you want control over the `CBCentralManager` instance after the DFU process is done you might need to provide the `onDFUComplete` and `onDFUError` callbacks to transfer back delegate control.
// Reset manager delegate since the Nordic DFU lib "steals" control over it
69
+
[RNNordicDfu setOnDFUComplete:^() {
70
+
NSLog(@"onDFUComplete");
71
+
}];
72
+
[RNNordicDfu setOnDFUError:^() {
73
+
NSLog(@"onDFUError");
74
+
}];
75
+
...
116
76
117
-
return YES;
118
77
}
119
-
120
-
```
121
-
122
-
You can find them aslo in example project.
123
-
124
-
On iOS side this library requires to BleManager module which that [react-native-ble-manager](https://github.com/innoveit/react-native-ble-manager) provides.
125
-
126
-
It required because;
127
-
128
-
- You need `BleManager.h` module on AppDelegate file for integration.
129
-
- You should call `BleManager.start()` (for once) before the trigger a DFU process on iOS or you will get error like [this issue](https://github.com/Pilloxa/react-native-nordic-dfu/issues/82).
130
-
131
-
### Android
132
-
133
-
Android requires that you have `FOREGROUND_SERVICE` permissions.
134
-
You will need the following in your AndroidManifest.xml
-`obj.deviceAddress`**[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The `identifier`\* of the device that should be updated
157
-
-`obj.deviceName`**[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The name of the device in the update notification (optional, default `null`)
158
-
-`obj.filePath`**[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The file system path to the zip-file used for updating
159
-
-`obj.alternativeAdvertisingNameEnabled`**[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Send unique name to device before it is switched into bootloader mode (iOS only) - defaults to `true`
160
-
161
-
\*`identifier` — MAC address (Android) / UUID (iOS)
Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)** A promise that resolves or rejects with the `deviceAddress` in the return value
DFUEmitter.addListener("DFUStateChanged", ({ state }) => {
196
-
console.log("DFU State:", state);
197
-
});
198
-
```
199
-
200
-
## Selecting firmware file from local storage
201
-
202
-
If your user will select the firmware file from local storage you should keep on mind some issues;
203
-
204
-
You can use [react-native-document-picker](https://github.com/Elyx0/react-native-document-picker) library for file selecting process.
205
-
206
-
### On iOS
207
-
208
-
You should select file type as `public.archive` or you will get null type error as like [this issue](https://github.com/Pilloxa/react-native-nordic-dfu/issues/100)
209
-
210
-
```js
211
-
DocumentPicker.pick({ type:"public.archive" });
212
-
```
213
-
214
-
If your device getting disconnect after enable DFU, you should set `false` value to `alternativeAdvertisingNameEnabled` prop while starting DFU.
215
-
216
-
```js
217
-
NordicDFU.startDFU({
218
-
deviceAddress:"XXXXXXXX-XXXX-XXXX-XXXX-XX",
219
-
filePath:firmwareFile.uri,
220
-
alternativeAdvertisingNameEnabled:false,
221
-
});
222
-
```
223
-
224
-
### On Android
225
-
226
-
Some Android versions directly selecting file may can cause errors. If you get any file error you should copy it to your local storage. Like cache directory.
227
-
228
-
You can use [react-native-fs](https://github.com/itinance/react-native-fs) for copying file.
-[How to create init packet](https://github.com/NordicSemiconductor/Android-nRF-Connect/tree/master/init%20packet%20handling"Init packet handling")
270
85
-[nRF51 Development Kit (DK)](http://www.nordicsemi.com/eng/Products/nRF51-DK"nRF51 DK") (compatible with Arduino Uno Revision 3)
271
86
-[nRF52 Development Kit (DK)](http://www.nordicsemi.com/eng/Products/Bluetooth-Smart-Bluetooth-low-energy/nRF52-DK"nRF52 DK") (compatible with Arduino Uno Revision 3)
// mimic behavior of iOSDFULibrary when packetReceiptNotificationParameter is set to `0` - see: https://github.com/NordicSemiconductor/IOS-Pods-DFU-Library/blob/master/iOSDFULibrary/Classes/Implementation/DFUServiceInitiator.swift#L115
0 commit comments