espconn.h 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886
  1. /*
  2. * ESPRESSIF MIT License
  3. *
  4. * Copyright (c) 2016 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>
  5. *
  6. * Permission is hereby granted for use on ESPRESSIF SYSTEMS ESP8266 only, in which case,
  7. * it is free of charge, to any person obtaining a copy of this software and associated
  8. * documentation files (the "Software"), to deal in the Software without restriction, including
  9. * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10. * and/or sell copies of the Software, and to permit persons to whom the Software is furnished
  11. * to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in all copies or
  14. * substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  18. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  19. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  20. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  21. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. *
  23. */
  24. #ifndef __ESPCONN_H__
  25. #define __ESPCONN_H__
  26. #include "lwip/err.h"
  27. #include "lwip/dns.h"
  28. #include "os_type.h"
  29. #include "lwip/app/espconn_buf.h"
  30. #if 0
  31. #define espconn_printf(fmt, args...) os_printf(fmt,## args)
  32. #else
  33. #define espconn_printf(fmt, args...)
  34. #endif
  35. typedef void *espconn_handle;
  36. typedef void (* espconn_connect_callback)(void *arg);
  37. typedef void (* espconn_reconnect_callback)(void *arg, sint8 err);
  38. /* Definitions for error constants. */
  39. #define ESPCONN_OK 0 /* No error, everything OK. */
  40. #define ESPCONN_MEM -1 /* Out of memory error. */
  41. #define ESPCONN_TIMEOUT -3 /* Timeout. */
  42. #define ESPCONN_RTE -4 /* Routing problem. */
  43. #define ESPCONN_INPROGRESS -5 /* Operation in progress */
  44. #define ESPCONN_MAXNUM -7 /* Total number exceeds the set maximum*/
  45. #define ESPCONN_ABRT -8 /* Connection aborted. */
  46. #define ESPCONN_RST -9 /* Connection reset. */
  47. #define ESPCONN_CLSD -10 /* Connection closed. */
  48. #define ESPCONN_CONN -11 /* Not connected. */
  49. #define ESPCONN_ARG -12 /* Illegal argument. */
  50. #define ESPCONN_IF -14 /* Low_level error */
  51. #define ESPCONN_ISCONN -15 /* Already connected. */
  52. #define ESPCONN_TIME -16 /* Sync Time error */
  53. #define ESPCONN_NODATA -17 /* No data can be read */
  54. #define ESPCONN_HANDSHAKE -28 /* ssl handshake failed */
  55. #define ESPCONN_SSL_INVALID_DATA -61 /* ssl application invalid */
  56. #define ESPCONN_SSL 0x01
  57. #define ESPCONN_NORM 0x00
  58. #define ESPCONN_STA 0x01
  59. #define ESPCONN_AP 0x02
  60. #define ESPCONN_AP_STA 0x03
  61. #define STA_NETIF 0x00
  62. #define AP_NETIF 0x01
  63. /** Protocol family and type of the espconn */
  64. enum espconn_type {
  65. ESPCONN_INVALID = 0,
  66. /* ESPCONN_TCP Group */
  67. ESPCONN_TCP = 0x10,
  68. /* ESPCONN_UDP Group */
  69. ESPCONN_UDP = 0x20,
  70. };
  71. /** Current state of the espconn. Non-TCP espconn are always in state ESPCONN_NONE! */
  72. enum espconn_state {
  73. ESPCONN_NONE,
  74. ESPCONN_WAIT,
  75. ESPCONN_LISTEN,
  76. ESPCONN_CONNECT,
  77. ESPCONN_WRITE,
  78. ESPCONN_READ,
  79. ESPCONN_CLOSE
  80. };
  81. typedef struct _esp_tcp {
  82. int remote_port;
  83. int local_port;
  84. uint8 local_ip[4];
  85. uint8 remote_ip[4];
  86. espconn_connect_callback connect_callback;
  87. espconn_reconnect_callback reconnect_callback;
  88. espconn_connect_callback disconnect_callback;
  89. espconn_connect_callback write_finish_fn;
  90. } esp_tcp;
  91. typedef struct _esp_udp {
  92. int remote_port;
  93. int local_port;
  94. uint8 local_ip[4];
  95. uint8 remote_ip[4];
  96. } esp_udp;
  97. typedef struct _remot_info{
  98. enum espconn_state state;
  99. int remote_port;
  100. uint8 remote_ip[4];
  101. }remot_info;
  102. /** A callback prototype to inform about events for a espconn */
  103. typedef void (* espconn_recv_callback)(void *arg, char *pdata, unsigned short len);
  104. typedef void (* espconn_sent_callback)(void *arg);
  105. /** A espconn descriptor */
  106. struct espconn {
  107. /** type of the espconn (TCP, UDP) */
  108. enum espconn_type type;
  109. /** current state of the espconn */
  110. enum espconn_state state;
  111. union {
  112. esp_tcp *tcp;
  113. esp_udp *udp;
  114. } proto;
  115. /** A callback function that is informed about events for this espconn */
  116. espconn_recv_callback recv_callback;
  117. espconn_sent_callback sent_callback;
  118. uint8 link_cnt;
  119. void *reverse;
  120. };
  121. enum espconn_option{
  122. ESPCONN_START = 0x00,
  123. ESPCONN_REUSEADDR = 0x01,
  124. ESPCONN_NODELAY = 0x02,
  125. ESPCONN_COPY = 0x04,
  126. ESPCONN_KEEPALIVE = 0x08,
  127. ESPCONN_MANUALRECV = 0x10,
  128. ESPCONN_END
  129. };
  130. enum espconn_level{
  131. ESPCONN_KEEPIDLE,
  132. ESPCONN_KEEPINTVL,
  133. ESPCONN_KEEPCNT
  134. };
  135. enum espconn_mode{
  136. ESPCONN_NOMODE,
  137. ESPCONN_TCPSERVER_MODE,
  138. ESPCONN_TCPCLIENT_MODE,
  139. ESPCONN_UDP_MODE,
  140. ESPCONN_NUM_MODE
  141. };
  142. struct espconn_packet{
  143. uint16 sent_length; /* sent length successful*/
  144. uint16 snd_buf_size; /* Available buffer size for sending */
  145. uint16 snd_queuelen; /* Available buffer space for sending */
  146. uint16 total_queuelen; /* total Available buffer space for sending */
  147. uint32 packseqno; /* seqno to be sent */
  148. uint32 packseq_nxt; /* seqno expected */
  149. uint32 packnum;
  150. };
  151. typedef struct _espconn_buf{
  152. uint8 *payload;
  153. uint8 *punsent;
  154. uint16 unsent;
  155. uint16 len;
  156. uint16 tot_len;
  157. struct _espconn_buf *pnext;
  158. } espconn_buf;
  159. typedef struct _comon_pkt{
  160. void *pcb;
  161. int remote_port;
  162. uint8 remote_ip[4];
  163. uint32 local_port;
  164. uint32 local_ip;
  165. espconn_buf *pbuf;
  166. espconn_buf *ptail;
  167. uint8* ptrbuf;
  168. uint16 cntr;
  169. sint8 err;
  170. uint32 timeout;
  171. uint32 recv_check;
  172. uint8 pbuf_num;
  173. struct espconn_packet packet_info;
  174. bool write_flag;
  175. enum espconn_option espconn_opt;
  176. }comon_pkt;
  177. typedef struct _espconn_msg{
  178. struct espconn *pespconn;
  179. comon_pkt pcommon;
  180. uint8 count_opt;
  181. uint8 espconn_mode;
  182. sint16_t hs_status; //the status of the handshake
  183. void *preverse;
  184. void *pssl;
  185. struct _espconn_msg *pnext;
  186. //***********Code for WIFI_BLOCK from upper**************
  187. uint8 recv_hold_flag;
  188. uint16 recv_holded_buf_Len;
  189. //*******************************************************
  190. ringbuf *readbuf;
  191. }espconn_msg;
  192. #ifndef _MDNS_INFO
  193. #define _MDNS_INFO
  194. struct mdns_info {
  195. char *host_name;
  196. char *server_name;
  197. uint16 server_port;
  198. unsigned long ipAddr;
  199. char *txt_data[10];
  200. };
  201. #endif
  202. #define linkMax 15
  203. #define espconn_delay_disabled(espconn) (((espconn)->pcommon.espconn_opt & ESPCONN_NODELAY) != 0)
  204. #define espconn_delay_enabled(espconn) (((espconn)->pcommon.espconn_opt & ESPCONN_NODELAY) == 0)
  205. #define espconn_reuse_disabled(espconn) (((espconn)->pcommon.espconn_opt & ESPCONN_REUSEADDR) != 0)
  206. #define espconn_copy_disabled(espconn) (((espconn)->pcommon.espconn_opt & ESPCONN_COPY) != 0)
  207. #define espconn_copy_enabled(espconn) (((espconn)->pcommon.espconn_opt & ESPCONN_COPY) == 0)
  208. #define espconn_keepalive_disabled(espconn) (((espconn)->pcommon.espconn_opt & ESPCONN_KEEPALIVE) != 0)
  209. #define espconn_keepalive_enabled(espconn) (((espconn)->pcommon.espconn_opt & ESPCONN_KEEPALIVE) == 0)
  210. #define espconn_TaskPrio 26
  211. #define espconn_TaskQueueLen 15
  212. enum espconn_sig {
  213. SIG_ESPCONN_NONE,
  214. SIG_ESPCONN_ERRER,
  215. SIG_ESPCONN_LISTEN,
  216. SIG_ESPCONN_CONNECT,
  217. SIG_ESPCONN_WRITE,
  218. SIG_ESPCONN_SEND,
  219. SIG_ESPCONN_READ,
  220. SIG_ESPCONN_CLOSE
  221. };
  222. /******************************************************************************
  223. * FunctionName : espconn_copy_partial
  224. * Description : reconnect with host
  225. * Parameters : arg -- Additional argument to pass to the callback function
  226. * Returns : none
  227. *******************************************************************************/
  228. void espconn_copy_partial(struct espconn *pesp_dest, struct espconn *pesp_source);
  229. /******************************************************************************
  230. * FunctionName : espconn_copy_partial
  231. * Description : insert the node to the active connection list
  232. * Parameters : arg -- Additional argument to pass to the callback function
  233. * Returns : none
  234. *******************************************************************************/
  235. void espconn_list_creat(espconn_msg **phead, espconn_msg* pinsert);
  236. /******************************************************************************
  237. * FunctionName : espconn_list_delete
  238. * Description : remove the node from the active connection list
  239. * Parameters : arg -- Additional argument to pass to the callback function
  240. * Returns : none
  241. *******************************************************************************/
  242. void espconn_list_delete(espconn_msg **phead, espconn_msg* pdelete);
  243. /******************************************************************************
  244. * FunctionName : espconn_find_connection
  245. * Description : Initialize the server: set up a listening PCB and bind it to
  246. * the defined port
  247. * Parameters : espconn -- the espconn used to build server
  248. * Returns : none
  249. *******************************************************************************/
  250. bool espconn_find_connection(struct espconn *pespconn, espconn_msg **pnode);
  251. /******************************************************************************
  252. * FunctionName : espconn_get_connection_info
  253. * Description : used to specify the function that should be called when disconnect
  254. * Parameters : espconn -- espconn to set the err callback
  255. * discon_cb -- err callback function to call when err
  256. * Returns : none
  257. *******************************************************************************/
  258. sint8 espconn_get_connection_info(struct espconn *pespconn, remot_info **pcon_info, uint8 typeflags);
  259. /******************************************************************************
  260. * FunctionName : espconn_get_packet_info
  261. * Description : get the packet info with host
  262. * Parameters : espconn -- the espconn used to disconnect the connection
  263. * infoarg -- the packet info
  264. * Returns : the errur code
  265. *******************************************************************************/
  266. sint8 espconn_get_packet_info(struct espconn *espconn, struct espconn_packet* infoarg);
  267. /******************************************************************************
  268. * FunctionName : espconn_connect
  269. * Description : The function given as the connect
  270. * Parameters : espconn -- the espconn used to listen the connection
  271. * Returns : none
  272. *******************************************************************************/
  273. extern sint8 espconn_connect(struct espconn *espconn);
  274. /******************************************************************************
  275. * FunctionName : espconn_disconnect
  276. * Description : disconnect with host
  277. * Parameters : espconn -- the espconn used to disconnect the connection
  278. * Returns : none
  279. *******************************************************************************/
  280. extern sint8 espconn_disconnect(struct espconn *espconn);
  281. /******************************************************************************
  282. * FunctionName : espconn_delete
  283. * Description : disconnect with host
  284. * Parameters : espconn -- the espconn used to disconnect the connection
  285. * Returns : none
  286. *******************************************************************************/
  287. extern sint8 espconn_delete(struct espconn *espconn);
  288. /******************************************************************************
  289. * FunctionName : espconn_accept
  290. * Description : The function given as the listen
  291. * Parameters : espconn -- the espconn used to listen the connection
  292. * Returns : none
  293. *******************************************************************************/
  294. extern sint8 espconn_accept(struct espconn *espconn);
  295. /******************************************************************************
  296. * FunctionName : espconn_create
  297. * Description : sent data for client or server
  298. * Parameters : espconn -- espconn to the data transmission
  299. * Returns : result
  300. *******************************************************************************/
  301. extern sint8 espconn_create(struct espconn *espconn);
  302. /******************************************************************************
  303. * FunctionName : espconn_tcp_get_wnd
  304. * Description : get the window size of simulatenously active TCP connections
  305. * Parameters : none
  306. * Returns : the number of TCP_MSS active TCP connections
  307. *******************************************************************************/
  308. extern uint8 espconn_tcp_get_wnd(void);
  309. /******************************************************************************
  310. * FunctionName : espconn_tcp_set_max_con
  311. * Description : set the window size simulatenously active TCP connections
  312. * Parameters : num -- the number of TCP_MSS
  313. * Returns : ESPCONN_ARG -- Illegal argument
  314. * ESPCONN_OK -- No error
  315. *******************************************************************************/
  316. extern sint8 espconn_tcp_set_wnd(uint8 num);
  317. /******************************************************************************
  318. * FunctionName : espconn_tcp_get_max_con
  319. * Description : get the number of simulatenously active TCP connections
  320. * Parameters : none
  321. * Returns : none
  322. *******************************************************************************/
  323. extern uint8 espconn_tcp_get_max_con(void);
  324. /******************************************************************************
  325. * FunctionName : espconn_tcp_set_max_con
  326. * Description : set the number of simulatenously active TCP connections
  327. * Parameters : num -- total number
  328. * Returns : none
  329. *******************************************************************************/
  330. extern sint8 espconn_tcp_set_max_con(uint8 num);
  331. /******************************************************************************
  332. * FunctionName : espconn_tcp_get_max_retran
  333. * Description : get the Maximum number of retransmissions of data active TCP connections
  334. * Parameters : none
  335. * Returns : the Maximum number of retransmissions
  336. *******************************************************************************/
  337. extern uint8 espconn_tcp_get_max_retran(void);
  338. /******************************************************************************
  339. * FunctionName : espconn_tcp_set_max_retran
  340. * Description : set the Maximum number of retransmissions of data active TCP connections
  341. * Parameters : num -- the Maximum number of retransmissions
  342. * Returns : result
  343. *******************************************************************************/
  344. extern sint8 espconn_tcp_set_max_retran(uint8 num);
  345. /******************************************************************************
  346. * FunctionName : espconn_tcp_get_max_syn
  347. * Description : get the Maximum number of retransmissions of SYN segments
  348. * Parameters : none
  349. * Returns : the Maximum number of retransmissions
  350. *******************************************************************************/
  351. extern uint8 espconn_tcp_get_max_syn(void);
  352. /******************************************************************************
  353. * FunctionName : espconn_tcp_set_max_syn
  354. * Description : set the Maximum number of retransmissions of SYN segments
  355. * Parameters : num -- the Maximum number of retransmissions
  356. * Returns : result
  357. *******************************************************************************/
  358. extern sint8 espconn_tcp_set_max_syn(uint8 num);
  359. /******************************************************************************
  360. * FunctionName : espconn_tcp_get_max_con_allow
  361. * Description : get the count of simulatenously active connections on the server
  362. * Parameters : espconn -- espconn to get the count
  363. * Returns : result
  364. *******************************************************************************/
  365. extern sint8 espconn_tcp_get_max_con_allow(struct espconn *espconn);
  366. /******************************************************************************
  367. * FunctionName : espconn_tcp_set_max_con_allow
  368. * Description : set the count of simulatenously active connections on the server
  369. * Parameters : espconn -- espconn to set the count
  370. * Returns : result
  371. *******************************************************************************/
  372. extern sint8 espconn_tcp_set_max_con_allow(struct espconn *espconn, uint8 num);
  373. /******************************************************************************
  374. * FunctionName : espconn_tcp_set_buf_count
  375. * Description : set the total number of espconn_buf on the unsent lists
  376. * Parameters : espconn -- espconn to set the count
  377. * num -- the total number of espconn_buf
  378. * Returns : result
  379. *******************************************************************************/
  380. extern sint8 espconn_tcp_set_buf_count(struct espconn *espconn, uint8 num);
  381. /******************************************************************************
  382. * FunctionName : espconn_regist_time
  383. * Description : used to specify the time that should be called when don't recv data
  384. * Parameters : espconn -- the espconn used to the connection
  385. * interval -- the timer when don't recv data
  386. * Returns : none
  387. *******************************************************************************/
  388. extern sint8 espconn_regist_time(struct espconn *espconn, uint32 interval, uint8 type_flag);
  389. /******************************************************************************
  390. * FunctionName : espconn_regist_sentcb
  391. * Description : Used to specify the function that should be called when data
  392. * has been successfully delivered to the remote host.
  393. * Parameters : struct espconn *espconn -- espconn to set the sent callback
  394. * espconn_sent_callback sent_cb -- sent callback function to
  395. * call for this espconn when data is successfully sent
  396. * Returns : none
  397. *******************************************************************************/
  398. extern sint8 espconn_regist_sentcb(struct espconn *espconn, espconn_sent_callback sent_cb);
  399. /******************************************************************************
  400. * FunctionName : espconn_regist_sentcb
  401. * Description : Used to specify the function that should be called when data
  402. * has been successfully delivered to the remote host.
  403. * Parameters : espconn -- espconn to set the sent callback
  404. * sent_cb -- sent callback function to call for this espconn
  405. * when data is successfully sent
  406. * Returns : none
  407. *******************************************************************************/
  408. extern sint8 espconn_regist_write_finish(struct espconn *espconn, espconn_connect_callback write_finish_fn);
  409. /******************************************************************************
  410. * FunctionName : espconn_send
  411. * Description : sent data for client or server
  412. * Parameters : espconn -- espconn to set for client or server
  413. * psent -- data to send
  414. * length -- length of data to send
  415. * Returns : none
  416. *******************************************************************************/
  417. extern sint8 espconn_send(struct espconn *espconn, uint8 *psent, uint16 length);
  418. /******************************************************************************
  419. * FunctionName : espconn_sent
  420. * Description : sent data for client or server
  421. * Parameters : espconn -- espconn to set for client or server
  422. * psent -- data to send
  423. * length -- length of data to send
  424. * Returns : none
  425. *******************************************************************************/
  426. extern sint8 espconn_sent(struct espconn *espconn, uint8 *psent, uint16 length);
  427. /******************************************************************************
  428. * FunctionName : espconn_regist_connectcb
  429. * Description : used to specify the function that should be called when
  430. * connects to host.
  431. * Parameters : espconn -- espconn to set the connect callback
  432. * connect_cb -- connected callback function to call when connected
  433. * Returns : none
  434. *******************************************************************************/
  435. extern sint8 espconn_regist_connectcb(struct espconn *espconn, espconn_connect_callback connect_cb);
  436. /******************************************************************************
  437. * FunctionName : espconn_regist_recvcb
  438. * Description : used to specify the function that should be called when recv
  439. * data from host.
  440. * Parameters : espconn -- espconn to set the recv callback
  441. * recv_cb -- recv callback function to call when recv data
  442. * Returns : none
  443. *******************************************************************************/
  444. extern sint8 espconn_regist_recvcb(struct espconn *espconn, espconn_recv_callback recv_cb);
  445. /******************************************************************************
  446. * FunctionName : espconn_regist_reconcb
  447. * Description : used to specify the function that should be called when connection
  448. * because of err disconnect.
  449. * Parameters : espconn -- espconn to set the err callback
  450. * recon_cb -- err callback function to call when err
  451. * Returns : none
  452. *******************************************************************************/
  453. extern sint8 espconn_regist_reconcb(struct espconn *espconn, espconn_reconnect_callback recon_cb);
  454. /******************************************************************************
  455. * FunctionName : espconn_regist_disconcb
  456. * Description : used to specify the function that should be called when disconnect
  457. * Parameters : espconn -- espconn to set the err callback
  458. * discon_cb -- err callback function to call when err
  459. * Returns : none
  460. *******************************************************************************/
  461. extern sint8 espconn_regist_disconcb(struct espconn *espconn, espconn_connect_callback discon_cb);
  462. /******************************************************************************
  463. * FunctionName : espconn_port
  464. * Description : access port value for client so that we don't end up bouncing
  465. * all connections at the same time .
  466. * Parameters : none
  467. * Returns : access port value
  468. *******************************************************************************/
  469. extern uint32 espconn_port(void);
  470. /******************************************************************************
  471. * FunctionName : espconn_set_opt
  472. * Description : access port value for client so that we don't end up bouncing
  473. * all connections at the same time .
  474. * Parameters : none
  475. * Returns : access port value
  476. *******************************************************************************/
  477. extern sint8 espconn_set_opt(struct espconn *espconn, uint8 opt);
  478. /******************************************************************************
  479. * FunctionName : espconn_set_keepalive
  480. * Description : access level value for connection so that we set the value for
  481. * keep alive
  482. * Parameters : espconn -- the espconn used to set the connection
  483. * level -- the connection's level
  484. * value -- the value of time(s)
  485. * Returns : access port value
  486. *******************************************************************************/
  487. extern sint8 espconn_set_keepalive(struct espconn *espconn, uint8 level, void* optarg);
  488. /******************************************************************************
  489. * FunctionName : espconn_get_keepalive
  490. * Description : access level value for connection so that we get the value for
  491. * keep alive
  492. * Parameters : espconn -- the espconn used to get the connection
  493. * level -- the connection's level
  494. * Returns : access keep alive value
  495. *******************************************************************************/
  496. extern sint8 espconn_get_keepalive(struct espconn *espconn, uint8 level, void *optarg);
  497. /******************************************************************************
  498. * FunctionName : espconn_gethostbyname
  499. * Description : Resolve a hostname (string) into an IP address.
  500. * Parameters : pespconn -- espconn to resolve a hostname
  501. * hostname -- the hostname that is to be queried
  502. * addr -- pointer to a ip_addr_t where to store the address if
  503. * it is already cached in the dns_table (only valid if
  504. * ESPCONN_OK is returned!)
  505. * found -- a callback function to be called on success, failure
  506. * or timeout (only if ERR_INPROGRESS is returned!)
  507. * Returns : err_t return code
  508. * - ESPCONN_OK if hostname is a valid IP address string or the host
  509. * name is already in the local names table.
  510. * - ESPCONN_INPROGRESS enqueue a request to be sent to the DNS server
  511. * for resolution if no errors are present.
  512. * - ESPCONN_ARG: dns client not initialized or invalid hostname
  513. *******************************************************************************/
  514. extern err_t espconn_gethostbyname(struct espconn *pespconn, const char *name, ip_addr_t *addr, dns_found_callback found);
  515. /******************************************************************************
  516. * FunctionName : espconn_abort
  517. * Description : Forcely abort with host
  518. * Parameters : espconn -- the espconn used to connect with the host
  519. * Returns : result
  520. *******************************************************************************/
  521. extern sint8 espconn_abort(struct espconn *espconn);
  522. /******************************************************************************
  523. * FunctionName : espconn_encry_connect
  524. * Description : The function given as connection
  525. * Parameters : espconn -- the espconn used to connect with the host
  526. * Returns : none
  527. *******************************************************************************/
  528. extern sint8 espconn_secure_connect(struct espconn *espconn);
  529. /******************************************************************************
  530. * FunctionName : espconn_encry_disconnect
  531. * Description : The function given as the disconnection
  532. * Parameters : espconn -- the espconn used to disconnect with the host
  533. * Returns : none
  534. *******************************************************************************/
  535. extern sint8 espconn_secure_disconnect(struct espconn *espconn);
  536. /******************************************************************************
  537. * FunctionName : espconn_secure_send
  538. * Description : sent data for client or server
  539. * Parameters : espconn -- espconn to set for client or server
  540. * psent -- data to send
  541. * length -- length of data to send
  542. * Returns : none
  543. *******************************************************************************/
  544. extern sint8 espconn_secure_send(struct espconn *espconn, uint8 *psent, uint16 length);
  545. /******************************************************************************
  546. * FunctionName : espconn_encry_sent
  547. * Description : sent data for client or server
  548. * Parameters : espconn -- espconn to set for client or server
  549. * psent -- data to send
  550. * length -- length of data to send
  551. * Returns : none
  552. *******************************************************************************/
  553. extern sint8 espconn_secure_sent(struct espconn *espconn, uint8 *psent, uint16 length);
  554. /******************************************************************************
  555. * FunctionName : espconn_secure_set_size
  556. * Description : set the buffer size for client or server
  557. * Parameters : level -- set for client or server
  558. * 1: client,2:server,3:client and server
  559. * size -- buffer size
  560. * Returns : true or false
  561. *******************************************************************************/
  562. extern bool espconn_secure_set_size(uint8 level, uint16 size);
  563. /******************************************************************************
  564. * FunctionName : espconn_secure_get_size
  565. * Description : get buffer size for client or server
  566. * Parameters : level -- set for client or server
  567. * 1: client,2:server,3:client and server
  568. * Returns : buffer size for client or server
  569. *******************************************************************************/
  570. extern sint16 espconn_secure_get_size(uint8 level);
  571. /******************************************************************************
  572. * FunctionName : espconn_secure_ca_enable
  573. * Description : enable the certificate authenticate and set the flash sector
  574. * as client or server
  575. * Parameters : level -- set for client or server
  576. * 1: client,2:server,3:client and server
  577. * flash_sector -- flash sector for save certificate
  578. * Returns : result true or false
  579. *******************************************************************************/
  580. extern bool espconn_secure_ca_enable(uint8 level, uint32 flash_sector );
  581. /******************************************************************************
  582. * FunctionName : espconn_secure_ca_disable
  583. * Description : disable the certificate authenticate as client or server
  584. * Parameters : level -- set for client or server
  585. * 1: client,2:server,3:client and server
  586. * Returns : result true or false
  587. *******************************************************************************/
  588. extern bool espconn_secure_ca_disable(uint8 level);
  589. /******************************************************************************
  590. * FunctionName : espconn_secure_cert_req_enable
  591. * Description : enable the client certificate authenticate and set the flash sector
  592. * as client or server
  593. * Parameters : level -- set for client or server
  594. * 1: client,2:server,3:client and server
  595. * flash_sector -- flash sector for save certificate
  596. * Returns : result true or false
  597. *******************************************************************************/
  598. extern bool espconn_secure_cert_req_enable(uint8 level, uint32 flash_sector );
  599. /******************************************************************************
  600. * FunctionName : espconn_secure_ca_disable
  601. * Description : disable the client certificate authenticate as client or server
  602. * Parameters : level -- set for client or server
  603. * 1: client,2:server,3:client and server
  604. * Returns : result true or false
  605. *******************************************************************************/
  606. extern bool espconn_secure_cert_req_disable(uint8 level);
  607. /******************************************************************************
  608. * FunctionName : espconn_secure_set_default_certificate
  609. * Description : Load the certificates in memory depending on compile-time
  610. * and user options.
  611. * Parameters : certificate -- Load the certificate
  612. * length -- Load the certificate length
  613. * Returns : result true or false
  614. *******************************************************************************/
  615. extern bool espconn_secure_set_default_certificate(const uint8* certificate, uint16 length);
  616. /******************************************************************************
  617. * FunctionName : espconn_secure_set_default_private_key
  618. * Description : Load the key in memory depending on compile-time
  619. * and user options.
  620. * Parameters : private_key -- Load the key
  621. * length -- Load the key length
  622. * Returns : result true or false
  623. *******************************************************************************/
  624. extern bool espconn_secure_set_default_private_key(const uint8* private_key, uint16 length);
  625. /******************************************************************************
  626. * FunctionName : espconn_secure_accept
  627. * Description : The function given as the listen
  628. * Parameters : espconn -- the espconn used to listen the connection
  629. * Returns : result
  630. *******************************************************************************/
  631. extern sint8 espconn_secure_accept(struct espconn *espconn);
  632. /******************************************************************************
  633. * FunctionName : espconn_secure_accepts
  634. * Description : delete the secure server host
  635. * Parameters : espconn -- the espconn used to listen the connection
  636. * Returns : result
  637. *******************************************************************************/
  638. extern sint8 espconn_secure_delete(struct espconn *espconn);
  639. /******************************************************************************
  640. * FunctionName : espconn_igmp_join
  641. * Description : join a multicast group
  642. * Parameters : host_ip -- the ip address of udp server
  643. * multicast_ip -- multicast ip given by user
  644. * Returns : none
  645. *******************************************************************************/
  646. extern sint8 espconn_igmp_join(ip_addr_t *host_ip, ip_addr_t *multicast_ip);
  647. /******************************************************************************
  648. * FunctionName : espconn_igmp_leave
  649. * Description : leave a multicast group
  650. * Parameters : host_ip -- the ip address of udp server
  651. * multicast_ip -- multicast ip given by user
  652. * Returns : none
  653. *******************************************************************************/
  654. extern sint8 espconn_igmp_leave(ip_addr_t *host_ip, ip_addr_t *multicast_ip);
  655. /******************************************************************************
  656. * FunctionName : espconn_recv_hold
  657. * Description : hold tcp receive
  658. * Parameters : espconn -- espconn to hold
  659. * Returns : none
  660. *******************************************************************************/
  661. extern sint8 espconn_recv_hold(struct espconn *pespconn);
  662. /******************************************************************************
  663. * FunctionName : espconn_recv_unhold
  664. * Description : unhold tcp receive
  665. * Parameters : espconn -- espconn to unhold
  666. * Returns : none
  667. *******************************************************************************/
  668. extern sint8 espconn_recv_unhold(struct espconn *pespconn);
  669. /******************************************************************************
  670. * FunctionName : espconn_mdns_init
  671. * Description : register a device with mdns
  672. * Parameters : ipAddr -- the ip address of device
  673. * hostname -- the hostname of device
  674. * Returns : none
  675. *******************************************************************************/
  676. extern void espconn_mdns_init(struct mdns_info *info);
  677. /******************************************************************************
  678. * FunctionName : espconn_mdns_init
  679. * Description : close mdns socket
  680. * Parameters : void
  681. * Returns : none
  682. *******************************************************************************/
  683. extern void espconn_mdns_close(void);
  684. /******************************************************************************
  685. * FunctionName : mdns_server_register
  686. * Description : register a server and join a multicast group
  687. * Parameters : none
  688. * Returns : none
  689. *******************************************************************************/
  690. extern void espconn_mdns_server_register(void);
  691. /******************************************************************************
  692. * FunctionName : mdns_server_register
  693. * Description : unregister server and leave multicast group
  694. * Parameters : none
  695. * Returns : none
  696. *******************************************************************************/
  697. extern void espconn_mdns_server_unregister(void);
  698. /******************************************************************************
  699. * FunctionName : espconn_mdns_get_servername
  700. * Description : get server name
  701. * Parameters : none
  702. * Returns : server name
  703. *******************************************************************************/
  704. extern char* espconn_mdns_get_servername(void);
  705. /******************************************************************************
  706. * FunctionName : espconn_mdns_get_servername
  707. * Description : set server name
  708. * Parameters : server name
  709. * Returns : none
  710. *******************************************************************************/
  711. extern void espconn_mdns_set_servername(const char *name);
  712. /******************************************************************************
  713. * FunctionName : espconn_mdns_set_hostname
  714. * Description : set host name
  715. * Parameters : host name
  716. * Returns : none
  717. *******************************************************************************/
  718. extern void espconn_mdns_set_hostname(char *name);
  719. /******************************************************************************
  720. * FunctionName : espconn_mdns_init
  721. * Description : get host name
  722. * Parameters : void
  723. * Returns : hostname
  724. *******************************************************************************/
  725. extern char* espconn_mdns_get_hostname(void);
  726. /******************************************************************************
  727. * FunctionName : espconn_mdns_disable
  728. * Description : join a multicast group
  729. * Parameters : host_ip -- the ip address of udp server
  730. * multicast_ip -- multicast ip given by user
  731. * Returns : none
  732. *******************************************************************************/
  733. extern void espconn_mdns_disable(void);
  734. /******************************************************************************
  735. * FunctionName : espconn_mdns_enable
  736. * Description : enable mdns
  737. * Parameters : void
  738. * Returns : none
  739. *******************************************************************************/
  740. extern void espconn_mdns_enable(void);
  741. /******************************************************************************
  742. * FunctionName : espconn_dns_setserver
  743. * Description : Initialize one of the DNS servers.
  744. * Parameters : numdns -- the index of the DNS server to set must
  745. * be < DNS_MAX_SERVERS = 2
  746. * dnsserver -- IP address of the DNS server to set
  747. * Returns : none
  748. *******************************************************************************/
  749. extern void espconn_dns_setserver(u8_t numdns, ip_addr_t *dnsserver);
  750. #endif