1 /* 2 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef __AT_H__ 17 #define __AT_H__ 18 19 #include <hi_at.h> 20 #include <hi_early_debug.h> 21 #include <hi_mem.h> 22 #include <hi_stdlib.h> 23 #include <hi_types_base.h> 24 25 #ifdef __cplusplus 26 #if __cplusplus 27 extern "C" { 28 #endif 29 #endif 30 31 #define AT_CMD_MAX_PARAS 64 32 #define AT_CMD_MAX_LEN 128 33 #define AT_CMD_LIST_NUM 20 34 35 #define AT_RESPONSE_OK do { \ 36 hi_at_printf("OK\r\n"); \ 37 } while (0) 38 39 #define AT_RESPONSE_ERROR do { \ 40 hi_at_printf("ERROR\r\n"); \ 41 } while (0) 42 43 #define AT_ENTER do { \ 44 hi_at_printf("\r\n"); \ 45 } while (0) 46 47 #ifdef AT_CMD_DEBUG 48 #define at_printf(fmt...) printf(fmt) 49 #else 50 #define at_printf(fmt...) 51 #endif 52 53 #define AT_MACSTR "%02x:%02x:%02x:%02x:%02x:%02x" 54 #define at_mac2str(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5] 55 56 57 typedef enum { 58 AT_CMD_TYPE_TEST = 1, 59 AT_CMD_TYPE_QUERY = 2, 60 AT_CMD_TYPE_SETUP = 3, 61 AT_CMD_TYPE_EXE = 4, 62 } at_cmd_type; 63 64 typedef struct { 65 hi_s8 at_cmd_len; 66 hi_char cmd_name[AT_CMD_MAX_LEN]; 67 at_cmd_type at_cmd_type; 68 hi_s32 at_param_cnt; /* command actual para num */ 69 hi_u32 param_array[AT_CMD_MAX_PARAS]; 70 } at_cmd_attr; 71 72 typedef struct { 73 HI_CONST at_cmd_func *at_cmd_list[AT_CMD_LIST_NUM]; /* user input at cmd list */ 74 hi_u16 at_cmd_num[AT_CMD_LIST_NUM]; /* command number */ 75 } at_cmd_func_list; 76 77 extern at_cmd_ctrl g_at_ctrl; 78 79 hi_u32 at_cmd_process(const hi_char *at_cmd_line); 80 hi_u32 at_param_null_check(hi_s32 argc, const hi_char **argv); 81 hi_u32 integer_check(const hi_char *val); 82 hi_u32 cmd_strtoaddr(const hi_char *param, hi_uchar *mac_addr, hi_u32 addr_len); 83 char* at_parse_string(const char *value, size_t *len); 84 const char* at_ssid_txt(const hi_u8 *ssid, size_t ssid_len); 85 void* at_malloc(size_t size); 86 void at_free(char *ptr); 87 88 #ifdef __cplusplus 89 #if __cplusplus 90 } 91 #endif 92 #endif 93 94 #endif 95