Seeed-Studio / Seeed_Arduino_rpcBLE

A library of maximum ESP32 BLE-compatible software.
MIT License
10 stars 6 forks source link

BLE Client does not correctly construct BLEUUID for Services #5

Open bkeller2 opened 3 years ago

bkeller2 commented 3 years ago

Describe the bug BLEUUID constructor defined on line 65 ( shown below) does not properly construct the BLEUUID class.

BLEUUID::BLEUUID(uint8_t* data, uint8_t length) {
    if ((length == 2) || (length == 4) || (length == 16)) {
        _length = length;
        uint8_t i = 0;
        for (i = 0; i < _length; i++) {
            _dataNative[i] = data[i];
            _data[i] = data[(_length - 1 - i)];
        }
    }
}

It never sets the m_valueSet which means it will not print out using the BLEUUID::toString() method. In addition, it never updates m_uuid which is what is primarily used in the class. This constructor is almost exclusively used at least when using the device as a client. For example, this constructor is being used by BLEAdvertisedDevice on lines 293:294, lines 307:308, and 319:320. In the BLEAdvertisedDevice::parseAdvertisement method, a pointer to a buffer is being passed to this constructor. Therefore, the BLEUUID is never properly constructed and because the buffer is deallocated when leaving BLEAdvertisedDevice::parseAdvertisement finishes.

To Reproduce The BLE_Client.ino will illustrate it by printing out nullptr for any server that has a service.

Pillar1989 commented 3 years ago

Please help him

------------------ 原始邮件 ------------------ 发件人: "Seeed-Studio/Seeed_Arduino_rpcBLE" @.>; 发送时间: 2021年3月31日(星期三) 上午8:07 @.>; @.***>; 主题: [Seeed-Studio/Seeed_Arduino_rpcBLE] BLE Client does not correctly construct BLEUUID for Services (#5)

Describe the bug BLEUUID constructor defined on line 65 ( shown below) does not properly construct the BLEUUID class. BLEUUID::BLEUUID(uint8_t* data, uint8_t length) { if ((length == 2) || (length == 4) || (length == 16)) { _length = length; uint8_t i = 0; for (i = 0; i < _length; i++) { _dataNative[i] = data[i]; _data[i] = data[(_length - 1 - i)]; } } }
It never sets the m_valueSet which means it will not print out using the BLEUUID::toString() method. In addition, it never updates m_uuid which is what is primarily used in the class. This constructor is almost exclusively used at least when using the device as a client. For example, this constructor is being used by BLEAdvertisedDevice on lines 293:294, lines 307:308, and 319:320. In the BLEAdvertisedDevice::parseAdvertisement method, a pointer to a buffer is being passed to this constructor and the UUID is never properly constructed, because the pointers get stored and the memory is deallocated when leaving BLEAdvertisedDevice::parseAdvertisement.

To Reproduce The (BLE_Client.ino)[https://github.com/Seeed-Studio/Seeed_Arduino_rpcBLE/tree/master/examples/BLE_client] will illustrate it by printing out nullptr for any server that has a service.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

Chunchun-tian commented 3 years ago

Don't use the ble client for the time being. If there is a problem, the server can still use it

kelchm commented 3 years ago

Don't use the ble client for the time being. If there is a problem, the server can still use it

@tyihuang -- what would you suggest as the alternative at this point? I ran into this issue along with a few others when trying to use a Wio Terminal to read BLE advertisements from various thermometer/hygrometer devices.

Are there any plans to address this bug and in general bring the functionality of BLEAdvertisedDevice up to parity with being able to retrieve service data, etc?

freebsdgirl commented 2 years ago

Are there any plans to address this issue? I ran into the same problem. I'd contribute a patch, but it's a bit beyond what I usually work on >.<