Skip to content

Commit a62770f

Browse files
committed
update api & utility
1 parent 9e06a51 commit a62770f

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/Blinker/BlinkerApi.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ class BlinkerApi
102102
bool button(const String & _bName)
103103
{
104104
int8_t num = checkNum(_bName, _Button, _bCount);
105-
String state = STRING_find_string_value(static_cast<Proto*>(this)->dataParse(), _bName);
105+
String state;
106106

107-
if (state != "") {
107+
if (STRING_find_string_value(static_cast<Proto*>(this)->dataParse(), state, _bName)) {
108108
_fresh = true;
109109
}
110110

@@ -306,9 +306,9 @@ class BlinkerApi
306306
bool buttonParse(const String & _bName)
307307
{
308308
int8_t num = checkNum(_bName, _Button, _bCount);
309-
String state = STRING_find_string_value(static_cast<Proto*>(this)->dataParse(), _bName);
309+
String state;
310310

311-
if (state != "") {
311+
if (STRING_find_string_value(static_cast<Proto*>(this)->dataParse(), state, _bName)) {
312312
_fresh = true;
313313
}
314314

src/utility/BlinkerUtility.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,19 @@ bool STRING_contais_string(const String & src, const String & key)
9494
return key == src.substring(addr_start, addr_start + keyLen);
9595
}
9696

97-
String STRING_find_string_value(const String & src, const String & key)
97+
bool STRING_find_string_value(const String & src,String & dst, const String & key)
9898
{
9999
int addr_start = src.indexOf(key);
100100
uint8_t keyLen = key.length();
101101

102102
int addr_end = src.indexOf(STRING_VALUE_END, addr_start + keyLen + STRING_VALUE_SKIP);
103103

104104
if (addr_start == -1 || addr_end == -1) {
105-
return "";
105+
return false;
106106
}
107107
else {
108-
return src.substring(addr_start + keyLen + STRING_VALUE_SKIP, addr_end);
108+
dst = src.substring(addr_start + keyLen + STRING_VALUE_SKIP, addr_end);
109+
return true;
109110
}
110111
}
111112

0 commit comments

Comments
 (0)