at_cmd_ftp.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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_FTP_H__
  13. #define __AT_FTP_H__
  14. #include "sockets.h"
  15. #define FTP_RXBUFFER_LEN (1)
  16. #define FTP_GET_TIMEOUT_DUR 360
  17. #define FTP_STRING_SIZE 256
  18. #define FTP_SEND_MAX_SIZE 3072
  19. enum FTP_COMMAND
  20. {
  21. FTP_CONNECT = 1,
  22. FTP_USER,
  23. FTP_PASS,
  24. FTP_SIZE,
  25. FTP_TYPE,
  26. FTP_REST,
  27. FTP_PASV,
  28. FTP_RETR,
  29. FTP_LIST,
  30. FTP_CWD,
  31. FTP_PWD,
  32. FTP_DATA_TRANSFER,
  33. FTP_STOR,
  34. FTP_ABOR,
  35. FTP_PORT,
  36. FTP_QUIT,
  37. };
  38. enum FTP_STATE
  39. {
  40. FTP_IDLE,
  41. CHANGEING_CUR_DIR,
  42. GET_FILE,
  43. PUT_FILE,
  44. LIST_DIR,
  45. LIST_FILE,
  46. FTP_LOGIN,
  47. FTP_LOGOUT,
  48. FTP_TRANSFER,
  49. FTP_WAIT_DATA,
  50. FTP_WAIT_DATA_PAUSE,
  51. };
  52. typedef struct
  53. {
  54. uint8_t buffer[FTP_SEND_MAX_SIZE];
  55. uint16_t len;
  56. uint16_t sended;
  57. uint16_t request;
  58. uint16_t tx_work;
  59. osiTimer_t *tmrID;
  60. } FTP_TXBUFFER_T;
  61. typedef enum FTP_SOCKET_CLOSE
  62. {
  63. FTP_SOCKET_NULL,
  64. FTP_SOCKET_GET,
  65. FTP_SOCKET_PUT,
  66. } FTP_SOCKET_ID_T;
  67. struct FTP_Param
  68. {
  69. uint8_t host[FTP_STRING_SIZE];
  70. uint16_t port;
  71. uint8_t username[FTP_STRING_SIZE];
  72. uint8_t passwd[FTP_STRING_SIZE];
  73. uint8_t mode;
  74. uint8_t Tout;
  75. uint8_t FTPtype;
  76. };
  77. typedef struct _CFW_FTP_CTX
  78. {
  79. enum FTP_STATE ftpState;
  80. enum FTP_COMMAND ftp_command;
  81. SOCKET ctrlSocket, dataSocket, listenSocket;
  82. uint8_t userName[FTP_STRING_SIZE];
  83. uint8_t passWord[FTP_STRING_SIZE];
  84. struct sockaddr_storage ser_ip;
  85. struct sockaddr_storage ser_ip_data;
  86. ip_addr_t serverIp;
  87. char getpath[256];
  88. bool get_closedelay;
  89. int32_t req_getoffset, req_getsize, getsize, getparam;
  90. char putpath[256];
  91. FTP_TXBUFFER_T tx_buf;
  92. bool connect;
  93. FTP_SOCKET_ID_T connected_socket;
  94. uint16_t port;
  95. uint16_t data_port;
  96. bool logined;
  97. osiTimer_t *FTPTimer;
  98. uint8_t nSimID;
  99. atCmdEngine_t *FTPengine;
  100. bool datamode;
  101. } CFW_FTP_CTX_T;
  102. typedef struct _CFW_FTP_CMD
  103. {
  104. enum FTP_COMMAND cmd_id;
  105. uint8_t cmd_str[30];
  106. uint8_t cmd_exp_rst[30];
  107. } CFW_FTP_CMD;
  108. void AT_FTP_CmdFunc_OPEN(atCommand_t *pParam);
  109. void AT_FTP_CmdFunc_CLOSE(atCommand_t *pParam);
  110. void AT_FTP_CmdFunc_SIZE(atCommand_t *pParam);
  111. void AT_FTP_CmdFunc_GET(atCommand_t *pParam);
  112. void AT_FTP_CmdFunc_PUT(atCommand_t *pParam);
  113. void AT_FTP_CmdFunc_PUTSET(atCommand_t *pParam);
  114. void AT_FTP_CmdFunc_GETSET(atCommand_t *pParam);
  115. #endif /* __CFW_FTP_H__ */