|
|
|
|
@ -17,7 +17,7 @@ |
|
|
|
|
#include "McuUtility.h" |
|
|
|
|
#include "challenge_com.h" |
|
|
|
|
#include "challenge_nvs.h" |
|
|
|
|
|
|
|
|
|
#include "led.h" |
|
|
|
|
|
|
|
|
|
/* LOCAL Var */ |
|
|
|
|
/* identifies robot Mode for the challenge: true = robot is stationary, false = robot is moveable */ |
|
|
|
|
@ -28,7 +28,7 @@ static TaskHandle_t appTaskHandle; /* task handle */ |
|
|
|
|
|
|
|
|
|
/* local function declarations */ |
|
|
|
|
static void Challenge_App_SetRobotMode(bool modeStationary, bool storeToNvs); |
|
|
|
|
|
|
|
|
|
static void Challenge_App_RebootEsp32(void); |
|
|
|
|
|
|
|
|
|
static void appTask(void *pv){ |
|
|
|
|
/*Task argument not used
|
|
|
|
|
@ -76,7 +76,9 @@ BaseType_t res; |
|
|
|
|
void Challenge_App_Init(void){ |
|
|
|
|
Challenge_Nvs_Init(); |
|
|
|
|
|
|
|
|
|
Challenge_Nvs_GetRobotModeFromNVS(&_robotModeStationary); |
|
|
|
|
bool retrievedMode = false; |
|
|
|
|
Challenge_Nvs_GetRobotModeFromNVS(&retrievedMode); |
|
|
|
|
Challenge_App_SetRobotMode(retrievedMode, false); // do not store to NVS, not required
|
|
|
|
|
|
|
|
|
|
res = xTaskCreate(appTask, "ChallengeAppTask", 4096/sizeof(StackType_t), (void*)"ARG_0", tskIDLE_PRIORITY, &appTaskHandle); |
|
|
|
|
if(res != pdPASS){ |
|
|
|
|
@ -91,11 +93,23 @@ bool Challenge_App_GetRobotMode(void){ |
|
|
|
|
static void Challenge_App_SetRobotMode(bool modeStationary, bool storeToNvs){ |
|
|
|
|
_robotModeStationary = modeStationary; |
|
|
|
|
ESP_LOGI(TAG, "Changed robot mode to %s", _robotModeStationary?(unsigned char*)"stationary":(unsigned char*)"mobile"); |
|
|
|
|
// update led behavior to be able to differentiate the robots
|
|
|
|
|
if(modeStationary){ |
|
|
|
|
LED_SetOnOffTime(5000, 1000); |
|
|
|
|
} else{ |
|
|
|
|
LED_SetOnOffTime(500, 500); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(storeToNvs){ |
|
|
|
|
Challenge_Nvs_StoreRobotModeToNVS(modeStationary); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void Challenge_App_RebootEsp32(void){ |
|
|
|
|
fflush(stdout); |
|
|
|
|
esp_restart(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*********/ |
|
|
|
|
/* SHELL */ |
|
|
|
|
/*********/ |
|
|
|
|
@ -111,6 +125,7 @@ static uint8_t PrintHelp(const McuShell_StdIOType *io) { |
|
|
|
|
McuShell_SendHelpStr((unsigned char*)" help|status", (unsigned char*)"Shows Challenge help or status\r\n", io->stdOut); |
|
|
|
|
McuShell_SendHelpStr((unsigned char*)" setMode s(tationary)", (unsigned char*)"Sets the mode of this robot to stationary\r\n", io->stdOut); |
|
|
|
|
McuShell_SendHelpStr((unsigned char*)" setMode m(mobile)", (unsigned char*)"Sets the mode of this robot to mobile\r\n", io->stdOut); |
|
|
|
|
McuShell_SendHelpStr((unsigned char*)" reboot", (unsigned char*)"Reboots the ESP32\r\n", io->stdOut); |
|
|
|
|
return ERR_OK; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -129,7 +144,10 @@ uint8_t Challenge_ParseShellCommand(const unsigned char* cmd, bool *handled, con |
|
|
|
|
McuUtility_strcmp((char*)cmd, (char*)"challenge setMode m")==0 ) { |
|
|
|
|
*handled = TRUE; |
|
|
|
|
Challenge_App_SetRobotMode(false, true); // set mobile
|
|
|
|
|
} |
|
|
|
|
}else if (McuUtility_strcmp((char*)cmd, (char*)"challenge reboot")==0) { |
|
|
|
|
*handled = TRUE; |
|
|
|
|
Challenge_App_RebootEsp32(); |
|
|
|
|
} |
|
|
|
|
return ERR_OK; |
|
|
|
|
} |
|
|
|
|
#endif /* PL_CONFIG_USE_SHELL */ |
|
|
|
|
|