I need a helping hand please. I use Ble_Manager in React-native, I receive the data from but I have a problem sending it.
const sendMessage = async (
selectedDevice,
isConnected,
Buffer,
messageToSend,
BleManager,
serviceid,
caracid,
) => {
if (selectedDevice && isConnected) {
sendLog('messageToSend: ' + messageToSend);
try {
let buffer = Buffer.from(messageToSend);
sendLog('buffer: ' + buffer);
BleManager.write(
selectedDevice.id,
serviceid,
caracid,
buffer.toJSON().data,
)
.then(() => {
sendLog('Write: ' + buffer.toJSON().data);
})
.catch(error => {
sendLog('error: ' + error);
});
} catch (error) {
sendLog('Error:' + error);
}
}
};
You can see the sendLog() method I use to log on my server. the first two logs arrive in real time, but from BleManager.write(), the logs do not arrive or a "Write" log arrives 1 minute or more later. In any case, no error logs. I didn't find a solution in the existing comments. When I test my hardware with nRFConnect, everything goes well, I receive and I can send data normally.
I would like to understand why this 'write' is malfunctioning? Thank you for your attention.