Skip to content

Commit c32ec18

Browse files
committed
Add getMTU to BLEDevice
1 parent 9e523b5 commit c32ec18

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

src/BLEDevice.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,11 @@ int BLEDevice::rssi()
261261
return _rssi;
262262
}
263263

264+
uint16_t BLEDevice::getMTU() const
265+
{
266+
return ATT.mtu(ATT.connectionHandle(_addressType, _address));
267+
}
268+
264269
bool BLEDevice::connect()
265270
{
266271
return ATT.connect(_addressType, _address);

src/BLEDevice.h

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class BLEDevice {
6868
int manufacturerData(uint8_t value[], int length) const;
6969

7070
virtual int rssi();
71+
virtual uint16_t getMTU() const;
7172

7273
bool connect();
7374
bool discoverAttributes();

src/local/BLELocalDevice.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,17 @@ int BLELocalDevice::rssi()
283283
return 127;
284284
}
285285

286+
uint16_t BLELocalDevice::getMTU()
287+
{
288+
BLEDevice central = ATT.central();
289+
290+
if (central) {
291+
return central.getMTU();
292+
}
293+
294+
return -1;
295+
}
296+
286297
bool BLELocalDevice::setAdvertisedServiceUuid(const char* advertisedServiceUuid)
287298
{
288299
return _advertisingData.setAdvertisedServiceUuid(advertisedServiceUuid);

src/local/BLELocalDevice.h

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class BLELocalDevice {
4747
virtual String address() const;
4848

4949
virtual int rssi();
50+
virtual uint16_t getMTU();
5051

5152
virtual bool setAdvertisedServiceUuid(const char* advertisedServiceUuid);
5253
virtual bool setAdvertisedService(const BLEService& service);

0 commit comments

Comments
 (0)