b.liu | d440f9f | 2025-04-18 10:44:31 +0800 | [diff] [blame^] | 1 | /* |
| 2 | * MBTK AT Header. |
| 3 | * |
| 4 | * Author : lb |
| 5 | * Date : 2021/11/5 10:41:24 |
| 6 | * |
| 7 | */ |
| 8 | #ifndef MBTK_AT_H |
| 9 | #define MBTK_AT_H |
| 10 | #include "ml_utils.h" |
| 11 | #include "teldef.h" |
| 12 | #include "telutl.h" |
| 13 | #include "utlTypes.h" |
| 14 | #include "utlAtParser.h" |
| 15 | |
| 16 | #include "mbtk/mbtk_type.h" |
| 17 | |
| 18 | void mbtk_log(int level, const char *format, ...); |
| 19 | |
| 20 | #define LOG_DEBUG_LEVEL 5 |
| 21 | #define LOG(fmt, args...) mbtk_log(LOG_DEBUG_LEVEL, fmt, ##args) |
| 22 | |
| 23 | #define MBTK_AT_RESP_LEN_MAX 2048 |
| 24 | #define MBTK_AT_FTP_NAME_LEN_MAX 21 |
| 25 | #define MBTK_AT_FTP_PASS_LEN_MAX 21 |
| 26 | #define MBTK_AT_FTP_ADDR_LEN_MAX 64 |
| 27 | #define MBTK_AT_FTP_DIR_LEN_MAX 90 |
| 28 | |
| 29 | #ifdef MBTK_DATA_MODE_SUPPORT |
| 30 | typedef void (*mbtk_data_mode_callback_func)(const char *data, int data_len); |
| 31 | #endif |
| 32 | |
| 33 | typedef enum { |
| 34 | MBTK_AT_FUNC_TYPE_BASIC = 0, // No change , refer to lib_list |
| 35 | MBTK_AT_FUNC_TYPE_FACTORY, |
| 36 | MBTK_AT_FUNC_TYPE_AUDIO, |
| 37 | MBTK_AT_FUNC_TYPE_GNSS, |
| 38 | MBTK_AT_FUNC_TYPE_ECALL, |
| 39 | MBTK_AT_FUNC_TYPE_SOCKET, |
| 40 | MBTK_AT_FUNC_TYPE_TCPIP, |
| 41 | MBTK_AT_FUNC_TYPE_HTTP, |
| 42 | MBTK_AT_FUNC_TYPE_FTP, |
| 43 | |
| 44 | /* Arrry number. */ |
| 45 | MBTK_AT_FUNC_TYPE_NUM |
| 46 | } mbtk_at_func_type_enum; |
| 47 | |
| 48 | typedef struct mbtk_at_func{ |
| 49 | mbtk_at_func_type_enum type; |
| 50 | char name[50]; |
| 51 | void *func; |
| 52 | |
| 53 | struct mbtk_at_func *next; |
| 54 | } mbtk_at_func_t; |
| 55 | |
| 56 | typedef enum |
| 57 | { |
| 58 | MBTK_PORT_TYPE_UART1, // /dev/ttyS1 |
| 59 | MBTK_PORT_TYPE_USB1, // /dev/ttyGS0 |
| 60 | MBTK_PORT_TYPE_USB2 // /dev/ttymodem0 |
| 61 | } mbtk_port_type_enum; |
| 62 | |
| 63 | typedef enum |
| 64 | { |
| 65 | MBTK_PORT_MODE_AT, // AT mode(default) |
| 66 | MBTK_PORT_MODE_ADB, // mbtk_adb mode |
| 67 | MBTK_PORT_MODE_CUSTOM // Custom mode |
| 68 | } mbtk_port_mode_enum; |
| 69 | |
| 70 | //void func_add(char *name); |
| 71 | mbtk_at_func_t *func_get(char *name); |
| 72 | |
| 73 | |
| 74 | //#define mbtk_cmd_line_ex_f (bool (*)(const char*, void (*)(char*int))) |
| 75 | |
| 76 | #define MBTK_FUNC_TYPEDEF |
| 77 | #include "mbtk_at_func.h" |
| 78 | #undef MBTK_FUNC_TYPEDEF |
| 79 | |
| 80 | |
| 81 | #define MBTK_FUNC(name) (*((name)(func_get(#name)->func))) |
| 82 | /*#define MBTK_FUNC(name) \ |
| 83 | do{ \ |
| 84 | if(name) \ |
| 85 | (*((name)(func_get(#name)->func))); \ |
| 86 | } while(0) |
| 87 | */ |
| 88 | //#define MBTK_FUNC(name) (name?(*((name)(func_get(#name)->func))):-1) |
| 89 | #define MBTK_FUNC_ADD(type, name) func_add(type, #name) |
| 90 | |
| 91 | //typedef void (*mbtk_cmd_cb_func)(char *buf,int buf_size); |
| 92 | //typedef bool (*mbtk_cmd_line_ex_f)(const char *cmd, void (*cb)(char *buf,int buf_size)); |
| 93 | //extern void* mbtk_cmd_line_ex; |
| 94 | |
| 95 | #if 0 |
| 96 | typedef int (*mbtk_audio_exec_f)(const char *args); |
| 97 | extern mbtk_audio_exec_f mbtk_at_play; |
| 98 | extern mbtk_audio_exec_f mbtk_at_rec; |
| 99 | #endif |
| 100 | |
| 101 | #if 0 |
| 102 | typedef enum { |
| 103 | MBTK_AT_PARAM_TYPE_INT, |
| 104 | MBTK_AT_PARAM_TYPE_STR |
| 105 | } mbtk_at_param_type_enum; |
| 106 | |
| 107 | typedef struct { |
| 108 | int min; |
| 109 | int max; |
| 110 | int int_def; |
| 111 | } mbtk_at_param_int_range_t; |
| 112 | |
| 113 | typedef struct { |
| 114 | int max_len; |
| 115 | char *str_def; |
| 116 | } mbtk_at_param_str_range_t; |
| 117 | |
| 118 | typedef struct { |
| 119 | mbtk_at_param_type_enum type; |
| 120 | union { |
| 121 | mbtk_at_param_int_range_t param_int; |
| 122 | mbtk_at_param_str_range_t param_str; |
| 123 | } param; |
| 124 | } mbtk_at_param_range_t; |
| 125 | #endif |
| 126 | |
| 127 | BOOL getExtValue( const utlAtParameterValue_P2c param_value_p, |
| 128 | int index, |
| 129 | int *value_p, |
| 130 | int minValue, |
| 131 | int maxValue, |
| 132 | int DefaultValue); |
| 133 | |
| 134 | BOOL getExtUValue(const utlAtParameterValue_P2c param_value_p, |
| 135 | int index, |
| 136 | unsigned int *value_p, |
| 137 | unsigned int minValue, |
| 138 | unsigned int maxValue, |
| 139 | unsigned int DefaultValue); |
| 140 | |
| 141 | BOOL getExtString( const utlAtParameterValue_P2c param_value_p, |
| 142 | int index, |
| 143 | CHAR *outString, |
| 144 | INT16 maxStringLength, |
| 145 | INT16 *outStringLength, |
| 146 | CHAR *defaultString); |
| 147 | char *op2str(utlAtParameterOp_T op); |
| 148 | |
| 149 | #ifdef MBTK_DATA_MODE_SUPPORT |
| 150 | utlReturnCode_T mbtk_data_mode_enter(TelAtParserID atp_index, mbtk_data_mode_callback_func cb); |
| 151 | #endif |
| 152 | #if 1//MBTK_RGMII_TEST |
| 153 | int mbtk_rgmii_loopback(void); |
| 154 | int mbtk_mdio(char* net_name,int mode, uint16_t reg_addr, uint16_t value); |
| 155 | #endif |
| 156 | #endif /* MBTK_AT_H */ |