at_cmd_myftp.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /* Copyright (C) 2016 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef __AT_MYFTP_H__
  13. #define __AT_MYFTP_H__
  14. #include "at_command.h"
  15. #include "sockets.h"
  16. #define FTP_GET_DATA_BLOCK_LEN_IN_BUFFER(_start, _end, _cycle) ((_start <= _end) ? (_end - _start) : (_end + _cycle - _start))
  17. #define FTP_MOD_BUFF_LEN(_val, _length) ((_val) & (_length - 1))
  18. #define FTP_RXBUFFER_LEN (1)
  19. #define FTP_GET_TIMEOUT_DUR 360
  20. #define FTP_STRING_SIZE 256
  21. #define FTP_SEND_MAX_SIZE 3072
  22. enum FTP_COMMAND
  23. {
  24. FTP_CONNECT = 1,
  25. FTP_USER,
  26. FTP_PASS,
  27. FTP_SIZE,
  28. FTP_TYPE,
  29. FTP_REST,
  30. FTP_PASV,
  31. FTP_RETR,
  32. FTP_LIST,
  33. FTP_CWD,
  34. FTP_PWD,
  35. FTP_DATA_TRANSFER,
  36. FTP_STOR,
  37. FTP_ABOR,
  38. FTP_PORT,
  39. FTP_QUIT,
  40. };
  41. enum FTP_STATE
  42. {
  43. FTP_IDLE,
  44. CHANGEING_CUR_DIR,
  45. GET_FILE,
  46. PUT_FILE,
  47. LIST_DIR,
  48. LIST_FILE,
  49. FTP_LOGIN,
  50. FTP_LOGOUT,
  51. FTP_TRANSFER,
  52. FTP_WAIT_DATA,
  53. FTP_WAIT_DATA_PAUSE,
  54. };
  55. typedef struct
  56. {
  57. uint8_t buffer[FTP_SEND_MAX_SIZE];
  58. uint16_t len;
  59. uint16_t sended;
  60. uint16_t request;
  61. uint16_t tx_work;
  62. osiTimer_t *tmrID;
  63. } FTP_TXBUFFER_T;
  64. typedef enum FTP_SOCKET_CLOSE
  65. {
  66. FTP_SOCKET_NULL,
  67. FTP_SOCKET_GET,
  68. FTP_SOCKET_PUT,
  69. } FTP_SOCKET_ID_T;
  70. typedef struct _CFW_FTP_CTX
  71. {
  72. enum FTP_STATE ftpState;
  73. enum FTP_COMMAND ftp_command;
  74. SOCKET ctrlSocket, dataSocket, listenSocket;
  75. uint8_t userName[50];
  76. uint8_t passWord[50];
  77. struct sockaddr_storage ser_ip;
  78. struct sockaddr_storage ser_ip_data;
  79. ip_addr_t serverIp;
  80. char *getpath;
  81. uint32_t req_getoffset, req_getsize, getsize;
  82. uint8_t *putpath;
  83. uint32_t req_putsize, req_puteof;
  84. FTP_TXBUFFER_T tx_buf;
  85. bool connect;
  86. FTP_SOCKET_ID_T connected_socket;
  87. uint16_t port;
  88. uint16_t data_port;
  89. bool logined;
  90. osiTimer_t *FTPTimer;
  91. uint8_t nDLCI;
  92. uint8_t nSimID;
  93. atCmdEngine_t *FTPengine;
  94. } CFW_FTP_CTX_T;
  95. typedef struct _CFW_FTP_CMD
  96. {
  97. enum FTP_COMMAND cmd_id;
  98. uint8_t cmd_str[30];
  99. uint8_t cmd_exp_rst[30];
  100. } CFW_FTP_CMD;
  101. typedef struct
  102. {
  103. uint8_t CircuBuf[FTP_RXBUFFER_LEN];
  104. uint32_t Buf_len;
  105. uint32_t Get;
  106. uint32_t Put;
  107. uint8_t NotEmpty;
  108. } FTP_RXBUFF_T;
  109. struct FTP_Param
  110. {
  111. uint8_t channel;
  112. uint8_t host[FTP_STRING_SIZE];
  113. uint16_t port;
  114. uint8_t username[FTP_STRING_SIZE];
  115. uint8_t passwd[FTP_STRING_SIZE];
  116. uint8_t mode;
  117. uint8_t Tout;
  118. uint8_t FTPtype;
  119. };
  120. void AT_GPRS_CmdFunc_MYFTPOPEN(atCommand_t *pParam);
  121. void AT_GPRS_CmdFunc_MYFTPCLOSE(atCommand_t *pParam);
  122. void AT_GPRS_CmdFunc_MYFTPSIZE(atCommand_t *pParam);
  123. void AT_GPRS_CmdFunc_MYFTPGET(atCommand_t *pParam);
  124. void AT_GPRS_CmdFunc_MYFTPPUT(atCommand_t *pParam);
  125. #endif /* __CFW_FTP_H__ */