package com.xty.common.bracelet

import android.bluetooth.BluetoothAdapter
import android.bluetooth.BluetoothDevice
import android.bluetooth.le.ScanCallback
import android.bluetooth.le.ScanResult
import com.hjq.toast.ToastUtils
import com.xty.common.LogUtils

class MyLeScanCallback(var result: (deviceName: String, macAddress: String) -> Unit) :
    BluetoothAdapter.LeScanCallback {

    override fun onLeScan(device: BluetoothDevice?, rssi: Int, scanRecord: ByteArray?) {
        device?.apply {
            if (name.isNullOrEmpty() || address.isNullOrEmpty()) {
                return
            }
            LogUtils.d("deviceName:$name;address:$address;rssi:$rssi;bondState:$bondState;type:$type")
            result.invoke(name, address)
        }
    }
}
