Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit458ae5e

Browse files
committed
Fix BLECharacteristic::readValue(...) triggering a read request after a notification/indication was received
1 parent631f807 commit458ae5e

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

‎src/BLECharacteristic.cpp‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,9 @@ int BLECharacteristic::readValue(uint8_t value[], int length)
170170
}
171171

172172
if (_remote) {
173-
// trigger a read if the value hasn't been updated via
174-
// indication or notification, and the characteristic is
175-
// readable
176-
if (!valueUpdated() &&canRead()) {
173+
// trigger a read if the updated value (notification/indication)
174+
// has already been read and the characteristic is readable
175+
if (_remote->updatedValueRead() &&canRead()) {
177176
if (!read()) {
178177
// read failed
179178
return0;

‎src/remote/BLERemoteCharacteristic.cpp‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ BLERemoteCharacteristic::BLERemoteCharacteristic(const uint8_t uuid[], uint8_t u
3333
_value(NULL),
3434
_valueLength(0),
3535
_valueUpdated(false),
36+
_updatedValueRead(true),
3637
_valueUpdatedEventHandler(NULL)
3738
{
3839
}
@@ -148,6 +149,15 @@ bool BLERemoteCharacteristic::valueUpdated()
148149
return result;
149150
}
150151

152+
boolBLERemoteCharacteristic::updatedValueRead()
153+
{
154+
bool result = _updatedValueRead;
155+
156+
_updatedValueRead =true;
157+
158+
return result;
159+
}
160+
151161
boolBLERemoteCharacteristic::read()
152162
{
153163
if (!ATT.connected(_connectionHandle)) {
@@ -177,7 +187,6 @@ bool BLERemoteCharacteristic::read()
177187
returnfalse;
178188
}
179189

180-
_valueUpdated =true;
181190
memcpy(_value, &resp[1], _valueLength);
182191

183192
returntrue;
@@ -245,6 +254,7 @@ void BLERemoteCharacteristic::writeValue(BLEDevice device, const uint8_t value[]
245254
}
246255

247256
_valueUpdated =true;
257+
_updatedValueRead =false;
248258
memcpy(_value, value, _valueLength);
249259

250260
if (_valueUpdatedEventHandler) {

‎src/remote/BLERemoteCharacteristic.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class BLERemoteCharacteristic : public BLERemoteAttribute {
4242
intwriteValue(constchar* value);
4343

4444
boolvalueUpdated();
45+
boolupdatedValueRead();
4546

4647
boolread();
4748
boolwriteCccd(uint16_t value);
@@ -71,6 +72,7 @@ class BLERemoteCharacteristic : public BLERemoteAttribute {
7172
int _valueLength;
7273

7374
bool _valueUpdated;
75+
bool _updatedValueRead;
7476

7577
BLELinkedList<BLERemoteDescriptor*> _descriptors;
7678

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp