Skip to content

Commit

Permalink
update api & utility
Browse files Browse the repository at this point in the history
  • Loading branch information
i3water committed Mar 14, 2018
1 parent 9e06a51 commit a62770f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/Blinker/BlinkerApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ class BlinkerApi
bool button(const String & _bName)
{
int8_t num = checkNum(_bName, _Button, _bCount);
String state = STRING_find_string_value(static_cast<Proto*>(this)->dataParse(), _bName);
String state;

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

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

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

Expand Down
7 changes: 4 additions & 3 deletions src/utility/BlinkerUtility.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,19 @@ bool STRING_contais_string(const String & src, const String & key)
return key == src.substring(addr_start, addr_start + keyLen);
}

String STRING_find_string_value(const String & src, const String & key)
bool STRING_find_string_value(const String & src,String & dst, const String & key)
{
int addr_start = src.indexOf(key);
uint8_t keyLen = key.length();

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

if (addr_start == -1 || addr_end == -1) {
return "";
return false;
}
else {
return src.substring(addr_start + keyLen + STRING_VALUE_SKIP, addr_end);
dst = src.substring(addr_start + keyLen + STRING_VALUE_SKIP, addr_end);
return true;
}
}

Expand Down

0 comments on commit a62770f

Please sign in to comment.