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

Call to getCentralManager returned nil[NordicDFU.startDFU][IOS] #82

Closed
daihieptn97 opened this issue Oct 31, 2019 · 1 comment
Closed

Comments

@daihieptn97
Copy link

daihieptn97 commented Oct 31, 2019

I implement startDFU function and faulty Call to getCentralManager returned nil

 RNFetchBlob
        .config({
          // response data will be saved to this path if it has access right.
          path: dirs.DocumentDir + '/FirmwareBLE.zip',
          fileCache: true,
        })
        .fetch('GET', 'http://localhost/uploads/SdoorMasterV1001_009.zip', {
          //some headers ..
        })
        .then((res) => {
          // the path should be dirs.DocumentDir + 'path-to-file.anything'
          console.log('The file saved to ', res.path());

          NordicDFU.startDFU({
            //deviceAddress: remote.macBleHex,
            deviceAddress: "6E400001-B5A3-F393-E0A9-E50E24DCCA9E",
            deviceName : "423423423",
            filePath: res.path(),
          })
            .then(res => console.log('Transfer done:', res))
            .catch(console.log);

        });
    }, 2000);

I have added the code to the xcode in the function didFinishLaunchingWithOptions(AppDelegate.m)

  [RNNordicDfu setCentralManagerGetter:^() {
    return [BleManager getCentralManager];
  }];

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

Package.json with me

"dependencies": {
    "@react-native-community/geolocation": "^2.0.2",
    "@react-native-community/netinfo": "^4.3.0",
    "base-64": "^0.1.0",
    "crypto-js": "^3.1.9-1",
    "native-base": "^2.13.8",
    "react": "16.9.0",
    "react-native": "0.61.3",
    "react-native-action-button": "^2.8.5",
    "react-native-background-timer": "^2.0.1",
    "react-native-base64": "0.0.2",
    "react-native-ble-manager": "^6.7.0",
    "react-native-ble-plx": "^1.1.0",
    "react-native-device-info": "^5.1.0",
    "react-native-elements": "^0.19.1",
    "react-native-facebook-account-kit": "1.0.0",
    "react-native-firebase": "^5.5.6",
    "react-native-gesture-handler": "^1.0.12",
    "react-native-image-picker": "^0.27.1",
    "react-native-ionicons": "^4.6.1",
    "react-native-keep-awake": "^3.1.0",
    "react-native-modal": "^11.4.0",
    "react-native-network-info": "^5.2.1",
    "react-native-nordic-dfu": "^3.0.1",
    "react-native-paho-mqtt": "^0.1.1",
    "react-native-parallax-header": "^1.1.3",
    "react-native-parallax-scroll-view": "^0.21.3",
    "react-native-progress": "^3.6.0",
    "react-native-smartconfig-2": "^1.2.3",
    "react-native-smartconfig-ll": "^0.2.4",
    "react-native-sortable-grid": "^2.0.0",
    "react-native-sortable-listview": "^0.2.9",
    "react-native-swiper": "^1.5.14",
    "react-native-udp": "^2.3.1",
    "react-native-vector-icons": "^6.6.0",
    "react-native-wheel-datepicker": "^2.2.3",
    "react-navigation": "^3.0.9",
    "react-navigation-collapsible": "^3.0.3",
    "react-redux": "^5.0.7",
    "recyclerlistview": "^1.3.4",
    "redux": "^4.0.0",
    "redux-thunk": "^2.3.0",
    "rn-fetch-blob": "github:joltup/rn-fetch-blob"
  },

thanks you !

@SaltedBlowfish
Copy link

SaltedBlowfish commented Mar 29, 2020

This is because you are not calling .start() on BleManager. See first bullet point here: https://github.com/innoveit/react-native-ble-manager#note

Example:

...
BleManager.start({showAlert: false})
  .then(() => {
    // Success code
    console.log('Module initialized');
  });
...

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

2 participants