1 /* 2 * Copyright (C) 2015-2020 Alibaba Group Holding Limited 3 */ 4 5 #ifndef _AOS_NETWORK_H_ 6 #define _AOS_NETWORK_H_ 7 #define SCANNED_WIFI_COUNT_MAX 32 8 #define SCANNED_LOCATOR_COUNT_MAX 32 9 10 typedef enum { 11 AOS_NETWORK_WIFI, 12 AOS_NETWORK_CELLULAR, 13 AOS_NETWORK_ETHERNET, 14 AOS_NETWORK_UNKNOW, 15 } AOS_NETWORK_TYPE_E; 16 17 typedef enum { 18 AOS_NETWORK_IPTYPE_IPV4, 19 AOS_NETWORK_IPTYPE_IPV6, 20 AOS_NETWORK_IPTYPE_IPV4V6, 21 AOS_NETWORK_IPTYPE_INVALID 22 } AOS_NETWORK_IPTYPE_E; 23 24 typedef enum { 25 AOS_NETWORK_SHAREMODE_RNDIS, 26 AOS_NETWORK_SHAREMODE_ECM, 27 AOS_NETWORK_SHAREMODE_INVALID 28 } AOS_NETWORK_SHAREMODE_E; 29 30 typedef enum { 31 AOS_NETWORK_SHAREMODE_AUTHTYPE_NONE, 32 AOS_NETWORK_SHAREMODE_AUTHTYPE_PAP, 33 AOS_NETWORK_SHAREMODE_AUTHTYPE_CHAP, 34 AOS_NETWORK_SHAREMODE_AUTHTYPE_PAPCHAP, 35 AOS_NETWORK_SHAREMODE_AUTHTYPE_INVALID 36 } AOS_NETWORK_SHAREMODE_AUTHTYPE_E; 37 38 typedef struct aos_sim_info { 39 char imsi[32]; 40 char imei[32]; 41 char iccid[32]; 42 } aos_sim_info_t; 43 44 typedef struct aos_locator_info { 45 char mcc[4]; 46 char mnc[4]; 47 int cellid; 48 int lac; 49 int signal; 50 } aos_locator_info_t; 51 52 typedef struct aos_scanned_locator_info { 53 int num; 54 aos_locator_info_t locator_info[SCANNED_LOCATOR_COUNT_MAX]; 55 } aos_scanned_locator_info_t; 56 57 typedef struct aos_wifi_info { 58 char ssid[128]; 59 char mac[6]; 60 char ip[16]; 61 int rssi; 62 } aos_wifi_info_t; 63 64 typedef struct aos_scanned_wifi_info { 65 int num; 66 aos_wifi_info_t wifi_info[SCANNED_WIFI_COUNT_MAX]; 67 } aos_scanned_wifi_info_t; 68 69 typedef struct aos_sharemode_info { 70 int action; 71 int auto_connect; 72 char apn[99]; 73 char username[64]; 74 char password[64]; 75 AOS_NETWORK_IPTYPE_E ip_type; 76 AOS_NETWORK_SHAREMODE_E share_mode; 77 } aos_sharemode_info_t; 78 79 /** 80 * @brief file close 81 * 82 * @param[out] ip: ip pointer 83 * 84 * @return 0: success, -1: failed 85 */ 86 int aos_wifi_init(); 87 88 /** 89 * @brief file close 90 * 91 * @param[out] ip: ip pointer 92 * 93 * @return 0: success, -1: failed 94 */ 95 int aos_wifi_connect(const char *ssid, const char *passwd); 96 97 /** 98 * @brief file close 99 * 100 * @param[out] ip: ip pointer 101 * 102 * @return 0: success, -1: failed 103 */ 104 int aos_wifi_disconnect(); 105 106 /** 107 * @brief file close 108 * 109 * @param[out] ip: ip pointer 110 * 111 * @return 0: success, -1: failed 112 */ 113 int aos_get_wifi_info(aos_wifi_info_t *wifi_info); 114 115 /** 116 * @brief file close 117 * 118 * @param[out] ip: ip pointer 119 * 120 * @return 0: success, -1: failed 121 */ 122 int aos_get_sim_info(aos_sim_info_t *sim_info); 123 124 /** 125 * @brief file close 126 * 127 * @param[out] ip: ip pointer 128 * 129 * @return 0: success, -1: failed 130 */ 131 int aos_get_locator_info(aos_locator_info_t *locator_info); 132 133 /** 134 * @brief file close 135 * 136 * @param[out] ip: ip pointer 137 * 138 * @return 0: success, -1: failed 139 */ 140 int aos_get_neighbor_locator_info(void (*cb)(aos_locator_info_t *, int)); 141 142 /** 143 * @brief file close 144 * 145 * @param[out] ip: ip pointer 146 * 147 * @return 0: success, -1: failed 148 */ 149 int aos_get_network_status(void); 150 151 /** 152 * @brief file close 153 * 154 * @param[out] ip: ip pointer 155 * 156 * @return 0: success, -1: failed 157 */ 158 AOS_NETWORK_TYPE_E aos_get_network_type(); 159 160 /* ECM */ 161 /** 162 * @brief get net share mode 163 * 164 * @return mode: 0-RNDIS 1-ECM 165 */ 166 AOS_NETWORK_SHAREMODE_E aos_get_netsharemode(void); 167 168 /** 169 * @brief set net share mode 170 * 171 * @param[out] share_mode: net mode 172 * 173 * @return 0: success, -1: failed 174 */ 175 int aos_set_netsharemode(AOS_NETWORK_SHAREMODE_E share_mode); 176 177 /** 178 * @brief net share action 179 * 180 * @param[out] action_p: net share mode: 0-close 1-open 181 * 182 * @return 0: success, -1: failed 183 */ 184 int aos_get_netshareconfig(aos_sharemode_info_t *share_mode_info); 185 186 /** 187 * @brief file close 188 * 189 * @param[out] ip: ip pointer 190 * 191 * @return 0: success, -1: failed 192 */ 193 int aos_set_netshareconfig(int ucid, int auth_type, aos_sharemode_info_t *share_mode_info); 194 195 int aos_location_access_wifi_info(aos_wifi_info_t *wifi_info); 196 197 int aos_location_scaned_wifi_info(aos_scanned_wifi_info_t *scaned_wifi); 198 199 #endif /* _AOS_NETWORK_H_ */ 200 201