forked from h2zero/esp-nimble-cpp
Revert 03b22e5 sub/unsub changes, app should specify response.
This commit is contained in:
1 parent
7d2d73d8fc
commit
d83cd94d5b
4 files changed
+96
-92
No files matched your search
@@ -564,7 +564,7 @@ int NimBLERemoteCharacteristic::onReadCB(uint16_t conn_handle,
|
||||
* If NULL is provided then no callback is performed.
|
||||
* @return false if writing to the descriptor failed.
|
||||
*/
|
||||
bool NimBLERemoteCharacteristic::setNotify(uint16_t val, notify_callback notifyCallback) {
|
||||
bool NimBLERemoteCharacteristic::setNotify(uint16_t val, notify_callback notifyCallback, bool response) {
|
||||
NIMBLE_LOGD(LOG_TAG, ">> setNotify(): %s, %02x", toString().c_str(), val);
|
||||
|
||||
m_notifyCallback = notifyCallback;
|
||||
@@ -576,7 +576,8 @@ bool NimBLERemoteCharacteristic::setNotify(uint16_t val, notify_callback notifyC
|
||||
}
|
||||
|
||||
NIMBLE_LOGD(LOG_TAG, "<< setNotify()");
|
||||
return desc->writeValue((uint8_t *)&val, 2, true);
|
||||
|
||||
return desc->writeValue((uint8_t *)&val, 2, response);
|
||||
} // setNotify
|
||||
|
||||
|
||||
@@ -584,14 +585,15 @@ bool NimBLERemoteCharacteristic::setNotify(uint16_t val, notify_callback notifyC
|
||||
* @brief Subscribe for notifications or indications.
|
||||
* @param [in] notifications If true, subscribe for notifications, false subscribe for indications.
|
||||
* @param [in] notifyCallback A callback to be invoked for a notification.
|
||||
* @param [in] response If true, require a write response from the descriptor write operation.
|
||||
* If NULL is provided then no callback is performed.
|
||||
* @return false if writing to the descriptor failed.
|
||||
*/
|
||||
bool NimBLERemoteCharacteristic::subscribe(bool notifications, notify_callback notifyCallback) {
|
||||
bool NimBLERemoteCharacteristic::subscribe(bool notifications, notify_callback notifyCallback, bool response) {
|
||||
if(notifications) {
|
||||
return setNotify(0x01, notifyCallback);
|
||||
return setNotify(0x01, notifyCallback, response);
|
||||
} else {
|
||||
return setNotify(0x02, notifyCallback);
|
||||
return setNotify(0x02, notifyCallback, response);
|
||||
}
|
||||
} // subscribe
|
||||
|
||||
@@ -601,8 +603,8 @@ bool NimBLERemoteCharacteristic::subscribe(bool notifications, notify_callback n
|
||||
* @param [in] response bool if true, require a write response from the descriptor write operation.
|
||||
* @return false if writing to the descriptor failed.
|
||||
*/
|
||||
bool NimBLERemoteCharacteristic::unsubscribe() {
|
||||
return setNotify(0x00, nullptr);
|
||||
bool NimBLERemoteCharacteristic::unsubscribe(bool response) {
|
||||
return setNotify(0x00, nullptr, response);
|
||||
} // unsubscribe
|
||||
|
||||
|
||||
|
||||
@@ -66,8 +66,9 @@ public:
|
||||
NimBLERemoteService* getRemoteService();
|
||||
NimBLEAttValue getValue(time_t *timestamp = nullptr);
|
||||
bool subscribe(bool notifications = true,
|
||||
notify_callback notifyCallback = nullptr);
|
||||
bool unsubscribe();
|
||||
notify_callback notifyCallback = nullptr,
|
||||
bool response = true);
|
||||
bool unsubscribe(bool response = true);
|
||||
bool writeValue(const uint8_t* data,
|
||||
size_t length,
|
||||
bool response = false);
|
||||
@@ -149,7 +150,7 @@ private:
|
||||
friend class NimBLERemoteDescriptor;
|
||||
|
||||
// Private member functions
|
||||
bool setNotify(uint16_t val, notify_callback notifyCallback = nullptr);
|
||||
bool setNotify(uint16_t val, notify_callback notifyCallback = nullptr, bool response = true);
|
||||
bool retrieveDescriptors(const NimBLEUUID *uuid_filter = nullptr);
|
||||
static int onReadCB(uint16_t conn_handle, const struct ble_gatt_error *error,
|
||||
struct ble_gatt_attr *attr, void *arg);
|
||||
|
||||
Reference in new issue
Block a user