Как получить фактические значения с устройства BLE в Android? - PullRequest
0 голосов
/ 11 сентября 2018

Я не могу получить значения ( Систолическое, Диастолическое и Пульсное от аппарата для измерения артериального давления ) после получения всех характеристик Службы артериального давления (uuid: 00002a35-0000-1000 -8000-00805f9b34fb) а также я не понимаю всех этих характеристик и дескрипторов. Так что, пожалуйста, кто-нибудь, помогите мне с этой проблемой в устройстве BLE.

Ответы [ 2 ]

0 голосов
/ 12 сентября 2018

Попробуйте проанализировать Scan Record, там вы можете найти некоторую информацию

Kotlin Code

    enum class EBLE {

    EBLE_ZERO, // Zero element
    EBLE_FLAGS, //«Flags»   Bluetooth Core Specification:
    EBLE_16BitUUIDInc, //«Incomplete List of 16-bit Service Class UUIDs»    Bluetooth Core Specification:
    EBLE_16BitUUIDCom, //«Complete List of 16-bit Service Class UUIDs»  Bluetooth Core Specification:
    EBLE_32BitUUIDInc,//«Incomplete List of 32-bit Service Class UUIDs» Bluetooth Core Specification:
    EBLE_32BitUUIDCom,//«Complete List of 32-bit Service Class UUIDs»   Bluetooth Core Specification:
    EBLE_128BitUUIDInc,//«Incomplete List of 128-bit Service Class UUIDs»   Bluetooth Core Specification:
    EBLE_128BitUUIDCom,//«Complete List of 128-bit Service Class UUIDs» Bluetooth Core Specification:
    EBLE_SHORTNAME,//«Shortened Local Name» Bluetooth Core Specification:
    EBLE_LOCALNAME,//«Complete Local Name»  Bluetooth Core Specification:
    EBLE_TXPOWERLEVEL,//«Tx Power Level»    Bluetooth Core Specification:
    EBLE_DEVICECLASS,//«Class of Device»    Bluetooth Core Specification:
    EBLE_SIMPLEPAIRHASH,//«Simple Pairing Hash C»   Bluetooth Core Specification:​«Simple Pairing Hash C-192»   ​Core Specification Supplement, Part A, section 1.6
    EBLE_SIMPLEPAIRRAND,//«Simple Pairing Randomizer R» Bluetooth Core Specification:​«Simple Pairing Randomizer R-192» ​Core Specification Supplement, Part A, section 1.6
    EBLE_DEVICEID,//«Device ID» Device ID Profile v1.3 or later,«Security Manager TK Value» Bluetooth Core Specification:
    EBLE_SECURITYMANAGER,//«Security Manager Out of Band Flags» Bluetooth Core Specification:
    EBLE_SLAVEINTERVALRA,//«Slave Connection Interval Range»    Bluetooth Core Specification:
    EBLE_16BitSSUUID,//«List of 16-bit Service Solicitation UUIDs»  Bluetooth Core Specification:
    EBLE_128BitSSUUID, //«List of 128-bit Service Solicitation UUIDs»   Bluetooth Core Specification:
    EBLE_SERVICEDATA,//«Service Data»   Bluetooth Core Specification:​«Service Data - 16-bit UUID»  ​Core Specification Supplement, Part A, section 1.11
    EBLE_PTADDRESS,//«Public Target Address»    Bluetooth Core Specification:
    EBLE_RTADDRESS,//«Random Target Address»    Bluetooth Core Specification:
    EBLE_APPEARANCE,//«Appearance»  Bluetooth Core Specification:
    EBLE_DEVADDRESS,//«​LE Bluetooth Device Address»    ​Core Specification Supplement, Part A, section 1.16
    EBLE_LEROLE,//«​LE Role»    ​Core Specification Supplement, Part A, section 1.17
    EBLE_PAIRINGHASH,//«​Simple Pairing Hash C-256» ​Core Specification Supplement, Part A, section 1.6
    EBLE_PAIRINGRAND,//«​Simple Pairing Randomizer R-256»   ​Core Specification Supplement, Part A, section 1.6
    EBLE_32BitSSUUID,//​«List of 32-bit Service Solicitation UUIDs» ​Core Specification Supplement, Part A, section 1.10
    EBLE_32BitSERDATA,//​«Service Data - 32-bit UUID»   ​Core Specification Supplement, Part A, section 1.11
    EBLE_128BitSERDATA,//​«Service Data - 128-bit UUID» ​Core Specification Supplement, Part A, section 1.11
    EBLE_SECCONCONF,//​«​LE Secure Connections Confirmation Value»  ​Core Specification Supplement Part A, Section 1.6
    EBLE_SECCONRAND,//​​«​LE Secure Connections Random Value»   ​Core Specification Supplement Part A, Section 1.6​
    EBLE_3DINFDATA, //​​«3D Information Data»   ​3D Synchronization Profile, v1.0 or later
    EBLE_MANDATA; //«Manufacturer Specific Data»    Bluetooth Core Specification:

    companion object {
        private val map = EBLE.values()
        fun fromInt(type: Int) = if (type > 0) map[type] else EBLE_MANDATA

        fun getDistance(rssi: Int, txPower: Int) = {
            /*
             * RSSI = TxPower - 10 * n * lg(d)
             * n = 2 (in free space)
             *
             * d = 10 ^ ((TxPower - RSSI) / (10 * n))
            */

             Math.pow(10.0, (txPower.toDouble() - rssi) / (10 * 2))
        }
        /*
     BLE Scan record parsing
    */
    fun ParseRecord(scanRecord: ByteArray): Map<EBLE, ByteArray> {
        val ret = HashMap<EBLE, ByteArray>()
        var index = 0
        while (index < scanRecord.size) {
            val length = scanRecord[index++].toInt()
            //Zero value indicates that we are done with the record now
            if (length == 0) break

            val type = scanRecord[index].toInt()
            //if the type is zero, then we are pass the significant section of the data,
            // and we are thud done
            if (type == 0) break

            Arrays.copyOfRange(scanRecord, index + 1, index + length)?.let {
                ret[EBLE.fromInt(type)] = it //HexUtil.formatHexString(it)
            }

            index += length
        }

        return ret
    }
    }
}
0 голосов
/ 11 сентября 2018

Вы задали слишком общий вопрос. Может быть, вам нужно понять поток Android BLE по этой ссылке.

См. Этот урок на BLE

База данных GATT реализует один или несколько profiles(Heart Rate, Audio etc), и каждый профиль состоит из одного или нескольких services, а каждая служба состоит из одного или нескольких characteristics.

Просто, чтобы дать вам представление, characteristics - это свойства, в которых вы определяете, какое из них вы хотите использовать для чтения или записи.

descriptors - это объект, для которого вы записываете данные для включения / отправки данных.

UUID то, что вы используете для отправки и получения данных, должно быть одинаковым для клиента и сервера.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...