im new in ionic, right now i'm trying to send a "code" in string. which the string consist of a few packets data in HEX. eg. V1-FC03-2ED1-FE01
V1 is the sequence, then after the first - is the first packet "FC03" the code successfully send to my arduino using serial monitor on pc. arduino serial monitor
now i want to send it trough BLE using ionic. i follow the example on github on doing the BLE. it works if send 1 or 0.
here is the function in ionic codes that going to send to arduino after button pressed
onPowerSwitchChange(event) {
console.log('onPowerSwitchChange');
let value = this.power ? 1 : 0;
let buffer = new Uint8Array([value]).buffer;
console.log('Power Switch Property ' + this.power);
this.ble.write(this.peripheral.id, LIGHTBULB_SERVICE, SWITCH_CHARACTERISTIC, buffer).then(
() => this.setStatus('Light is ' + (this.power ? 'on' : 'off')),
e => this.showAlert('Unexpected Error', 'Error updating power switch')
);
}
here i tried to change
let value = this.power ? 1 : 0;
to
let value = "V1-FC03-2ED1-FE01";
but when compile, got error
Argument of type 'string[]' is not assignable to parameter of type 'ArrayBuffer'. Property 'byteLength' is
missing in type 'string[]'.
L68: let value = "V1-FC03-2ED1-FE01";
L69: let buffer = new Uint8Array([value]).buffer;
L70: console.log('Power Switch Property ' + this.power);
hopefully someone can help me on this problem