Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
7 years, 5 months ago.
onDataSent() compile error
onDataWritten works, but onDataSent causes an "error: no matching function for call".
How am I supposed to set up a callback function for onDataSent??
void myService::onDataWritten(const GattCharacteristicWriteCBParams *params) { if(params->charHandle == txChar->getValueAttribute().getHandle()) { numBytesReceived = params->len; memcpy(receiveBuffer, params->data, numBytesReceived); onTxDataWritten(receiveBuffer, numBytesReceived); } } void myService::onDataSent(unsigned count) { sent = true; } void myService::init() { ble.onDataWritten(this, &myService::onDataWritten); ble.onDataSent(this, &myService::onDataSent); }
In BLEDevice.h we have:
/** * Setup a callback for the GATT event DATA_SENT. */ void onDataSent(GattServer::ServerEventCallbackWithCount_t callback); /** * Setup a callback for when a characteristic has its value updated by a * client. * * @Note: it is possible to chain together multiple onDataWritten callbacks * (potentially from different modules of an application) to receive updates * to characteristics. Many services, such as DFU and UART add their own * onDataWritten callbacks behind the scenes to trap interesting events. * * @Note: it is also possible to setup a callback into a member function of * some object. */ void onDataWritten(void (*callback)(const GattCharacteristicWriteCBParams *eventDataP)); template <typename T> void onDataWritten(T *objPtr, void (T::*memberPtr)(const GattCharacteristicWriteCBParams *context));
But I can't really understand how to set up onDataSent. I looked at all examples I could find and tried but always some error from the compiler... Thanks for any help.