小编wla*_*and的帖子

使用bluez5读取蓝牙低能量信标的rssi

我想在2个蓝牙le usb适配器上同时读取蓝牙低能量信标的RSSI.我正在使用带有bluez 5的fedora 20系统和LogiLink BT0015适配器(CSR芯片).

当只连接一个适配器时,我的代码就像一个魅力,但在连接第二个适配器后,我收到输入/输出错误.

有人知道代码有什么问题吗?

还有其他方法可以读出RSSI吗?

#include <rssi.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>

#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
#include <bluetooth/hci_lib.h>

#include <time.h>
#include <unistd.h>

class Adapter {
    const char* bt_addr;
    int hci_deviceid;

    int hciSocket;
    uint16_t hciHandle;

    int l2capSock;
    struct sockaddr_l2 sockAddr;
    struct l2cap_conninfo l2capConnInfo;
    socklen_t l2capConnInfoLen;

    void init();

public:
    Adapter(int hci_deviceid, const char* bt_addr);
    Adapter(const char * bt_addr);

    int getHciDeviceId();
    int8_t read_rssi(int to);
};

Adapter::Adapter(int hci_deviceid, const char* bt_addr) {
    this->hci_deviceid = hci_deviceid;
    this->bt_addr = bt_addr;
    init();
} …
Run Code Online (Sandbox Code Playgroud)

c++ rssi bluetooth-lowenergy bluez

6
推荐指数
0
解决办法
2768
查看次数

标签 统计

bluetooth-lowenergy ×1

bluez ×1

c++ ×1

rssi ×1