|
|
|
|
@ -38,7 +38,6 @@ static void RemoteTask(void *pv) { |
|
|
|
|
unsigned char espMsg[McuShell_DEFAULT_SHELL_BUFFER_SIZE] = ""; |
|
|
|
|
uint8_t saveChar = 0; |
|
|
|
|
uint8_t writeIndex = 0; |
|
|
|
|
uint8_t readIndex = 0; |
|
|
|
|
(void)pv; /* not used */ |
|
|
|
|
#if 0 /* example making a beep */
|
|
|
|
|
BUZ_Beep(200, 500); |
|
|
|
|
@ -69,39 +68,33 @@ static void RemoteTask(void *pv) { |
|
|
|
|
/* something was received */ |
|
|
|
|
/* handle remote stream from ESP */ |
|
|
|
|
if(ch == '@'){ |
|
|
|
|
saveChar = 1; |
|
|
|
|
} |
|
|
|
|
if(saveChar == 1){ |
|
|
|
|
espMsg[writeIndex++] = ch; |
|
|
|
|
if(writeIndex >= McuShell_DEFAULT_SHELL_BUFFER_SIZE){ |
|
|
|
|
writeIndex = 0; |
|
|
|
|
saveChar = 1; // enable saving
|
|
|
|
|
writeIndex = 0; // initialize string to first position
|
|
|
|
|
// empty string
|
|
|
|
|
for(uint8_t i = 0; i < McuShell_DEFAULT_SHELL_BUFFER_SIZE; i++){ |
|
|
|
|
espMsg[i] = '\0'; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
/* save characters on and character is termination character */ |
|
|
|
|
if(ch == '!' && saveChar == 1){ |
|
|
|
|
saveChar = 0; |
|
|
|
|
unsigned char str[McuShell_DEFAULT_SHELL_BUFFER_SIZE] = {'\0'}; |
|
|
|
|
if(str != NULL){ |
|
|
|
|
uint8_t i; |
|
|
|
|
for(i = 0; i < McuShell_DEFAULT_SHELL_BUFFER_SIZE; i++){ |
|
|
|
|
str[i] = espMsg[readIndex++]; |
|
|
|
|
if(readIndex >= McuShell_DEFAULT_SHELL_BUFFER_SIZE){ |
|
|
|
|
readIndex = 0; |
|
|
|
|
} |
|
|
|
|
if(str[i] == '!'){ |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
McuShell_SendStr((const uint8_t *)str, McuShell_GetStdio()->stdOut); |
|
|
|
|
if(McuUtility_strncmp((char *)str,"@robot:cmd ",sizeof("@robot:cmd ")-1) == 0){ |
|
|
|
|
unsigned char *p; |
|
|
|
|
p = (unsigned char*)str + sizeof(ESP_MSG_PREFIX) - 1; |
|
|
|
|
McuUtility_strCutTail((uint8_t*)p, (uint8_t*)ESP_MSG_POSTFIX); |
|
|
|
|
McuShell_SendStr((uint8_t*)p, McuShell_GetStdio()->stdOut); |
|
|
|
|
saveChar = 0; // turn off
|
|
|
|
|
// send to shell
|
|
|
|
|
McuShell_SendStr((uint8_t *)"Parsed command from ESP32: ", McuShell_GetStdio()->stdOut); |
|
|
|
|
McuShell_SendStr((uint8_t *)espMsg, McuShell_GetStdio()->stdOut); |
|
|
|
|
McuShell_SendStr((uint8_t *)"\r\n", McuShell_GetStdio()->stdOut); |
|
|
|
|
// if it is a robot cmd => parse command
|
|
|
|
|
if(McuUtility_strncmp((char *)espMsg,"@robot:cmd ",sizeof("@robot:cmd ")-1) == 0){ |
|
|
|
|
unsigned char *p; |
|
|
|
|
p = (unsigned char*)espMsg + sizeof(ESP_MSG_PREFIX) - 1; |
|
|
|
|
//McuUtility_strCutTail((uint8_t*)p, (uint8_t*)ESP_MSG_POSTFIX);
|
|
|
|
|
SHELL_ParseCommandWithIO((unsigned char*)p, McuESP32_GetTxToESPStdio()); |
|
|
|
|
free(p); |
|
|
|
|
} |
|
|
|
|
/* save characters on but character is not termination character */ |
|
|
|
|
}else if(saveChar == 1){ |
|
|
|
|
espMsg[writeIndex++] = ch; |
|
|
|
|
if(writeIndex >= McuShell_DEFAULT_SHELL_BUFFER_SIZE){ |
|
|
|
|
writeIndex = 0; // reset to 0
|
|
|
|
|
} |
|
|
|
|
free(str); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|