JSON parsing not yet implemented, improved main workflow for challenge_app, updated CMakeListsmain
parent
e38ca71a99
commit
6b7d7e0635
@ -0,0 +1,66 @@ |
||||
/*
|
||||
* challenge_com.c |
||||
* |
||||
* Created on: 05.12.2022 |
||||
* Author: jonas |
||||
*/ |
||||
|
||||
#include "stdbool.h" |
||||
#include "challenge_app.h" |
||||
|
||||
#define TAG "CHALLENGE_COM" /* tag for logging with ESP_LOG */ |
||||
|
||||
static void Challenge_Com_ParseMqtt(void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data){ |
||||
/* INFO
|
||||
* TOPIC: event->topic |
||||
* TOPIC LENGTH: event->topic_len |
||||
* DATA: event->data |
||||
* DATA LENGTH: event->data_len |
||||
* CLIENT: event->client |
||||
*/ |
||||
|
||||
esp_mqtt_event_handle_t event = event_data; |
||||
bool handled = false; |
||||
|
||||
// check if event id is MQTT_EVENT_DATA => break if not
|
||||
if((esp_mqtt_event_id_t)event_id != MQTT_EVENT_DATA) { |
||||
ESP_LOGE(TAG, "Wrong data received. Can only handle MQTT_EVENT_DATA (event id %i). But received event id: %i", MQTT_EVENT_DATA, (esp_mqtt_event_id_t)event_id); |
||||
return; |
||||
} |
||||
|
||||
/* check topic and call related command if allowed by robot mode */ |
||||
/* stationary robot allowed commands */ |
||||
if(Challenge_App_GetRobotMode() == true) { |
||||
if(McuUtility_strcmp((char*)event->topic, MQTT_TOPIC_SF_CONFIG_SETUP)==0){ |
||||
handled = true; |
||||
// TODO JSON PARSER
|
||||
uint8_t setupId = 0; |
||||
uint8_t hwId = 1; |
||||
SplitFlap_Wrapper_SetHardwareIdentifier(setupId, hwId); |
||||
} else if(McuUtility_strcmp((char*)event->topic, MQTT_TOPIC_SF_INITALL)==0){ |
||||
handled = true; |
||||
SplitFlap_Wrapper_MoveAllToZeroPosition(); |
||||
} else if(McuUtility_strcmp((char*)event->topic, MQTT_TOPIC_SF_DISPLAY)==0){ |
||||
handled = true; |
||||
// TODO JSON PARSER
|
||||
char message[] = "TST"; |
||||
SplitFlap_Wrapper_Display(message); |
||||
} |
||||
} |
||||
/* mobile robot allowed commands */ |
||||
else{ |
||||
|
||||
} |
||||
|
||||
/* both robot modes allowed commands */ |
||||
|
||||
|
||||
|
||||
if(handled == false) |
||||
{ |
||||
ESP_LOGE(TAG, "Received data could not be handled. Topic was %s", event->topic); |
||||
} |
||||
|
||||
return; |
||||
} |
||||
|
||||
@ -0,0 +1,19 @@ |
||||
/*
|
||||
* challenge_communication.h |
||||
* |
||||
* Created on: 05.12.2022 |
||||
* Author: jonas |
||||
*/ |
||||
|
||||
#ifndef MAIN_CHALLENGE_COM_H_ |
||||
#define MAIN_CHALLENGE_COM_H_ |
||||
|
||||
/* TOPICS */ |
||||
const char MQTT_TOPIC_SF_DISPLAY[] = "/splitFlap/cmd/display/"; |
||||
const char MQTT_TOPIC_SF_INITALL[] = "/splitFlap/cmd/init/"; |
||||
const char MQTT_TOPIC_SF_CONFIG_SETUP[] = "/splitFlap/config/setup/"; |
||||
|
||||
|
||||
|
||||
|
||||
#endif /* MAIN_CHALLENGE_COM_H_ */ |
||||
Loading…
Reference in new issue