gagent_cloud.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. typedef struct
  33. {
  34. char product_key[PRODUCT_KEY_LEN + 1];
  35. char product_secret[PRODUCT_SECERT_LEN + 1];
  36. char mac[MAX_MAC_LEN + 1];
  37. int (*read_param_callback)(void *param, rt_uint32_t len);
  38. int (*write_param_callback)(void *param, rt_uint32_t len);
  39. int (*recv_packet_callback)(rt_uint8_t from, rt_uint8_t action, rt_uint8_t *kv, rt_uint16_t kv_len);
  40. } gagent_cloud_param;
  41. enum ATCTION_TYPE
  42. {
  43. ACTION_CONTROL = 1,
  44. ACTION_READ_STATUS = 2,
  45. ACTION_READ_STATUS_ACK = 3,
  46. ACTION_REPORT_STATUS = 4,
  47. ACTION_TRANS_RECV = 5,
  48. ACTION_TRANS_SEND = 6,
  49. ACTION_PUSH_OTA = 254,
  50. };
  51. int gagent_cloud_recv_packet(rt_uint8_t from, rt_uint8_t action, rt_uint8_t *kv, rt_uint16_t kv_len);
  52. int gagent_cloud_send_packet(rt_uint8_t action, rt_uint8_t *buf, rt_uint16_t buf_len);
  53. int gagent_cloud_start(gagent_cloud_param *param);
  54. #ifdef __cplusplus
  55. }
  56. #endif
  57. #endif