Skip to content

Make writeValue return the number of bytes written #392

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 11, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/local/BLELocalCharacteristic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,13 @@

if (_broadcast) {
uint16_t serviceUuid = GATT.serviceUuidForCharacteristic(this);

BLE.setAdvertisedServiceData(serviceUuid, value, length);

BLE.setAdvertisedServiceData(serviceUuid, value, _valueLength);

Check warning on line 129 in src/local/BLELocalCharacteristic.cpp

View check run for this annotation

Codecov / codecov/patch

src/local/BLELocalCharacteristic.cpp#L129

Added line #L129 was not covered by tests
if (!ATT.connected() && GAP.advertising()) {
BLE.advertise();
}
}

return 1;
return _valueLength;
}

int BLELocalCharacteristic::writeValue(const char* value)
Expand Down
8 changes: 4 additions & 4 deletions src/utility/ATT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@
return BLEDevice();
}

bool ATTClass::handleNotify(uint16_t handle, const uint8_t* value, int length)
int ATTClass::handleNotify(uint16_t handle, const uint8_t* value, int length)

Check warning on line 601 in src/utility/ATT.cpp

View check run for this annotation

Codecov / codecov/patch

src/utility/ATT.cpp#L601

Added line #L601 was not covered by tests
{
int numNotifications = 0;

Expand Down Expand Up @@ -626,10 +626,10 @@
numNotifications++;
}

return (numNotifications > 0);
return (numNotifications > 0) ? length : 0;

Check warning on line 629 in src/utility/ATT.cpp

View check run for this annotation

Codecov / codecov/patch

src/utility/ATT.cpp#L629

Added line #L629 was not covered by tests
}

bool ATTClass::handleInd(uint16_t handle, const uint8_t* value, int length)
int ATTClass::handleInd(uint16_t handle, const uint8_t* value, int length)

Check warning on line 632 in src/utility/ATT.cpp

View check run for this annotation

Codecov / codecov/patch

src/utility/ATT.cpp#L632

Added line #L632 was not covered by tests
{
int numIndications = 0;

Expand Down Expand Up @@ -666,7 +666,7 @@
numIndications++;
}

return (numIndications > 0);
return (numIndications > 0) ? length : 0;

Check warning on line 669 in src/utility/ATT.cpp

View check run for this annotation

Codecov / codecov/patch

src/utility/ATT.cpp#L669

Added line #L669 was not covered by tests
}

void ATTClass::error(uint16_t connectionHandle, uint8_t dlen, uint8_t data[])
Expand Down
4 changes: 2 additions & 2 deletions src/utility/ATT.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ class ATTClass {

virtual BLEDevice central();

virtual bool handleNotify(uint16_t handle, const uint8_t* value, int length);
virtual bool handleInd(uint16_t handle, const uint8_t* value, int length);
virtual int handleNotify(uint16_t handle, const uint8_t* value, int length);
virtual int handleInd(uint16_t handle, const uint8_t* value, int length);

virtual void setEventHandler(BLEDeviceEvent event, BLEDeviceEventHandler eventHandler);

Expand Down
Loading