So, I'm trying to send data to BLE device.My phone and BLE device are already connected.
My function:
const sendCom = async () => { const data = utf8Encode('1') // convert data to bytes const service = 'fff0' const characteristic = 'fff1' try { await BleManager.retrieveServices(peripheral.id) await BleManager.startNotification(peripheral.id, service, characteristic) await BleManager.write(peripheral.id, service, characteristic, data) console.log(`Sent: ${data}`) } catch (error) { console.log(`Error writing ${characteristic}: ${error}`) }}
peripheral
is outside of my function and is working well, I'm calling this function by onPress
prop in Pressable
component. Error occurs only when I trying to write()
something.
The error I getting:
Error writing fff1: Error writing 0000fff1-0000-1000-8000-00805f9b34fb status=3
I tried to find answer on the internet, but didn't find.I also tried this function in different variations for example using Promises with .then()
and .catch()