I currently have two functions in my code: getRawData() and getBTRawData().
- The purpose of getBTRawData() function is to retrieve data from Bluetooth connected to a mobile device.
- On the other hand, getRawData() function takes the return value from getBTRawData() but encounters some issues when trying to iterate over it. Although I can successfully print the value within a promise, I am unable to perform any operations on it.
getRawData() {
const result = this.getBTRawData().then((item) => {
console.log("Item retrieved: ", item);
let flatten = [];
for(let i in item) {
console.log("something happening here");
flatten.push(...item[i]);
}
console.log(flatten);
}).catch(err => {
console.log(err);
});
}
async getBTRawData() {
let result = [];
const res = await this.bluetoothSerial.subscribeRawData().subscribe((data) => {
//console.log("raw data");
// console.log(data);
var buffer = new Uint8Array(data);
//this.raw_data_c.push(buffer);
result.push(buffer);
//console.log(this.raw_data_c);).map(
// console.log(result);
});
return result;
}
Any assistance or insights on how to resolve this issue would be greatly valued. Thank you.