Class HelperBlePeripheral
java.lang.Object
com.codename1.bluetooth.BluetoothDevice
com.codename1.bluetooth.le.BlePeripheral
com.codename1.bluetooth.helper.HelperBlePeripheral
Real-radio BlePeripheral bridging the core GATT client contract
onto cn1-ble-helper commands. One canonical instance exists per
address (cached by HelperBleBackend), so discovered
GattCharacteristic objects stay identical across the
scan/connect/notify lifecycle.
btleplug constraints surface here: no bonding
(doCreateBond(AsyncResource)), no L2CAP (doOpenL2cap(int, boolean, AsyncResource)), no MTU
negotiation (doRequestMtu(int, AsyncResource) resolves with the current value), no
connection-priority hints, and RSSI reads answer with the last
advertisement sighting.
-
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoConnect(ConnectionOptions options, AsyncResource<BlePeripheral> out) Establishes the platform connection and completes/failsout.protected voiddoCreateBond(AsyncResource<Boolean> out) Initiates bonding and completesoutwhen the bond state settles.protected voidTears down the platform connection;BlePeripheral.fireConnectionStateChanged(ConnectionState, BluetoothException)reports the resultingDISCONNECTEDtransition.protected voidPerforms service discovery and completesoutwith the discoveredGattServicelist (constructed via the public gatt-package constructors).protected voiddoOpenL2cap(int psm, boolean secure, AsyncResource<L2capChannel> out) Opens an L2CAP channel and completesoutwith it.protected voiddoReadCharacteristic(GattCharacteristic c, AsyncResource<byte[]> out) Reads a characteristic and completesoutwith its value.protected voiddoReadDescriptor(GattDescriptor d, AsyncResource<byte[]> out) Reads a descriptor and completesoutwith its value.protected voiddoReadRssi(AsyncResource<Integer> out) Reads the connection RSSI and completesout.protected voiddoRequestConnectionPriority(ConnectionPriority priority, AsyncResource<Boolean> out) Requests a connection-interval preference and completesout.protected voiddoRequestMtu(int mtu, AsyncResource<Integer> out) Requests an MTU and completesoutwith the granted value.protected voiddoSetNotifications(GattCharacteristic c, boolean enable, boolean indication, AsyncResource<Boolean> out) Arms or disarms notifications/indications (including the CCCD write) and completesoutonce done.protected voiddoWriteCharacteristic(GattCharacteristic c, byte[] value, boolean withResponse, AsyncResource<Boolean> out) Writes a characteristic and completesoutonce acknowledged (withResponse) or queued to the controller.protected voiddoWriteDescriptor(GattDescriptor d, byte[] value, AsyncResource<Boolean> out) Writes a descriptor and completesoutonce acknowledged.A stable identifier for this device: the MAC address on Android and the desktop ports (AA:BB:CC:DD:EE:FF), but the per-app CoreBluetooth identifier UUID string on iOS.The current pairing state of this device; defaults toBondState.NONE.getName()The advertised or cached device name; may benullwhen the device never advertised one.getType()The transport family of this device; defaults toDeviceType.UNKNOWN.static intpropertiesMask(List<Object> names) Maps the wire property names onto the GattCharacteristic bits.Methods inherited from class BlePeripheral
addConnectionListener, connect, connect, createBond, disconnect, discoverServices, fireConnectionStateChanged, fireNotification, fireServicesInvalidated, getCharacteristic, getConnectionState, getMtu, getService, getServices, isSubscribed, openL2capChannel, readCharacteristic, readDescriptor, readRssi, removeConnectionListener, requestConnectionPriority, requestMtu, setMtu, setOperationTimeout, subscribe, unsubscribe, writeCharacteristic, writeDescriptorMethods inherited from class BluetoothDevice
equals, hashCode, toString
-
Method Details
-
getAddress
Description copied from class:BluetoothDeviceA stable identifier for this device: the MAC address on Android and the desktop ports (AA:BB:CC:DD:EE:FF), but the per-app CoreBluetooth identifier UUID string on iOS. The value is stable for this app on this device and safe to persist for reconnection on the same install, but it is NOT portable across phones or platforms -- never treat it as the peripheral's real hardware address.- Specified by:
getAddressin classBluetoothDevice
-
getName
Description copied from class:BluetoothDeviceThe advertised or cached device name; may benullwhen the device never advertised one.- Specified by:
getNamein classBluetoothDevice
-
getType
Description copied from class:BluetoothDeviceThe transport family of this device; defaults toDeviceType.UNKNOWN.- Overrides:
getTypein classBluetoothDevice
-
getBondState
Description copied from class:BluetoothDeviceThe current pairing state of this device; defaults toBondState.NONE. iOS manages bonds internally and usually reportsBondState.NONE-- seeBondState.- Overrides:
getBondStatein classBluetoothDevice
-
doConnect
Description copied from class:BlePeripheralEstablishes the platform connection and completes/failsout.- Specified by:
doConnectin classBlePeripheral
-
doDisconnect
protected void doDisconnect()Description copied from class:BlePeripheralTears down the platform connection;BlePeripheral.fireConnectionStateChanged(ConnectionState, BluetoothException)reports the resultingDISCONNECTEDtransition.- Specified by:
doDisconnectin classBlePeripheral
-
doDiscoverServices
Description copied from class:BlePeripheralPerforms service discovery and completesoutwith the discoveredGattServicelist (constructed via the public gatt-package constructors).- Specified by:
doDiscoverServicesin classBlePeripheral
-
propertiesMask
-
doReadCharacteristic
Description copied from class:BlePeripheralReads a characteristic and completesoutwith its value.- Specified by:
doReadCharacteristicin classBlePeripheral
-
doWriteCharacteristic
protected void doWriteCharacteristic(GattCharacteristic c, byte[] value, boolean withResponse, AsyncResource<Boolean> out) Description copied from class:BlePeripheralWrites a characteristic and completesoutonce acknowledged (withResponse) or queued to the controller.- Specified by:
doWriteCharacteristicin classBlePeripheral
-
doReadDescriptor
Description copied from class:BlePeripheralReads a descriptor and completesoutwith its value.- Specified by:
doReadDescriptorin classBlePeripheral
-
doWriteDescriptor
Description copied from class:BlePeripheralWrites a descriptor and completesoutonce acknowledged.- Specified by:
doWriteDescriptorin classBlePeripheral
-
doSetNotifications
protected void doSetNotifications(GattCharacteristic c, boolean enable, boolean indication, AsyncResource<Boolean> out) Description copied from class:BlePeripheralArms or disarms notifications/indications (including the CCCD write) and completesoutonce done.- Specified by:
doSetNotificationsin classBlePeripheral
-
doReadRssi
Description copied from class:BlePeripheralReads the connection RSSI and completesout.- Specified by:
doReadRssiin classBlePeripheral
-
doRequestMtu
Description copied from class:BlePeripheralRequests an MTU and completesoutwith the granted value.- Specified by:
doRequestMtuin classBlePeripheral
-
doRequestConnectionPriority
Description copied from class:BlePeripheralRequests a connection-interval preference and completesout.- Specified by:
doRequestConnectionPriorityin classBlePeripheral
-
doCreateBond
Description copied from class:BlePeripheralInitiates bonding and completesoutwhen the bond state settles.- Specified by:
doCreateBondin classBlePeripheral
-
doOpenL2cap
Description copied from class:BlePeripheralOpens an L2CAP channel and completesoutwith it. Called directly (not through the operation queue).- Specified by:
doOpenL2capin classBlePeripheral
-