public class BluetoothLeService
extends Service
| Modifier and Type | Class and Description |
|---|---|
class |
BluetoothLeService.LocalBinder
The LocalBinder implementation
|
| Modifier and Type | Field and Description |
|---|---|
static String |
ACTION_DATA_NOTIFY |
static String |
ACTION_DATA_READ |
static String |
ACTION_GATT_CONNECTED |
static String |
ACTION_GATT_DISCONNECTED |
static String |
ACTION_GATT_SERVICES_DISCOVERED |
static String |
EXTRA_DATA |
static String |
EXTRA_UUID |
| Constructor and Description |
|---|
BluetoothLeService() |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close a connection
|
boolean |
connect(String address)
Connect to a device with the address of the device
|
static BluetoothGatt |
getBtGatt()
Get the BluetoothGatt object
|
boolean |
initialize()
Initialize the blueooth le service Gets the bluetoothManager and the bluetoothAdapter
|
IBinder |
onBind(Intent intent)
Return the communication channel to the service
|
boolean |
onUnbind(Intent intent)
Called when all clients have disconnected
|
boolean |
setCharacteristicNotification(BluetoothGattCharacteristic characteristic,
boolean enable)
Set the notification of a characteristic on the device
|
boolean |
waitIdle(int timeout)
Wait a given time
|
boolean |
writeCharacteristic(BluetoothGattCharacteristic characteristic,
byte value)
Write a given byte to the characteristic on the device
|
public static final String ACTION_GATT_CONNECTED
public static final String ACTION_GATT_DISCONNECTED
public static final String ACTION_GATT_SERVICES_DISCOVERED
public static final String ACTION_DATA_NOTIFY
public static final String ACTION_DATA_READ
public static final String EXTRA_DATA
public static final String EXTRA_UUID
public IBinder onBind(Intent intent)
intent - to bindpublic boolean onUnbind(Intent intent)
intent - to unbindpublic boolean initialize()
public boolean connect(String address)
address - the adress of the devicepublic void close()
public boolean writeCharacteristic(BluetoothGattCharacteristic characteristic,
byte value)
characteristic - value - public boolean setCharacteristicNotification(BluetoothGattCharacteristic characteristic,
boolean enable)
characteristic - enable - public boolean waitIdle(int timeout)
timeout - the timeoutpublic static BluetoothGatt getBtGatt()