Ver Fonte

send answer to transport layer protocol by switching the write function to transport layer protocol

Fischer, Simon há 3 anos atrás
pai
commit
c3d2f94190
1 ficheiros alterados com 8 adições e 4 exclusões
  1. 8 4
      src/shellmatta.c

+ 8 - 4
src/shellmatta.c

@@ -450,13 +450,12 @@ shellmatta_retCode_t shellmatta_processData(shellmatta_handle_t     handle,
                 /* handling of transport layer fsm */
                 ret = shellmatta_handle_transport_fsm(data);
                 
+                /* crc error handling */
                 if (SHELLMATTA_ERROR == ret)
                 {
-                    // TODO: Better error handling
-                    /* error in this case means crc error */
-                    utils_terminateInput(inst);
                     shellmatta_reset_transport();
-                    shellmatta_printf(handle, "crc error\r\n");
+                    shellmatta_printf(handle, "crc error");
+                    utils_terminateInput(inst);
                     return SHELLMATTA_OK;
                 }
 
@@ -465,7 +464,12 @@ shellmatta_retCode_t shellmatta_processData(shellmatta_handle_t     handle,
                 if (transportLayerInst.state == STATE_PROCESS_PAYLOAD)
                 {
                     /* recursive call with complete payload */
+                    // TODO: replace inst->write function pointer with transport layer write function
+                    transportLayerInst.originalWrite = inst->write;
+                    inst->write = shellmatta_write_transport;
                     shellmatta_processData(handle, payloadBuffer, payloadLength);
+                    // TODO: set back inst->write function pointer to original
+                    inst->write = transportLayerInst.originalWrite;
                     shellmatta_handle_transport_fsm(data);
                     return SHELLMATTA_OK;
                 }