Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 3:5e1a54378107, committed 2021-04-19
- Comitter:
- kashish_mbed
- Date:
- Mon Apr 19 17:43:09 2021 +0000
- Parent:
- 0:bacc6e701fb4
- Commit message:
- Successful Build file with CmdProcess Functionality
Changed in this revision
--- /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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Driver/CmdProcess.h Mon Apr 19 17:43:09 2021 +0000
@@ -0,0 +1,34 @@
+#ifndef __CMD_PROCESS_H
+#define __CMD_PROCESS_H
+
+/* Includes ------------------------------------------------------------------*/
+#include "debug.h"
+#include "lora_driver.h"
+//#include "hxc-api.h"
+//#include "lora_conf.h"
+//#include "bridge.h"
+#include "stdlib.h"
+#include "stdint.h"
+#include "limits.h"
+#include "errno.h"
+#include "time.h"
+
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Exported define -----------------------------------------------------------*/
+
+
+/* Exported types ------------------------------------------------------------*/
+
+/* Public functions ----------------------------------------------------------*/
+void CmdModeProcess(void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif
--- a/Driver/debug.c Mon Mar 29 15:37:08 2021 +0000
+++ b/Driver/debug.c Mon Apr 19 17:43:09 2021 +0000
@@ -48,6 +48,7 @@
#include <stdarg.h>
#include "hw.h"
#include "tiny_vsnprintf.h"
+#include "debug.h"
static UART_HandleTypeDef debugUart;
static char buffTx[256];
@@ -161,6 +162,21 @@
va_end(args);
}
+uint8_t Debug_Read_Char(char * c)
+{
+ if(HW_UART_Modem_IsNewCharReceived()){
+ HW_UART_Modem_GetNewChar();
+// DBG_PRINTF("Debug RX %c \n\r",*c);
+ return 1;
+ }
+ return 0;
+}
+
+void Debug_Reset_Input_Buffer(void)
+{
+ HW_UART_ResetBuffer();
+}
+
/**
* @brief Error_Handler
* @param None
--- a/Driver/debug.h Mon Mar 29 15:37:08 2021 +0000 +++ b/Driver/debug.h Mon Apr 19 17:43:09 2021 +0000 @@ -58,6 +58,7 @@ #include <string.h> #include <stdio.h> +#include <stdint.h> #include "hw_conf.h" //#include "vcom.h" /* if vcom is used for trace purpose*/ @@ -77,6 +78,8 @@ */ void Debug_UART_SendBytes(const char *format, ...); void Debug_UART_Init(void); +uint8_t Debug_Read_Char(char * c); +void Debug_Reset_Input_Buffer(void); #ifdef DEBUG
--- a/LoRa/lora_driver.c Mon Mar 29 15:37:08 2021 +0000
+++ b/LoRa/lora_driver.c Mon Apr 19 17:43:09 2021 +0000
@@ -144,7 +144,7 @@
* @Param : None
* @Retval : AT_OK or other eAtStatus_t
******************************************************************************/
-static void Lora_printDevEui(void)
+void Lora_printDevEui(void)
{
char deveui_str[25];
--- a/main.cpp Mon Mar 29 15:37:08 2021 +0000
+++ b/main.cpp Mon Apr 19 17:43:09 2021 +0000
@@ -45,8 +45,9 @@
#include "mbed.h"
#include "hw.h"
#include "hxcclient_bsp.h"
+#include "lora_driver.h"
#include "lora_conf.h"
-
+#include "CmdProcess.h"
/* Variables -----------------------------------------------------------------*/
//Flag to indicate if the MCU is Initialized
static bool McuInitialized = false;
@@ -61,7 +62,7 @@
DBG_PRINTF("HXC900-NucleoL053R8 Demo Application\r\n");
Lora_init(&LoraConfigParam, &LoraDriverParam);
-
+ CmdModeProcess();
while(1)
{
Lora_fsm();