Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: microbit-dal microbit-dal microbit-ble-open microbit-dal ... more
Fork of BLE_API by
Diff: public/GattCharacteristic.h
- Revision:
- 252:69d049317cae
- Parent:
- 249:5d9118449482
- Child:
- 253:097be53aea02
diff -r 6ce809c972bb -r 69d049317cae public/GattCharacteristic.h
--- a/public/GattCharacteristic.h Fri Dec 12 13:32:24 2014 +0000
+++ b/public/GattCharacteristic.h Fri Dec 12 13:32:24 2014 +0000
@@ -334,7 +334,7 @@
_properties(props),
_descriptors(descriptors),
_descriptorCount(numDescriptors),
- enableWriteAuthorization(false),
+ enabledWriteAuthorization(false),
writeAuthorizationCallback() {
/* empty */
}
@@ -344,13 +344,13 @@
* Setup write authorization.
*/
void setWriteAuthorizationCallback(void (*callback)(GattCharacteristicWriteAuthCBParams *)) {
- enableWriteAuthorization = true;
writeAuthorizationCallback.attach(callback);
+ enabledWriteAuthorization = true;
}
template <typename T>
void setWriteAuthorizationCallback(T *object, void (T::*member)(GattCharacteristicWriteAuthCBParams *)) {
- enableWriteAuthorization = true;
writeAuthorizationCallback.attach(object, member);
+ enabledWriteAuthorization = true;
}
/**
@@ -360,6 +360,10 @@
* @return true if the write is authorized to proceed.
*/
bool authorizeWrite(GattCharacteristicWriteAuthCBParams *params) {
+ if (!isWriteAuthorizationEnabled()) {
+ return true;
+ }
+
params->authorizationReply = true; /* initialized to true by default */
writeAuthorizationCallback.call(params);
return params->authorizationReply;
@@ -370,7 +374,7 @@
GattAttribute::Handle_t getValueHandle(void) const {return getValueAttribute().getHandle();}
uint8_t getProperties(void) const {return _properties; }
uint8_t getDescriptorCount(void) const {return _descriptorCount;}
- bool isWriteAuthorizationEnabled() const {return enableWriteAuthorization;}
+ bool isWriteAuthorizationEnabled() const {return enabledWriteAuthorization; }
GattAttribute *getDescriptor(uint8_t index) {
if (index >= _descriptorCount) {
@@ -385,7 +389,7 @@
uint8_t _properties;
GattAttribute **_descriptors;
uint8_t _descriptorCount;
- bool enableWriteAuthorization;
+ bool enabledWriteAuthorization;
FunctionPointerWithContext<GattCharacteristicWriteAuthCBParams *> writeAuthorizationCallback;
private:
