fixed erronius behaviour with "response to response" in communication

protocol, additional handler needed
This commit is contained in:
Bogdan Pilyugin 2023-10-12 14:43:09 +02:00
parent 9d743f3044
commit b140b22354
2 changed files with 15 additions and 1 deletions

View File

@ -41,6 +41,7 @@ typedef enum
{ {
SYS_OK_DATA = 0, SYS_OK_DATA = 0,
SYS_OK, SYS_OK,
SYS_GOT_RESPONSE_MESSAGE,
SYS_ERROR_WRONG_JSON_FORMAT = 200, SYS_ERROR_WRONG_JSON_FORMAT = 200,
SYS_ERROR_PARSE_DATA, SYS_ERROR_PARSE_DATA,

View File

@ -248,8 +248,10 @@ static sys_error_code DataHeaderParser(data_message_t *MSG)
if (result.elements == 1) if (result.elements == 1)
{ {
MSG->parsedData.msgType = atoi((char*) result.pValue); MSG->parsedData.msgType = atoi((char*) result.pValue);
if (MSG->parsedData.msgType > 2 || MSG->parsedData.msgType < 1) if (MSG->parsedData.msgType > DATA_MESSAGE_TYPE_RESPONSE || MSG->parsedData.msgType < DATA_MESSAGE_TYPE_COMMAND)
return SYS_ERROR_PARSE_MSGTYPE; return SYS_ERROR_PARSE_MSGTYPE;
if (MSG->parsedData.msgType == DATA_MESSAGE_TYPE_RESPONSE)
return SYS_GOT_RESPONSE_MESSAGE;
} }
else else
return SYS_ERROR_PARSE_MSGTYPE; return SYS_ERROR_PARSE_MSGTYPE;
@ -298,6 +300,17 @@ esp_err_t ServiceDataHandler(data_message_t *MSG)
else else
MSG->err_code = (int) DataHeaderParser(MSG); MSG->err_code = (int) DataHeaderParser(MSG);
if (MSG->err_code == SYS_GOT_RESPONSE_MESSAGE)
{
//ToDo Here handler of received data
#if REAST_API_DEBUG_MODE
ESP_LOGI(TAG, "Got response message with msgid=%d", MSG->parsedData.msgID);
#endif
MSG->outputDataBuffer[0] = 0x00;
MSG->outputDataLength = 0;
return ESP_OK;
}
if (MSG->err_code) if (MSG->err_code)
{ {
struct jWriteControl jwc; struct jWriteControl jwc;