Skip to main content

Module ble

Module ble 

Source
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_SUCCESS and 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
AdvertiseSettings mode 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_BONDING or BOND_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, applying f to 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 in onPhyRead.
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