React Native BleManager write function doesn't return any value

Viewed 19

Hello I'm new to BLE and React-Native BleManager. I want to send and recieve data from my device. I'm connected to the device. I can send data and recieve data. Whenever I get the respond the BleManager.write function prints the respond on console. As shown on picture below.

I want to get a return(bluetooth peripheral return) from the BleManager.write function.

But I whenever I return the result("writeBuffer") It is always empty.

Thanks for the help. :-) !!!CONSOLE OUTPUT PICTURE PLS CHECK IT!!!

          let writeBuffer;
         writeBuffer= await BleManager.write(
            "XX:XX:XX:XX:XX:XX",
            'XXXXXXXX-0000-XXXX-XXXX-XXXXXXXXXXXX',
            'XXXXXXXX-0000-XXXX-XXXX-XXXXXXXXXXXX',
            data,
            35
          )
            .then(async() => {
              console.log(`*******************************Sent ${data}`);
            })
            .catch((error) => {
              console.log(error);
            });
            
            console.log("writeBuffer:"+writeBuffer);
            return writeBuffer;//The respond this is the output 

0 Answers
Related