Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jan 31 2019 14:20
    stonehippo edited #401
  • Jan 31 2019 14:17
    stonehippo opened #401
  • Jan 29 2019 18:49
    leo-tavares closed #400
  • Jan 29 2019 15:39
    leo-tavares edited #400
  • Jan 29 2019 15:37
    leo-tavares edited #400
  • Jan 29 2019 15:33
    leo-tavares edited #400
  • Jan 29 2019 15:31
    leo-tavares edited #400
  • Jan 29 2019 15:31
    leo-tavares opened #400
  • Jan 28 2019 19:17
    paulreimer closed #398
  • Jan 26 2019 19:05
    bhenav edited #399
  • Jan 26 2019 18:34
    bhenav edited #399
  • Jan 26 2019 18:33
    bhenav edited #399
  • Jan 26 2019 18:32
    bhenav edited #399
  • Jan 26 2019 18:25
    bhenav edited #399
  • Jan 26 2019 18:24
    bhenav edited #399
  • Jan 26 2019 18:21
    bhenav edited #399
  • Jan 26 2019 18:20
    bhenav opened #399
  • Jan 26 2019 00:03
    paulreimer opened #398
  • Jan 25 2019 23:46
    paulreimer opened #397
  • Jan 25 2019 23:20
    ChrisEdson opened #396
mass85
@mass85
Hi. I am wondering if there is some easy way in react-native-ble API to scan and connect to a device by providing a long device name. Typically advertisement packets contain shortened device name (8 bytes), but the device name characteristic (UUID 0x2A00) may be longer. So I want to find a device providing the full device name that in my case is 12 bytes.
Horst Ruedigger
@rusagent
Hey, i'm pretty new to react-native and need some example that shows how to use this library with functional components. Is there some resource? I can't find any...
J D
@Derewith
Hey. I'm wondering if there is an example with ReactNative function components and hooks ..
Datagrdn
@Datagrdn
What is the quickest way to be notified when a device is disconnected? BleError?
2 replies
J D
@Derewith

Hey. I'm wondering if there is an example with ReactNative function components and hooks ..

The main problem that i have using hooks is that i'm unable to implement the monitor function while i'm re-reading every 1 second ..

shakogele
@shakogele

@here, @all
Hello Guys,
We plan to develop a RN Apps to manage BLE Device. The concept is following:

  1. Once the Device is discovered by Mobile APP the connection should be established
  2. the BLE sends data periodically to mobile APP, which in turn sends this data to Backend Server.
  3. the connection between BLE Device and Mobile APP should be maintained in following cases:
    * the Mobiles App goes into background Mode
    * the Mobile app is closed by the USER

I have following questions:
can we develop a React Native Mobile Application using react-native-ble-plx library that meets all above requirements or we'll need a Native Code Interference ?

if you read this message please write your opinion,
Thanks in Advance

shakogele
@shakogele

Hello
I have initial project setup in RN and implemented the react-native-ble-plx library. I am able to connect to BLE Device and retrieve its services and characteristics. then I want to subscribe to characteristics and read data. I did this using

serviceChar.monitor((error, characteristic) => {
if(error){
console.log({error})
}
if(characteristic){
console.log("Does not enter's here");
console.log(characteristic.value())
}
})

I did the same functionality using Browser's Navigator.Bluetooth with following steps:

  1. I paired with BLE device
  2. requested primary service and then all its characteristics
  3. started the notification service using characteristic.startNotifications()
  4. subscribed to notification using characteristic.addListener('characteristicvaluechanged', someListenerFunction)

Please tell me what I am doing wrong? Why I am not able to subscribe to these services? I did everything according to https://github.com/Polidea/react-native-ble-plx/wiki/Characteristic-Notifying this documentation

Thanks in Advance

shakogele
@shakogele
@brianwk Could you give me some suggestions?
Datagrdn
@Datagrdn

Hey there. I'm creating a device editor menu that is a separate component from the one where the device connection is established to allow users to modify settings on their device. However I think my error is because the connection isn't available in the new component, I'm wondering how I can write to a characteristic on a device that was connected in a previous component.

The following yields the error Possible Unhandled Promise Rejection (id: 4):
BleError: Device 24:62:AB:CF:24:DA is not connected

writeToPlantWave(value) {
    const {devices} = this.props;
    let deviceID = null;
    devices.forEach((pw) => {
      if (pw.connected === true) {
        console.log('Within', pw.bleDevice.id);
        deviceID = pw.bleDevice.id;
      }
    });
    const encodedValue = base64.encode('set sense', value);
    const service = '6E400001-B5A3-F393-E0A9-E50E24DCCA9E';
    const characteristicW = '6E400002-B5A3-F393-E0A9-E50E24DCCA9E';
    console.log('Without', deviceID);

    this.manager.writeCharacteristicWithoutResponseForDevice(
      deviceID,
      service,
      characteristicW,
      encodedValue,
    );
  }

Am I going about this correctly? Or maybe the error lies somewhere else?

Datagrdn
@Datagrdn
UPDATE: Figured it out! I'll leave this here in case someone has a similar issue. Realized the solution is to pass the instance of this.manager into the children components as a prop
shalvagelenidze
@shalvagelenidze
Hello. I want to use react-native-nordic-dfu library to update device firmware, this library needs react-native-ble-manager plugin in order to work. I tried this solution Polidea/react-native-ble-plx#260 but I am getting "Could not find device with deviceAddress" error. Just do not get why is this a 'solution' when it does not work and if there is any other solution using this library with react-native-ble-plx ????
3 replies
shalvagelenidze
@shalvagelenidze
@dariuszseweryn hello, could you please tell me how to update the DFU using react-native-nordic-dfu library without implementing react-native-ble-manager
Datagrdn
@Datagrdn
Has anyone had trouble getting accepted to the Google Play Store? I keep getting rejected with the "Prominent disclosure not found" error. I'm calling this from the constructor of our main component but the dialogue isn't popping up before the native dialogue. Seems like a known issue in React. Anyone have solutions specific to this library?
  startBLEActions = async () => {
    try {
      const granted = await PermissionsAndroid.request(
        PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
        {
          title: 'Location Access for Bluetooth Usage',
          message:
            'This app collects location data to enable your PlantWave to pair with your phone even when the app is closed or not in use',
          buttonNeutral: 'Ask Me Later',
          buttonNegative: 'Cancel',
          buttonPositive: 'OK',
        },
      );

      if(this.manager == null){
        this.manager = new BleManager();
        this.manager.setLogLevel('Verbose');
      }

      if (granted === PermissionsAndroid.RESULTS.GRANTED) {
        console.log('You can access location');

        clearInterval(this.findPlantwavesInterval);
        clearInterval(this.flushConnectedListInterval);
        this.findPlantWaves();
        this.flushConnectedList();

        this.findPlantwavesInterval = setInterval(() => this.findPlantWaves(), 7000);
        this.flushConnectedListInterval = setInterval(() => this.flushConnectedList(), 2000);

      } else {
        console.log('Location permission denied');
      }
    } catch (err) {
      console.warn(err);
    }
  };
Datagrdn
@Datagrdn
It seems like the custom message doesn't display when I first open the app. Only if I deny permission on the native dialogue and then re-open
Datagrdn
@Datagrdn
Ah ok, just read that PermissionsAndroid.request() only fires if the user has denied the native permissions dialogue so this is the expected behavior. However, Google's new permissions policy requires a detailed explanation to always show before asking permission. It's preventing me from submitting my app to the Play Store. How are people reconciling this?
mass85
@mass85
Hi. What is "androidErrorCode":133 right after connecting to peripheral? I never have any problems with connecting to that device from nRF Connect, but this tends to happen in JS application using react-native-ble.
26 replies
hamzadahmani
@hamzadahmani
characteristics.monitor((error, result) => {
if (error) {
dispatch(MaintenanceNotifyState(true));
console.log('error', error);
} else {
coldwayParem = coldwayParem.concat(
saveParemetre(decoder(result.value, 'hex'), coldwayParem.length),
);
hello i have problem on ios
cant catch error when remove notify
but its work in android
@dariuszseweryn can u help me
Dayo Akinkuowo
@dayaki
Please what is the best way to format data for writeCharacteristicWithResponseForDevice, the data MUST be base64 encoded?
1 reply
Datagrdn
@Datagrdn
is there a way to discover and connect to a previously paired device without running the whole native dialogue flow? right now a i need to do that each time i pair a device, even if it's already been paired. currently doing it like this:
1 reply
` connect(selectedAddress) {
// might need to pull address from state array for multimode passing it in from radioButton for now
const {availableDevices} = this.state;
this.info('Connecting to PlantWave');
this.manager
  .connectToDevice(selectedAddress)
  .then((device) => {
    this.info('Discovering services and characteristics');
    device.discoverAllServicesAndCharacteristics();
    return device;
  })
  .then((device) => {
    console.log('Negotiating MTU');
    device.requestMTU(300);
    console.log('Setting notifications');`
Priyanka-SP
@Priyanka-SP
Hi all,
I want to display a notification to the user as soon as the device which was connected previously get disconnects either by manually or when its away from the range.
Im using onDisconnected() callback which is totally working fine in ios.but it's taking more than 10 seconds in android
device .connect()
.then((dev) => {
dev.onDisconnected(() => {
const modal = {
name: 'no_sensor',
header: ${dev.name} Disconnected,
buttons: [{ title: 'Ok', isAction: false }],
};
dispatch(triggerAlert(null, modal));
dispatch({
type: DEVICE_UPDATE,
payload: device,
isConnected: false,
isConnecting: false,
});
});
return dev
})
.then((devicewith) => {
dispatch({
type: DEVICE_UPDATE,
payload: devicewith,
isConnected: true,
isConnecting: false,
});
return devicewith.discoverAllServicesAndCharacteristics();
})
1 reply
Priyanka-SP
@Priyanka-SP
@dariuszseweryn how can I listen to 2 notifications at the same time from the same device??
4 replies
Marius Jakobsen
@jakobsen9
Hi! I am not receiving any state changes when listening to onStateChange and turning BT on/off on iOS. Is this a known issue or did I set it up wrong?
  useEffect(() => {
    const subscription = bleManager.onStateChange((state) => {
      console.log('hei');
      setIsBlePoweredOn(state === State.PoweredOn);
      if (state === State.PoweredOn) {
        subscription.remove();
      }
    }, true);
  }, []);
14 replies
Alex
@MasterLambaster
Hello. I have simple question: is it possible to get access for the native manager logs, the ones like [RxBLEKit|DEBG|15:26:22.486]: Peripheral(uuid: ... from the code? I'm fine with file paths or any other way that I can upload that logs from someones device elsewhere to debug issues on the device/peripheral that I don't have access to.
1 reply
Polletto85
@Polletto85

Hi there i have to read all glucose measurement from a ble device. I can read the glucose value from realtime measurement this is my code to write characteristic 0101 for all stored values.
code
async readAll(device) {
const service = this.serviceUUID()
const characteristicW = this.writeUUID()

var myData = '0x0101';
const dataMostSignificantByte = (myData >> 8) & 0xFF;
const dataLeastSignificantByte = myData & 0xFF;

const dataByteArrayInLittleEndian = [dataLeastSignificantByte, dataMostSignificantByte];
const dataInBase64 = Buffer.from(dataByteArrayInLittleEndian).toString('base64');
const write = this.manager.writeCharacteristicWithResponseForDevice(
  device.id,
  service,
  characteristicW,
  dataInBase64,
)
console.log(write)

}
code

11 replies
Wong Xin Wei
@xinweiiiii
Screenshot 2021-01-29 at 10.39.09 PM.png
Hi, i am using an ibeacon and this is my set of code to scan for BLE devices but i am not able to detect the ibeacon.
3 replies
Datagrdn
@Datagrdn
Getting pretty consistent feedback from our users that pairing works with Pixels but not Galaxy. Has anyone come across a similar issue with this library on Galaxy phones?
Bohdan Pomohaibo
@chocky335
@dariuszseweryn How we can get advertising data? It's required to identify the manufacturer of the device.
https://image.slidesharecdn.com/ibeaconworkshop-april2014-140430015502-phpapp01/95/build-your-own-ibeacon-12-638.jpg
Dariusz Seweryn
@dariuszseweryn
iBeacons are mentioned in the wiki
Simone Bianchin
@powext
Hi folks, after i remove a subscription from a notifications monitoring i always get "BleError: Operation was cancelled" and the device remains unavailable.
Bouvier
@fouv
Hi everyone, I need your help regarding disconnection error. To resume, i have a button to connect device and another one to disconnect it. I use the function manager.cancelDeviceConnection(device) and I have this error "Unable to disconnect from device [BleError: Device B5:36:C0:A4:4E:59 is not connected]". But it seems device is well connected if I check in the app BLE scanner. I don't know what is the pb. Need help ... this is my code export const disconnectFromDevice = async(newDevice) => {
device = newDevice.item.id
console.log('device disconnect',device)
manager.cancelDeviceConnection(device)

.then(() => {
setConnectedDeviceStatus(false)
})
.catch(error => {
console.log('Unable to disconnect from device', error);
})
}
bellow my function connectToDevice
//connect to select device
    const connectToDevice =  async(device) => {
    console.log('ok process ongoing to connectToDevice');
    console.log('device nme',device.name);
    console.log('deviceId',device.id)
    setDeviceId(device.id);

    //check connection state of a device
    /*if(manager.isDeviceConnected(deviceId) === true){
            console.log("cancelling");
               manager.cancelDeviceConnection(deviceId); // deconnexion
     }*/

    //setConnectedDeviceList([]);
    //connexion au device
        device.connect()
          .then((connectedDevice) => {
          console.log('device connected',connectedDevice)

     //Add device to connectedDeviceList
      //   setConnectedDeviceList([...connectedDeviceList, device])
     //processing double
          var newConnectedDevice = true
              //console.log('lenght device', deviceList.length)
                       for( let connectDevice of connectedDeviceList ) {
                          if( connectDevice.id === connectedDevice.id ) {
                          //console.log('connect device id',connectDevice.id)
                          //console.log('connected device id',connectedDevice.id)
                          //console.log("ok same devices")
                             newConnectedDevice = false
                             break;
                         } else {
                         console.log('break ?')
                         }
                      }
                      if( newConnectedDevice === true ) {
                      //console.log('device news')
                      setConnectedDeviceList([...connectedDeviceList, device])
                       }

          setConnectedDeviceName(device.name);
          setConnectedDeviceStatus(true);
          setConnectedDevice(device);

        //check deconnection
         //listenerDeviceDisconnect(deviceId);
         //store in AsyncStorage deviceId
         //storeDeviceConnected(device.id)
         //console.log('connectedDevice',connectedDevice)

         console.log('Discovering services and characteristics');
         device.discoverAllServicesAndCharacteristics()
         .then(device=>{ console.log('device discover',device.name)})
         .catch(c=>{console.log('error discover',c)})
         })
         .then((device) => {
         console.log('Setting notifications');
         //const services = device.services();
         })
         .catch(error => {
         if(error) {
         console.log('error connectToDevice',error)
         }
          })
        }
St├ęphane Juban
@StephaneJuban

Hi !

Recently I have some iOS phone that failed to keep the connection active. I can connect to my device, but after some delay (it looks like every time, 30s after connecting), it gets automatically disconnected.
When I check with onDeviceDisconnected I have no error.

Any idea why ?

Prateek Sharma
@Sharma1220_twitter
Hi guys, I am using React-Native-Ble-Plx lib. I am always getting this error [BleError: Operation was cancelled] on manager.connectToDevice(device id) in iOS. it is working fine for Android. But somehow it is not working on iOS now. It was working on both platforms earlier.
Is anybody have an idea to solve this issue?
Datagrdn
@Datagrdn
Hello everyone, finally got my hands on a Samsung Galaxy to troubleshoot. All our customers with various models of this phone say they are unable to connect to our device. I'm not seeing any errors in the logs but it is not discovering my device. Does anyone know of why a Galaxy might be different from other Android devices? Thanks so much!
Datagrdn
@Datagrdn
Interesting, getting inconsistent results. Now I can discover devices but when I connect it immediately disconnections with 2021-02-18 22:45:41.863 18865-20061/com.datagarden.plantwaveandroid W/ReactNativeJS: Possible Unhandled Promise Rejection (id: 0): BleError: Characteristic 6e400002-b5a3-f393-e0a9-e50e24dcca9e write failed for device FC:F5:C4:08:98:6A and service 6e400001-b5a3-f393-e0a9-e50e24dcca9
unless I manually send a message to the peripheral via the app. Again this is the exact setup that works on Pixel and other Android devices
It seems like RxBLE doesn't get consistent access to the native Bluetooth functions
Datagrdn
@Datagrdn
Ah got this right before the above error now
2021-02-18 23:17:19.443 28788-30924/com.datagarden.plantwaveandroid W/RxBle#ConnectionOperationQueue: Queue's awaitRelease() has been interrupted abruptly while it wasn't released by the release() method.
    java.lang.InterruptedException
        at java.lang.Object.wait(Native Method)
        at java.lang.Object.wait(Object.java:442)
        at java.lang.Object.wait(Object.java:568)
        at com.polidea.rxandroidble.internal.serialization.QueueSemaphore.awaitRelease(QueueSemaphore.java:15)
        at com.polidea.rxandroidble.internal.serialization.ConnectionOperationQueueImpl$1.run(ConnectionOperationQueueImpl.java:73)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:919)
2021-02-18 23:17:19.597 28788-28788/com.datagarden.plantwaveandroid E/ViewRootImpl: sendUserActionEvent() mView returned.
St├ęphane Juban
@StephaneJuban
Is this library still supported ? I am wondering since Polidea was acquired by snowflake
1 reply
Lucas Ramage
@lramage94_gitlab
2021-02-17 10:13:14.105 -0500 EST error RN Method.java:-2 java.lang.reflect.Method.invoke 20681_46fa990f-2e9b-5bc0-9823-5cbbdb28e927 4.15.15 1024605174 en 10 245213 106  Error while reading characteristic (service: 0000181c-0000-1000-8000-00805f9b34fb, characteristic: 00002B00-0000-1000-8000-00805f9b34fb): Error BleError: Characteristic 00002b00-0000-1000-8000-00805f9b34fb read failed for device 08:7C:BE:7F:1A:1F and service 0000181c-0000-1000-8000-00805f9b34fb
2021-02-17 10:13:14.111 -0500 EST error RN Method.java:-2 java.lang.reflect.Method.invoke 20681_46fa990f-2e9b-5bc0-9823-5cbbdb28e927 4.15.15 1024605174 en 10 245213 107  BleError: Characteristic 00002b00-0000-1000-8000-00805f9b34fb read failed for device 08:7C:BE:7F:1A:1F and service 0000181c-0000-1000-8000-00805f9b34fb
2021-02-17 10:13:14.118 -0500 EST error RN Method.java:-2 java.lang.reflect.Method.invoke 20681_46fa990f-2e9b-5bc0-9823-5cbbdb28e927 4.15.15 1024605174 en 10 245213 108  Error while reading characteristic (service: 0000181c-0000-1000-8000-00805f9b34fb, characteristic: 00002B03-0000-1000-8000-00805f9b34fb): Error BleError: Device 08:7C:BE:7F:1A:1F is not connected
2021-02-17 10:13:14.119 -0500 EST warning RN Method.java:-2 java.lang.reflect.Method.invoke 20681_46fa990f-2e9b-5bc0-9823-5cbbdb28e927 4.15.15 1024605174 en 10 245213 109  connection error: Device 08:7C:BE:7F:1A:1F is not connected, retry: 2
2021-02-17 10:13:14.131 -0500 EST warning RN Method.java:-2 java.lang.reflect.Method.invoke 20681_46fa990f-2e9b-5bc0-9823-5cbbdb28e927 4.15.15 1024605174 en 10 245213 110  BleError: Device 08:7C:BE:7F:1A:1F is not connected
2021-02-17 10:13:16.405 -0500 EST error RN Method.java:-2 java.lang.reflect.Method.invoke 20681_46fa990f-2e9b-5bc0-9823-5cbbdb28e927 4.15.15 1024605174 en 10 245213 122  Error while reading characteristic (service: 0000181c-0000-1000-8000-00805f9b34fb, characteristic: 00002B00-0000-1000-8000-00805f9b34fb): Error BleError: Device 08:7C:BE:7F:1A:1F was disconnected
2021-02-17 10:13:19.725 -0500 EST error RN Method.java:-2 java.lang.reflect.Method.invoke 20681_46fa990f-2e9b-5bc0-9823-5cbbdb28e927 4.15.15 1024605174 en 10 245213 133  Error while reading characteristic (service: 0000181c-0000-1000-8000-00805f9b34fb, characteristic: 00002B00-0000-1000-8000-00805f9b34fb): Error BleError: Characteristic 00002b00-0000-1000-8000-00805f9b34fb read failed for device 08:7C:BE:7F:1A:1F and service 0000181c-0000-1000-8000-00805f9b34fb
2021-02-17 10:13:19.726 -0500 EST error RN Method.java:-2 java.lang.reflect.Method.invoke 20681_46fa990f-2e9b-5bc0-9823-5cbbdb28e927 4.15.15 1024605174 en 10 245213 134  BleError: Characteristic 00002b00-0000-1000-8000-00805f9b34fb read failed for device 08:7C:BE:7F:1A:1F and service 0000181c-0000-1000-8000-00805f9b34fb
2021-02-17 10:13:19.733 -0500 EST error RN Method.java:-2 java.lang.reflect.Method.invoke 20681_46fa990f-2e9b-5bc0-9823-5cbbdb28e927 4.15.15 1024605174 en 10 245213 135  Error while reading characteristic (service: 0000181c-0000-1000-8000-00805f9b34fb, characteristic: 00002B03-0000-1000-8000-00805f9b34fb): Error BleError: Device 08:7C:BE:7F:1A:1F is not connected
2021-02-17 10:13:19.734 -0500 EST warning RN Method.java:-2 java.lang.reflect.Method.invoke 20681_46fa990f-2e9b-5bc0-9823-5cbbdb28e927 4.15.15 1024605174 en 10 245213 136  connection error: Device 08:7C:BE:7F:1A:1F is not connected, retry: 2
2021-02-17 10:13:19.746 -0500 EST warning RN Method.java:-2 java.lang.reflect.Method.invoke 20681_46fa990f-2e9b-5bc0-9823-5cbbdb28e927 4.15.15 1024605174 en 10 245213 137  BleError: Device 08:7C:BE:7F:1A:1F is not connected
2021-02-17 10:13:25.184 -0500 EST error RN Method.java:-2 java.lang.reflect.Method.invoke 20681_46fa990f-2e9b-5bc0-9823-5cbbdb28e927 4.15.15 1024605174 en 10 245213 159  Error while reading characteristic (service: 0000181c-0000-1000-8000-00805f9b34fb, characteristic: 00002B00-0000-1000-8000-00805f9b34fb): Error BleError: Characteristic 00002b00-0000-1000-8000-00805f9b34fb read failed for device 08:7C:BE:7F:1A:1F and service 0000181c-0000-1000-8000-00805f9b34fb
2021-02-17 10:13
4 replies
Tuanpm31
@Tuanpm31
anyone have an example of multiple connections? Thanks for helping
6 replies
spkteam
@spkteam
Hi everyone, I was trying to read the manufacturerData from my BLE device and it comes encoded. I looked up the documentation and see that the value is base64 encoded.
But when I decode it back, I get an entirely different string.
https://polidea.github.io/react-native-ble-plx/#devicemanufacturerdata
10 replies
Is there a specific method to parse it?