1 /* 2 * Copyright (C) 2015-2018 Alibaba Group Holding Limited 3 */ 4 5 #ifndef __AWSS_PACKET_H__ 6 #define __AWSS_PACKET_H__ 7 #include "linkkit/infra/infra_sha1.h" 8 9 #define MSG_REQ_ID_LEN (16) 10 #define TOPIC_LEN_MAX (128) 11 #define DEV_INFO_LEN_MAX (512) 12 #define DEV_SIGN_SIZE (SHA1_DIGEST_SIZE) 13 14 #define ILOP_VER "1.0" 15 #define AWSS_VER \ 16 "{\"smartconfig\":\"2.0\",\"zconfig\":\"2.0\",\"router\":\"2.0\",\"ap\":" \ 17 "\"2.0\",\"softap\":\"2.0\"}" 18 19 #define TOPIC_AWSS_SWITCHAP "/sys/%s/%s/awss/device/switchap" 20 #define TOPIC_AWSS_GETDEVICEINFO_MCAST "/sys/awss/device/info/get" 21 #define TOPIC_AWSS_GETDEVICEINFO_UCAST "/sys/%s/%s/awss/device/info/get" 22 #define TOPIC_AWSS_GET_CONNECTAP_INFO_MCAST \ 23 "/sys/awss/device/connectap/info/get" 24 #define TOPIC_AWSS_GET_CONNECTAP_INFO_UCAST \ 25 "/sys/%s/%s/awss/device/connectap/info/get" 26 #define TOPIC_GETDEVICEINFO_MCAST "/sys/device/info/get" 27 #define TOPIC_GETDEVICEINFO_UCAST "/sys/%s/%s/device/info/get" 28 #define TOPIC_POST_STATIS "/sys/%s/%s/thing/log/post" 29 #define TOPIC_AWSS_NOTIFY "/sys/awss/device/info/notify" 30 #define TOPIC_AWSS_CONNECTAP_NOTIFY "/sys/awss/event/connectap/notify" 31 #define TOPIC_NOTIFY "/sys/device/info/notify" 32 #define TOPIC_SWITCHAP "/sys/%s/%s/thing/awss/device/switchap" 33 #define TOPIC_SWITCHAP_REPLY "/sys/%s/%s/thing/awss/device/switchap_reply" 34 #define TOPIC_ZC_ENROLLEE "/sys/%s/%s/thing/awss/enrollee/found" 35 #define TOPIC_ZC_ENROLLEE_REPLY "/sys/%s/%s/thing/awss/enrollee/found_reply" 36 #define TOPIC_ZC_CHECKIN "/sys/%s/%s/thing/awss/enrollee/checkin" 37 #define TOPIC_ZC_CHECKIN_REPLY "/sys/%s/%s/thing/awss/enrollee/checkin_reply" 38 #define TOPIC_ZC_CIPHER "/sys/%s/%s/thing/cipher/get" 39 #define TOPIC_ZC_CIPHER_REPLY "/sys/%s/%s/thing/cipher/get_reply" 40 #define TOPIC_MATCH_REPORT "/sys/%s/%s/thing/awss/enrollee/match" 41 #define TOPIC_MATCH_REPORT_REPLY "/sys/%s/%s/thing/awss/enrollee/match_reply" 42 #define TOPIC_AWSS_DEV_AP_SWITCHAP "/sys/awss/device/softap/switchap" 43 44 #define METHOD_DEV_INFO_NOTIFY "device.info.notify" 45 #define METHOD_AWSS_DEV_INFO_NOTIFY "awss.device.info.notify" 46 #define METHOD_AWSS_CONNECTAP_NOTIFY "awss.event.connectap.notify" 47 #define METHOD_AWSS_DEV_AP_SWITCHAP "awss.device.softap.switchap" 48 #define METHOD_EVENT_ZC_SWITCHAP "thing.awss.device.switchap" 49 #define METHOD_EVENT_ZC_ENROLLEE "thing.awss.enrollee.found" 50 #define METHOD_EVENT_ZC_CHECKIN "thing.awss.enrollee.checkin" 51 #define METHOD_EVENT_ZC_CIPHER "thing.cipher.get" 52 #define METHOD_MATCH_REPORT "thing.awss.enrollee.match" 53 #define METHOD_LOG_POST "things.log.post" 54 55 #define AWSS_ACK_FMT "{\"id\":%s,\"code\":%d,\"data\":%s}" 56 #define AWSS_REQ_FMT \ 57 "{\"id\":%s,\"version\":\"%s\",\"method\":\"%s\",\"params\":%s}" 58 #define AWSS_JSON_PARAM "params" 59 #define AWSS_JSON_CODE "code" 60 #define AWSS_JSON_ID "id" 61 #define AWSS_STATIS_FMT \ 62 "{\"template\":\"timestamp logLevel module traceContext " \ 63 "logContent\",\"contents\":[\"%u %s %s %u %s\"]}" 64 65 enum { 66 AWSS_CMP_PKT_TYPE_REQ = 1, 67 AWSS_CMP_PKT_TYPE_RSP, 68 }; 69 70 void produce_random(uint8_t *random, uint32_t len); 71 char *awss_build_sign_src(char *sign_src, int *sign_src_len); 72 void *awss_build_dev_info(int type, void *dev_info, int info_len); 73 const char *awss_build_topic(const char *topic_fmt, char *topic, uint32_t tlen); 74 int awss_build_packet(int type, void *id, void *ver, void *method, void *data, 75 int code, void *pkt, int *pkt_len); 76 77 #endif 78