How to use the react-native-ble-manager.read 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
setTimeout(() => {
            BleManager.read(peripheral.id, service, lengthCharacteristic).then((readData) => {
              let length = readData[0] + (readData[1] << 8) + (readData[2] << 16) + (readData[3] << 24);
              console.log('fileLength', readData, length);
              changeCode({"type": "clear"});
              setFileLength(length);
              setFileState("loading");
            });

          }, 500);
        } else if (fileState == "loading") {
github zhanguangao / react-native-ble-manager-demo / src / BleModule.js View on Github external
return new Promise( (resolve, reject) =>{
            BleManager.read(this.peripheralId, this.readServiceUUID[index], this.readCharacteristicUUID[index])
                .then((data) => {
                    const str = this.byteToString(data);
                    console.log('Read: ', data, str);                    
                    resolve(str);
                })
                .catch((error) => {
                    console.log(error);
                    reject(error);
                });
        });
    }