首页 文章

AltBeacon忽略了我的信标包的pdu类型

提问于
浏览
1

我正在使用AltBeacon库来处理我的信标(由深圳市矿业科技有限公司提供) . 我使用以下

beaconManager.getBeaconParsers().add(new BeaconParser().
            setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"));

设置布局 . 在我的logcat中,我看到来自我的信标的RSSI值如:

06-21 01:50:27.091  13496-13507/com.example.tkobilov.minewtestapp D/BluetoothAdapter﹕ onScanResult() - Device=CD:A6:29:2F:08:26 RSSI=-73
06-21 01:50:27.503  13496-13508/com.example.tkobilov.minewtestapp D/BluetoothAdapter﹕ onScanResult() - Device=D3:EB:21:87:9D:7E RSSI=-58
06-21 01:50:27.508  13496-13582/com.example.tkobilov.minewtestapp D/BluetoothAdapter﹕ onScanResult() - Device=D3:EB:21:87:9D:7E RSSI=-59

然而在

protected Beacon fromScanData(byte[] bytesToProcess, int rssi, BluetoothDevice device, Beacon beacon) {

    BleAdvertisement advert = new BleAdvertisement(bytesToProcess);
    Pdu pduToParse = null;
    for (Pdu pdu: advert.getPdus()) {
        if (pdu.getType() == Pdu.GATT_SERVICE_UUID_PDU_TYPE ||
                pdu.getType() == Pdu.MANUFACTURER_DATA_PDU_TYPE) {
            pduToParse = pdu;
            if (LogManager.isVerboseLoggingEnabled()) {
                LogManager.d(TAG, "Processing pdu type %02X: %s with startIndex: %d, endIndex: %d", pdu.getType(), bytesToHex(bytesToProcess), pdu.getStartIndex(), pdu.getEndIndex());
            }
            break;
        }
        else {
            if (LogManager.isVerboseLoggingEnabled()) {
                LogManager.d(TAG, "Ignoring pdu type %02X", pdu.getType());
            }
        }

我每次都来“忽略pdu型......” . 我检查了bytesToProcess数组 . 每次它只有第一个和第二个非零值 . 其他值为零 . Minew推荐的BeaconCFG应用程序发现这些信标没有任何问题,但我需要AltBeacon用于我的项目 . 这可能是什么原因?

我的LogCat输出:

D / BluetoothDevice:mAddress:EE:74:8B:CA:DB:F1 D / BluetoothAdapter:onScanResult() - Device = EE:74:8B:CA:DB:F1 RSSI = -52 D / CycledLeScannerForJellyBeanMr2:得到记录D / BluetoothDevice:mAddress:EE:74:8B:CA:DB:F1 D / BeaconParser:忽略pdu类型01 D / BeaconParser:忽略pdu类型0A D / BeaconParser:没有要在此数据包中处理的PDU . D / BeaconParser:没有PDU在此数据包中处理 . D / BeaconParser:忽略pdu类型0A D / BeaconParser:忽略pdu类型01 D / BeaconParser:没有PDU在此数据包中处理 . D / BeaconParser:没有PDU在此数据包中处理 . D / BluetoothAdapter:onScanResult() - Device = ED:EE:AD:02:1B:30 RSSI = -62 D / CycledLeScannerForJellyBeanMr2:得到记录D / BluetoothDevice:mAddress:ED:EE:AD:02:1B:30 D / BluetoothAdapter:onScanResult() - Device = ED:EE:AD:02:1B:30 RSSI = -62 D / CycledLeScannerForJellyBeanMr2:得到记录D / BluetoothDevice:mAddress:ED:EE:AD:02:1B:30 D / BeaconParser:忽略pdu类型01 D / BeaconParser:没有PDU在此数据包中处理 . D / BeaconParser:忽略pdu类型01 D / BeaconParser:没有要在此数据包中处理的PDU . D / BeaconParser:忽略pdu类型0A D / BeaconParser:没有PDU在此数据包中处理 . D / BeaconParser:忽略pdu类型0A D / BeaconParser:没有PDU在此数据包中处理 . D / CycledLeScanner:等待停止扫描周期另外98毫秒D / CycledLeScanner:完成扫描周期D / BluetoothAdapter:isEnabled D / CycledLeScanner:停止蓝牙扫描D / BluetoothAdapter:stopLeScan()D / CycledLeScanner:开始新的扫描周期D / BluetoothAdapter:isEnabled D / CycledLeScanner:启动新的蓝牙文件扫描D / BluetoothAdapter:startLeScan():null D / BluetoothAdapter:onClientRegistered() - status = 0 clientIf = 1 D / CycledLeScanner:等待停止另一个1100的扫描周期毫秒

Content of my PDUs

D / CycledLeScanner:等待停止扫描周期另外1100毫秒D / CycledLeScanner:扫描开始D / BluetoothAdapter:onScanResult() - Device = EE:74:8B:CA:DB:F1 RSSI = -63 D / CycledLeScannerForJellyBeanMr2:got记录D /蓝牙设备:m地址:EE:74:8B:CA:DB:F1 D / BeaconParser:忽略pdu类型01 D / BeaconParser:此数据包中没有要处理的PDU - 02 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00今日00 00 00 00 00 00 00日00 00 00 00 00 00 00日00 00 00 00 00 00 00 00 00日00 00 00 00 00 00 00 00 00 00看到D / BeaconParser:忽略pdu类型01 D / BeaconParser:此包中没有要处理的PDU - 02 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00看到D / BluetoothAdapter:onScanResult() - Device = EE:74: 8B:CA:DB:F1 RSSI = -63

2 回答

  • 1

    从蓝牙LE信标中读取标识符有两种主要方式:

    • Android Beacon Library和类似的SDK通过查看蓝牙LE广告数据包来检测信标,而无需与信标设备 Build 蓝牙LE连接 - 这是检测应用中蓝牙信标的标准机制 .

    • iBeaconCFG等配置应用程序通常与设备 Build 蓝牙LE连接,以使用GATT读取和设置信标标识符和其他配置参数 . 该配置机制是非标准的,并且实际上在 Build 连接时停止信标发送 . 出于这个原因,这种检测信标的辅助手段不适合使用的应用程序 . 它仅对信标的初始配置有用 .

    根据问题和评论中报告的信息,似乎飞利浦v387 Android设备的蓝牙堆栈存在问题,无法使用第一种机制检测信标 . (它错误地报告它读取的广告包中包含全零 . )这意味着该设备将无法运行检测到的应用程序信标 . 据报道,它可以与配置应用程序配合使用,这意味着它可以成功 Build GATT连接以配置信标 .

    The Philips v387 Android device cannot be used to detect beacons in a general purpose app. It may, however, be used to configure beacons that are connectable using a GATT interface.

  • 0

    最后作为一种解决方法,我看到了一种方法来检查PDU并生成具有真实MAC,RSSI和信标名称的假信标对象(如果adv包错误) . 在这种情况下,我不能使用Major,Minor和TxPower,但可以使用RSSI和信标名称 .

相关问题