HXC Client Shield Repository.

Dependencies:   mbed

Revision:
3:5e1a54378107
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Driver/CmdProcess.c	Mon Apr 19 17:43:09 2021 +0000
@@ -0,0 +1,85 @@
+/* Includes ------------------------------------------------------------------*/
+#include "CmdProcess.h"
+//#include "lora_conf.h"
+void CmdModeProcess(void) {
+    char c = 0;
+    char buf[256];
+    uint8_t index = 0;
+    uint8_t state = 0;
+    int16_t size = 0;
+    uint32_t timer = HAL_GetTick();
+    uint32_t timeout = 5000;
+//    static bool inRS485TestMode = false;
+//    static bool inTriggerMode = false;
+//    char recv;
+//    char substr[3];
+//    uint hex;
+//    uint8_t subStrIdx = 0;
+//    uint8_t bytesIdx = 0;
+//    uint8_t port = 0;
+//    sInputConfig_t config;
+//    uint8_t bytes[40];
+//    bool valid = false;
+
+    while(1){
+        switch(state){
+            case 0:
+                if( HAL_GetTick() - timer > timeout ){
+//                  DBG_PRINTF("Enter Command Mode Timeout... \n\r");
+                    return;
+                }
+                if(Debug_Read_Char(&c))
+                {
+                    if(c == '\n' || c == '\r')
+                    {
+                        buf[index] = '\0';
+                        index = 0;
+                        Debug_Reset_Input_Buffer();
+                        //                        DBG_PRINTF("Debug RX Cmd %s \n\r",buf);
+
+                        if(strncmp("ENTER_CMD_MODE", buf , 14) == 0)
+                        {
+                            DBG_PRINTF("Entering Command Mode... \n\r");
+                            state = 1;
+                            timeout = 30000;
+//                            Lora_init(&LoraConfigParam, &LoraDriverParam);
+                        }
+                    }
+                    else
+                    {
+                        buf[index++] = c;
+                    }
+                }
+                break;
+            case 1:
+                if( HAL_GetTick() - timer > timeout )
+                {
+                    DBG_PRINTF("Command Mode Timeout... \n\r");
+                    return;
+                    //state = 2;
+                }
+                if(Debug_Read_Char(&c))
+                {
+                    timer = HAL_GetTick();
+                    if(c == '\n' || c == '\r')
+                    {
+                        buf[index] = '\0';
+                        size = index;
+                        index = 0;
+                        Debug_Reset_Input_Buffer();
+                        //                    DBG_PRINTF("Debug RX Cmd %s \n\r",buf);
+
+                        if (strncmp("READ_DEV_EUI", buf , 12) == 0)
+                        {
+                            Lora_printDevEui();
+                        }
+                    }
+                    else
+                    {
+                      buf[index++] = c;
+                    }
+                }
+                break;
+        }
+    }
+}
\ No newline at end of file