Hello,
I have.a problem with ionic and bluetooth. I need to create an Android Bluetooth server (API 19 only …) and an ionic client (for Android & IOS).
My iPhone detect my Bluetooth server and can pair with it but my ionic apps doesn’t see it.
I am new to the Bluetooth World and I am a bit lost
My Android server :
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 300);
activity.startActivity(discoverableIntent);
tmp = mBluetoothAdapter.listenUsingRfcommWithServiceRecord("MyAPP", MY_UUID_SECURE);
When I start this code on my Android Phone, my iPhone see it in the Bluetooth menu and I can pair with it (both Phones request to validate a code).
When I launch my ionic app on my iPhone, the Android server is not found. I only see 4 results : my MacOS computer and 3 results without name … If I stop the bluetooth on my Computer, all results disappear.
import { BleClient } from '@capacitor-community/bluetooth-le';
try {
await BleClient.initialize();
await BleClient.requestLEScan(
{
},
(result) => {
console.log('BLUE received new scan result', result);
}
);
setTimeout(async () => {
await BleClient.stopLEScan();
console.log('BLUE stopped scanning');
}, 20000);
} catch (error) {
console.error(error);
}
There is something I do not understand, someone can help you please ?
Thank you,