I try to send commands to a BLE device from an Android phone, after connecting to the device, I call the write function and it always returns “Write failed”, any suggestions?
this.utils.isConnected(this.deviceId).then(() => {
let data = new Uint8Array(3);
data[0] = 0x24;
data[1] = 0x0B;
data[2] = 0x23;
this.utils.writeToDevice(data).then((response) => {
alert('Send data ok!');
}).catch((error) => {
alert('Error! \n' + JSON.stringify(error));
});
}).catch(() => {
//no conected
alert(`device: ${this.deviceId}, not conected!`);
});
public writeToDevice(data): Promise<any> {
return this.ble.writeWithoutResponse(this.DEVICE_CURRENT, this.SERVICE_UID, this.CHARACTERISTIC_UID, data.buffer);
}
1 post - 1 participant