Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to check BLE Gatt Client Mode is supported by device?

In android, I have used BLE both mode as Peripheral and Client. But I want to check isBLeGattClientSupported()

As we know some devices in android are not capable to act as BLE Gatt Client so jut wants to throw an exception that such device is not able to act as client.

I have the rest of the past for BLE my code is working fine for both mode, but stuck when I said to my device to act as a client and that device is not capable to act as the client.

like image 490
Amandeep Tomar Avatar asked Oct 28 '22 03:10

Amandeep Tomar


People also ask

What is GATT service on my phone?

The Bluetooth GATT (Generic Attribute Profile) is the foundation for the design of any BLE system and defines the way a smartphone application (or any central device) interacts with the end device (the peripheral device).

What is a GATT client?

A GATT Client is a device which accesses data on a remote GATT Server, paired via BLE, using read, write, notify, or indicate operations. Once two devices are paired each device can act as both a GATT Server and a GATT Client.

How do I find a BLE device?

To find BLE devices, you use the startScan() method. This method takes a ScanCallback as a parameter. You must implement this callback, because that is how scan results are returned.


1 Answers

This is straight from the android developer guide -

at run-time you can determine BLE availability by using PackageManager.hasSystemFeature():

The java example provided (a Kotlin example is also on the same page) to check the same is as follows -

if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
    Toast.makeText(this, R.string.ble_not_supported, Toast.LENGTH_SHORT).show();
    finish();
}

This way you can check if your device supports BLE and throw an exception as required

like image 52
Karan Shishoo Avatar answered Nov 15 '22 05:11

Karan Shishoo