Skip to content

Instantly share code, notes, and snippets.

@KamikX
Created February 4, 2021 10:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KamikX/f3d372a4e9a71197ef9e8dc5b6174639 to your computer and use it in GitHub Desktop.
Save KamikX/f3d372a4e9a71197ef9e8dc5b6174639 to your computer and use it in GitHub Desktop.
Android check BLEv5 support
import android.bluetooth.BluetoothAdapter
import android.os.Build
import androidx.annotation.RequiresApi
@RequiresApi(Build.VERSION_CODES.O)
fun BluetoothAdapter.hasBleV5Support(): Boolean {
if (isLe2MPhySupported
|| isLeCodedPhySupported
|| isLeExtendedAdvertisingSupported
|| isLePeriodicAdvertisingSupported
|| leMaximumAdvertisingDataLength > 31) { // BLE 4.X message capacity is only 31 bytes.
return true
}
return false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment