Kashish Haresh Shah / Mbed 2 deprecated HXCClientShield

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
kashish_mbed
Date:
Tue Apr 13 22:04:32 2021 +0000
Parent:
1:d4df183e5c12
Commit message:
Provisioning Cmd process(Not Working)

Changed in this revision

Driver/CmdProcess.c Show annotated file Show diff for this revision Revisions of this file
Driver/CmdProcess.h Show annotated file Show diff for this revision Revisions of this file
Driver/debug.c Show annotated file Show diff for this revision Revisions of this file
LoRa/hxc_client.c Show annotated file Show diff for this revision Revisions of this file
LoRa/hxc_client.h Show annotated file Show diff for this revision Revisions of this file
LoRa/lora_driver.c Show annotated file Show diff for this revision Revisions of this file
LoRa/lora_driver.h Show annotated file Show diff for this revision Revisions of this file
lora_conf.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Driver/CmdProcess.c	Thu Apr 01 19:03:45 2021 +0000
+++ b/Driver/CmdProcess.c	Tue Apr 13 22:04:32 2021 +0000
@@ -1,22 +1,22 @@
 /* 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 = millis();
+    uint32_t timer = HAL_GetTick();
     uint32_t timeout = 5000;
 //    static bool inRS485TestMode = false;
 //    static bool inTriggerMode = false;
-    char recv;
-    char substr[3];
+//    char recv;
+//    char substr[3];
 //    uint hex;
-    uint8_t subStrIdx = 0;
-    uint8_t bytesIdx = 0;
-    uint8_t port = 0;
+//    uint8_t subStrIdx = 0;
+//    uint8_t bytesIdx = 0;
+//    uint8_t port = 0;
 //    sInputConfig_t config;
 //    uint8_t bytes[40];
 //    bool valid = false;
@@ -24,7 +24,7 @@
     while(1){
         switch(state){
             case 0:
-                if( millis() - timer > timeout ){
+                if( HAL_GetTick() - timer > timeout ){
 //                  DBG_PRINTF("Enter Command Mode Timeout... \n\r");
                     return;
                 }
@@ -42,7 +42,7 @@
                             DBG_PRINTF("Entering Command Mode... \n\r");
                             state = 1;
                             timeout = 30000;
-                            HXCA_init(&LoraConfigParam);
+//                            Lora_init(&LoraConfigParam, &LoraDriverParam);
                         }
                     }
                     else
@@ -52,14 +52,15 @@
                 }
                 break;
             case 1:
-                if( millis() - timer > timeout )
+                if( HAL_GetTick() - timer > timeout )
                 {
                     DBG_PRINTF("Command Mode Timeout... \n\r");
-                    state = 2;
+                    return;
+                    //state = 2;
                 }
                 if(Debug_Read_Char(&c))
                 {
-                    timer = millis ();
+                    timer = HAL_GetTick();
                     if(c == '\n' || c == '\r')
                     {
                         buf[index] = '\0';
--- a/Driver/CmdProcess.h	Thu Apr 01 19:03:45 2021 +0000
+++ b/Driver/CmdProcess.h	Tue Apr 13 22:04:32 2021 +0000
@@ -3,12 +3,17 @@
 
 /* Includes ------------------------------------------------------------------*/
 #include "debug.h"
+//#include "lora_driver.h"
 //#include "hxc-api.h"
-#include "lora_conf.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" {
--- a/Driver/debug.c	Thu Apr 01 19:03:45 2021 +0000
+++ b/Driver/debug.c	Tue Apr 13 22:04:32 2021 +0000
@@ -163,8 +163,8 @@
 
 uint8_t Debug_Read_Char(char * c)
 {
-	if(HW_UART_IsNewCharReceived(&usart2)){
-		  HW_UART_GetNewChar(&usart2, c);
+	if(HW_UART_Modem_IsNewCharReceived()){
+		  HW_UART_Modem_GetNewChar();
 //		  DBG_PRINTF("Debug RX %c \n\r",*c);
 		  return 1;
 	}
@@ -173,7 +173,7 @@
 
 void Debug_Reset_Input_Buffer(void)
 {
-	HW_UART_ResetBuffer(&usart2);
+	HW_UART_ResetBuffer();
 }
 
 /**
--- a/LoRa/hxc_client.c	Thu Apr 01 19:03:45 2021 +0000
+++ b/LoRa/hxc_client.c	Tue Apr 13 22:04:32 2021 +0000
@@ -51,17 +51,7 @@
 /* Includes ------------------------------------------------------------------*/
 #include <stdbool.h>
 #include <stdint.h>
-#include <stdarg.h>
-#include <string.h>
-#include "hw_usart.h"
-#include "utilities.h"
-#include "tiny_vsnprintf.h"
 #include "hxc_client.h"
-#include "hw_conf.h"
-#include "delay.h"
-#include "time_server.h"
-#include "hw_gpio.h"
-
 
 /* Private macro -------------------------------------------------------------*/
 #define AT_VPRINTF(...)         at_cmd_vprintf(__VA_ARGS__)
--- a/LoRa/hxc_client.h	Thu Apr 01 19:03:45 2021 +0000
+++ b/LoRa/hxc_client.h	Tue Apr 13 22:04:32 2021 +0000
@@ -54,6 +54,15 @@
 /* Includes ------------------------------------------------------------------*/
 #include<stdint.h>
 #include<stdbool.h>
+#include <stdarg.h>
+#include <string.h>
+#include "hw_usart.h"
+#include "utilities.h"
+#include "tiny_vsnprintf.h"
+#include "hw_conf.h"
+#include "delay.h"
+#include "time_server.h"
+#include "hw_gpio.h"
 
 /* Typedefs ------------------------------------------------------------------*/
 /*
--- a/LoRa/lora_driver.c	Thu Apr 01 19:03:45 2021 +0000
+++ b/LoRa/lora_driver.c	Tue Apr 13 22:04:32 2021 +0000
@@ -43,15 +43,7 @@
   ******************************************************************************
   */
 /* Includes ------------------------------------------------------------------*/
-#include <stdio.h>
-#include "hxc_client.h"
-#include "debug.h"
-#include "stm32l0xx_nucleo.h"
-#include "time_server.h"
 #include "lora_driver.h"
-#include "tiny_sscanf.h"
-#include "utilities.h"
-#include "hxcclient_bsp.h"
 
 /* Private Macros ------------------------------------------------------------*/
 #define JOIN_SEND_DELAY_MAX   (10000U) // Randomization range - 10s
@@ -61,8 +53,8 @@
 #define REJOIN_TIME           (1 * 60 * 60 * 1000U) // 1 hour
 
 /* Private global variables --------------------------------------------------*/
-static sLoraConfig_t *LoraConfigParam;
-static sLoraDriverParam_t *LoraDriverParam;
+sLoraConfig_t *LoraConfigParam;
+sLoraDriverParam_t *LoraDriverParam;
 static volatile eDeviceState_t DeviceState = CLIENT_INIT;
 
 static TimerEvent_t JoinRequestTimer;
--- a/LoRa/lora_driver.h	Thu Apr 01 19:03:45 2021 +0000
+++ b/LoRa/lora_driver.h	Tue Apr 13 22:04:32 2021 +0000
@@ -52,6 +52,14 @@
 
 /* Exported define -----------------------------------------------------------*/
 #include <stdint.h>
+#include <stdio.h>
+#include "hxc_client.h"
+#include "debug.h"
+#include "stm32l0xx_nucleo.h"
+#include "time_server.h"
+#include "tiny_sscanf.h"
+#include "utilities.h"
+#include "hxcclient_bsp.h"
 #define MAX_PAYLOAD_SIZE   64U
 
 /* Exported types ------------------------------------------------------------*/
@@ -115,7 +123,7 @@
 uint16_t Lora_getFwVersion(void);
 uint8_t Lora_getBatteryLevel(void);
 void Lora_updateUplinkRate(uint32_t time_s);
-
+void Lora_printDevEui(void);
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
--- a/lora_conf.h	Thu Apr 01 19:03:45 2021 +0000
+++ b/lora_conf.h	Tue Apr 13 22:04:32 2021 +0000
@@ -75,7 +75,7 @@
     DW_UPLINK_RATE,
 }eDownlinkType;
 
-static sLoraConfig_t LoraConfigParam =
+sLoraConfig_t LoraConfigParam =
 {
     .JoinMode  = OTAA,
     .AdrStatus = ADR_OFF,
@@ -85,7 +85,7 @@
     .AppKey    = "CDF5E6547CF354542335DCAEB657DBDF"
 };
 
-static sLoraDriverParam_t LoraDriverParam =
+sLoraDriverParam_t LoraDriverParam =
 {
     .UplinkCycle     = UPLINK_CYCLE,
     .UplinkHandler   = GetSensorData,
--- a/main.cpp	Thu Apr 01 19:03:45 2021 +0000
+++ b/main.cpp	Tue Apr 13 22:04:32 2021 +0000
@@ -46,7 +46,7 @@
 #include "hw.h"
 #include "hxcclient_bsp.h"
 #include "lora_conf.h"
-
+#include "CmdProcess.h"
 /* Variables -----------------------------------------------------------------*/
 //Flag to indicate if the MCU is Initialized
 static bool McuInitialized = false;
@@ -60,8 +60,8 @@
     HW_Init();
     
     DBG_PRINTF("HXC900-NucleoL053R8 Demo Application\r\n");    
-    Lora_init(&LoraConfigParam, &LoraDriverParam);
-
+//    Lora_init(&LoraConfigParam, &LoraDriverParam);
+    CmdModeProcess();
     while(1) 
     {
         Lora_fsm();