ZTBleManager

object ZTBleManager

This class is responsible for getting BLE device through a given MAC address or QRCode data. The class ensures that there is only one active device, as the SDK does handle only one active connection at a time for now. BLE scanning is done through this class. You can also listen for general BLE events.

Author

Alexandre Lemoult <a.lemoult@zhortech.com>

Functions

connectToDevice
Link copied to clipboard
fun connectToDevice(device: ZTDevice): Single<ZTDevice>
Connect to provided ZTDevice.
getBleDeviceWithCode
Link copied to clipboard
fun getBleDeviceWithCode(code: String): Single<ZTDevice>
Get a BLE device with ZT QRCode data.
getConnectedDevices
Link copied to clipboard
fun getConnectedDevices(): Observable<ZTDevice>
Get currently connected ZT BLE devices
getProduct
Link copied to clipboard
fun getProduct(): ZTBaseProduct
Returns the registered user product.
invoke
Link copied to clipboard
operator fun invoke(context: Context, product: ZTBaseProduct): ZTBleManager
Returns instance of ZTBleManager using application context.
reconnectLastDevice
Link copied to clipboard
fun reconnectLastDevice(): Single<ZTDevice>
Attempt to reconnect to last connected device
scanForDevices
Link copied to clipboard
fun scanForDevices(duration: Long? = null, timeUnit: TimeUnit? = null): Observable<ZTScanRecord>
Scan for all BLE devices.
scanForProduct
Link copied to clipboard
fun scanForProduct(productType: ZTProductType, duration: Long? = null, timeUnit: TimeUnit? = null): Observable<ZTScanRecord>
Scan for a specific BLE product.

Properties

onBluetoothStateChange
Link copied to clipboard
lateinit var onBluetoothStateChange: ZTSignalBluetoothStateChange
Observable to handles Bluetooth adapter state changes