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
Cassio Xavier Rocha
@cxrocha
Can anyone help me to understand why my function bleManager.monitorCharacteristicForDevice is never called. I am sending ON / OFF strings every two seconds of ESP32.
import React, { useState, useEffect } from 'react';
import {
  Text,
  View,
  PermissionsAndroid,
} from 'react-native';

import {
    BleManager,
    nativeDevice
  } from 'react-native-ble-plx';

export default function App() {

  const bleManager = new BleManager();

  useEffect(() => {
    const subscription = bleManager.onStateChange(async (state) => {
        if (state === 'PoweredOn') {
            const permission = await requestLocationPermission();
            console.log('permission: ', permission);
            if(permission){
                scanAndConnect();
                subscription.remove();
            }
        }
    }, true);
  });

  useEffect(() => {
    async function monitor() {
      const subscription = await bleManager.monitorCharacteristicForDevice("8C:AA:B5:85:F4:EE", 
        "4fafc201-1fb5-459e-8fcc-c5c9c331914b", 
        "beb5483e-36e1-4688-b7f5-ea07361b26a8", 
        (error, characteristic) => {
            if (error) { console.log('Error Message: ', error.message); return }
            console.log("characteristic: ", characteristic);
        });
      subscription.remove();
      }
    monitor();
  },[]);

  async function scanAndConnect() {
    await bleManager.startDeviceScan(null, null, (error, device) => {
      if (error) {
          console.log('ERRO: ', error);
          return
      }
      if (device.localName !== null) {
        if (device.localName.substr(0, 9) === 'SpeedTest') {
          console.log('1');
          bleManager.stopDeviceScan();
          bleManager
            .connectToDevice(device.id, {autoConnect: true})
            .then(device => { return device.discoverAllServicesAndCharacteristics() })
            .then(device => {
              readData(device);
            })
            .catch(error => {
              console.log(error);
              bleManager
                .isDeviceConnected(device.id)
                .then(res => console.log(res))
                .catch(err => console.log(err));
              console.log('error.message: ', error.message);
              device.cancelConnection();
              scanAndConnect();
            } )
        }
      }

    } ) 
  };

  async function readData(device) {
  device.services()
      .then( services => {
        const characteristics = [];
        services.forEach( ( service, i ) => {
          service.characteristics()
            .then( c => {
              characteristics.push( c );
              if ( i === services.length - 1 ) {
                console.log('characteristics: ', characteristics );
              }
            } )
          })
      })
  }

  async function requestLocationPermission() {
    const granted = await PermissionsAndroid.request(
      PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
      { title: "Permição para Bluetooth BLE",
        message: "Este App pode acessar o Bluetooth LE. ",
        buttonNeutral: "Ask Me Later",
        buttonNegative: "Cancel",
        buttonPositive: "OK"
      });
    if (granted === PermissionsAndroid.RESULTS.GRANTED) {
      console.log("You can use the Bluetooth LE");
      return (true)
    } else {
      console.log("Bluetooth LE permission denied");
      return (false)
    }
  }

  return (
      <View>
          <Text>Let’s start</Text>
      </View>
  );
}
[Fri Jul 31 2020 03:49:00.122]  LOG      You can use the Bluetooth LE
[Fri Jul 31 2020 03:49:00.123]  LOG      permission:  true
[Fri Jul 31 2020 03:49:12.419]  LOG      1
[Fri Jul 31 2020 03:49:13.491]  LOG      characteristics:  [[{"_manager": [BleManager], "deviceID": "8C:AA:B5:85:F4:EE", "id": 2, "isIndicatable": true, "isNotifiable": false, "isNotifying": false, "isReadable": false, "isWritableWithResponse": false, "isWritableWithoutResponse": false, "serviceID": 1, "serviceUUID": "00001801-0000-1000-8000-00805f9b34fb", "uuid": "00002a05-0000-1000-8000-00805f9b34fb", "value": null}], [{"_manager": [BleManager], "deviceID": "8C:AA:B5:85:F4:EE", "id": 5, "isIndicatable": false, "isNotifiable": false, "isNotifying": false, "isReadable": true, "isWritableWithResponse": false, "isWritableWithoutResponse": false, "serviceID": 4, "serviceUUID": "00001800-0000-1000-8000-00805f9b34fb", "uuid": "00002a00-0000-1000-8000-00805f9b34fb", "value": null}, {"_manager": [BleManager], "deviceID": "8C:AA:B5:85:F4:EE", "id": 6, "isIndicatable": false, "isNotifiable": false, "isNotifying": false, "isReadable": true, "isWritableWithResponse": false, "isWritableWithoutResponse": false, "serviceID": 4, "serviceUUID": "00001800-0000-1000-8000-00805f9b34fb", "uuid": "00002a01-0000-1000-8000-00805f9b34fb", "value": null}, {"_manager": [BleManager], "deviceID": "8C:AA:B5:85:F4:EE", "id": 7, "isIndicatable": false, "isNotifiable": false, "isNotifying": false, "isReadable": true, "isWritableWithResponse": false, "isWritableWithoutResponse": false, "serviceID": 4, "serviceUUID": "00001800-0000-1000-8000-00805f9b34fb", "uuid": "00002aa6-0000-1000-8000-00805f9b34fb", "value": null}], [{"_manager": [BleManager], "deviceID": "8C:AA:B5:85:F4:EE", "id": 9, "isIndicatable": false, "isNotifiable": true, "isNotifying": false, "isReadable": true, "isWritableWithResponse": false, "isWritableWithoutResponse": false, "serviceID": 8, "serviceUUID": "4fafc201-1fb5-459e-8fcc-c5c9c331914b", "uuid": "beb5483e-36e1-4688-b7f5-ea07361b26a8", "value": null}]]
Dariusz Seweryn
@dariuszseweryn
because you stop it right away?
psi
@annazus
I have to use react-native-ble-plx in an older react native that is not using cocoapods. I have tried manually linking the library with no success. Could you help me link this? The react native version is .60.4
Dariusz Seweryn
@dariuszseweryn
Try checking older revisions
Johan Isaksson
@izaxon
Hi, we have a new HW version of our BT device. Now both the Android and iOS apps see delays in communication (e.g. writing to the device). Before commands (writing) took < 1s, now it takes 7+ s. Any ideas what to do? (I found this issue: Polidea/react-native-ble-plx#101 but cannot understand how to apply it, i.e. change the polling interval). BLEScanner is fast with both version of the HW.
19 replies
Stefan New
@stefannew

Ran into MissingBackpressureException again, OnePlus 6 running Android 10.

ExceptionsManager.js:126 Unhandled promise rejection BleError: Unknown error occurred. This is probably a bug! Check reason property.
    at parseBleError (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:172893:18)
    at BleManager._callPromise$ (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:173157:51)
    at tryCatch (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:29088:19)
    at Generator.invoke [as _invoke] (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:29264:24)
    at Generator.prototype.<computed> [as throw] (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:29131:23)
    at tryCatch (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:29088:19)
    at invoke (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:29164:22)
    at http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:29176:15
    at http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:193393:24
    at flush (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:194048:11)

logcat:

08-10 21:07:18.787 25068 25113 W System  : A resource failed to call response.body().close().
08-10 21:11:08.089 25068 25089 D BluetoothGatt: onClientConnectionState() - status=8 clientIf=7 device=D8:82:82:A7:30:4A
08-10 21:11:08.120 25068 25089 D BluetoothGatt: setCharacteristicNotification() - uuid: 6e400003-b5a3-f393-e0a9-e50e24dcca9e enable: false
08-10 21:11:08.133 25068 25185 D BluetoothGatt: close()
08-10 21:11:08.133 25068 25185 D BluetoothGatt: unregisterApp() - mClientIf=7
1 reply
don't know if that first System log is actually related... just looked suspicious
Stefan New
@stefannew
08-10 21:44:48.712 19099 19153 I bt_stack: [INFO:gatt_main.cc(916)] gatt_data_process op_code = 27, msg_len = 3
08-10 21:44:48.712 19099 19153 E bt_btif : bta_gattc_process_indicate, ignore HID ind/notificiation
08-10 21:44:48.713 27950 28083 D BluetoothGatt: setCharacteristicNotification() - uuid: 6e400003-b5a3-f393-e0a9-e50e24dcca9e enable: false
08-10 21:44:48.716 19099 19161 D BtGatt.GattService: registerForNotification() - address=D8:82:82:A7:30:4A enable: false
08-10 21:44:48.718 19099 19125 D BtGatt.GattService: onRegisterForNotifications() - address=null, status=0, registered=0, handle=27
08-10 21:44:48.722   805   805 I vendor.qti.bluetooth@1.0-ibs_handler: DeviceWakeUp: Writing IBS_WAKE_IND
08-10 21:44:48.722   805 19149 I vendor.qti.bluetooth@1.0-ibs_handler: ProcessIbsCmd: Received IBS_WAKE_ACK: 0xFC
08-10 21:44:48.750   805 19149 I vendor.qti.bluetooth@1.0-ibs_handler: ProcessIbsCmd: Received IBS_SLEEP_IND: 0xFE
08-10 21:44:48.753   805 19149 I vendor.qti.bluetooth@1.0-ibs_handler: ProcessIbsCmd: Received IBS_WAKE_IND: 0xFD
08-10 21:44:48.753   805 19149 I vendor.qti.bluetooth@1.0-ibs_handler: ProcessIbsCmd: Writing IBS_WAKE_ACK
08-10 21:44:48.785 19099 19153 I bt_stack: [INFO:gatt_main.cc(916)] gatt_data_process op_code = 19, msg_len = 0
08-10 21:44:48.824   805 19149 I vendor.qti.bluetooth@1.0-ibs_handler: ProcessIbsCmd: Received IBS_SLEEP_IND: 0xFE
Stefan New
@stefannew
what's weird is that my hardware peripheral is still showing a connection
Datagrdn
@Datagrdn

Hey there. Modified the SensorTag example to read UUIDs from my device. See code below. Without having changed the code it seems to work once every 20 or so tries, otherwise throws the error that the device isn't connected.

Can anyone see what I'm doing wrong?

function* readUUIDs(device: Device): Generator<*, boolean, *> {
  try {
    const services: Array<Service> = yield call([device, device.services]);
    for (const service of services) {
      yield put(log('Found service: ' + service.uuid));
      const characteristics: Array<Characteristic> = yield call([
        service,
        service.characteristics,
      ]);

      for (const characteristic of characteristics) {
        yield put(log('Found characteristic: ' + characteristic.uuid));

        const descriptors: Array<Descriptor> = yield call([
          characteristic,
          characteristic.descriptors,
        ]);

        for (const descriptor of descriptors) {
          yield put(log('* Found descriptor: ' + descriptor.uuid));
          const d: Descriptor = yield call([descriptor, descriptor.read]);
          yield put(log('Descriptor value: ' + (d.value || 'null')));
        }

        yield put(log('Found characteristic: ' + characteristic.uuid));
      }
    }
  } catch (error) {
    yield put(logError(error));
    return false;
  }

  return true;
}
acheve
@acheve
Hi, I would like to know if react-native-ble supports long write? It seems to be supported by RxAndroidBle see: https://github.com/Polidea/RxAndroidBle/#long-write but not present in the MultiPlatformBleAdapter. Thanks for your feedback.
6 replies
Ghost
@ghost~5f430befd73408ce4fecf87a
hi, id like to read data from an already connected peripheral. startDeviceScan() doesnt seem to pick up connected peripheral so how can i make this possible?
fitbuff
@fitbuff
hi, id like to read data from an already connected peripheral. startDeviceScan() doesnt seem to pick up connected peripheral so how can i make this possible?
d0xi5
@d0xi5
Hello to all, and thanks for reading. I would like to know if its possible to write on multiple characteristics at the same time. Also, once I write for the first time, for some reason I cannot do it again. I have to quit the app and launch it again to do it. Should I use cancelTransaction before trying to write once again? Thank you for your time.
7 replies
Drew André
@drewandre

Howdy everyone. I'm seeing some odd behavior that I'm not sure is issue-worthy. Maybe I just don't understand the BLE advertising protocol. Before I connect to my device (an ESP32), the device found from scanning shows all the advertising data I need. RSSI, manufacturer data, services, etc etc. After successfully connecting, all of that data just disappears from the Device instance returned from device.connect(), device.discoverAllServicesAndCharacteristics(), and any other Device method.

This hasn't really been a problem for me so far because I save the device info in state before calling device.connect() and I'm still able to monitor characteristics and what not. This only became a problem recently when I started needing to reference the manufacturerData which disappear on connect() when the application re-enters the foreground. In this scenario, I call this.manager.connectedDevices([SERVICE_UUID]), followed by this.manager.isDeviceConnected(device.id). If the device is connected, I attempt to read from manufacturerData, but this is null as explained above.

Does this make sense? My scanning/connecting functions are pretty simple. I'll walk through them below:

scan():

  scan = () => {
    this.manager.startDeviceScan([SERVICE_UUID], { allowDuplicates: false }, (error, device) => {
      if (error) {
        console.warn(error)
        return this.handleConnectionError(error);
      }
      // At this point, "device" has all the correct advertising data
      this.connectToBleDevice(device);
    });
  };

connectToBleDevice():

  connectToBleDevice = async device => {
    const connectedDevice = await device.connect()
    // At this point, all advertising data is null :(

    await connectedDevice.discoverAllServicesAndCharacteristics()
    const deviceServices = await connectedDevice.services()
    const primaryService = deviceServices[0]
    const characteristics = await primaryService.characteristics()

    characteristics.forEach((characteristic) => {
      if (characteristic.uuid === OTA_FILE_WRITE_CHARACTERISTIC) {
        this.otaFileWriteCharacteristicSubscription = ...
      } else {
        console.log("Unknown characteristic discovered", characteristic.id)
      }
    });
  };
4 replies
d0xi5
@d0xi5
Hello to all. How can I know the transfer unit size of a base64 string that I'm trying to write?
10 replies
Nishith
@nishith987_twitter
Hi @dariuszseweryn monitorCharacteristicForService, when I listen to this service data which I am receiving, is greater than 20bytes all the data after 20bytes are getting lost, is there any way to get the full data packet?
2 replies
Datagrdn
@Datagrdn
Can someone share an example of subscribing to characteristic notifications? Read the entry on monitorCharacteristicForDevice but not sure how to get started
5 replies
d0xi5
@d0xi5
Hello, quick question: Will this code print on the console whenever the characteristic changes?
characteristic.isNotifiable &&
 characteristic.monitor((error, c) => {
   if (error) {
    console.log(error)
   }

   console.log(
    'Monitoring characteristic ' + index + '...'
   )

   console.log(c)
  }
2 replies
d0xi5
@d0xi5
Is there a way of retrieving the battery level of the peripheral if it doesn't expose it on any characteristic?
1 reply
Datagrdn
@Datagrdn
I'm trying to replicate the SensorTag test format to subscribe to a specific UUID. Here's what I'm trying based on d0xi5's advice above. Can anyone see what I'm doing wrong?
function* getStatusString(device: Device): Generator<*, booelean, *> {
  try {
    const services: Array<Service> = yield call([device, device.services]);
    for (const service of services) {
      yield put(log('Found service: ' + service.uuid));
      const characteristics: Array<Characteristic> = yield call([
        service,
        service.characteristics,
      ]);

      // for (const characteristic of characteristics) {
        // yield put(log('Found characteristic: ' + characteristic.uuid));

        if(characteristic.uuid == '6E400003-B5A3-F393-E0A9-E50E24DCCA9E'){
          characteristic.isNotifiable &&
          characteristic.monitor((error, c) => {
            if (error) {
             console.log(error);
            }

            console.log('Monitoring characteristic ' + index + '...');

            console.log(c);
           }
        }
      }
    }
  } catch (error) {
    yield put(logError(error));
    return false;
  }

  return true;
}
Gaurav Naik
@gaurav-naik

Hi. I'm using react-native-ble-plx v2.0.1 on Android 10 to scan EddyStone-UID-enabled beacons (Estimote) using this simple function:

    async function startScan() {
        const permission = Platform.OS === 'ios'? true: await requestLocationPermission();
        if (permission) {
            manager.startDeviceScan(null, null, (error, device) => {
                if (error) {
                    console.log("Error", error);
                    return
                }
                console.log('Device details', device);
        })
        } else {
            console.log("No permission to scan.")
        }
    }

Every example that I have seen appears to be able to successfully use the if device.name == "something" condition inside the startDeviceScan function. My console.log('Device details', device); yields a mac address via the ID field as a unique identifier, but other fields are null. Here is one of the devices logged:

[Tue Sep 29 2020 17: 14: 43.947
]  LOG      Device details {
    "_manager": {
        "_activePromises": {},
        "_activeSubscriptions": {},
        "_errorCodesToMessagesMapping": {
            ... 
        },
        "_eventEmitter": {
            "_subscriber": [EventSubscriptionVendor
            ]
        },
        "_scanEventSubscription": {
            "context": undefined,
            "emitter": [NativeEventEmitter
            ],
            "eventType": "ScanEvent",
            "key": 3,
            "listener": [Function scanListener
            ],
            "subscriber": [EventSubscriptionVendor
            ]
        },
        "_uniqueId": 0
    },
    "id": "C6:9B:DF:77:0C:D9",
    "isConnectable": null,
    "localName": null,
    "manufacturerData": null,
    "mtu": 23,
    "name": null,
    "overflowServiceUUIDs": null,
    "rssi": -75,
    "serviceData": {
        "0000fe9a-0000-1000-8000-00805f9b34fb": "ETK/GG666rkv1ffvpfYOCjrBAw=="
    },
    "serviceUUIDs": [
        "0000fe9a-0000-1000-8000-00805f9b34fb"
    ],
    "solicitedServiceUUIDs": null,
    "txPowerLevel": null
}

Have I missed something in the code or do I need to tweak the configuration on the beacon itself? Would appreciate any help. Thanks in advance!

7 replies
d0xi5
@d0xi5
Can a characteristic write while on background after X time of leaving foreground? I have read https://github.com/Polidea/react-native-ble-plx/wiki/Background-mode-(iOS) but I'm not sure if its talking about this
6 replies
Olli
@R4MSE5_twitter
Hey guys I have a simple question. Lets say I'm scanning for certain devices and display them to the user in a list. While the scan is running how do I detect that one of the previously detected devices has been turned off so that I can remove it from the list?
7 replies
Hemanth-HKSOLDIER
@HKSOLDIER
Hey guys i am developing an app it works as "when a person sits in his car it give an message 'you are inside car' like that can anyone help me out "my gmail- hemanthchitta98@gmail.com"
1 reply
d0xi5
@d0xi5
Are the characteristics meant to be monitored forever? Or should I remove the subscription?
1 reply
Datagrdn
@Datagrdn

I've been using characterisitc.monitor to subscribe to a uuid that I'm using to send a string from my peripheral. That is just returning information about the characteristic, including 'isReadable: false' which I know isn't true.

I'm sending via UART, looks like someone else on Github was having a similar problem. Is it due to UART or is there another way I should be retrieving the string?

6 replies
smunx
@smunx
How do I get list of paired bluetooth devices ?
Sami Kallinen
@skallinen
hi. would it be possible to use this library and make an app that treats the phone as a peripheral, ie emulating a ble keyboard that can be paired with other devices?
5 replies
Nishith
@nishith987_twitter
@dariuszseweryn, is there any way I can listen to 2 different notifications in the same time, from the same device? Thank you for the great library :)
1 reply
Datagrdn
@Datagrdn

I am following this example: https://www.polidea.com/blog/ReactNative_and_Bluetooth_to_An_Other_level/
and I am successful in subscribing to my characteristic but my device is disconnected after 30 seconds

I thought it might be related to the autoConnect issue on Android so I added

device .connect({autoConnect: true})
But I still have the same problem

The only clue I could find in the log is

10-12 13:44:30.941 1152 1152 W adbd : timeout expired while flushing socket, closing

Any idea what's going on here?

Datagrdn
@Datagrdn

Ah I see this as well "Background execution not allowed" in the log. Is the issue that the subscription is no longer foreground after 30 seconds?

I also see that you have instructions for background mode on iOS, what is the equivalent for Android?

3 replies
Datagrdn
@Datagrdn

Ok, I think the issue has to do with the Android 'Pairing Request' dialogue that Android opens. If I press 'Pair & Connect' my code works to subscribe to the characteristic but then I am disconnected shortly thereafter.

If I ignore the Android dialogue, my code works and I get 30 seconds of data at which point I am disconnected, which seems to be the Android timing out because I haven't responded.

Do you know the Native process that controls this? Do I need to disable it in order to continue?

14 replies
Datagrdn
@Datagrdn

After troubleshooting the above it seems like it is definitely the native pairing dialogue that interferes with the pairing flow I have setup on both the blog tutorial and SensorTag example.

Has anyone else had this issue? I always receive a second prompt once I accept and if I accept after the monitor function is called then I lose the connection.

Is there anyway to interface with the dialogs through the library?

5 replies
Jølly Good
@good-lly

hi, need to write "x55 x04 x02 x00 x00 xAA" hex bytes to characteristic - tried all possible ways how to convert it to base64 but none of it works ... have an idea?

I am now setting up BLE sniffer - cos want to see how exactly looks sended packets

25 replies
Jølly Good
@good-lly
only error i am getting is BleError: Operation was cancelled
Jølly Good
@good-lly
the characteristic is :
isWritableWithResponse: true,
isWritableWithoutResponse: false,
i call device.writeCharacteristicWithResponseForService
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