feat: add BleRelayManager class skeleton
This commit is contained in:
parent
61c5c1de32
commit
f41f1c3380
1 changed files with 45 additions and 0 deletions
|
|
@ -0,0 +1,45 @@
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
package com.eddy.atomrelay
|
||||||
|
|
||||||
|
import android.bluetooth.BluetoothGatt
|
||||||
|
import android.bluetooth.BluetoothGattCharacteristic
|
||||||
|
import android.content.Context
|
||||||
|
import android.os.Handler
|
||||||
|
import android.os.Looper
|
||||||
|
import java.util.UUID
|
||||||
|
|
||||||
|
class BleRelayManager(
|
||||||
|
private val context: Context,
|
||||||
|
private val callbacks: BleCallbacks
|
||||||
|
) {
|
||||||
|
companion object {
|
||||||
|
private val SERVICE_UUID: UUID = UUID.fromString("4fafc201-1fb5-459e-8fcc-c5c9c331914b")
|
||||||
|
private val CHARACTERISTIC_UUID: UUID = UUID.fromString("beb5483e-36e1-4688-b7f5-ea07361f26d8")
|
||||||
|
private val UUID_CHAR_UUID: UUID = UUID.fromString("beb5483e-36e1-4688-b7f5-ea07361f26d9")
|
||||||
|
private val CCCD_UUID: UUID = UUID.fromString("00002902-0000-1000-8000-00805f9b34fb")
|
||||||
|
private const val SCAN_TIMEOUT_MS = 30000L
|
||||||
|
private const val RECONNECT_DELAY_MS = 2000L
|
||||||
|
private const val MAX_SCAN_RETRIES = 3
|
||||||
|
}
|
||||||
|
|
||||||
|
private var bluetoothGatt: BluetoothGatt? = null
|
||||||
|
private var relayCharacteristic: BluetoothGattCharacteristic? = null
|
||||||
|
private var isScanning = false
|
||||||
|
private var scanTimedOut = false
|
||||||
|
private var scanTimeoutRetries = 0
|
||||||
|
private val handler = Handler(Looper.getMainLooper())
|
||||||
|
private var seq = 1
|
||||||
|
private var hmacKey: ByteArray? = null
|
||||||
|
private var deviceUuid: ByteArray? = null
|
||||||
|
private var triedAddresses = mutableSetOf<String>()
|
||||||
|
|
||||||
|
fun startScan() {}
|
||||||
|
fun stopScan() {}
|
||||||
|
fun sendRelayCommand(cmd: Byte) {}
|
||||||
|
fun disconnect() {}
|
||||||
|
fun updateKeys() {}
|
||||||
|
fun resetTriedAddresses() {}
|
||||||
|
fun hasPermissions(): Boolean = false
|
||||||
|
fun getRequiredPermissions(): Array<String> = emptyArray()
|
||||||
|
fun destroy() {}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue