You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi guys l need some assistance with the BluetoothLE writing and sending data to another device. I can connect to a broadcasting device and being able to send data to the broadcasting device.
My problem is l am scanning NFC Tags data and send the data via BluetoothLE to the broadcasting device but the thing is it only sends data for 2 NFC tags and the bluetoothWrite() function just stops working on 3rd or fourth NFC tag scan to send the data. No error message is give and bluetooth is still connected, only the bluetothWrite function doesn't write the service.
Code Sample after 2 scans the bluetoothLE.write({}) function doesn't execute at all
deviceNFCReadWrite() {
console.log('Reader Initializing');
this.alertMsg('Please place the device close to tag to read.');
// eslint-disable-next-line no-bitwise
this.flags = this.nfc.FLAG_READER_NFC_A | this.nfc.FLAG_READER_NFC_V;
this.readerMode = this.nfc.readerMode(this.flags).subscribe((tagRes: any) => {
try {
console.log(tagRes);
this.tag = tagRes;
const tagCheck = this.tag.ndefMessage;
if (!tagCheck) {
this.alertMsg('The tag is empty!');
} else {
if (this.tag.ndefMessage[0]) {
console.log('SiteID: Yes');
this.siteID = this.nfc.bytesToString(this.tag.ndefMessage[0].payload).substring(3);
//siteID
this.bluetoothLE.write({
address: this.address,
service: '883f4662-48e4-4fd2-808b-8cf78a37d787', // Copy the UUID used to initialize the peripheral service
characteristic: 'd6da1884-7d0e-11ed-a1eb-0242ac120002', // Copy the UUID of a service characteristic.
value: btoa(this.siteID)
}).then((siteRes: any) => {
console.log('Writing Yes +++++++++');
console.log(siteRes);
}, err => {
console.log('Writing No ===========');
console.log(err);
});
} else {
this.siteID = '';
}
}
}
});
}
Hi guys l need some assistance with the BluetoothLE writing and sending data to another device. I can connect to a broadcasting device and being able to send data to the broadcasting device.
My problem is l am scanning NFC Tags data and send the data via BluetoothLE to the broadcasting device but the thing is it only sends data for 2 NFC tags and the bluetoothWrite() function just stops working on 3rd or fourth NFC tag scan to send the data. No error message is give and bluetooth is still connected, only the bluetothWrite function doesn't write the service.
Code Sample after 2 scans the bluetoothLE.write({}) function doesn't execute at all
deviceNFCReadWrite() {
console.log('Reader Initializing');
this.alertMsg('Please place the device close to tag to read.');
// eslint-disable-next-line no-bitwise
this.flags = this.nfc.FLAG_READER_NFC_A | this.nfc.FLAG_READER_NFC_V;
this.readerMode = this.nfc.readerMode(this.flags).subscribe((tagRes: any) => {
try {
console.log(tagRes);
this.tag = tagRes;
const tagCheck = this.tag.ndefMessage;
if (!tagCheck) {
this.alertMsg('The tag is empty!');
} else {
if (this.tag.ndefMessage[0]) {
console.log('SiteID: Yes');
this.siteID = this.nfc.bytesToString(this.tag.ndefMessage[0].payload).substring(3);
//siteID
this.bluetoothLE.write({
address: this.address,
service: '883f4662-48e4-4fd2-808b-8cf78a37d787', // Copy the UUID used to initialize the peripheral service
characteristic: 'd6da1884-7d0e-11ed-a1eb-0242ac120002', // Copy the UUID of a service characteristic.
value: btoa(this.siteID)
}).then((siteRes: any) => {
console.log('Writing Yes +++++++++');
console.log(siteRes);
}, err => {
console.log('Writing No ===========');
console.log(err);
});
} else {
this.siteID = '';
}
}
}
});
}
My Environment
Ionic:
Ionic CLI : 6.20.1 (C:\Users\Tigere Bervin\AppData\Roaming\npm\node_modules@ionic\cli)
Ionic Framework : @ionic/angular 6.7.5
@angular-devkit/build-angular : 13.0.4
@angular-devkit/schematics : 13.0.4
@angular/cli : 13.0.4
@ionic/angular-toolkit : 5.0.3
Cordova:
Cordova CLI : 11.0.0
Cordova Platforms : android 10.1.2
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 5.0.0, (and 14 other plugins)
Utility:
cordova-res : 0.15.4
native-run (update available: 1.7.2) : 1.5.0
System:
Android SDK Tools : 26.1.1 (C:\Users\Tigere Bervin\AppData\Local\Android\Sdk)
NodeJS : v16.14.0 (C:\Program Files\nodejs\node.exe)
npm : 8.3.1
OS : Windows 10
The text was updated successfully, but these errors were encountered: