Pilloxa / react-native-nordic-dfu

Nordic Device Firmware Update for React Native
MIT License
137 stars 118 forks source link

iOS 13 breaking changes #78

Open NN01010101 opened 5 years ago

NN01010101 commented 5 years ago

Looks like in iOS 13 Apple made some changes to the CBCentralManager. The issue happens at line 209 inside of RNNordicDfu.m retrievePeripheralsWithIdentifiers returns 0 so the DFU process quits with error "Could not find device with deviceAddress"

As pointed out here it's now mandatory to wait before the state CBCentralManager becomes poweredOn before calling theretrievePeripheralsWithIdentifiers

As a workaround, I put [NSThread sleepForTimeInterval: 2]; right after CBCentralManager * centralManager = getCentralManager(); and it works.

Looveh commented 5 years ago

@NN01010101 Great! If this is a problem that many others might face, feel free to create a PR with your fixes. If you could get it to work with something more general than a sleep for an arbitrary number of seconds I think it would be better suited for other's projects and setups as well.

NN01010101 commented 5 years ago

@Looveh the issue is definitely there for iOS 13. Unfortunately, I'm not that versatile in Objective C, so I won't be able to write anything better than a delay, but it looks like guys could fix it here

LackoDan commented 5 years ago

We're also having this issue. Unfortunately, the delay does not help in our case -- it blocks the app. I tried forcing the library to use iOSDFULibrary 4.5.1 (in which the Bugfix for iOS 13 was merged), but that did not change anything.

ThomasStubbe commented 5 years ago

Same here. The sleep does makes the error to go away, but my app also just hangs...

Looveh commented 5 years ago

For what it's worth I know we're successfully using the version 3.0.1 in our app without having to make any alterations for iOS 13. Not sure about what makes our setup successful.

ThomasStubbe commented 5 years ago

I've managed to work around the problem, by introducing two sleeps + updating the iOS-DFU-Library to 4.5.1... I've forked this lib: https://github.com/ThomasStubbe/react-native-nordic-dfu

Jurpp commented 4 years ago

@ThomasStubbe We've been using your fork to work around the iOS13 issue. Android still works fine like it used to, but on iOS the first try always fails on [Error: X bytes were sent while X bytes were reported as received]. When trying a second time it always works. Do you have similar experiences? Update: Increasing the second delay to two seconds seems to fix this. Update: It seems our DFU bootloader was too slow for the latest iPhones, a workaround for slow bootloaders can be found in my fork of the ThomasStubbe fork.

RRMoelker commented 4 years ago

We've been running into the same iOS13 issue [Error: X bytes were sent while Y bytes were reported as received].

The fork from @Jurpp did not mesh well with other pods (some versions mismatch).

I created a recent fork with the same changes: https://github.com/DreamOnward/react-native-nordic-dfu

This fork solved the bytes sent issue for us.