Skip to content

Commit

Permalink
Updated readme. Added handle for notify and indicate.
Browse files Browse the repository at this point in the history
  • Loading branch information
kdewald committed Jul 29, 2024
1 parent 39cc358 commit 9603886
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
3 changes: 2 additions & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ The format is based on `Keep a Changelog`_, and this project adheres to `Semanti

**Changed**

-
- Implemented standalone ByteArray class derived from `kvn::bytearray`. *(Thanks tlifschitz!)*
- **API CHANGE**: Notify and Indicate callback in C bindings now receive the peripheral handle as the first argument.

**Fixed**

Expand Down
4 changes: 2 additions & 2 deletions simpleble/include/simpleble_c/peripheral.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ SIMPLEBLE_EXPORT simpleble_err_t simpleble_peripheral_write_command(simpleble_pe
*/
SIMPLEBLE_EXPORT simpleble_err_t
simpleble_peripheral_notify(simpleble_peripheral_t handle, simpleble_uuid_t service, simpleble_uuid_t characteristic,
void (*callback)(simpleble_uuid_t service, simpleble_uuid_t characteristic,
void (*callback)(simpleble_peripheral_t handle, simpleble_uuid_t service, simpleble_uuid_t characteristic,
const uint8_t* data, size_t data_length, void* userdata),
void* userdata);

Expand All @@ -229,7 +229,7 @@ simpleble_peripheral_notify(simpleble_peripheral_t handle, simpleble_uuid_t serv
*/
SIMPLEBLE_EXPORT simpleble_err_t
simpleble_peripheral_indicate(simpleble_peripheral_t handle, simpleble_uuid_t service, simpleble_uuid_t characteristic,
void (*callback)(simpleble_uuid_t service, simpleble_uuid_t characteristic,
void (*callback)(simpleble_peripheral_t handle, simpleble_uuid_t service, simpleble_uuid_t characteristic,
const uint8_t* data, size_t data_length, void* userdata),
void* userdata);

Expand Down
3 changes: 3 additions & 0 deletions simpleble/src/backends/linux/AdapterBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ void AdapterBase::scan_start() {

// Start scanning and notify the user.
adapter_->discovery_start();

// TODO: Does a discovery filter need to be set?

SAFE_CALLBACK_CALL(this->callback_on_scan_start_);
is_scanning_ = true;
}
Expand Down
8 changes: 4 additions & 4 deletions simpleble/src_c/peripheral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ simpleble_err_t simpleble_peripheral_write_command(simpleble_peripheral_t handle

simpleble_err_t simpleble_peripheral_notify(
simpleble_peripheral_t handle, simpleble_uuid_t service, simpleble_uuid_t characteristic,
void (*callback)(simpleble_uuid_t, simpleble_uuid_t, const uint8_t*, size_t, void*), void* userdata) {
void (*callback)(simpleble_peripheral_t,simpleble_uuid_t, simpleble_uuid_t, const uint8_t*, size_t, void*), void* userdata) {
if (handle == nullptr || callback == nullptr) {
return SIMPLEBLE_FAILURE;
}
Expand All @@ -327,7 +327,7 @@ simpleble_err_t simpleble_peripheral_notify(

bool success = peripheral->notify(SimpleBLE::BluetoothUUID(service.value),
SimpleBLE::BluetoothUUID(characteristic.value), [=](SimpleBLE::ByteArray data) {
callback(service, characteristic, (const uint8_t*)data.data(), data.size(),
callback(handle, service, characteristic, (const uint8_t*)data.data(), data.size(),
userdata);
});

Expand All @@ -336,7 +336,7 @@ simpleble_err_t simpleble_peripheral_notify(

simpleble_err_t simpleble_peripheral_indicate(
simpleble_peripheral_t handle, simpleble_uuid_t service, simpleble_uuid_t characteristic,
void (*callback)(simpleble_uuid_t, simpleble_uuid_t, const uint8_t*, size_t, void*), void* userdata) {
void (*callback)(simpleble_peripheral_t,simpleble_uuid_t, simpleble_uuid_t, const uint8_t*, size_t, void*), void* userdata) {
if (handle == nullptr || callback == nullptr) {
return SIMPLEBLE_FAILURE;
}
Expand All @@ -345,7 +345,7 @@ simpleble_err_t simpleble_peripheral_indicate(

bool success = peripheral->indicate(SimpleBLE::BluetoothUUID(service.value),
SimpleBLE::BluetoothUUID(characteristic.value), [=](SimpleBLE::ByteArray data) {
callback(service, characteristic, (const uint8_t*)data.data(), data.size(),
callback(handle, service, characteristic, (const uint8_t*)data.data(), data.size(),
userdata);
});

Expand Down

0 comments on commit 9603886

Please sign in to comment.