cli.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef __CLI_H
  2. #define __CLI_H
  3. #include <stdint.h>
  4. #include <stdbool.h>
  5. #include "FreeRTOS.h"
  6. #include "fr_timers.h"
  7. #include "settings_api.h"
  8. /* Dimensions the buffer into which input characters are placed. */
  9. #define cmdMAX_INPUT_SIZE 144
  10. #define MAX_SESSIONS 2
  11. typedef enum{
  12. CLI_AUTH = 0,
  13. CLI_AUTH_PASSW,
  14. CLI_CMD,
  15. CLI_CHANGE_PWD,
  16. CLI_CHANGE_PWD_ACK
  17. } input_state_t;
  18. typedef enum {
  19. STATE_NORMAL,
  20. STATE_IAC,
  21. STATE_OPT,
  22. STATE_SB,
  23. STATE_OPTDAT,
  24. STATE_SE,
  25. STATE_CLOSE,
  26. } conn_state_t;
  27. /**
  28. * A cli connection structure.
  29. */
  30. typedef struct {
  31. TimerHandle_t RepeatSensorInfoTimer;
  32. conn_state_t state;
  33. // uint8_t code;
  34. char buf[cmdMAX_INPUT_SIZE];
  35. char bufptr;
  36. char prev_cmd[cmdMAX_INPUT_SIZE];
  37. unsigned char optdata[cmdMAX_INPUT_SIZE];
  38. uint8_t optlen;
  39. input_state_t input_state;
  40. user_level_t user_id;
  41. char login[MAX_WEB_LOGIN_LEN];
  42. uint8_t login_err; // the number of failed password entry attempts
  43. // bool active_conn;
  44. bool flag_telnet_ip_option; // wtf is this
  45. //send( cli_states[num_timer].num_connect, pcOutputString, strlen( ( const char * ) pcOutputString ), 0 );
  46. void (*send)(intptr_t fd, const char *str, unsigned len);
  47. intptr_t num_connect; // fd
  48. } cli_state_t;
  49. void cli_getchar(cli_state_t *s, char incoming_char);
  50. #endif