Skip to content

Commit 953f973

Browse files
author
Paolo Calao
authored
Merge pull request arduino-libraries#148 from Polldo/fix-find-info-resp
Fix find info resp when called on non-descriptor attributes
2 parents 840501e + de759d4 commit 953f973

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/local/BLELocalAttribute.h

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
#include "utility/BLEUuid.h"
2424

25+
#define BLE_ATTRIBUTE_TYPE_SIZE 2
26+
2527
enum BLEAttributeType {
2628
BLETypeUnknown = 0x0000,
2729

src/utility/ATT.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,8 @@ void ATTClass::findInfoReq(uint16_t connectionHandle, uint16_t mtu, uint8_t dlen
683683
BLELocalAttribute* attribute = GATT.attribute(i);
684684
uint16_t handle = (i + 1);
685685
bool isValueHandle = (attribute->type() == BLETypeCharacteristic) && (((BLELocalCharacteristic*)attribute)->valueHandle() == handle);
686-
int uuidLen = isValueHandle ? 2 : attribute->uuidLength();
686+
bool isDescriptor = attribute->type() == BLETypeDescriptor;
687+
int uuidLen = (isValueHandle || isDescriptor) ? attribute->uuidLength() : BLE_ATTRIBUTE_TYPE_SIZE;
687688
int infoType = (uuidLen == 2) ? 0x01 : 0x02;
688689

689690
if (response[1] == 0) {
@@ -699,7 +700,7 @@ void ATTClass::findInfoReq(uint16_t connectionHandle, uint16_t mtu, uint8_t dlen
699700
memcpy(&response[responseLength], &handle, sizeof(handle));
700701
responseLength += sizeof(handle);
701702

702-
if (isValueHandle || attribute->type() == BLETypeDescriptor) {
703+
if (isValueHandle || isDescriptor) {
703704
// add the UUID
704705
memcpy(&response[responseLength], attribute->uuidData(), uuidLen);
705706
responseLength += uuidLen;

0 commit comments

Comments
 (0)