'How can I use get data from the bluetooth device using react-native-ble-plx?

I'm trying to add bluetooth function in my app.

What I want to link to is a Bluetooth blood pressure machine, and while looking at the document, I wrote the code below.

const scanAndConnect = () => {
    console.log('scanStart');
    let preparedDeviceList = [];
    manager.startDeviceScan(null, null, (error, device) => {
      if (error) {
        console.log('error : ' + error);
        return;
      }

      console.log(device.name);

      if (
        device.name === 'BP170B 7219' ||
        device.name === 'BP170B' ||
        device.name === '7219'
      ) {
        console.log('detected!!');
        manager.stopDeviceScan();

        device
          .connect()
          .then(device => {
            console.log('connected!!');

            return device.discoverAllServicesAndCharacteristics();
          })
          .then(device => {
            // console.log(device.services()); // {"_U": 0, "_V": 0, "_W": null, "_X": null}

            // I don't know this code is suitable.
            device.services().then(services => {
              services.forEach((service, i) => {
                service.characteristics().then(c => {
                  console.log('----' + i + '-----');
                  console.log(c);

                  // I don't know what can I do more in here.
                  
                });
              });
            });

            
          })

          .catch(error => {
            console.log(error.message);
          });
      }
    });
  };

I was able to do the scanning and connection smoothly, but I don't know what to do from now on.

The result of [console.log] is blow.

 LOG  BP170B 7219
 LOG  detected!!
 LOG  connected!!
 LOG  ----0-----
 LOG  [{"_manager": {"_activePromises": [Object], "_activeSubscriptions": [Object], "_errorCodesToMessagesMapping": [Object], "_eventEmitter": [NativeEventEmitter], "_scanEventSubscription": null, "_uniqueId": 9}, "deviceID": "CB:B1:A4:D9:30:03", "id": 2, "isIndicatable": false, "isNotifiable": false, "isNotifying": false, "isReadable": true, "isWritableWithResponse": true, "isWritableWithoutResponse": false, "serviceID": 1, "serviceUUID": "00001800-0000-1000-8000-00805f9b34fb", "uuid": "00002a00-0000-1000-8000-00805f9b34fb", "value": null}, {"_manager": {"_activePromises": [Object], "_activeSubscriptions": [Object], "_errorCodesToMessagesMapping": [Object], "_eventEmitter": [NativeEventEmitter], "_scanEventSubscription": null, "_uniqueId": 9}, "deviceID": "CB:B1:A4:D9:30:03", "id": 3, "isIndicatable": false, "isNotifiable": false, "isNotifying": false, "isReadable": true, "isWritableWithResponse": false, "isWritableWithoutResponse": false, "serviceID": 1, "serviceUUID": "00001800-0000-1000-8000-00805f9b34fb", "uuid": "00002a01-0000-1000-8000-00805f9b34fb", "value": null}, {"_manager": {"_activePromises": [Object], "_activeSubscriptions": [Object], "_errorCodesToMessagesMapping": [Object], "_eventEmitter": [NativeEventEmitter], "_scanEventSubscription": null, "_uniqueId": 9}, "deviceID": "CB:B1:A4:D9:30:03", "id": 4, "isIndicatable": false, "isNotifiable": false, "isNotifying": false, "isReadable": true, "isWritableWithResponse": false, "isWritableWithoutResponse": false, "serviceID": 1, "serviceUUID": "00001800-0000-1000-8000-00805f9b34fb", "uuid": "00002a04-0000-1000-8000-00805f9b34fb", "value": null}]
 LOG  ----1-----
 LOG  []
 LOG  ----2-----
 LOG  [{"_manager": {"_activePromises": [Object], "_activeSubscriptions": [Object], "_errorCodesToMessagesMapping": [Object], "_eventEmitter": [NativeEventEmitter], "_scanEventSubscription": null, "_uniqueId": 9}, "deviceID": "CB:B1:A4:D9:30:03", "id": 7, "isIndicatable": true, "isNotifiable": false, "isNotifying": false, "isReadable": false, "isWritableWithResponse": false, "isWritableWithoutResponse": false, "serviceID": 6, "serviceUUID": "00001810-0000-1000-8000-00805f9b34fb", "uuid": "00002a35-0000-1000-8000-00805f9b34fb", "value": null}, {"_manager": {"_activePromises": [Object], "_activeSubscriptions": [Object], "_errorCodesToMessagesMapping": [Object], "_eventEmitter": [NativeEventEmitter], "_scanEventSubscription": null, "_uniqueId": 9}, "deviceID": "CB:B1:A4:D9:30:03", "id": 9, "isIndicatable": false, "isNotifiable": false, "isNotifying": false, "isReadable": true, "isWritableWithResponse": false, "isWritableWithoutResponse": false, "serviceID": 6, "serviceUUID": "00001810-0000-1000-8000-00805f9b34fb", "uuid": "00002a49-0000-1000-8000-00805f9b34fb", "value": null}]
 LOG  ----3-----
 LOG  [{"_manager": {"_activePromises": [Object], "_activeSubscriptions": [Object], "_errorCodesToMessagesMapping": [Object], "_eventEmitter": [NativeEventEmitter], "_scanEventSubscription": null, "_uniqueId": 9}, "deviceID": "CB:B1:A4:D9:30:03", "id": 11, "isIndicatable": false, "isNotifiable": false, "isNotifying": false, "isReadable": true, "isWritableWithResponse": false, "isWritableWithoutResponse": false, "serviceID": 10, "serviceUUID": "0000180a-0000-1000-8000-00805f9b34fb", "uuid": "00002a29-0000-1000-8000-00805f9b34fb", "value": null}, {"_manager": {"_activePromises": [Object], "_activeSubscriptions": [Object], "_errorCodesToMessagesMapping": [Object], "_eventEmitter": [NativeEventEmitter], "_scanEventSubscription": null, "_uniqueId": 9}, "deviceID": "CB:B1:A4:D9:30:03", "id": 12, "isIndicatable": false, "isNotifiable": false, "isNotifying": false, "isReadable": true, "isWritableWithResponse": false, "isWritableWithoutResponse": false, "serviceID": 10, "serviceUUID": "0000180a-0000-1000-8000-00805f9b34fb", "uuid": "00002a24-0000-1000-8000-00805f9b34fb", "value": null}, {"_manager": {"_activePromises": [Object], "_activeSubscriptions": [Object], "_errorCodesToMessagesMapping": [Object], "_eventEmitter": [NativeEventEmitter], "_scanEventSubscription": null, "_uniqueId": 9}, "deviceID": "CB:B1:A4:D9:30:03", "id": 13, "isIndicatable": false, "isNotifiable": false, "isNotifying": false, "isReadable": true, "isWritableWithResponse": false, "isWritableWithoutResponse": false, "serviceID": 10, "serviceUUID": "0000180a-0000-1000-8000-00805f9b34fb", "uuid": "00002a23-0000-1000-8000-00805f9b34fb", "value": null}]
 LOG  ----4-----
 LOG  [{"_manager": {"_activePromises": [Object], "_activeSubscriptions": [Object], "_errorCodesToMessagesMapping": [Object], "_eventEmitter": [NativeEventEmitter], "_scanEventSubscription": null, "_uniqueId": 9}, "deviceID": "CB:B1:A4:D9:30:03", "id": 15, "isIndicatable": false, "isNotifiable": true, "isNotifying": false, "isReadable": false, "isWritableWithResponse": false, "isWritableWithoutResponse": false, "serviceID": 14, "serviceUUID": "6e400001-b5a3-f393-e0a9-e50e24dcca9e", "uuid": "6e400003-b5a3-f393-e0a9-e50e24dcca9e", "value": null}, {"_manager": {"_activePromises": [Object], "_activeSubscriptions": [Object], "_errorCodesToMessagesMapping": [Object], "_eventEmitter": [NativeEventEmitter], "_scanEventSubscription": null, "_uniqueId": 9}, "deviceID": "CB:B1:A4:D9:30:03", "id": 17, "isIndicatable": false, "isNotifiable": false, "isNotifying": false, "isReadable": false, "isWritableWithResponse": true, "isWritableWithoutResponse": true, "serviceID": 14, "serviceUUID": "6e400001-b5a3-f393-e0a9-e50e24dcca9e", "uuid": "6e400002-b5a3-f393-e0a9-e50e24dcca9e", "value": null}]


How can I get data from the sphygmomanometer?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source