|
|
|
@ -114,16 +114,8 @@ bool Robo_Wrapper_GetBatteryVoltage(unsigned char *voltage){ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static bool getValueOfStatusResponse(unsigned char* response, const unsigned char* key, unsigned char* value, size_t valueStringLen){ |
|
|
|
static bool getValueOfStatusResponse(unsigned char* response, const unsigned char* key, unsigned char* value, size_t valueStringLen){ |
|
|
|
int16_t pos = McuUtility_strFind(response, (unsigned char*)key); |
|
|
|
|
|
|
|
unsigned char extractedString[50] = ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(pos == -1){ // error string not found = -1
|
|
|
|
|
|
|
|
ESP_LOGE(TAG, "Could not find key %s in response.", key); |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unsigned char *p; |
|
|
|
unsigned char *p; |
|
|
|
p = (unsigned char*)response + pos; |
|
|
|
p = (unsigned char*)response; |
|
|
|
|
|
|
|
|
|
|
|
// skip first line (if the keyword would also appear in the headline, this is an issue)
|
|
|
|
// skip first line (if the keyword would also appear in the headline, this is an issue)
|
|
|
|
while(*p!='\n'){ |
|
|
|
while(*p!='\n'){ |
|
|
|
@ -131,6 +123,14 @@ static bool getValueOfStatusResponse(unsigned char* response, const unsigned cha |
|
|
|
} |
|
|
|
} |
|
|
|
p+=1; // skip newline
|
|
|
|
p+=1; // skip newline
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// find key
|
|
|
|
|
|
|
|
int16_t pos = McuUtility_strFind(p, (unsigned char*)key); |
|
|
|
|
|
|
|
if(pos == -1){ // error string not found = -1
|
|
|
|
|
|
|
|
ESP_LOGE(TAG, "Could not find key %s in response.", key); |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
p+=pos; // move pointer to found key
|
|
|
|
|
|
|
|
|
|
|
|
// skip until colon
|
|
|
|
// skip until colon
|
|
|
|
while(true){ |
|
|
|
while(true){ |
|
|
|
if(*p==':'){ |
|
|
|
if(*p==':'){ |
|
|
|
@ -147,6 +147,7 @@ static bool getValueOfStatusResponse(unsigned char* response, const unsigned cha |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// extract value
|
|
|
|
// extract value
|
|
|
|
|
|
|
|
unsigned char extractedString[50] = ""; |
|
|
|
uint8_t i = 0; |
|
|
|
uint8_t i = 0; |
|
|
|
while(true){ |
|
|
|
while(true){ |
|
|
|
if(*p == '\n'){ |
|
|
|
if(*p == '\n'){ |
|
|
|
|