Import of CSR's demo for SirfV. Has minor cleanup.

Dependencies:   CsrLocation mbed GPSProvider

Fork of CsrLocationDemo by jie zhao

Revision:
15:495c22f32cc6
Parent:
14:fca7e09f5b78
Child:
16:24128dedf8db
--- a/CsrLocationDemo.cpp	Mon Oct 13 06:31:17 2014 +0000
+++ b/CsrLocationDemo.cpp	Thu Oct 16 12:42:11 2014 +0000
@@ -1,32 +1,55 @@
-
 /* CsrLocation class for mbed Microcontroller
  * Copyright 2014 CSR plc
  */
 
-
 #include "mbed.h"
 #include "CsrLocation.h"
 
+#ifdef TARGET_LPC1768
+    #define PINMAP_UART_DEBUG_TX        USBTX
+    #define PINMAP_UART_DEBUG_RX        USBRX
+    #define PINMAP_UART_LOC_TX          D8
+    #define PINMAP_UART_LOC_RX          D9
+    #define PINMAP_GPIO_LOC_ONOFF       D11
+    #define PINMAP_GPIO_LOC_RESET       D12
+    #define PINMAP_GPIO_LOC_WAKEUP      D3
+    #define PINMAP_GPIO_BTN             D6
+    #define PINMAP_GPIO_TEST            D10
+    #define LOC_LED1                    LED1
+    #define LOC_LED2                    LED2
+#elif defined(TARGET_LPC1549) || defined(TARGET_NUCLEO_F103RB)
+    #define PINMAP_UART_DEBUG_TX        D1
+    #define PINMAP_UART_DEBUG_RX        D0
+    #define PINMAP_UART_LOC_TX          D8
+    #define PINMAP_UART_LOC_RX          D2
+    #define PINMAP_GPIO_LOC_ONOFF       D9
+    #define PINMAP_GPIO_LOC_RESET       D4
+    #define PINMAP_GPIO_LOC_WAKEUP      D3
+    #define PINMAP_GPIO_BTN             D5
+    #define PINMAP_GPIO_TEST            D10
+    #define LOC_LED1                    D7
+    #define LOC_LED2                    D6
+#endif // ifdef TARGET_LPC1768
+
 #define APP_DBG_PORT_BAUD       115200
 #define CSR_APP_LOG_INFO(...)   sSerialDebug.printf(__VA_ARGS__)
 
 /* appliation commands */
-typedef enum AppCmd
-{
-    APP_CMD_IDLE, 			// No special command
-    APP_CMD_HELP,			// Show the supported commands
-    APP_CMD_START,			// Start location
-    APP_CMD_STOP,			// Stop location
-    APP_CMD_PM_FULL,		// Set full power mode
-    APP_CMD_PM_PTF,			// Set low power PTF mode
-    APP_CMD_PTF_GETPOS,		// Get location immediately in low power PTF mode
-    APP_CMD_NMEA,			// proto mode is NMEA
+typedef enum AppCmd {
+    APP_CMD_IDLE,           // No special command
+    APP_CMD_HELP,           // Show the supported commands
+    APP_CMD_START,          // Start location
+    APP_CMD_STOP,           // Stop location
+    APP_CMD_PM_FULL,        // Set full power mode
+    APP_CMD_PM_PTF,         // Set low power PTF mode
+    APP_CMD_PTF_GETPOS,     // Get location immediately in low power PTF mode
+    APP_CMD_NMEA,           // proto mode is NMEA
     APP_CMD_OSP,            // proto mode is OSP
     APP_CMD_SWITCH_NMEA,    // Debug command, switch chip to NMEA protocol at 4800bps
     APP_CMD_SWITCH_OSP,     // Debug command, switch chip to NMEA protocol at 4800bps
     APP_CMD_START_FAILED,   // Process start failed case
     APP_CMD_STOP_FAILED,    // Process stop failed case
-    APP_CMD_ONOFF_ON,		// Debug command, pull onoff pin high level
+    APP_CMD_ONOFF_ON,       // Debug command, pull onoff pin high level
     APP_CMD_ONOFF_OFF,      // Debug command, pull onoff pin low level
     APP_CMD_RESET_ON,       // Debug command, pull reset pin high level
     APP_CMD_RESET_OFF,      // Debug command, pull reset pin low level
@@ -34,180 +57,164 @@
     APP_CMD_PINTEST_ON,     // Debug command, pull test pin high level
     APP_CMD_PINTEST_OFF,    // Debug command, pull test pin low level
     APP_CMD_PINTEST_OFF_ON  // Debug command, pull test pin low firstly, then pull high level
-    
-}eAppCmd;
-
+} eAppCmd;
 
 static void _AppShowCmd(void);
 static void _AppBtnPushed(void);
-static void _AppOutputCallback(uint32_t  msgId, void * const pMsgData, uint32_t msgLength);
+static void _AppOutputCallback(uint32_t msgId, void *const pMsgData, uint32_t msgLength);
 static void _AppEventCallback(eCsrLocEventType event, uint32_t data);
 static void _ConsoleRxHandler(void);
 static void _AppCmdProcess(char *pCmd);
 
-
-static int sAppCmd  = APP_CMD_IDLE;
-static ePowerMode sPwrMode = PWR_FULL;
-static eProto     sProto = PROTO_OSP;
+static int             sAppCmd  = APP_CMD_IDLE;
+static ePowerMode      sPwrMode = PWR_FULL;
+static eProto          sProto   = PROTO_OSP;
 
-static DBG_SERIAL_TYPE  sSerialDebug(PINMAP_UART_DEBUG_TX, PINMAP_UART_DEBUG_RX);
-static LOC_SERIAL_TYPE  sSerialLoc(PINMAP_UART_LOC_TX, PINMAP_UART_LOC_RX);
-static DigitalOut		sPinOnoff(PINMAP_GPIO_LOC_ONOFF);
-static DigitalOut		sPinReset(PINMAP_GPIO_LOC_RESET);
-static DigitalOut		sLedLocOn(LOC_LED1);
-static DigitalOut		sLedPosReport(LOC_LED2);
-static DigitalIn 		sWakeup(PINMAP_GPIO_LOC_WAKEUP);
-static InterruptIn 		sBtn(PINMAP_GPIO_BTN);
-static DigitalOut		sPinTest(PINMAP_GPIO_TEST);
+static DBG_SERIAL_TYPE sSerialDebug(PINMAP_UART_DEBUG_TX, PINMAP_UART_DEBUG_RX);
+static RawSerial       sSerialLoc(PINMAP_UART_LOC_TX, PINMAP_UART_LOC_RX);
+static DigitalOut      sPinOnoff(PINMAP_GPIO_LOC_ONOFF);
+static DigitalOut      sPinReset(PINMAP_GPIO_LOC_RESET);
+static DigitalOut      sLedLocOn(LOC_LED1);
+static DigitalOut      sLedPosReport(LOC_LED2);
+static DigitalIn       sWakeup(PINMAP_GPIO_LOC_WAKEUP);
+static InterruptIn     sBtn(PINMAP_GPIO_BTN);
+static DigitalOut      sPinTest(PINMAP_GPIO_TEST);
 
 int main(void)
 {
     CsrLocation  *pCsrLoc;
-	tCsrLocConfig locConfig;
 
-	sLedLocOn = 0;
-	sLedPosReport = 0;
-	sPinTest = 1;
-	sBtn.mode(PullUp);
-	sBtn.fall(&_AppBtnPushed);
-	
-	/* initialize the debug serial port */
+    sLedLocOn     = 0;
+    sLedPosReport = 0;
+    sPinTest      = 1;
+    sBtn.mode(PullUp);
+    sBtn.fall(&_AppBtnPushed);
+
+    /* initialize the debug serial port */
     sSerialDebug.baud(APP_DBG_PORT_BAUD);
     sSerialDebug.attach(&_ConsoleRxHandler);
 
-	/* initialize the CsrLocConfig */
-	locConfig.pSerialDebug 	= &sSerialDebug;
-	locConfig.pSerialLoc 	= &sSerialLoc;
-	locConfig.pPinOnoff 	= &sPinOnoff;
-	locConfig.pPinReset 	= &sPinReset;
-	locConfig.pWakeup 		= &sWakeup;
-
-	/* new the CsrLocation instance */
-    pCsrLoc = new CsrLocation(&locConfig);
-    if(pCsrLoc == NULL)
-    {
+    /* new the CsrLocation instance */
+    pCsrLoc = new CsrLocation(sSerialLoc, sPinOnoff, sPinReset, sWakeup, &sSerialDebug);
+    if (pCsrLoc == NULL) {
         CSR_APP_LOG_INFO("Failed to new csrLocation.\r\n");
         sSerialDebug.attach(NULL);
-        return -1;
+        while (true)
+            ;
     }
-    else
-    {
-        CSR_APP_LOG_INFO("Success to new csrLocation.\r\n");
-    }
+    CSR_APP_LOG_INFO("Success to new csrLocation.\r\n");
 
     /* Register output callback and event callback functions */
     pCsrLoc->CsrLocRegOutput(_AppOutputCallback, _AppEventCallback);
 
     _AppShowCmd();
 
-    while(1)
-    {
-        switch(sAppCmd)
-        {
-        case APP_CMD_HELP:
-            sAppCmd = APP_CMD_IDLE;
-            _AppShowCmd();
-            break;
-        case APP_CMD_START:
-            sAppCmd = APP_CMD_IDLE;
-            CSR_APP_LOG_INFO("start location.\r\n");
-            sLedLocOn = 1;
-            pCsrLoc->CsrLocStart(sPwrMode, sProto);
-            break;
-        case APP_CMD_STOP:
-            sAppCmd = APP_CMD_IDLE;
-            CSR_APP_LOG_INFO("stop location.\r\n");
-            sLedLocOn = 0;
-            pCsrLoc->CsrLocStop();
-            break;
-        case APP_CMD_START_FAILED:
-            sAppCmd = APP_CMD_IDLE;
-            CSR_APP_LOG_INFO("reset as start failed.\r\n");
-            sLedLocOn = 0;
-            pCsrLoc->CsrLocStop();
-            pCsrLoc->CsrLocReset();
-            break;
-        case APP_CMD_STOP_FAILED:
-            sAppCmd = APP_CMD_IDLE;
-            CSR_APP_LOG_INFO("reset as stop failed.\r\n");
-            sLedLocOn = 0;
-            pCsrLoc->CsrLocStop();
-            pCsrLoc->CsrLocReset();
-            break;
-        case APP_CMD_IDLE:
-            pCsrLoc->CsrLocUpdate();
-            break;
-        case APP_CMD_ONOFF_ON:
-            CSR_APP_LOG_INFO("onoff on.\r\n");
-            sAppCmd = APP_CMD_IDLE;
-            sPinOnoff = 1;
-            break;
-        case APP_CMD_ONOFF_OFF:
-            CSR_APP_LOG_INFO("onoff off.\r\n");
-            sAppCmd = APP_CMD_IDLE;
-            sPinOnoff = 0;
-            break;
-        case APP_CMD_RESET_ON:
-            CSR_APP_LOG_INFO("reset on.\r\n");
-            sAppCmd = APP_CMD_IDLE;
-            sPinReset = 1;
-            break;
-        case APP_CMD_RESET_OFF:
-            CSR_APP_LOG_INFO("reset off.\r\n");
-            sAppCmd = APP_CMD_IDLE;
-            sPinReset = 0;
-            break;
-        case APP_CMD_PINTEST_ON:
-            CSR_APP_LOG_INFO("test pin on.\r\n");
-            sAppCmd = APP_CMD_IDLE;
-            sPinTest = 1;
-            break;
-        case APP_CMD_PINTEST_OFF:
-            CSR_APP_LOG_INFO("test pin off.\r\n");
-            sAppCmd = APP_CMD_IDLE;
-            sPinTest = 0;
-            break;
-        case APP_CMD_PINTEST_OFF_ON:
-            CSR_APP_LOG_INFO("test pin off and high.\r\n");
-            sAppCmd = APP_CMD_IDLE;
-            sPinTest = 0;
-            wait_ms(100);
-            sPinTest = 1;
-            break;
-        case APP_CMD_WAKEUP_STATUS:
-            CSR_APP_LOG_INFO("wakeup status : %d.\r\n", sWakeup.read());
-            sAppCmd = APP_CMD_IDLE;
-        	break;
-        case APP_CMD_PTF_GETPOS:
-            CSR_APP_LOG_INFO("lpm get pos.\r\n");
-            sAppCmd = APP_CMD_IDLE;
-            pCsrLoc->CsrLocLpmGetPos();
-            break;
-        case APP_CMD_NMEA:
-            CSR_APP_LOG_INFO("select NMEA protocol.\r\n");
-            sProto = PROTO_NMEA;
-            sAppCmd = APP_CMD_IDLE;
-            break;
-        case APP_CMD_OSP:
-            CSR_APP_LOG_INFO("select OSP protocol.\r\n");
-            sProto = PROTO_OSP;
-            sAppCmd = APP_CMD_IDLE;
-            break;
-        case APP_CMD_SWITCH_NMEA:
-            CSR_APP_LOG_INFO("switch to NMEA protocol.\r\n");
-            sAppCmd = APP_CMD_IDLE;
-            pCsrLoc->CsrLocDebugSwitch2Nmea();
-            break;
-        case APP_CMD_PM_FULL:
-            CSR_APP_LOG_INFO("fpm set.\r\n");
-            sAppCmd = APP_CMD_IDLE;
-            sPwrMode = PWR_FULL;
-            break;
-        case APP_CMD_PM_PTF:
-            CSR_APP_LOG_INFO("lpm ptf set.\r\n");
-            sAppCmd = APP_CMD_IDLE;
-            sPwrMode = PWR_PTF;
-            break;
+    while (true) {
+        switch (sAppCmd) {
+            case APP_CMD_HELP:
+                sAppCmd = APP_CMD_IDLE;
+                _AppShowCmd();
+                break;
+            case APP_CMD_START:
+                sAppCmd = APP_CMD_IDLE;
+                CSR_APP_LOG_INFO("start location.\r\n");
+                sLedLocOn = 1;
+                pCsrLoc->CsrLocStart(sPwrMode, sProto);
+                break;
+            case APP_CMD_STOP:
+                sAppCmd = APP_CMD_IDLE;
+                CSR_APP_LOG_INFO("stop location.\r\n");
+                sLedLocOn = 0;
+                pCsrLoc->CsrLocStop();
+                break;
+            case APP_CMD_START_FAILED:
+                sAppCmd = APP_CMD_IDLE;
+                CSR_APP_LOG_INFO("reset as start failed.\r\n");
+                sLedLocOn = 0;
+                pCsrLoc->CsrLocStop();
+                pCsrLoc->CsrLocReset();
+                break;
+            case APP_CMD_STOP_FAILED:
+                sAppCmd = APP_CMD_IDLE;
+                CSR_APP_LOG_INFO("reset as stop failed.\r\n");
+                sLedLocOn = 0;
+                pCsrLoc->CsrLocStop();
+                pCsrLoc->CsrLocReset();
+                break;
+            case APP_CMD_IDLE:
+                pCsrLoc->CsrLocUpdate();
+                break;
+            case APP_CMD_ONOFF_ON:
+                CSR_APP_LOG_INFO("onoff on.\r\n");
+                sAppCmd   = APP_CMD_IDLE;
+                sPinOnoff = 1;
+                break;
+            case APP_CMD_ONOFF_OFF:
+                CSR_APP_LOG_INFO("onoff off.\r\n");
+                sAppCmd   = APP_CMD_IDLE;
+                sPinOnoff = 0;
+                break;
+            case APP_CMD_RESET_ON:
+                CSR_APP_LOG_INFO("reset on.\r\n");
+                sAppCmd   = APP_CMD_IDLE;
+                sPinReset = 1;
+                break;
+            case APP_CMD_RESET_OFF:
+                CSR_APP_LOG_INFO("reset off.\r\n");
+                sAppCmd   = APP_CMD_IDLE;
+                sPinReset = 0;
+                break;
+            case APP_CMD_PINTEST_ON:
+                CSR_APP_LOG_INFO("test pin on.\r\n");
+                sAppCmd  = APP_CMD_IDLE;
+                sPinTest = 1;
+                break;
+            case APP_CMD_PINTEST_OFF:
+                CSR_APP_LOG_INFO("test pin off.\r\n");
+                sAppCmd  = APP_CMD_IDLE;
+                sPinTest = 0;
+                break;
+            case APP_CMD_PINTEST_OFF_ON:
+                CSR_APP_LOG_INFO("test pin off and high.\r\n");
+                sAppCmd  = APP_CMD_IDLE;
+                sPinTest = 0;
+                wait_ms(100);
+                sPinTest = 1;
+                break;
+            case APP_CMD_WAKEUP_STATUS:
+                CSR_APP_LOG_INFO("wakeup status : %d.\r\n", sWakeup.read());
+                sAppCmd = APP_CMD_IDLE;
+                break;
+            case APP_CMD_PTF_GETPOS:
+                CSR_APP_LOG_INFO("lpm get pos.\r\n");
+                sAppCmd = APP_CMD_IDLE;
+                pCsrLoc->CsrLocLpmGetPos();
+                break;
+            case APP_CMD_NMEA:
+                CSR_APP_LOG_INFO("select NMEA protocol.\r\n");
+                sProto  = PROTO_NMEA;
+                sAppCmd = APP_CMD_IDLE;
+                break;
+            case APP_CMD_OSP:
+                CSR_APP_LOG_INFO("select OSP protocol.\r\n");
+                sProto  = PROTO_OSP;
+                sAppCmd = APP_CMD_IDLE;
+                break;
+            case APP_CMD_SWITCH_NMEA:
+                CSR_APP_LOG_INFO("switch to NMEA protocol.\r\n");
+                sAppCmd = APP_CMD_IDLE;
+                pCsrLoc->CsrLocDebugSwitch2Nmea();
+                break;
+            case APP_CMD_PM_FULL:
+                CSR_APP_LOG_INFO("fpm set.\r\n");
+                sAppCmd  = APP_CMD_IDLE;
+                sPwrMode = PWR_FULL;
+                break;
+            case APP_CMD_PM_PTF:
+                CSR_APP_LOG_INFO("lpm ptf set.\r\n");
+                sAppCmd  = APP_CMD_IDLE;
+                sPwrMode = PWR_PTF;
+                break;
         }
     }
 }
@@ -223,173 +230,123 @@
     CSR_APP_LOG_INFO("    getpos   - get location immediately in low power ptf mode\r\n");
     CSR_APP_LOG_INFO("    osp      - OSP mode\r\n");
     CSR_APP_LOG_INFO("    nmea     - NMEA mode\r\n");
-    
 }
 
 static void _AppBtnPushed(void)
 {
-	sAppCmd = APP_CMD_PTF_GETPOS;
-//	sLedLocOn = !sLedLocOn;
+    sAppCmd = APP_CMD_PTF_GETPOS;
+    //	sLedLocOn = !sLedLocOn;
 }
 
-static void _AppOutputCallback(uint32_t  msgId, void * const pMsgData, uint32_t msgLength)
+static void _AppOutputCallback(uint32_t msgId, void *const pMsgData, uint32_t msgLength)
 {
-    switch(msgId)
-    {
-    case LOC_OUTPUT_LOCATION:
-    {
-        tLocPosResp *pPosRsp = (tLocPosResp *)pMsgData;
-        CSR_APP_LOG_INFO("Loc: lat=%f, lon=%f, alt=%f\r\n", pPosRsp->lat, pPosRsp->lon, pPosRsp->alt);
-        sLedPosReport = 1;
-        wait_ms(10);
-        sLedPosReport = 0;
-        break;
+    switch (msgId) {
+        case LOC_OUTPUT_LOCATION:
+        {
+            tLocPosResp *pPosRsp = (tLocPosResp *)pMsgData;
+            CSR_APP_LOG_INFO("Loc: lat=%f, lon=%f, alt=%f\r\n", pPosRsp->lat, pPosRsp->lon, pPosRsp->alt);
+            sLedPosReport = 1;
+            wait_ms(10);
+            sLedPosReport = 0;
+            break;
+        }
+        case LOC_OUTPUT_SV_STATUS:
+        {
+            tLocSvStatus *pSvStatus = (tLocSvStatus *)pMsgData;
+            CSR_APP_LOG_INFO("SV:week=%u, tow=%lu, GPS Num=%u, GLO Num=%u, GPS Mask=0x%lx, GLO Mask=0x%lx\r\n",
+                             pSvStatus->gps_week, pSvStatus->tow, pSvStatus->numOfSVs, pSvStatus->numOfGloSVs,
+                             pSvStatus->svUsedInFixMask, pSvStatus->gloSvUsedInFixMask);
+            break;
+        }
+
+        default:
+            break;
     }
-    case LOC_OUTPUT_SV_STATUS:
-    {
-        tLocSvStatus *pSvStatus = (tLocSvStatus *)pMsgData;
-        CSR_APP_LOG_INFO("SV:week=%u, tow=%lu, GPS Num=%u, GLO Num=%u, GPS Mask=0x%lx, GLO Mask=0x%lx\r\n", 
-                pSvStatus->gps_week, pSvStatus->tow, pSvStatus->numOfSVs, pSvStatus->numOfGloSVs, 
-                pSvStatus->svUsedInFixMask, pSvStatus->gloSvUsedInFixMask);
-        break;
-    }
-
-    default :
-        break;
-    }   
 }
 
 static void _AppEventCallback(eCsrLocEventType event, uint32_t data)
 {
-    switch(event)
-    {
-    case CSR_LOC_EVENT_START_RESULT:
-        if(data != 0)
-        {
-            CSR_APP_LOG_INFO("start failed.\r\n");
-            sAppCmd = APP_CMD_START_FAILED;
-        }
-        else
-        {
-            CSR_APP_LOG_INFO("start OK.\r\n");
-        }
-        break;
-    case CSR_LOC_EVENT_STOP_RESULT:
-        if(data != 0)
-        {
-            CSR_APP_LOG_INFO("stop failed.\r\n");
-            sAppCmd = APP_CMD_STOP_FAILED;
-        }
-        else
-        {
-            CSR_APP_LOG_INFO("stop OK.\r\n");
-        }
-        break;
-    default:
-        break;
+    switch (event) {
+        case CSR_LOC_EVENT_START_RESULT:
+            if (data != 0) {
+                CSR_APP_LOG_INFO("start failed.\r\n");
+                sAppCmd = APP_CMD_START_FAILED;
+            } else {
+                CSR_APP_LOG_INFO("start OK.\r\n");
+            }
+            break;
+        case CSR_LOC_EVENT_STOP_RESULT:
+            if (data != 0) {
+                CSR_APP_LOG_INFO("stop failed.\r\n");
+                sAppCmd = APP_CMD_STOP_FAILED;
+            } else {
+                CSR_APP_LOG_INFO("stop OK.\r\n");
+            }
+            break;
+        default:
+            break;
     }
 }
 
 static void _ConsoleRxHandler(void)
 {
-	static char cmd[32] = {0};
-    char ch;
+    static char cmd[32] = {0};
+    char        ch;
 
     ch = sSerialDebug.getc();
     sSerialDebug.putc(ch);
-	if(ch == '\r')
-	{
+    if (ch == '\r') {
         sSerialDebug.putc('\n');
-        if(strlen(cmd) > 0)
-        {
-	        _AppCmdProcess(cmd);
-	        memset(cmd, 0, sizeof(cmd));
+        if (strlen(cmd) > 0) {
+            _AppCmdProcess(cmd);
+            memset(cmd, 0, sizeof(cmd));
         }
-	}
-	else
-	{
-		cmd[strlen(cmd)] = ch;
-	}
+    } else {
+        cmd[strlen(cmd)] = ch;
+    }
 }
-	
+
 static void _AppCmdProcess(char *pCmd)
 {
-	if(strcmp(pCmd, "help") == 0)
-    {
+    if (strcmp(pCmd, "help") == 0) {
         sAppCmd = APP_CMD_HELP;
-    }
-    else if(strcmp(pCmd, "start") == 0)
-    {
+    } else if (strcmp(pCmd, "start") == 0) {
         sAppCmd = APP_CMD_START;
-    }
-    else if(strcmp(pCmd, "stop") == 0)
-    {
+    } else if (strcmp(pCmd, "stop") == 0) {
         sAppCmd = APP_CMD_STOP;
-    }
-    else if(strcmp(pCmd, "fpm") == 0)
-    {
+    } else if (strcmp(pCmd, "fpm") == 0) {
         sAppCmd = APP_CMD_PM_FULL;
-    }
-    else if(strcmp(pCmd, "ptf") == 0)
-    {
+    } else if (strcmp(pCmd, "ptf") == 0) {
         sAppCmd = APP_CMD_PM_PTF;
-    }
-    else if(strcmp(pCmd, "getpos") == 0)
-    {
+    } else if (strcmp(pCmd, "getpos") == 0) {
         sAppCmd = APP_CMD_PTF_GETPOS;
-    }
-    else if(strcmp(pCmd, "nmea") == 0)
-    {
+    } else if (strcmp(pCmd, "nmea") == 0) {
         sAppCmd = APP_CMD_NMEA;
-    }
-    else if(strcmp(pCmd, "osp") == 0)
-    {
+    } else if (strcmp(pCmd, "osp") == 0) {
         sAppCmd = APP_CMD_OSP;
-    }
-    else if(strcmp(pCmd, "switchnmea") == 0)
-    {
+    } else if (strcmp(pCmd, "switchnmea") == 0) {
         sAppCmd = APP_CMD_SWITCH_NMEA;
-    }
-    else if(strcmp(pCmd, "switchosp") == 0)
-    {
+    } else if (strcmp(pCmd, "switchosp") == 0) {
         sAppCmd = APP_CMD_SWITCH_OSP;
-    }
-    else if(strcmp(pCmd, "onoffon") == 0)
-    {
+    } else if (strcmp(pCmd, "onoffon") == 0) {
         sAppCmd = APP_CMD_ONOFF_ON;
-    }
-    else if(strcmp(pCmd, "onoffoff") == 0)
-    {
+    } else if (strcmp(pCmd, "onoffoff") == 0) {
         sAppCmd = APP_CMD_ONOFF_OFF;
-    }
-    else if(strcmp(pCmd, "reseton") == 0)
-    {
+    } else if (strcmp(pCmd, "reseton") == 0) {
         sAppCmd = APP_CMD_RESET_ON;
-    }
-    else if(strcmp(pCmd, "resetoff") == 0)
-    {
+    } else if (strcmp(pCmd, "resetoff") == 0) {
         sAppCmd = APP_CMD_RESET_OFF;
-    }
-    else if(strcmp(pCmd, "pinteston") == 0)
-    {
+    } else if (strcmp(pCmd, "pinteston") == 0) {
         sAppCmd = APP_CMD_PINTEST_ON;
-    }
-    else if(strcmp(pCmd, "pintestoff") == 0)
-    {
+    } else if (strcmp(pCmd, "pintestoff") == 0) {
         sAppCmd = APP_CMD_PINTEST_OFF;
-    }
-    else if(strcmp(pCmd, "pintestoffon") == 0)
-    {
+    } else if (strcmp(pCmd, "pintestoffon") == 0) {
         sAppCmd = APP_CMD_PINTEST_OFF_ON;
-    }
-    else if(strcmp(pCmd, "iswakeup") == 0)
-    {
-    	sAppCmd = APP_CMD_WAKEUP_STATUS;
-    }
-    else
-    {
+    } else if (strcmp(pCmd, "iswakeup") == 0) {
+        sAppCmd = APP_CMD_WAKEUP_STATUS;
+    } else {
         CSR_APP_LOG_INFO("\r\nUnknown command %s\r\n", pCmd);
     }
-	
-	CSR_APP_LOG_INFO("\r\n");
+
+    CSR_APP_LOG_INFO("\r\n");
 }