|
1 | 1 |
|
2 | 2 | /** |
3 | | - * @file minbasecli.h |
| 3 | + * @file minbasecli_arduino.h |
4 | 4 | * @author Jose Miguel Rios Rubio <jrios.github@gmail.com> |
5 | | - * @date 26-05-2021 |
6 | | - * @version 1.0.0 |
| 5 | + * @date 08-02-2022 |
| 6 | + * @version 1.0.1 |
7 | 7 | * |
8 | 8 | * @section DESCRIPTION |
9 | 9 | * |
|
33 | 33 |
|
34 | 34 | /* Include Guard */ |
35 | 35 |
|
36 | | -#ifdef ARDUINO |
| 36 | +#if defined(ARDUINO) |
37 | 37 |
|
38 | | -#ifndef MINBASECLI_H_ |
39 | | -#define MINBASECLI_H_ |
| 38 | +#ifndef MINBASECLI_ARDUINO_H_ |
| 39 | +#define MINBASECLI_ARDUINO_H_ |
40 | 40 |
|
41 | 41 | /*****************************************************************************/ |
42 | 42 |
|
|
51 | 51 |
|
52 | 52 | /* Constants & Defines */ |
53 | 53 |
|
54 | | -#define SIMPLECLI_READ_TIMEOUT_MS 100 |
55 | | -#define SIMPLECLI_READ_INTERCHAR_TIMEOUT_MS 10 |
56 | | -#define SIMPLECLI_MAX_READ_SIZE 64 |
57 | | -#define SIMPLECLI_MAX_CMD_LEN 24 |
58 | | -#define SIMPLECLI_MAX_ARGV_LEN 32 |
59 | | -#define SIMPLECLI_MAX_ARGV 4 |
60 | | - |
61 | 54 | /*****************************************************************************/ |
62 | 55 |
|
63 | | -/* Data Types */ |
64 | | - |
65 | | -typedef struct t_cli_result |
66 | | -{ |
67 | | - char cmd[SIMPLECLI_MAX_CMD_LEN]; |
68 | | - char argv[SIMPLECLI_MAX_ARGV][SIMPLECLI_MAX_ARGV_LEN]; |
69 | | - uint8_t argc; |
70 | | -} t_cli_result; |
71 | | - |
72 | | -/*****************************************************************************/ |
| 56 | +/* CLass Interface */ |
73 | 57 |
|
74 | | -class MINBASECLI |
| 58 | +class MINBASECLI_ARDUINO |
75 | 59 | { |
76 | 60 | public: |
77 | | - MINBASECLI(); |
78 | | - |
79 | | - bool setup(); |
80 | | - bool setup(void* iface); |
81 | | - bool manage(t_cli_result* cli_result); |
82 | | - uint32_t get_received_bytes(); |
| 61 | + MINBASECLI_ARDUINO(); |
83 | 62 |
|
84 | 63 | private: |
85 | 64 | void* iface; |
86 | | - bool initialized; |
87 | | - uint32_t received_bytes; |
88 | | - char rx_read[SIMPLECLI_MAX_READ_SIZE]; |
89 | | - |
90 | | - void set_default_result(t_cli_result* cli_result); |
91 | | - bool iface_is_not_initialized(); |
92 | | - bool iface_read_data(char* rx_read, const size_t rx_read_size); |
93 | | - size_t iface_read_data_t(char* rx_read, const size_t rx_read_size); |
94 | | - uint32_t str_count_words(const char* str_in, const size_t str_in_len); |
95 | | - bool str_read_until_char(char* str, const size_t str_len, |
96 | | - const char until_c, char* str_read, |
97 | | - const size_t str_read_size); |
98 | | - |
99 | | - bool hal_uart_setup(); |
100 | | - uint32_t hal_millis(); |
| 65 | + |
| 66 | + protected: |
| 67 | + bool hal_setup(const uint32_t baud_rate); |
| 68 | + bool hal_setup(void* iface, const uint32_t baud_rate); |
101 | 69 | void hal_iface_print(const char* str); |
102 | 70 | void hal_iface_println(const char* str); |
103 | 71 | size_t hal_iface_available(); |
104 | 72 | uint8_t hal_iface_read(); |
| 73 | + void hal_millis_init(); |
| 74 | + uint32_t hal_millis(); |
105 | 75 | }; |
106 | 76 |
|
107 | 77 | /*****************************************************************************/ |
108 | 78 |
|
109 | | -#endif /* MINBASECLI_H_ */ |
| 79 | +#endif /* MINBASECLI_ARDUINO_H_ */ |
110 | 80 |
|
111 | | -#endif /* ARDUINO */ |
| 81 | +#endif /* defined(ARDUINO) */ |
0 commit comments