airkiss.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * airkiss.h
  3. *
  4. * Created on: 2015-1-26
  5. * Author: peterfan
  6. */
  7. #ifndef AIRKISS_H_
  8. #define AIRKISS_H_
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. typedef void* (*airkiss_memset_fn) (void* ptr, int value, unsigned int num);
  13. typedef void* (*airkiss_memcpy_fn) (void* dst, const void* src, unsigned int num);
  14. typedef int (*airkiss_memcmp_fn) (const void* ptr1, const void* ptr2, unsigned int num);
  15. typedef int (*airkiss_printf_fn) (const char* format, ...);
  16. typedef struct
  17. {
  18. airkiss_memset_fn memset;
  19. airkiss_memcpy_fn memcpy;
  20. airkiss_memcmp_fn memcmp;
  21. airkiss_printf_fn printf;
  22. } airkiss_config_t;
  23. /**
  24. * @brief Get airkiss lib version.
  25. *
  26. * @attention The lenth of version is unknown
  27. *
  28. * @param null.
  29. *
  30. * @return const char*
  31. */
  32. const char* airkiss_version(void);
  33. typedef enum
  34. {
  35. /* the length of the data buffer is lack*/
  36. AIRKISS_LAN_ERR_OVERFLOW = -5,
  37. /* Do not support the type of instruction */
  38. AIRKISS_LAN_ERR_CMD = -4,
  39. /* Error reading data package */
  40. AIRKISS_LAN_ERR_PAKE = -3,
  41. /* Error function passing parameters */
  42. AIRKISS_LAN_ERR_PARA = -2,
  43. /* Packet data error */
  44. AIRKISS_LAN_ERR_PKG = -1,
  45. /* Message format is correct */
  46. AIRKISS_LAN_CONTINUE = 0,
  47. /* Find equipment request packet is received */
  48. AIRKISS_LAN_SSDP_REQ = 1,
  49. /* Packet packaging complete */
  50. AIRKISS_LAN_PAKE_READY = 2
  51. } airkiss_lan_ret_t;
  52. typedef enum
  53. {
  54. AIRKISS_LAN_SSDP_REQ_CMD = 0x1,
  55. AIRKISS_LAN_SSDP_RESP_CMD = 0x1001,
  56. AIRKISS_LAN_SSDP_NOTIFY_CMD = 0x1002
  57. } airkiss_lan_cmdid_t;
  58. /**
  59. * @brief Receive UDP packet and input this API for analyzing.
  60. *
  61. * @attention null.
  62. *
  63. * @param const void* body : The start of the UDP message body data pointer.
  64. * @param unsigned short length : the effective length of data.
  65. * @param const airkiss_config_t* config : input struct airkiss_config_t
  66. *
  67. * @return >=0 : succeed (reference airkiss_lan_ret_t)
  68. * @return <0 : error code (reference airkiss_lan_ret_t)
  69. */
  70. int airkiss_lan_recv(const void* body, unsigned short length, const airkiss_config_t* config);
  71. /**
  72. * @brief Packaging the UDP packet to send.
  73. *
  74. * @attention null.
  75. *
  76. * @param airkiss_lan_cmdid_t ak_lan_cmdid : The packet type.
  77. * @param void* appid : Vendor's Wechat public number id.
  78. * @param void* deviceid : device model id.
  79. * @param void* _datain : the data to be sent.
  80. * @param unsigned short inlength : the lenth of data to be sent.
  81. * @param void* _dataout : Data buffer addr.
  82. * @param unsigned short* outlength : the size of data buffer.
  83. * @param const airkiss_config_t* config : input struct airkiss_config_t
  84. *
  85. * @return >=0 : succeed (reference airkiss_lan_ret_t)
  86. * @return <0 : error code (reference airkiss_lan_ret_t)
  87. */
  88. int airkiss_lan_pack(airkiss_lan_cmdid_t ak_lan_cmdid, void* appid, void* deviceid, void* _datain, unsigned short inlength, void* _dataout, unsigned short* outlength, const airkiss_config_t* config);
  89. #ifdef __cplusplus
  90. }
  91. #endif
  92. #endif /* AIRKISS_H_ */