diff options
Diffstat (limited to 'Software/Embedded_SW/Embedded/Communication')
3 files changed, 48 insertions, 5 deletions
diff --git a/Software/Embedded_SW/Embedded/Communication/Connection.c b/Software/Embedded_SW/Embedded/Communication/Connection.c index aa0db0ea9..c7077124c 100644 --- a/Software/Embedded_SW/Embedded/Communication/Connection.c +++ b/Software/Embedded_SW/Embedded/Communication/Connection.c @@ -139,7 +139,7 @@ void DisconnectionRequest(MessageContainer* requestContainer) int KeepAliveOneSecondCounter = 0; #define KEEPALIVE_COMMUNICATION_ABORT_LIMIT 10 bool KeepAliveActive = false; -bool keepalivetest = false; +bool keepalivetest = true; void KeepAliveRequestFunc(MessageContainer* requestContainer) { MessageContainer responseContainer; @@ -158,12 +158,50 @@ void KeepAliveRequestFunc(MessageContainer* requestContainer) SendChars((char*)container_buffer, container_size); //keep_alive_request__free_unpacked(request,NULL); } + +int KARequestId = 0x01010101; +char KARequestToken[36+1]; +void KeepAliveResponseFunc(MessageContainer* requestContainer) +{ + //KeepAliveRequest* request = + KeepAliveResponse *response = keep_alive_response__unpack(NULL, requestContainer->data.len, requestContainer->data.data); + if (strcmp(requestContainer->token,KARequestToken)==0) + { + if (keepalivetest == false) + KeepAliveOneSecondCounter = 0; + KeepAliveActive = true; + //Report("keepalive response received",__FILE__,__LINE__,KARequestId,RpWarning,msec_millisecondCounter, 0); + } + keep_alive_response__free_unpacked(response,NULL); +} + +void KeepAliveRequest1Second(void) +{ + MessageContainer responseContainer; + + KeepAliveResponse request = KEEP_ALIVE_REQUEST__INIT; + + strcpy(KARequestToken,"Happy days are coming to us, soon"); + memcpy(&KARequestToken[32],&KARequestId,sizeof(KARequestId)); + KARequestId++; + //Report("keepalive request sent",__FILE__,__LINE__,KARequestId,RpWarning,msec_millisecondCounter, 0); + + if (keepalivetest == false) + KeepAliveOneSecondCounter = 0; + //KeepAliveActive = true; + responseContainer = createContainer(MESSAGE_TYPE__KeepAliveRequest, KARequestToken, true, &request, &keep_alive_request__pack, &keep_alive_request__get_packed_size); + //------------------------------------------------------------------------------------------- + uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer)); + size_t container_size = message_container__pack(&responseContainer, container_buffer); + SendChars((char*)container_buffer, container_size); +} void KeepAliveOneSecondCall(void) { - if (KeepAliveActive == false) - return; if (FileUploadGetState()==false) return; + KeepAliveRequest1Second(); + if (KeepAliveActive == false) + return; KeepAliveOneSecondCounter++; if (KeepAliveOneSecondCounter > (KEEPALIVE_COMMUNICATION_ABORT_LIMIT/2)) @@ -181,7 +219,7 @@ void KeepAliveOneSecondCall(void) JobStopReporting(); //AlarmHandlingStop(); //CommunicationMailboxFlush(); - keepalivetest = false; + //keepalivetest = false; //USBCDCD_init(); USBCDCD_Reinit(); //UART_ResetBuffers(); diff --git a/Software/Embedded_SW/Embedded/Communication/Connection.h b/Software/Embedded_SW/Embedded/Communication/Connection.h index 8089cd82f..c0a31344f 100644 --- a/Software/Embedded_SW/Embedded/Communication/Connection.h +++ b/Software/Embedded_SW/Embedded/Communication/Connection.h @@ -12,6 +12,7 @@ void ConnectionRequest(MessageContainer* requestContainer); void DisconnectionRequest(MessageContainer* requestContainer); void KeepAliveRequestFunc(MessageContainer* requestContainer); +void KeepAliveResponseFunc(MessageContainer* requestContainer); void KeepAliveOneSecondCall(void); extern int KeepAliveOneSecondCounter; diff --git a/Software/Embedded_SW/Embedded/Communication/Container.c b/Software/Embedded_SW/Embedded/Communication/Container.c index 64f06a8c5..b14efbd55 100644 --- a/Software/Embedded_SW/Embedded/Communication/Container.c +++ b/Software/Embedded_SW/Embedded/Communication/Container.c @@ -42,6 +42,7 @@ #include "Modules/General/process.h" #include "Modules/Thread/Thread_ex.h" #include "Modules/Ids/Ids_ex.h" +#include "Modules/Ifs/Ifs.h" #include "Common/SWUpdate/FileSystem.h" #include "Common/SWUpdate/FirmwareUpgrade.h" @@ -142,7 +143,7 @@ void receive_callback(char* buffer, size_t length) if (requestContainer == NULL) return; #ifndef DISPESER_TEST - if ((requestContainer->type>= MESSAGE_TYPE__StartDiagnosticsRequest)&&(requestContainer->type != MESSAGE_TYPE__KeepAliveRequest)) //user action resets the idle counter + if ((requestContainer->type>= MESSAGE_TYPE__StartDiagnosticsRequest)&&(requestContainer->type != MESSAGE_TYPE__KeepAliveRequest)&&(requestContainer->type != MESSAGE_TYPE__KeepAliveResponse)) //user action resets the idle counter { ReportWithPackageFilter(CommFilter,"Message received", __FILE__,__LINE__,requestContainer->type, RpMessage,length, 0); } @@ -411,6 +412,9 @@ void receive_callback(char* buffer, size_t length) case MESSAGE_TYPE__KeepAliveRequest: KeepAliveRequestFunc(requestContainer); break; + case MESSAGE_TYPE__KeepAliveResponse: + KeepAliveResponseFunc(requestContainer); + break; case MESSAGE_TYPE__FileUploadRequest: FileUploadRequestFunc(requestContainer); break; |
