Package io.heraldprox.herald.sensor.ble
Class ConcreteBLEReceiver
- java.lang.Object
-
- android.bluetooth.BluetoothGattCallback
-
- io.heraldprox.herald.sensor.ble.ConcreteBLEReceiver
-
- All Implemented Interfaces:
BLEReceiver
,Sensor
public class ConcreteBLEReceiver extends android.bluetooth.BluetoothGattCallback implements BLEReceiver
-
-
Field Summary
-
Fields inherited from interface io.heraldprox.herald.sensor.ble.BLEReceiver
delegates
-
-
Constructor Summary
Constructors Constructor Description ConcreteBLEReceiver(android.content.Context context, BluetoothStateManager bluetoothStateManager, BLETimer timer, BLEDatabase database, BLETransmitter transmitter, PayloadDataSupplier payloadDataSupplier)
Receiver starts automatically when Bluetooth is enabled.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(SensorDelegate delegate)
boolean
immediateSend(Data data, TargetIdentifier targetIdentifier)
boolean
immediateSendAll(Data data)
void
onCharacteristicRead(android.bluetooth.BluetoothGatt gatt, android.bluetooth.BluetoothGattCharacteristic characteristic, int status)
void
onCharacteristicWrite(android.bluetooth.BluetoothGatt gatt, android.bluetooth.BluetoothGattCharacteristic characteristic, int status)
void
onConnectionStateChange(android.bluetooth.BluetoothGatt gatt, int status, int newState)
void
onMtuChanged(android.bluetooth.BluetoothGatt gatt, int mtu, int status)
void
onServicesDiscovered(android.bluetooth.BluetoothGatt gatt, int status)
void
start()
void
stop()
-
-
-
Constructor Detail
-
ConcreteBLEReceiver
public ConcreteBLEReceiver(@NonNull android.content.Context context, @NonNull BluetoothStateManager bluetoothStateManager, @NonNull BLETimer timer, @NonNull BLEDatabase database, @NonNull BLETransmitter transmitter, @NonNull PayloadDataSupplier payloadDataSupplier)
Receiver starts automatically when Bluetooth is enabled.- Parameters:
context
- The Herald execution environment ContextbluetoothStateManager
- To determine whether Bluetooth is enabledtimer
- Used to register a need for periodic events to occurdatabase
- BLE Device database to locate nearby device informationtransmitter
- The associated BLETransmitter instancepayloadDataSupplier
- Source of the payload to transmit
-
-
Method Detail
-
add
public void add(@NonNull SensorDelegate delegate)
-
immediateSend
public boolean immediateSend(@NonNull Data data, @NonNull TargetIdentifier targetIdentifier)
- Specified by:
immediateSend
in interfaceBLEReceiver
-
immediateSendAll
public boolean immediateSendAll(@NonNull Data data)
- Specified by:
immediateSendAll
in interfaceBLEReceiver
-
onConnectionStateChange
public void onConnectionStateChange(@NonNull android.bluetooth.BluetoothGatt gatt, int status, int newState)
- Overrides:
onConnectionStateChange
in classandroid.bluetooth.BluetoothGattCallback
-
onServicesDiscovered
public void onServicesDiscovered(@NonNull android.bluetooth.BluetoothGatt gatt, int status)
- Overrides:
onServicesDiscovered
in classandroid.bluetooth.BluetoothGattCallback
-
onMtuChanged
public void onMtuChanged(@NonNull android.bluetooth.BluetoothGatt gatt, int mtu, int status)
- Overrides:
onMtuChanged
in classandroid.bluetooth.BluetoothGattCallback
-
onCharacteristicRead
public void onCharacteristicRead(@NonNull android.bluetooth.BluetoothGatt gatt, @NonNull android.bluetooth.BluetoothGattCharacteristic characteristic, int status)
- Overrides:
onCharacteristicRead
in classandroid.bluetooth.BluetoothGattCallback
-
onCharacteristicWrite
public void onCharacteristicWrite(@NonNull android.bluetooth.BluetoothGatt gatt, @NonNull android.bluetooth.BluetoothGattCharacteristic characteristic, int status)
- Overrides:
onCharacteristicWrite
in classandroid.bluetooth.BluetoothGattCallback
-
-