Skip to content

Commit 8d76ce9

Browse files
committed
sync with upstream version 1.4.1, update namings
1 parent a34850e commit 8d76ce9

11 files changed

+43
-341
lines changed

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ sentence=Enables Bluetooth® Low Energy connectivity on the Arduino MKR WiFi 101
66
paragraph=This library supports creating a Bluetooth® Low Energy peripheral & central mode.
77
category=Communication
88
url=https://www.arduino.cc/en/Reference/ArduinoBLE
9-
architectures=*
9+
architectures=samd,megaavr,mbed,apollo3,mbed_nano,mbed_portenta,mbed_nicla,esp32,mbed_giga,renesas,renesas_portenta,mbed_opta,renesas_uno,silabs
1010
includes=ArduinoBLE.h

src/BLEAdvertisingData.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,11 @@ BLEAdvertisingData::BLEAdvertisingData() :
3030
_flags(0),
3131
_hasFlags(false),
3232
_localName(NULL),
33-
3433
_minimumConnectionInterval(0),
3534
_maximumConnectionInterval(0),
3635
_hasConnectionInterval(false),
3736
_TransmitPowerLevel(0),
3837
_hasTransmitPowerLevel(false),
39-
4038
_manufacturerData(NULL),
4139
_manufacturerDataLength(0),
4240
_manufacturerCompanyId(0),
@@ -81,13 +79,11 @@ void BLEAdvertisingData::clear()
8179
_rawDataLength = 0;
8280
_hasFlags = false;
8381
_localName = NULL;
84-
8582
_minimumConnectionInterval = 0;
8683
_maximumConnectionInterval = 0;
8784
_hasConnectionInterval = false;
8885
_TransmitPowerLevel = 0;
8986
_hasTransmitPowerLevel = false;
90-
9187
_manufacturerData = NULL;
9288
_manufacturerDataLength = 0;
9389
_hasManufacturerCompanyId = false;
@@ -105,13 +101,11 @@ void BLEAdvertisingData::copy(const BLEAdvertisingData& adv)
105101
_flags = adv._flags;
106102
_hasFlags = adv._hasFlags;
107103
_localName = adv._localName;
108-
109104
_minimumConnectionInterval = adv._minimumConnectionInterval;
110105
_maximumConnectionInterval = adv._maximumConnectionInterval;
111106
_hasConnectionInterval = adv._hasConnectionInterval;
112107
_TransmitPowerLevel = adv._TransmitPowerLevel;
113108
_hasTransmitPowerLevel = adv._hasTransmitPowerLevel;
114-
115109
_manufacturerData = adv._manufacturerData;
116110
_manufacturerDataLength = adv._manufacturerDataLength;
117111
_manufacturerCompanyId = adv._manufacturerCompanyId;
@@ -321,11 +315,17 @@ bool BLEAdvertisingData::hasFlags() const
321315

322316
bool BLEAdvertisingData::addLocalName(const char *localName)
323317
{
324-
uint8_t tempData[AD_NAME_LENGTH];
325-
uint8_t tempDataLength = strlen(localName);
326-
memcpy(tempData, (uint8_t*)localName, tempDataLength + 1);
327-
memset(&tempData[tempDataLength + 1], 0x20, AD_NAME_LENGTH - tempDataLength - 1);
328-
return addField(BLEFieldCompleteLocalName, tempData, AD_NAME_LENGTH);
318+
bool success = false;
319+
if (strlen(localName) > (MAX_AD_DATA_LENGTH - AD_FIELD_OVERHEAD)) {
320+
success = addField(BLEFieldShortLocalName, (uint8_t*)localName, (MAX_AD_DATA_LENGTH - AD_FIELD_OVERHEAD));
321+
} else {
322+
uint8_t tempData[AD_NAME_LENGTH];
323+
uint8_t tempDataLength = strlen(localName);
324+
memcpy(tempData, (uint8_t*)localName, tempDataLength + 1);
325+
memset(&tempData[tempDataLength + 1], 0x20, AD_NAME_LENGTH - tempDataLength - 1);
326+
success = addField(BLEFieldCompleteLocalName, tempData, AD_NAME_LENGTH);
327+
}
328+
return success;
329329
}
330330

331331
bool BLEAdvertisingData::addAdvertisedServiceUuid(const char* advertisedServiceUuid)

src/BLEAdvertisingData.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,8 @@ enum BLEAdField {
4040
BLEFieldCompleteAdvertisedService128 = 0x07,
4141
BLEFieldShortLocalName = 0x08,
4242
BLEFieldCompleteLocalName = 0x09,
43-
4443
BLEFieldTransmitPowerLevel = 0x0A,
4544
BLEFieldConnectionInterval = 0x12,
46-
4745
BLEFieldServiceData = 0x16,
4846
BLEFieldManufacturerData = 0xFF,
4947

@@ -70,10 +68,8 @@ class BLEAdvertisingData {
7068
bool setManufacturerData(const uint8_t manufacturerData[], int manufacturerDataLength);
7169
bool setManufacturerData(const uint16_t companyId, const uint8_t manufacturerData[], int manufacturerDataLength);
7270
bool setLocalName(const char *localName);
73-
7471
bool setAdvertisedConnectionInterval(uint16_t minimumConnectionInterval, uint16_t maximumConnectionInterval);
7572
bool setAdvertisedTransmitPowerLevel(uint8_t TransmitPowerLevel);
76-
7773
bool setAdvertisedServiceData(uint16_t uuid, const uint8_t data[], int length);
7874
bool setRawData(const uint8_t* data, int length);
7975
bool setRawData(const BLEAdvertisingRawData& data);
@@ -94,10 +90,8 @@ class BLEAdvertisingData {
9490
bool addManufacturerData(const uint8_t manufacturerData[], int manufacturerDataLength);
9591
bool addManufacturerData(const uint16_t companyId, const uint8_t manufacturerData[], int manufacturerDataLength);
9692
bool addLocalName(const char *localName);
97-
9893
bool addAdvertisedConnectionInterval(uint16_t minimumConnectionInterval, uint16_t maximumConnectionInterval);
9994
bool addAdvertisedTransmitPowerLevel(uint8_t TransmitPowerLevel);
100-
10195
bool addAdvertisedServiceData(uint16_t uuid, const uint8_t data[], int length);
10296
bool addRawData(const uint8_t* data, int length);
10397
bool addFlags(uint8_t flags);

src/BLEProperty.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ enum BLE_GATT_PERM_ {
7575
WRITE_AUTHORIZATION = 1 << 10,
7676
};
7777

78-
#define DEFAULT_PPCP_minimumConnectionInterval 80 /* 100 ms */
79-
#define DEFAULT_PPCP_maximumConnectionInterval 160 /* 200 ms */
80-
#define DEFAULT_PPCP_slaveLatency 0 /* 0 ms */
81-
#define DEFAULT_PPCP_connectionSupervisionTimeout 1000 /* 1000 ms */
78+
#define GAP_PPCP_MIN_CONN_INTERVAL (80) /* 100 ms */
79+
#define GAP_PPCP_MAX_CONN_INTERVAL (160) /* 200 ms */
80+
#define GAP_PPCP_SLAVE_LATENCY (0) /* 0 ms */
81+
#define GAP_PPCP_SUPERVISION_TMO (1000) /* 1000 ms */
8282

8383
#endif

src/local/BLELocalDevice.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,6 @@
2525

2626
#include "BLELocalDevice.h"
2727

28-
#ifdef __ZEPHYR__
29-
#undef ARDUINO_PORTENTA_H7_M7
30-
#undef ARDUINO_OPTA
31-
#undef ARDUINO_GIGA
32-
#undef ARDUINO_NICLA_VISION
33-
#undef ARDUINO_PORTENTA_C33
34-
#endif
35-
3628
#if defined(PORTENTA_H7_PINS) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_OPTA)
3729
#ifndef BT_REG_ON
3830
#define BT_REG_ON PJ_12
@@ -354,9 +346,9 @@ void BLELocalDevice::setAppearance(uint16_t appearance)
354346
GATT.setAppearance(appearance);
355347
}
356348

357-
void BLELocalDevice::setPPCP(uint16_t minimumConnectionInterval, uint16_t maximumConnectionInterval, uint16_t slaveLatency, uint16_t connectionSupervisionTimeout)
349+
void BLELocalDevice::setPreferredConnectionParameters(uint16_t minimumConnectionInterval, uint16_t maximumConnectionInterval, uint16_t slaveLatency, uint16_t connectionSupervisionTimeout)
358350
{
359-
GATT.setPPCP(minimumConnectionInterval, maximumConnectionInterval, slaveLatency, connectionSupervisionTimeout);
351+
GATT.setPreferredConnectionParameters(minimumConnectionInterval, maximumConnectionInterval, slaveLatency, connectionSupervisionTimeout);
360352
}
361353

362354
void BLELocalDevice::addService(BLEService& service)

src/local/BLELocalDevice.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class BLELocalDevice {
6060

6161
virtual void setDeviceName(const char* deviceName);
6262
virtual void setAppearance(uint16_t appearance);
63-
virtual void setPPCP(uint16_t minimumConnectionInterval, uint16_t maximumConnectionInterval, uint16_t slaveLatency, uint16_t connectionSupervisionTimeout);
63+
virtual void setPreferredConnectionParameters(uint16_t minimumConnectionInterval, uint16_t maximumConnectionInterval, uint16_t slaveLatency, uint16_t connectionSupervisionTimeout);
6464

6565
virtual void addService(BLEService& service);
6666

src/utility/GATT.cpp

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,9 @@ GATTClass::GATTClass() :
3131
_genericAccessService(NULL),
3232
_deviceNameCharacteristic(NULL),
3333
_appearanceCharacteristic(NULL),
34-
35-
_PPCPCharacteristic(NULL),
36-
34+
_preferredConnectionParametersCharacteristic(NULL),
3735
_genericAttributeService(NULL)
38-
//_servicesChangedCharacteristic(NULL) // removed
36+
//_servicesChangedCharacteristic(NULL)
3937
{
4038
}
4139

@@ -49,30 +47,25 @@ void GATTClass::begin()
4947
_genericAccessService = new BLELocalService("1800");
5048
_deviceNameCharacteristic = new BLELocalCharacteristic("2a00", BLERead, 20);
5149
_appearanceCharacteristic = new BLELocalCharacteristic("2a01", BLERead, 2);
52-
53-
_PPCPCharacteristic = new BLELocalCharacteristic("2a04", BLERead, 8);
54-
50+
_preferredConnectionParametersCharacteristic = new BLELocalCharacteristic("2a04", BLERead, 8);
5551
_genericAttributeService = new BLELocalService("1801");
56-
//_servicesChangedCharacteristic = new BLELocalCharacteristic("2a05", BLEIndicate, 4); // removed
52+
//_servicesChangedCharacteristic = new BLELocalCharacteristic("2a05", BLEIndicate, 4);
5753

5854
_genericAccessService->retain();
5955
_deviceNameCharacteristic->retain();
6056
_appearanceCharacteristic->retain();
61-
62-
_PPCPCharacteristic->retain();
63-
57+
_preferredConnectionParametersCharacteristic->retain();
6458
_genericAttributeService->retain();
65-
//_servicesChangedCharacteristic->retain(); // removed
59+
//_servicesChangedCharacteristic->retain();
6660

6761
_genericAccessService->addCharacteristic(_deviceNameCharacteristic);
6862
_genericAccessService->addCharacteristic(_appearanceCharacteristic);
69-
_genericAccessService->addCharacteristic(_PPCPCharacteristic);
70-
//_genericAttributeService->addCharacteristic(_servicesChangedCharacteristic); // removed
63+
_genericAccessService->addCharacteristic(_preferredConnectionParametersCharacteristic);
64+
//_genericAttributeService->addCharacteristic(_servicesChangedCharacteristic);
7165

7266
setDeviceName("Arduino");
7367
setAppearance(0x000);
74-
75-
setPPCP(DEFAULT_PPCP_minimumConnectionInterval, DEFAULT_PPCP_maximumConnectionInterval, DEFAULT_PPCP_slaveLatency, DEFAULT_PPCP_connectionSupervisionTimeout);
68+
setPreferredConnectionParameters(GAP_PPCP_MIN_CONN_INTERVAL, GAP_PPCP_MAX_CONN_INTERVAL, GAP_PPCP_SLAVE_LATENCY, GAP_PPCP_SUPERVISION_TMO);
7669

7770
clearAttributes();
7871

@@ -97,21 +90,21 @@ void GATTClass::end()
9790
_appearanceCharacteristic = NULL;
9891
}
9992

100-
if (_PPCPCharacteristic &&_PPCPCharacteristic->release() == 0) {
101-
delete(_PPCPCharacteristic);
102-
_PPCPCharacteristic = NULL;
93+
if (_preferredConnectionParametersCharacteristic &&_preferredConnectionParametersCharacteristic->release() == 0) {
94+
delete(_preferredConnectionParametersCharacteristic);
95+
_preferredConnectionParametersCharacteristic = NULL;
10396
}
10497

10598
if (_genericAttributeService && _genericAttributeService->release() == 0) {
10699
delete(_genericAttributeService);
107100
_genericAttributeService = NULL;
108101
}
109-
110-
//if (_servicesChangedCharacteristic && _servicesChangedCharacteristic->release() == 0) {
111-
// delete(_servicesChangedCharacteristic);
112-
// _servicesChangedCharacteristic = NULL;
113-
//}
114-
102+
/*
103+
if (_servicesChangedCharacteristic && _servicesChangedCharacteristic->release() == 0) {
104+
delete(_servicesChangedCharacteristic);
105+
_servicesChangedCharacteristic = NULL;
106+
}
107+
*/
115108
clearAttributes();
116109
}
117110

@@ -125,9 +118,9 @@ void GATTClass::setAppearance(uint16_t appearance)
125118
_appearanceCharacteristic->writeValue((uint8_t*)&appearance, sizeof(appearance));
126119
}
127120

128-
void GATTClass::setPPCP(uint16_t minimumConnectionInterval, uint16_t maximumConnectionInterval, uint16_t slaveLatency, uint16_t connectionSupervisionTimeout)
121+
void GATTClass::setPreferredConnectionParameters(uint16_t minimumConnectionInterval, uint16_t maximumConnectionInterval, uint16_t slaveLatency, uint16_t connectionSupervisionTimeout)
129122
{
130-
uint16_t PPCPData[] = { minimumConnectionInterval, maximumConnectionInterval, slaveLatency, connectionSupervisionTimeout };
123+
uint16_t PPCPData[] = {minimumConnectionInterval, maximumConnectionInterval, slaveLatency, connectionSupervisionTimeout};
131124
_PPCPCharacteristic->writeValue((uint8_t*)&PPCPData, sizeof(PPCPData));
132125
}
133126

src/utility/GATT.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ class GATTClass {
3838

3939
virtual void setDeviceName(const char* deviceName);
4040
virtual void setAppearance(uint16_t appearance);
41-
42-
virtual void setPPCP(uint16_t minimumConnectionInterval, uint16_t maximumConnectionInterval, uint16_t slaveLatency, uint16_t connectionSupervisionTimeout);
41+
virtual void setPreferredConnectionParameters(uint16_t minimumConnectionInterval, uint16_t maximumConnectionInterval, uint16_t slaveLatency, uint16_t connectionSupervisionTimeout);
4342

4443
virtual void addService(BLEService& service);
4544

@@ -66,11 +65,9 @@ class GATTClass {
6665
BLELocalService* _genericAccessService;
6766
BLELocalCharacteristic* _deviceNameCharacteristic;
6867
BLELocalCharacteristic* _appearanceCharacteristic;
69-
70-
BLELocalCharacteristic* _PPCPCharacteristic;
71-
68+
BLELocalCharacteristic* _preferredConnectionParametersCharacteristic;
7269
BLELocalService* _genericAttributeService;
73-
//BLELocalCharacteristic* _servicesChangedCharacteristic; // removed
70+
//BLELocalCharacteristic* _servicesChangedCharacteristic;
7471
};
7572

7673
extern GATTClass& GATT;

src/utility/HCIUartTransport.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1818
*/
1919

20-
#if !defined(ARDUINO_ARCH_MBED) && !defined(__ZEPHYR__) && !defined(ESP32) && !defined(ARDUINO_SILABS) && !defined(ARDUINO_UNOR4_WIFI) && !defined(__ZEPHYR__) || defined(TARGET_NANO_RP2040_CONNECT) //|| defined(CORE_CM4)
20+
#if !defined(ARDUINO_ARCH_MBED) && !defined(ESP32) && !defined(ARDUINO_SILABS) && !defined(ARDUINO_UNOR4_WIFI) || defined(TARGET_NANO_RP2040_CONNECT) //|| defined(CORE_CM4)
2121

2222
#include "HCIUartTransport.h"
2323

0 commit comments

Comments
 (0)