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