#ifndef _INCLUDE_LWMQTT_ALIYUN_H_ #define _INCLUDE_LWMQTT_ALIYUN_H_ #include "lwmqtt.h" /** * @brief Functions of Aliyun MQTT message. */ typedef enum _lwmqtt_aliyun_function_ { LWMQTT_ALIFUNC_POWERSWITCH, LWMQTT_ALIFUNC_RAW_MSG, LWMQTT_ALIFUNC_TEMP, LWMQTT_ALIFUNC_MAX } lwmqtt_alifunc_t; /** * @brief Metholds of Aliyun MQTT message. */ typedef enum _lwmqtt_aliyun_method_ { LWMQTT_ALIMTHD_SET, /* LWMQTT_ALI_MTHD_SET_STR */ LWMQTT_ALIMTHD_GET, /* LWMQTT_ALI_MTHD_GET_STR */ LWMQTT_ALIMTHD_POST,/* LWMATT_ALI_MTHD_PST_STR */ LWMQTT_ALIMTHD_MAX }lwmqtt_alimthd_t; /** * @brief Structure of Aliyun MQTT message that used by our module. */ typedef struct _lwmqtt_aliyun_message_type_ { /** Methold of MQTT message. Reference to lwmqtt_alimthd_t. */ uint16_t alimthd; /** Function of MQTT message. Reference to lwmqtt_alifunc_t. */ uint16_t alifunc; /** Quick param(if needed by function of MQTT message). */ uint32_t param; /** Source of MQTT message. */ uint16_t src; /** Length of data for MQTT message(if needed by function of MQTT message). */ uint16_t dlen; /** Data for MQTT message(if needed by function of MQTT message). */ uint8_t data[0]; }lwmqtt_alimsg_t; /** * @brief Special const information for Aliyun. TODO : Will be maked up later. */ #define LWMQTT_ALI_SERVER "a13gv5ZzTDX.iot-as-mqtt.cn-shanghai.aliyuncs.com" #define LWMQTT_ALI_SERVER_IPV4 0x8BC48787 #define LWMQTT_ALI_CTID "RAIN0001Example001|securemode=3,signmethod=hmacsha1,timestamp=10|" #define LWMQTT_ALI_USER "Example001&a13gv5ZzTDX" #define LWMQTT_ALI_PASS "f66718aa1cc5c7343df8e989ee9747723413fb3a" #define LWMQTT_ALI_DEVICE_STR "/sys/a13gv5ZzTDX/Example001/" #define LWMQTT_ALI_MTHD_SET_STR "thing/service/property/set" #define LWMQTT_ALI_MTHD_GET_STR "thing/service/property/get" #define LWMQTT_ALI_MTHD_PST_STR "thing/event/property/post" #define LWMQTT_ALI_SUB LWMQTT_ALI_DEVICE_STR LWMQTT_ALI_MTHD_SET_STR #define LWMQTT_ALI_PUB LWMQTT_ALI_DEVICE_STR LWMQTT_ALI_MTHD_PST_STR #define PARAM_STRING_SWITCH "\"params\":{\"PowerSwitch\":" #define RARAM_STRING_POST_MESSAGE "{\"method\":\"thing.event.property.post\",\"params\":{\"Message\":\"Powerswitch to %d successfully!\"},\"version\":\"1.0.0\"}" #define RARAM_STRING_POST_SWITCH "{\"method\":\"thing.event.property.post\",\"params\":{\"PowerSwitch\":%d},\"version\":\"1.0.0\"}" typedef void (*lwmqtt_alifunc_func_t)(lwmqtt_alimsg_t *p_alimsg); /** * @brief lwmqtt_ali_function_deliver() - Deliver a Ali-MQTT function to execute. * @param p_alimsg: MQTT message. * @return: ERR_OK -- Process the message successfully. * @return: ERR_FAIL -- Error occurs when process this message. */ uint32_t lwmqtt_ali_function_deliver(lwmqtt_alimsg_t *p_alimsg); /** * @brief lwmqtt_ali_message_receive() - Process an Ali-MQTT message from ETH. * @param p_topic: Topic of Ali-MQTT message. * @param p_message: Message data of Ali-MQTT message. */ void lwmqtt_ali_message_receive(lwmqtt_string_t *p_topic, lwmqtt_message_t *p_message); #endif