How to use the react-native-ble-manager.scan 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 adafruit / glider / App.js View on Github external
function peripheralReducer(state, action) {
    if (action.action == "add") {
        let peripheral = action.peripheral;
        console.log(peripheral);
        if (state.has(peripheral.id)) {
            return state; // No state change
        }
        if (!peripheral.advertising.serviceUUIDs || peripheral.advertising.serviceUUIDs.length == 0 || peripheral.advertising.serviceUUIDs[0].toLowerCase() != 'adaf0100-4369-7263-7569-74507974686e') {
            return state;
        }
        console.log(peripheral);
        var newMap = new Map(state);
        newMap.set(peripheral.id, peripheral);
        return newMap;
    } else if (action.action == "scan") {
        BleManager.scan([], 3).then((results) => {
            console.log('Scanning...');
        });
    } else if (action.action == "clear") {
        state.clear();
    }
    return state;
}
github innoveit / react-native-ble-manager / example / App.js View on Github external
startScan() {
    if (!this.state.scanning) {
      //this.setState({peripherals: new Map()});
      BleManager.scan([], 3, true).then((results) => {
        console.log('Scanning...');
        this.setState({scanning:true});
      });
    }
  }
github anchetaWern / RNFaceAttendance / App.js View on Github external
startScan = () => {
    this.peripherals = [];

    this.setState({
      is_scanning: true
    });

    BleManager.scan([], 3, true)
    .then(() => {
      console.log('scan started');
    });
  }
github CalPlug / Espressif_ESP32-Scale / React Native / BLE Demo / src / ble_manager / BLE.js View on Github external
startScan() {
    if (!this.state.scanning) {
      this.setState({peripherals: new Map()});
      BleManager.scan([], 3, true).then((results) => {
        console.log('Scanning...');
        this.setState({scanning:true});
      });
    }
  }
github zhanguangao / react-native-ble-manager-demo / src / BleModule.js View on Github external
return new Promise( (resolve, reject) =>{
            BleManager.scan([], 5, true)
                .then( () => {
                    console.log('Scan started');
                    resolve();
                }).catch( (err)=>{
	                console.log('Scan started fail');
	                reject(err);
	            });
        });
    }
github zhanguangao / react-native-ble-manager-demo / demo for v3.2.1 deprecated / app / BleManager.js View on Github external
return new Promise( (resolve, reject) =>{
            BleManager.scan([], 5, true)
                .then( () => {
                    console.log('Scan started');
                    resolve();
                }).catch( (err)=>{
	                console.log('Scan started fail');
	                reject(err);
	            });
        });
    }
github bailabs / tailpos / src / stories / components / PrinterSettingsComponent.js View on Github external
BleManager.start().then(() => {
      BleManager.scan([], 10, false).then(() => {
        NativeAppEventEmitter.addListener(
          "BleManagerDiscoverPeripheral",
          data => {
            if (data.name === null) {
              for (let i = 0; i < this.props.addedDevice.length; i += 1) {
                if (data.id === this.props.addedDevice[i].macAddress) {
                  dup += 1;
                }
              }
              for (let i = 0; i < devices.length; i += 1) {
                if (data.id === devices[i].macAddress) {
                  dup1 += 1;
                }
              }
              if (dup === 0) {
                if (dup1 === 0) {