aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Communication/Connection.c
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Embedded_SW/Embedded/Communication/Connection.c')
-rw-r--r--Software/Embedded_SW/Embedded/Communication/Connection.c46
1 files changed, 42 insertions, 4 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();