From c0a6cb5a529f2c5cfb9bec942e583f29f79cf5fe Mon Sep 17 00:00:00 2001 From: Jonas Arnold Date: Mon, 5 Dec 2022 19:00:20 +0100 Subject: [PATCH] implemented function and shell command to set the mode --- ADIS_ESP32_Eclipse/main/challenge_app.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/ADIS_ESP32_Eclipse/main/challenge_app.c b/ADIS_ESP32_Eclipse/main/challenge_app.c index 1fab1df..e43126f 100644 --- a/ADIS_ESP32_Eclipse/main/challenge_app.c +++ b/ADIS_ESP32_Eclipse/main/challenge_app.c @@ -14,11 +14,11 @@ #include "wifi.h" /* LOCAL Var */ -// identifies robot Mode for the challenge: true = robot is stationary, false = robot is moveable +/* identifies robot Mode for the challenge: true = robot is stationary, false = robot is moveable */ static bool robotModeStationary = false; -// task handle -static TaskHandle_t appTaskHandle; +static TaskHandle_t appTaskHandle; /* task handle */ +#define TAG "CHALLENGE_APP" /* tag for logging with ESP_LOG */ static void appTask(void *pv){ @@ -61,10 +61,15 @@ BaseType_t res; void Challenge_App_Init(void){ res = xTaskCreate(appTask, "ChallengeAppTask", 4096/sizeof(StackType_t), (void*)"ARG_0", tskIDLE_PRIORITY, &appTaskHandle); if(res != pdPASS){ - printf("creating appTask failed!\r\n"); + ESP_LOGE(TAG, "Creating appTask failed"); } } +static void Challenge_App_SetMode(bool modeStationary){ + robotModeStationary = modeStationary; + ESP_LOGI(TAG, "Changed robot mode to %s", robotModeStationary?(unsigned char*)"stationary":(unsigned char*)"mobile"); +} + /*********/ /* SHELL */ /*********/ @@ -89,13 +94,15 @@ uint8_t Challenge_ParseCommand(const unsigned char* cmd, bool *handled, const Mc *handled = TRUE; return PrintStatus(io); } - /*else if (McuUtility_strcmp((char*)cmd, (char*)"led suspend")==0) { + else if (McuUtility_strcmp((char*)cmd, (char*)"challenge setMode stationary")==0 || + McuUtility_strcmp((char*)cmd, (char*)"challenge setMode s")==0) { *handled = TRUE; - LED_Suspend(); - } else if (McuUtility_strcmp((char*)cmd, (char*)"led resume")==0) { + Challenge_App_SetMode(true); // set stationary + } else if (McuUtility_strcmp((char*)cmd, (char*)"challenge setMode mobile")==0 || + McuUtility_strcmp((char*)cmd, (char*)"challenge setMode m")==0 ) { *handled = TRUE; - LED_Resume(); - }*/ + Challenge_App_SetMode(false); // set mobile + } return ERR_OK; } #endif /* PL_CONFIG_USE_SHELL */