Skip to content

Commit 9e06a51

Browse files
committed
fix ESP32 BLE receive bug & add button cmd
1 parent 30c9abd commit 9e06a51

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

src/Blinker/BlinkerApi.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,11 @@ class BlinkerApi
104104
int8_t num = checkNum(_bName, _Button, _bCount);
105105
String state = STRING_find_string_value(static_cast<Proto*>(this)->dataParse(), _bName);
106106

107-
if (state == BLINKER_CMD_BUTTON_PRESSED) {
107+
if (state != "") {
108+
_fresh = true;
109+
}
110+
111+
if (state == BLINKER_CMD_BUTTON_PRESSED || state == BLINKER_CMD_BUTTON_TAP) {
108112
if( num == BLINKER_OBJECT_NOT_AVAIL ) {
109113
if ( _bCount < BLINKER_MAX_WIDGET_SIZE ) {
110114
_Button[_bCount] = new BlinkerButton();
@@ -304,7 +308,11 @@ class BlinkerApi
304308
int8_t num = checkNum(_bName, _Button, _bCount);
305309
String state = STRING_find_string_value(static_cast<Proto*>(this)->dataParse(), _bName);
306310

307-
if (state == BLINKER_CMD_BUTTON_PRESSED) {
311+
if (state != "") {
312+
_fresh = true;
313+
}
314+
315+
if (state == BLINKER_CMD_BUTTON_PRESSED || state == BLINKER_CMD_BUTTON_TAP) {
308316
if( num == BLINKER_OBJECT_NOT_AVAIL ) {
309317
if ( _bCount < BLINKER_MAX_WIDGET_SIZE ) {
310318
_Button[_bCount] = new BlinkerButton();
@@ -346,7 +354,7 @@ class BlinkerApi
346354
return false;
347355
}
348356

349-
return _Button[num]->getState();;
357+
return _Button[num]->getState();
350358
}
351359
}
352360
};

src/Blinker/BlinkerConfig.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333

3434
#define BLINKER_CMD_VIBRATE "vibrate"
3535

36+
#define BLINKER_CMD_BUTTON_TAP "tap"
37+
3638
#define BLINKER_CMD_BUTTON_PRESSED "pressed"
3739

3840
#define BLINKER_CMD_BUTTON_RELEASED "released"

src/BlinkerSimpleESP32_BLE.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ class BlinkerTransportESP32_BLE
139139
if (vlen > 0) {
140140
freshTime = millis();
141141

142+
if (_bufLen == 0) {
143+
memset(BLEBuf, '\0', BLINKER_BUFFER_SIZE);
144+
}
145+
142146
for (uint8_t _num = 0; _num < vlen; _num++) {
143147
BLEBuf[_bufLen] = value[_num];
144148
_bufLen++;

0 commit comments

Comments
 (0)