gagent_cloud.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * File : gagent_cloud.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2018, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2018-01-03 flyingcys first version
  23. */
  24. #ifndef __GAGENT_CLOUD_H__
  25. #define __GAGENT_CLOUD_H__
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. #define PRODUCT_KEY_LEN 32
  30. #define PRODUCT_SECERT_LEN 32
  31. #define MAX_MAC_LEN 32
  32. struct gagent_config
  33. {
  34. char mac[32 + 1];
  35. char did[32 + 1];
  36. char passcode[16 + 1];
  37. char pk[48 + 1];
  38. char pk_secret[48 + 1];
  39. char hard_version[16 + 1];
  40. char soft_version[16 + 1];
  41. };
  42. typedef struct
  43. {
  44. char product_key[PRODUCT_KEY_LEN + 1];
  45. char product_secret[PRODUCT_SECERT_LEN + 1];
  46. char mac[MAX_MAC_LEN + 1];
  47. int (*read_param_callback)(struct gagent_config *param, rt_uint32_t len);
  48. int (*write_param_callback)(struct gagent_config *param, rt_uint32_t len);
  49. int (*recv_packet_callback)(rt_uint8_t from, rt_uint8_t action, rt_uint8_t *kv, rt_uint16_t kv_len);
  50. } gagent_cloud_param;
  51. enum ATCTION_TYPE
  52. {
  53. ACTION_CONTROL = 1,
  54. ACTION_READ_STATUS = 2,
  55. ACTION_READ_STATUS_ACK = 3,
  56. ACTION_REPORT_STATUS = 4,
  57. ACTION_TRANS_RECV = 5,
  58. ACTION_TRANS_SEND = 6,
  59. ACTION_PUSH_OTA = 254,
  60. };
  61. int gagent_cloud_recv_packet(rt_uint8_t from, rt_uint8_t action, rt_uint8_t *kv, rt_uint16_t kv_len);
  62. int gagent_cloud_send_packet(rt_uint8_t action, rt_uint8_t *buf, rt_uint16_t buf_len);
  63. int gagent_cloud_start(gagent_cloud_param *param);
  64. #ifdef __cplusplus
  65. }
  66. #endif
  67. #endif