cli.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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_UNUSED,
  20. STATE_NORMAL,
  21. STATE_IAC,
  22. STATE_OPT,
  23. STATE_SB,
  24. STATE_OPTDAT,
  25. STATE_SE,
  26. STATE_CLOSE,
  27. } conn_state_t;
  28. /**
  29. * A cli connection structure.
  30. */
  31. typedef struct {
  32. TimerHandle_t RepeatSensorInfoTimer;
  33. conn_state_t state;
  34. // uint8_t code;
  35. char buf[cmdMAX_INPUT_SIZE];
  36. uint_fast8_t bufptr;
  37. char prev_cmd[cmdMAX_INPUT_SIZE];
  38. unsigned char optdata[cmdMAX_INPUT_SIZE];
  39. uint8_t optlen;
  40. input_state_t input_state;
  41. user_level_t user_id;
  42. char login[MAX_WEB_LOGIN_LEN];
  43. uint8_t login_err; // the number of failed password entry attempts
  44. // bool active_conn;
  45. bool flag_telnet_ip_option; // wtf is this
  46. //send( cli_states[num_timer].num_connect, pcOutputString, strlen( ( const char * ) pcOutputString ), 0 );
  47. void (*send)(intptr_t fd, const char *str, unsigned len);
  48. intptr_t num_connect; // fd
  49. } cli_state_t;
  50. void cli_init(void);
  51. void cli_getchar(cli_state_t *s, char incoming_char);
  52. cli_state_t *alloc_state(void);
  53. void cli_hello(cli_state_t *cli_state);
  54. user_level_t cli_auth_user(char *user, char *password);
  55. #endif