1 /* 2 * Copyright (C) 2015-2018 Alibaba Group Holding Limited 3 */ 4 5 #include "linkkit/infra/infra_defs.h" 6 7 #ifndef _INFRA_REPORT_H_ 8 #define _INFRA_REPORT_H_ 9 10 11 #ifndef VERSION_NUM_SIZE 12 #define VERSION_NUM_SIZE 4 13 #endif 14 15 #ifndef RANDOM_NUM_SIZE 16 #define RANDOM_NUM_SIZE 4 17 #endif 18 19 #ifndef MAC_ADDRESS_SIZE 20 #define MAC_ADDRESS_SIZE 8 21 #endif 22 23 #ifndef CHIP_CODE_SIZE 24 #define CHIP_CODE_SIZE 4 25 #endif 26 27 #define AOS_ACTIVE_INFO_LEN (81) 28 29 /* activation device type */ 30 typedef enum { 31 ACTIVE_SUBDEV, /* it's a subDevice */ 32 ACTIVE_SINGLE_GW /* it s a single or gateway device */ 33 } active_device_type_t; 34 35 /* activation system type */ 36 typedef enum { 37 ACTIVE_LINKKIT_ONLY, /* only linkkit implement */ 38 ACTIVE_LINKKIT_AOS, /* both linkkit and AOS implement */ 39 ACTIVE_LINKKIT_OTHERS /* linkkit and 3-party OS implement */ 40 } active_system_type_t; 41 42 typedef int (*info_report_func_pt)(void *handle, const char *topic_name, 43 int req_ack, void *data, int len); 44 45 #define MIDREPORT_PAYLOAD_LEN \ 46 (62 + IOTX_PARTNER_ID_LEN + IOTX_MODULE_ID_LEN + 32 + 1) 47 #define MIDREPORT_REQID_LEN (IOTX_PRODUCT_KEY_LEN + IOTX_DEVICE_NAME_LEN + 6) 48 #define AOS_VERSON_MSG_LEN (256) 49 #define LINKKIT_VERSION_MSG_LEN (192) 50 #define FIRMWARE_VERSION_MSG_LEN (64) 51 52 int iotx_report_id(void); 53 int iotx_midreport_reqid(char *requestId, char *product_key, char *device_name); 54 int iotx_midreport_payload(char *msg, char *requestId, char *mid, char *pid); 55 int iotx_midreport_topic(char *topic_name, char *topic_head, char *product_key, 56 char *device_name); 57 58 /* AOS version report API */ 59 int iotx_gen_aos_report_topic(char *topic_name, char *product_key, 60 char *device_name); 61 int iotx_gen_aos_report_payload(char *msg, int requestId, char *versionData); 62 63 void aos_get_version_hex(unsigned char version[VERSION_NUM_SIZE]); 64 65 #ifndef BUILD_AOS 66 unsigned int aos_get_version_info(unsigned char version_num[VERSION_NUM_SIZE], 67 unsigned char random_num[RANDOM_NUM_SIZE], 68 unsigned char mac_address[MAC_ADDRESS_SIZE], 69 unsigned char chip_code[CHIP_CODE_SIZE], 70 unsigned char *output_buffer, 71 unsigned int output_buffer_size); 72 #endif 73 74 void iotx_set_report_func(info_report_func_pt func); 75 int iotx_report_devinfo(void *pclient); 76 int iotx_report_mid(void *pclient); 77 int iotx_report_firmware_version(void *pclient); 78 79 #endif 80