1 /*
2  * Copyright (C) 2018-2020 Alibaba Group Holding Limited
3  */
4 #ifndef __GENIE_AT_H__
5 #define __GENIE_AT_H__
6 
7 typedef enum
8 {
9     AT_CMD_NO_ADD = 0x1,
10     AT_CMD_ADD = 0x2,
11     AT_CMD_QUERY = 0x4,
12     AT_CMD_DOU = 0x8,
13     AT_CMD_FIND = 0x10,
14 } AT_CMD_TYPE_e;
15 
16 typedef enum
17 {
18     AT_OP_EXECUTE = 0x1,
19     AT_OP_FCURRENT = 0x2,
20     AT_OP_HLOOKUP = 0x3,
21     AT_OP_HELP = 0x4,
22 } AT_OP_CODE_e;
23 
24 typedef enum
25 {
26     AT_ERR_NOT_FOUND = -1,
27     AT_ERR_FORMAT = -2,
28     AT_ERR_EXE = -3,
29 } AT_OP_ERROR_e;
30 
31 typedef enum
32 {
33     MESH_TEST_RSSI = 0x00,
34 } MESH_TEST_OP_CODE_e;
35 
36 typedef enum
37 {
38     MESH_EVENT_PROV_SUCCESS = 0x00,
39     MESH_EVENT_PROV_FAILED = 0x05,
40     MESH_EVENT_DEV_READY = 0x04,
41     MESH_EVENT_UNKNOW = 0xFF,
42 } MESH_EVENT_VAL_e;
43 
44 typedef enum
45 {
46     MESH_ADV_CLOSE = 0x00,
47     MESH_ADV_START = 0x01,
48     MESH_ADV_SILENT = 0x02,
49 } MESH_ADV_TYPE_e;
50 
51 typedef int (*at_cmd_function_t)(int argc, char *argv[]);
52 
53 typedef struct at_cmd_s
54 {
55     const char *cmd_name;
56     at_cmd_function_t cb;
57     const char *help;
58     at_cmd_function_t fcb;
59 } at_cmd_t;
60 
61 #define AT_MAX_ARGC 10
62 #define AT_MAX_ARGV_LEN 32
63 
64 #define AT_CME_ERROR_STR "+ERROR:%d\r\n"
65 #define AT_RESPONSE_STR "+%s:"
66 #define AT_OK_STR "OK\r\n"
67 
68 // control cmd
69 #define BLE_MESH_ADV "MESHADV"          // start adv
70 #define BLE_MESH_REBOOT "REBOOT"        // reboot
71 #define BLE_MESH_RESET "MESHRST"        // mesh reset
72 #define BLE_MESH_INFO "MESHINF"         // mesh info
73 #define BLE_MESH_VER "MESHVER"          // mesh version
74 #define BLE_MESH_TEST "MESHTEST"        // mesh test
75 #define BLE_MESH_GROUP "MESHGRP"        // mesh group
76 #define BLE_MESH_MSG_TX "MESHMSGTX"     // mesh trans msg send
77 #define BLE_MESH_MAC "MESHMAC"          // mesh MAC
78 #define BLE_MESH_FACTY_TEST "FACTYTEST" // factory test
79 #define BLE_MESH_LOG "MESHLOG"          // mesh log
80 
81 //event
82 #define BLE_MESH_EVENT "MESHEVT"    // mesh event
83 #define BLE_MESH_MSG_RX "MESHMSGRX" // mesh trans msg recv
84 
85 int genie_at_cmd_reboot(int argc, char *argv[]);
86 int genie_at_cmd_adv_start(int argc, char *argv[]);
87 int genie_at_cmd_adv_query(int argc, char *argv[]);
88 int genie_at_cmd_mesh_reset(int argc, char *argv[]);
89 int genie_at_cmd_mesh_info(int argc, char *argv[]);
90 int genie_at_cmd_mesh_ver(int argc, char *argv[]);
91 int genie_at_cmd_mesh_mac(int argc, char *argv[]);
92 int genie_at_cmd_facty_test(int argc, char *argv[]);
93 int genie_at_cmd_mesh_test(int argc, char *argv[]);
94 int genie_at_cmd_mesh_group(int argc, char *argv[]);
95 int genie_at_cmd_mesh_group_query(int argc, char *argv[]);
96 int genie_at_cmd_mesh_trans_send(int argc, char *argv[]);
97 int genie_at_cmd_mesh_log(int argc, char *argv[]);
98 int genie_at_cmd_mesh_log_query(int argc, char *argv[]);
99 
100 int genie_at_output_event(genie_event_e event, void *p_arg);
101 int genie_at_cmd_send_data_to_mcu(uint8_t *p_data, uint16_t data_len);
102 
103 #endif /*--_GENIE_AT_CMDS_H_--*/
104