Expand description
Calling the Android BLE APIs.
Methods are resolved by name and signature at each call rather than cached.
BLE operates at human speed — a scan result every few hundred milliseconds,
a GATT read now and then — so the lookup costs nothing measurable, and it
removes a whole class of bug where a cached jmethodID outlives the class
it came from.
Structs§
- Adapter
- The Bluetooth adapter and its scanner.
- Callback
- A generated callback class, instantiated and bound to a sink.
- Discard
- Discard events — useful where a callback is required but nothing listens.
Constants§
- ATT_
SUCCESS BluetoothGattServer.GATT_SUCCESSand the ATT codes it forwards.- GATT_
SUCCESS BluetoothGatt.GATT_SUCCESS.- WRITE_
TYPE_ DEFAULT BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT/_NO_RESPONSE.- WRITE_
TYPE_ NO_ RESPONSE
Functions§
- advertise_
mode AdvertiseSettingsmode for a preferred maximum interval: low latency (~100 ms), balanced (~250 ms) or low power (~1 s).- attribute_
uuid - bond_
state device.getBondState()—BOND_NONE,BOND_BONDINGorBOND_BONDED.- call_
bool - call_
int - call_
object - call_
void - characteristic_
add_ descriptor - characteristic_
descriptors - characteristic_
properties - characteristic_
value - close
- Release the connection’s resources.
- connect_
gatt - create_
bond - create_
l2cap_ channel device.createL2capChannel(psm)— API 29+.- device_
address - disconnect
- discover_
services - for_
each - Walk a
java.util.List, applyingfto each element. - listen_
l2cap adapter.listenUsingInsecureL2capChannel()— API 29+.- listen_
rfcomm adapter.listenUsingRfcommWithServiceRecord(name, uuid).- new_
characteristic new BluetoothGattCharacteristic(uuid, properties, permissions).- new_
descriptor new BluetoothGattDescriptor(uuid, permissions).- new_
service new BluetoothGattService(uuid, primary ? PRIMARY : SECONDARY).- open_
gatt_ server manager.openGattServer(context, callback).- permissions_
to_ android - Map the shared permission bits onto Android’s.
- read_
characteristic - read_
descriptor - read_
phy gatt.readPhy()— the answer arrives inonPhyRead.- read_
remote_ rssi - request_
connection_ priority BluetoothGatt.requestConnectionPriority(int).- request_
mtu - server_
add_ service - server_
clear_ services - server_
close - server_
connected_ devices - The centrals connected to the GATT server.
- server_
notify - Push a value to one subscriber.
- server_
remove_ service - server_
send_ response server.sendResponse(device, requestId, status, offset, value).- server_
socket_ accept - Block until a central connects, then return the accepted socket.
- server_
socket_ close - server_
socket_ psm - service_
add_ characteristic - service_
characteristics - service_
included_ services BluetoothGattService.getIncludedServices().- services
- set_
notify - Subscribe.
- set_
preferred_ phy device.connectGatt(context, false, callback, TRANSPORT_LE).- set_
value - socket_
close - socket_
connect - socket_
input_ stream - socket_
output_ stream - start_
advertising - Start advertising.
- start_
scan - Start a scan, filtering on service UUIDs where possible.
- stop_
advertising - stop_
scan - stream_
read - Read once from a
java.io.InputStream.Ok(None)at end of stream. - stream_
write - uuid
java.util.UUID.fromString.- uuid_
string - The canonical string of a
java.util.UUID, lowercase as the spec wants. - write_
characteristic - Write a characteristic, using whichever API this device has.
- write_
descriptor