1 /*
2  * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef IOT_PROFILE_H
17 #define IOT_PROFILE_H
18 
19 #include <hi_types_base.h>
20 #include "iot_config.h"
21 
22 #define OC_BEEP_STATUS_ON       ((hi_u8) 0x01)
23 #define OC_BEEP_STATUS_OFF      ((hi_u8) 0x00)
24 
25 // < enum all the data type for the oc profile
26 typedef enum {
27     EN_IOT_DATATYPE_INT = 0,
28     EN_IOT_DATATYPE_LONG,
29     EN_IOT_DATATYPE_FLOAT,
30     EN_IOT_DATATYPE_DOUBLE,
31     EN_IOT_DATATYPE_STRING,           // < must be ended with '\0'
32     EN_IOT_DATATYPE_LAST,
33 }IoTDataType_t;
34 
35 typedef enum {
36     OC_LED_ON = 1,
37     OC_LED_OFF
38 }OcLedValue;
39 
40 typedef struct {
41     void                            *nxt; // < ponit to the next key
42     const char                      *key;
43     const char                      *value;
44     hi_u32                          iValue;
45     IoTDataType_t                   type;
46 }IoTProfileKV_t;
47 
48 typedef struct {
49     void *nxt;
50     char *serviceID;
51     char *eventTime;
52     IoTProfileKV_t *serviceProperty;
53 }IoTProfileService_t;
54 
55 typedef struct {
56     int  retCode;           // < response code, 0 success while others failed
57     const char   *respName; // < response name
58     const char   *requestID; // < specified by the message command
59     IoTProfileKV_t  *paras; // < the command paras
60 }IoTCmdResp_t;
61 
62 typedef struct {
63     const char *subState;
64     const char *subReport;
65     const char *reportVersion;
66     const char *Token;
67 }WeChatProfileStatus;
68 
69 typedef struct {
70     int lightActionStatus;
71     int motorActionStatus;
72     int temperatureData;
73     int humidityActionData;
74     int lightIntensityActionData;
75     const char *subDeviceActionLight;
76     const char *subDeviceActionMotor;
77     const char *subDeviceActionTemperature;
78     const char *subDeviceActionHumidity;
79     const char *subDeviceActionLightIntensity;
80 }WeChatProfileReporte;
81 
82 typedef struct {
83     const char *subscribeType;
84     WeChatProfileStatus status;
85     WeChatProfileReporte reportAction;
86 }WeChatProfile;
87 
88 /**
89  * use this function to report the property to the iot platform
90 */
91 int IoTProfilePropertyReport(char *deviceID, WeChatProfile *payload);
92 void cJsonInit(void);
93 void WifiStaReadyWait(void);
94 #endif