Skip to content

Commit ec83c8a

Browse files
committed
Align to ArduinoBLE master
2 parents 73a4e1a + 524b3a6 commit ec83c8a

File tree

6 files changed

+20
-18
lines changed

6 files changed

+20
-18
lines changed

examples/Central/Scan/Scan.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Scan
33
44
This example scans for BLE peripherals and prints out their advertising details:
5-
address, local name, adverised service UUID's.
5+
address, local name, advertised service UUID's.
66
77
The circuit:
88
- STEVAL-MKSBOX1V1, B-L475E-IOT01A1, or a Nucleo board plus the X-NUCLEO-IDB05A1 or the X-NUCLEO-BNRG2A1

examples/Central/ScanCallback/ScanCallback.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Scan Callback
33
44
This example scans for BLE peripherals and prints out their advertising details:
5-
address, local name, adverised service UUIDs. Unlike the Scan example, it uses
5+
address, local name, advertised service UUIDs. Unlike the Scan example, it uses
66
the callback style APIs and disables filtering so the peripheral discovery is
77
reported for every single advertisement it makes.
88

library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=STM32duinoBLE
2-
version=1.2.0
2+
version=1.2.1
33
author=Arduino, SRA
44
maintainer=stm32duino
55
sentence=Fork of ArduinoBLE library to add the support of SPBTLE-RF and SPBTLE-1S BLE modules.

src/utility/ATT.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ void ATTClass::findByTypeReq(uint16_t connectionHandle, uint16_t mtu, uint8_t dl
756756
} *findByTypeReq = (FindByTypeReq*)data;
757757

758758
if (dlen < sizeof(FindByTypeReq)) {
759-
sendError(connectionHandle, ATT_OP_FIND_BY_TYPE_RESP, findByTypeReq->startHandle, ATT_ECODE_INVALID_PDU);
759+
sendError(connectionHandle, ATT_OP_FIND_BY_TYPE_REQ, findByTypeReq->startHandle, ATT_ECODE_INVALID_PDU);
760760
return;
761761
}
762762

@@ -794,7 +794,7 @@ void ATTClass::findByTypeReq(uint16_t connectionHandle, uint16_t mtu, uint8_t dl
794794
}
795795

796796
if (responseLength == 1) {
797-
sendError(connectionHandle, ATT_OP_FIND_BY_TYPE_RESP, findByTypeReq->startHandle, ATT_ECODE_ATTR_NOT_FOUND);
797+
sendError(connectionHandle, ATT_OP_FIND_BY_TYPE_REQ, findByTypeReq->startHandle, ATT_ECODE_ATTR_NOT_FOUND);
798798
} else {
799799
HCI.sendAclPkt(connectionHandle, ATT_CID, responseLength, response);
800800
}
@@ -1561,7 +1561,7 @@ bool ATTClass::discoverDescriptors(uint16_t connectionHandle, BLERemoteDevice* d
15611561

15621562
for (int j = 0; j < characteristicCount; j++) {
15631563
BLERemoteCharacteristic* characteristic = service->characteristic(j);
1564-
BLERemoteCharacteristic* nextCharacteristic = (j == (characteristicCount - 1)) ? NULL : service->characteristic(j);
1564+
BLERemoteCharacteristic* nextCharacteristic = (j == (characteristicCount - 1)) ? NULL : service->characteristic(j + 1);
15651565

15661566
reqStartHandle = characteristic->valueHandle() + 1;
15671567
reqEndHandle = nextCharacteristic ? nextCharacteristic->valueHandle() : serviceEndHandle;

src/utility/ATT.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626

2727
#define ATT_CID 0x0004
2828

29-
#ifdef DM_CONN_MAX
29+
#if defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7)
30+
#define ATT_MAX_PEERS 7
31+
#elif DM_CONN_MAX
3032
#define ATT_MAX_PEERS DM_CONN_MAX // Mbed + Cordio
3133
#else
3234
#define ATT_MAX_PEERS 3

src/utility/GAP.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void GAPClass::setManufacturerData(const uint8_t manufacturerData[], int manufac
5656

5757
void GAPClass::setManufacturerData(const uint16_t companyId, const uint8_t manufacturerData[], int manufacturerDataLength)
5858
{
59-
uint8_t tmpManufacturerData[manufacturerDataLength + 2];
59+
uint8_t* tmpManufacturerData = (uint8_t*)malloc(manufacturerDataLength + 2);
6060
tmpManufacturerData[0] = companyId & 0xff;
6161
tmpManufacturerData[1] = companyId >> 8;
6262
memcpy(&tmpManufacturerData[2], manufacturerData, manufacturerDataLength);
@@ -79,7 +79,7 @@ int GAPClass::advertise()
7979

8080
uint8_t type = (_connectable) ? 0x00 : (_localName ? 0x02 : 0x03);
8181

82-
_advertising = false;
82+
stopAdvertise();
8383

8484
if (HCI.leSetAdvertisingParameters(_advertisingInterval, _advertisingInterval, type, 0x00, 0x00, directBdaddr, 0x07, 0) != 0) {
8585
return 0;
@@ -97,20 +97,20 @@ int GAPClass::advertise()
9797
BLEUuid uuid(_advertisedServiceUuid);
9898
int uuidLen = uuid.length();
9999

100-
advertisingData[3] = 1 + uuidLen;
101-
advertisingData[4] = (uuidLen > 2) ? 0x06 : 0x02;
102-
memcpy(&advertisingData[5], uuid.data(), uuidLen);
100+
advertisingData[advertisingDataLen++] = 1 + uuidLen;
101+
advertisingData[advertisingDataLen++] = (uuidLen > 2) ? 0x06 : 0x02;
102+
memcpy(&advertisingData[advertisingDataLen], uuid.data(), uuidLen);
103103

104-
advertisingDataLen += (2 + uuidLen);
104+
advertisingDataLen += uuidLen;
105105
} else if (_manufacturerData && _manufacturerDataLength) {
106-
advertisingData[3] = 1 + _manufacturerDataLength;
107-
advertisingData[4] = 0xff;
108-
memcpy(&advertisingData[5], _manufacturerData, _manufacturerDataLength);
106+
advertisingData[advertisingDataLen++] = 1 + _manufacturerDataLength;
107+
advertisingData[advertisingDataLen++] = 0xff;
108+
memcpy(&advertisingData[advertisingDataLen], _manufacturerData, _manufacturerDataLength);
109109

110-
advertisingDataLen += (2 + _manufacturerDataLength);
110+
advertisingDataLen += _manufacturerDataLength;
111111
}
112112

113-
if (_serviceData && _serviceDataLength > 0 && advertisingDataLen >= (_serviceDataLength + 4)) {
113+
if (_serviceData && _serviceDataLength > 0 && (sizeof(advertisingData) - advertisingDataLen) >= (_serviceDataLength + 4)) {
114114
advertisingData[advertisingDataLen++] = _serviceDataLength + 3;
115115
advertisingData[advertisingDataLen++] = 0x16;
116116

0 commit comments

Comments
 (0)