@ -12,6 +12,7 @@
# include "Shell.h"
# include "Shell.h"
# include "Buzzer.h"
# include "Buzzer.h"
# include "McuESP32.h"
# include "McuESP32.h"
# include "McuLog.h"
/*! \todo ADIS: This is a (mostly empty) template where the remote commands from the ESP32 could be handled. This module should be extended to send data back to the ESP32 */
/*! \todo ADIS: This is a (mostly empty) template where the remote commands from the ESP32 could be handled. This module should be extended to send data back to the ESP32 */
@ -30,7 +31,11 @@ void REMOTE_GatewayRxFromESP(unsigned char ch) {
static void RemoteTask ( void * pv ) {
static void RemoteTask ( void * pv ) {
unsigned char ch ;
unsigned char ch ;
BaseType_t res ;
BaseType_t res ;
unsigned char espMsg [ McuShell_DEFAULT_SHELL_BUFFER_SIZE ] = " " ;
const char espMsgPrefix [ ] = " @robot:cmd " ;
const char espMsgPostfix [ ] = " ! \r \n " ;
uint8_t saveChar = 0 ;
uint8_t writeIndex = 0 ;
( void ) pv ; /* not used */
( void ) pv ; /* not used */
#if 0 /* example making a beep */
#if 0 /* example making a beep */
BUZ_Beep ( 200 , 500 ) ;
BUZ_Beep ( 200 , 500 ) ;
@ -55,13 +60,39 @@ static void RemoteTask(void *pv) {
res = xQueueReceive ( REMOTE_RxFromESP_Queue , & ch , pdMS_TO_TICKS ( 10 ) ) ; /* wait max 10 ms */
res = xQueueReceive ( REMOTE_RxFromESP_Queue , & ch , pdMS_TO_TICKS ( 10 ) ) ; /* wait max 10 ms */
if ( res = = errQUEUE_EMPTY ) {
if ( res = = errQUEUE_EMPTY ) {
ch = ' \0 ' ; /* nothing received */
ch = ' \0 ' ; /* nothing received */
}
}
else if ( res = = pdPASS ) {
else if ( res = = pdPASS ) {
/* something was received */
/* something was received */
/* handle remote stream from ESP */
/* handle remote stream from ESP */
// uint8_t mCh = (uint8_t)ch;
// uint8_t mCh[10] = "Char: ";
// unsigned char newLine = '\n';
// McuUtility_strcat(mCh, 10, &ch);
// McuUtility_strcat(mCh, 10, &newLine);
// McuShell_SendStr(mCh, McuShell_GetStdio()->stdOut);
if ( ch = = ' @ ' ) {
if ( ch = = ' @ ' ) {
saveChar = 1 ;
writeIndex = 0 ;
BUZ_Beep ( 200 , 500 ) ;
BUZ_Beep ( 200 , 500 ) ;
}
}
if ( saveChar = = 1 ) {
espMsg [ writeIndex + + ] = ch ;
}
if ( ch = = ' ! ' & & saveChar = = 1 ) {
saveChar = 0 ;
McuShell_SendStr ( espMsg , McuShell_GetStdio ( ) - > stdOut ) ;
McuShell_SendStr ( ( uint8_t * ) " okok. \r \n " , McuShell_GetStdio ( ) - > stdOut ) ;
if ( McuUtility_strncmp ( espMsg , espMsgPrefix , sizeof ( espMsgPrefix ) - 1 ) = = 0 ) { /* check prefix */
unsigned char recCmd [ 32 ] = { 0 } ;
memmove ( recCmd , espMsg [ 11 ] , writeIndex ) ;
McuShell_SendStr ( recCmd , McuShell_GetStdio ( ) - > stdOut ) ;
}
} else if ( writeIndex = = McuShell_DEFAULT_SHELL_BUFFER_SIZE & & saveChar = = 1 ) {
saveChar = 0 ;
McuShell_SendStr ( espMsg , McuShell_GetStdio ( ) - > stdOut ) ;
McuShell_SendStr ( ( uint8_t * ) " Error in cmd. \r \n " , McuShell_GetStdio ( ) - > stdOut ) ;
}
}
}
}
}
}
}