Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not find device with deviceAddress [3.2.1] #160

Open
marcopiraccini opened this issue Mar 1, 2022 · 8 comments
Open

Could not find device with deviceAddress [3.2.1] #160

marcopiraccini opened this issue Mar 1, 2022 · 8 comments

Comments

@marcopiraccini
Copy link

I am having this issue when I startDFU on iOS (on Android it works).
I already checked and the deviceAddress is the UUID of the device (at it should be).
Any idea?

@marcopiraccini
Copy link
Author

@marcopiraccini
Copy link
Author

OK, this is probably a duplicate of: #121 (I am also using react-native-ble-plx )

@david-gettins
Copy link

To save people from having to follow various links and collate the information, here is the solution that works for me when using react-native-ble-plx...

1. Your AppDelegate.m

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

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

  [RNNordicDfu setOnDFUComplete:^() {
  }];

  [RNNordicDfu setOnDFUError:^() {
  }];

  // ...
}

Originally from here

2. Inside the react-native-nordic-dfu folder in node_modules - RNNordicDfu.m

At line 200 or underneath the line: CBCentralManager * centralManager = getCentralManager(); add this:

[NSThread sleepForTimeInterval: 2];

Originally from here

Now everything works as expected. Apologies for duplicating this information but it took me 15mins to bring various bits from other issue comments together, hopefully this saves someone that time.

Finally, here is the patch I generated to apply this on install using patch-package:

diff --git a/node_modules/react-native-nordic-dfu/ios/RNNordicDfu.m b/node_modules/react-native-nordic-dfu/ios/RNNordicDfu.m
index ed58530..4c8b4a7 100644
--- a/node_modules/react-native-nordic-dfu/ios/RNNordicDfu.m
+++ b/node_modules/react-native-nordic-dfu/ios/RNNordicDfu.m
@@ -197,6 +197,7 @@ - (void)logWith:(enum LogLevel)level message:(NSString * _Nonnull)message
     reject(@"nil_central_manager_getter", @"Attempted to start DFU without central manager getter", nil);
   } else {
     CBCentralManager * centralManager = getCentralManager();
+    [NSThread sleepForTimeInterval: 2];
 
     if (!centralManager) {
       reject(@"nil_central_manager", @"Call to getCentralManager returned nil", nil);

@marcopiraccini
Copy link
Author

marcopiraccini commented Apr 11, 2022

OK, but there is a reason why this patch is not applied directly to the code?
I can prepare a PR

@p4bl1t0
Copy link

p4bl1t0 commented Apr 20, 2022

Yes, this should be a Pull Request or be added to the library

@david-gettins
Copy link

@marcopiraccini Did you get around to preparing the PR?

@Irenedan
Copy link

@marcopiraccini, I'm using the "react-native-ble-plx" too, but I don't know what parts are zip made of. Could you please put a zip file of yours here?

NordicDFU.startDFU({ deviceAddress: '94:54:93:17:63:75', deviceName: 'test', filePath: fs.CachesDirectoryPath + '/dry.zip' })

@p4bl1t0
Copy link

p4bl1t0 commented Sep 20, 2022

The zip file should be your firmware code compiled by Arduino or Platform.io with the upload_protocol in nrfutil

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants