Implement a secure ICS protocol targeting LoRa Node151 microcontroller for controlling irrigation.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

56 lines
1.5 KiB

  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. void CliProcess( Uart_t* uart )
  25. {
  26. uint8_t data = 0;
  27. if( UartGetChar( uart, &data ) == 0 )
  28. {
  29. if( data == '\x1B' )
  30. { // Escape character has been received
  31. printf( "ESC + " );
  32. while( UartGetChar( uart, &data ) != 0 )
  33. {
  34. }
  35. printf( "%c\n", data );
  36. if( data == 'N' )
  37. { // N character has been received
  38. data = 0;
  39. // Reset NVM
  40. if( NvmDataMgmtFactoryReset( ) == true )
  41. {
  42. printf( "\n\nNVM factory reset succeed\n" );
  43. }
  44. else
  45. {
  46. printf( "\n\nNVM factory reset failed\n" );
  47. }
  48. printf( "\n\nPLEASE RESET THE END-DEVICE\n\n" );
  49. while( 1 );
  50. }
  51. }
  52. }
  53. }