How to use the react-native-ble-manager.disconnect function in react-native-ble-manager

To help you get started, we’ve selected a few react-native-ble-manager examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github innoveit / react-native-ble-manager / example / App.js View on Github external
test(peripheral) {
    if (peripheral){
      if (peripheral.connected){
        BleManager.disconnect(peripheral.id);
      }else{
        BleManager.connect(peripheral.id).then(() => {
          let peripherals = this.state.peripherals;
          let p = peripherals.get(peripheral.id);
          if (p) {
            p.connected = true;
            peripherals.set(peripheral.id, p);
            this.setState({peripherals});
          }
          console.log('Connected to ' + peripheral.id);


          setTimeout(() => {

            /* Test read current RSSI value
            BleManager.retrieveServices(peripheral.id).then((peripheralData) => {
github zhanguangao / react-native-ble-manager-demo / demo for v3.2.1 deprecated / app / BleManager.js View on Github external
disconnect() {	  
	    BleManager.disconnect(this.peripheralId)
		    .then( () => {
			    console.log('Disconnected');
		    })
		    .catch( (error) => {
			    console.log('Disconnected error:',error);
		    });
       /* return new Promise( (resolve, reject) =>{
	        BleManager.disconnect(this.peripheralId)
	            .then( () => {
	                console.log('Disconnected');
	                resolve();
	            })
	            .catch( (error) => {
	                console.log('Disconnected error:',error);
	                reject(error);
	            });
github zhanguangao / react-native-ble-manager-demo / src / BleModule.js View on Github external
disconnect() {
	    BleManager.disconnect(this.peripheralId)
		    .then( () => {
			    console.log('Disconnected');
		    })
		    .catch( (error) => {
			    console.log('Disconnected error:',error);
		    });      
    }
github adafruit / glider / App.js View on Github external
useEffect(() => {
        if (currentAppState === 'active') {
          console.log('App has come to the foreground!', bleState);
          BleManager.start({showAlert: true});
          BleManager.checkState();
        } else {
            if (peripheral) {
              changeCode({"type": "disconnect", "peripheral_id": peripheral.id});
              BleManager.disconnect(peripheral.id);
            }

            setBleState("disconnected");
        }
    }, [currentAppState]);
github anchetaWern / RNFaceAttendance / App.js View on Github external
.then(() => {
        BleManager.disconnect(connected_peripheral)
          .then(() => {
            Alert.alert('Attended', 'You have successfully attended the event. The app will now close.');

            setTimeout(() => {
              RNExitApp.exitApp();
            }, 3000);
          })
          .catch((error) => {
            Alert.alert('Error disconnecting', "You have successfully attended the event but there's a problem disconnecting to the peripheral, please disable bluetooth to force disconnection.");
          });

      })
      .catch((error) => {