1 /*!
2  * \file      cli.h
3  *
4  * \brief     Command Line Interface handling implementation
5  *
6  * \copyright Revised BSD License, see section \ref LICENSE.
7  *
8  * \code
9  *                ______                              _
10  *               / _____)             _              | |
11  *              ( (____  _____ ____ _| |_ _____  ____| |__
12  *               \____ \| ___ |    (_   _) ___ |/ ___)  _ \
13  *               _____) ) ____| | | || |_| ____( (___| | | |
14  *              (______/|_____)_|_|_| \__)_____)\____)_| |_|
15  *              (C)2013-2020 Semtech
16  *
17  * \endcode
18  */
19 #include <stdio.h>
20 #include <stdint.h>
21 #include <stdbool.h>
22 #include "NvmDataMgmt.h"
23 #include "cli.h"
24 
CliProcess(Uart_t * uart)25 void CliProcess( Uart_t* uart )
26 {
27     uint8_t data = 0;
28 
29     if( UartGetChar( uart, &data ) == 0 )
30     {
31         if( data == '\x1B' )
32         { // Escape character has been received
33             printf( "ESC + " );
34             while( UartGetChar( uart, &data ) != 0 )
35             {
36             }
37             printf( "%c\n", data );
38             if( data == 'N' )
39             { // N character has been received
40                 data = 0;
41                 // Reset NVM
42                 if( NvmDataMgmtFactoryReset( ) == true )
43                 {
44                     printf( "\n\nNVM factory reset succeed\n" );
45                 }
46                 else
47                 {
48                     printf( "\n\nNVM factory reset failed\n" );
49                 }
50 
51                 printf( "\n\nPLEASE RESET THE END-DEVICE\n\n" );
52                 while( 1 );
53             }
54         }
55     }
56 }