Bluetooth Low power consumption

agreement

Roles and Responsibilities

  • Center and periphery. This applies to BLE connections themselves. Equipment in a central role scans for broadcasts; Peripheral devices broadcast.
  • GATT server and GATT client. This determines how the two devices communicate with each other once they have established a connection.

permissions

<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>

<! -- If your app targets Android 9 or lower, you can declare ACCESS_COARSE_LOCATION instead. -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Copy the code

If you want to declare that your app is only for BLE enabled devices, add the following to the app manifest:

<uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>
Copy the code

If you want your application to work on devices that do not support BLE, you should still add this element to the application manifest, but set required=”false”. Then you can use at run time PackageManager. HasSystemFeature () to determine the BLE availability:

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

Ble Bluetooth signal strength RSSI

Received Signal Strength Indicator (DBM) An optional part of the wireless transmission layer used to determine link quality and whether to increase broadcast transmission Strength.

Generally negative value, reflecting the degree of signal attenuation, ideal state (no attenuation) Rssi value is 0dBm, the actual situation is, even if bluetooth devices are very close to each other, Rssi intensity is only -50dbm, in the transmission process, loss is inevitable.

In general, classic Bluetooth strength

The signal strength is 0dBm to -50dBm. The signal strength is -50dBm to -70dBm. The signal strength is -70dBm to dBm

  • BLE in Android bluetooth to get RSSI

    On the Android platform, the RSSI of each Bluetooth device can be obtained through bluetooth device scan callback and Bluetooth device connection monitoring.

  • Ranging theory

    The distance between the signal point and the receiving point is determined by the strength of the received signal, and then the location calculation is carried out according to the corresponding data.