如何在扫描时读取Android中的蓝牙LE广告数据 [英] How can I read the Bluetooth LE advertisement data in Android at the time of scanning

查看:26
本文介绍了如何在扫描时读取Android中的蓝牙LE广告数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

蓝牙 LE 设备可以向其他设备广播消息.该消息包可以包含诸如长度、配置文件、RSSI(信号强度)等信息.

Bluetooth LE devices can broadcast messages to other devices. That message packet can include informations like length, profile, rssi (signal strength), etc.

在 Android 中扫描 BLE 设备时如何读取那些低功耗蓝牙广播数据?

How can I read those Bluetooth LE broadcast data when scanning for BLE devices in Android?

推荐答案

API Levels 21+

android.bluetooth.le.ScanCallback中,如下回调方法有一个名为result的参数,它有一个名为scanRecord的字段, with 应该包含 BLE 设备发送的广告数据.

In android.bluetooth.le.ScanCallback, the callback method as follows has a parameter named result, which has a field called scanRecord, with should contain the advertisement data sent by a BLE device.

void onScanResult (int callbackType, ScanResult result)

API 级别 18-20

BluetoothAdapter.LeScanCallback中,回调方法有一个名为scanRecord的参数,里面应该包含BLE设备发送的广告数据.

In BluetoothAdapter.LeScanCallback, the callback method as follows has a parameter named scanRecord, which should contain the advertisement data sent by a BLE device.

public abstract void onLeScan (BluetoothDevice device, int rssi, byte[] scanRecord)

scanRecord:远程设备提供的广告记录的内容.

scanRecord: The content of the advertisement record offered by the remote device.

这篇关于如何在扫描时读取Android中的蓝牙LE广告数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆