Trying to write from phone to a device using the method below. We have three packets of data to transmit. The first packet transmits, then our phones disconnect with error Response Characteristic Error: Error: Device disconnected
.
Can anyone shed light on how to troubleshoot this response characteristic error? We're using the react-native-ble-plx library.
writeToDevice = async (fullMessage, machineID) => {
let subMessagesToSend = [];
let subMessagesToSendCounter = 0;
let i, j;
let maxBytes = 19;
for (i = 0, j = fullMessage.length; i < j; i += maxBytes) {
subMessagesToSend.push(fullMessage.slice(i, i + maxBytes));
}
const sequenceNum = Buffer.alloc(1);
sequenceNum.writeUInt8(subMessagesToSendCounter, 0);
const subMessage = subMessagesToSend[0];
const buffer = Buffer(subMessage, 'utf8');
const fullBuffer = Buffer.concat([sequenceNum, buffer]);
const message = fullBuffer.toString('base64');
ble.writeCharacteristicWithResponseForDevice(
machineID,
hUUID,
rxUUID,
message)
});
subMessagesToSendCounter++;
}