ProvisionManager

ProvisionManager is a utility class that manages the Bluetooth provisioning process.

This class provides a set of functions to handle various Bluetooth operations, such as initializing the Bluetooth connection, scanning for devices, connecting to devices, retrieving device information, configuring Wi-Fi settings, and sending upgrade information to Bluetooth devices. It is designed to streamline the provisioning process for Bluetooth Low Energy (BLE) devices, including sensor configuration, Wi-Fi setup, and software upgrades.

Key features of this class include:

  • Initializing Bluetooth and managing connection state

  • Scanning for Bluetooth devices and filtering by device name or prefix

  • Connecting to, disconnecting from, and managing Bluetooth device states

  • Retrieving information from Bluetooth devices such as Wi-Fi networks, sensor state, and sensor info

  • Sending Wi-Fi configuration and upgrade information to devices

  • Handling device configuration completion notifications

  • Managing Bluetooth scan operations and cleanup

Functions

Link copied to clipboard
fun addConnectStateCallback(lifecycleOwner: LifecycleOwner, connectCallback: ConnectStateCallback)

Adds a connection state callback

Link copied to clipboard
fun connectDevice(lifecycleOwner: LifecycleOwner, device: BleDevice?, duration: Long = 5000, connectCallback: ConnectStateCallback)

Connects to a Bluetooth device

Link copied to clipboard

Disconnects the Bluetooth device

Link copied to clipboard
fun getSensorInfoFromDevice(owner: LifecycleOwner, device: BleDevice?, infoCallback: SensorInfoCallback)

Retrieves the sensor information from a Bluetooth device

Link copied to clipboard
fun getSensorStateFromDevice(owner: LifecycleOwner, device: BleDevice?, stateCallback: SensorStateCallback)

Retrieves the sensor state from a Bluetooth device

Link copied to clipboard
fun getUpgradeStateFromDevice(lifecycleOwner: LifecycleOwner, device: BleDevice?, updateInfoCallback: UpdateInfoCallback)

Retrieves the upgrade state from a Bluetooth device

Link copied to clipboard
fun getWifiListFromDevice(owner: LifecycleOwner, device: BleDevice?, wifiListCallback: WiFiListCallback)

Retrieves the Wi-Fi list from a Bluetooth device

Link copied to clipboard
fun init(application: Application, enableLog: Boolean = false, bluetoothStateChangeListener: BluetoothStateChangeListener? = null)

Initializes Bluetooth connection settings

Link copied to clipboard
fun scanPSDevices(context: <Error class: unknown class>, prefix: String? = "", duration: Long = 5000, exactMatch: Boolean? = true, scanCallback: BleScanCallback)

Scans for Bluetooth devices with a specified prefix

Link copied to clipboard
fun sendCompleteInfoToDevice(owner: LifecycleOwner, device: BleDevice?, configFinishCallback: ConfigFinishCallback)

Sends complete configuration information to a Bluetooth device

Link copied to clipboard
fun sendUpgradeInfoToDevice(owner: LifecycleOwner, device: BleDevice?, model: String?, version: String?, url: String?, stateCallback: SensorStateCallback)

Sends upgrade information to a Bluetooth device

Link copied to clipboard
fun sendWiFiConfigToDevice(owner: LifecycleOwner, device: BleDevice?, orgId: String, certPem: String, publicKey: String, privateKey: String, host: String, wifiName: String, password: String, target: Int?, stateCallback: SensorStateCallback)

Sends Wi-Fi configuration to a Bluetooth device

Link copied to clipboard
fun stopScan()

Stops the Bluetooth device scan

Link copied to clipboard
fun stopSensorUpgrade(lifecycleOwner: LifecycleOwner, bleDevice: BleDevice?, callback: StopUpgradeCallback)

Stops the sensor firmware upgrade process for the specified BLE device.

Link copied to clipboard

Unregisters the Bluetooth receiver