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 #include "iot_profile.h"
19 #include "app_demo_multi_sample.h"
20 
21 typedef hi_void (*ClflCallBackFunc) (HiColorfulLightMode currentMode, HiControlModeType currentType);
22 typedef hi_void (*TrflCallBackFunc) (HiTrafficLightMode currentMode,  HiControlModeType currentType);
23 typedef hi_void (*EnvCallBackFunc)  (HiEnvironmentMode currentMode,   HiControlModeType currentType);
24 
25 #define OC_BEEP_STATUS_ON       ((hi_u8) 0x01)
26 #define OC_BEEP_STATUS_OFF      ((hi_u8) 0x00)
27 
28 ////< enum all the data type for the oc profile
29 typedef enum {
30     EN_IOT_DATATYPE_INT = 0,
31     EN_IOT_DATATYPE_LONG,
32     EN_IOT_DATATYPE_FLOAT,
33     EN_IOT_DATATYPE_DOUBLE,
34     EN_IOT_DATATYPE_STRING, ///< must be ended with '\0'
35     EN_IOT_DATATYPE_LAST,
36 }IoTDataType;
37 
38 typedef enum {
39     OC_LED_ON = 1,
40     OC_LED_OFF
41 }LedValue;
42 
43 typedef struct {
44     HiColorfulLightMode  *colorfulLightModule;
45     void  *colorfulDeviceOnlineTime;
46     void  *clfRedValue;
47     void  *clfGreenValue;
48     void  *clfBlueValue;
49     void  *humanTestModuleValue;
50     void  *humanTestModuleTimeCount;
51 }ColorfulLightDef;
52 
53 typedef struct {
54     HiTrafficLightMode  *trafficLightModule;
55     void  *trafficDeviceOnlineTime;
56     void  *trfRedValue;
57     void  *trfYellowValue;
58     void  *trfGreenValue;
59 }TrafficLightDef;
60 
61 typedef struct {
62     HiEnvironmentMode  *environmentModule;
63     void  *envDeviceOnlineTime;
64     void  *envTemperratureValue;
65     void  *envHumidityValue;
66 }EnvironmentDef;
67 
68 typedef struct {
69     void    *nxt;  ///< ponit to the next key
70     const char   *key;
71     const char   *value;
72     int   iValue;
73     hi_float  environmentValue;
74     IoTDataType  type;
75 }IoTProfileKV;
76 
77 typedef struct {
78     void *nxt;
79     char *serviceID; ///< the service id in the profile, which could not be NULL
80     char *eventTime; ///< eventtime, which could be NULL means use the platform time
81     IoTProfileKV *serviceProperty; ///< the property in the profile, which could not be NULL
82 }IoTProfileService;
83 
84 typedef struct {
85     int  retCode; ///< response code, 0 success while others failed
86     const char   *respName; ///< response name
87     const char   *requestID;///< specified by the message command
88     IoTProfileKV  *paras;  ///< the command paras
89 }IoTCmdResp;
90 /**
91  * Use this function to make the command response here
92  * and you must supplied the device id, and the payload defines as IoTCmdResp_t
93  *
94 */
95 int IoTProfileCmdResp(char *deviceID, IoTCmdResp *payload);
96 /**
97  * use this function to report the property to the iot platform
98  *
99 */
100 int IoTProfilePropertyReport(char *deviceID, IoTProfileService *payload);
101 
102 hi_void SetupTrflControlModule(HiTrafficLightMode currentMode, HiControlModeType currentType);
103 hi_void SetupTrflAutoModule(HiTrafficLightMode currentMode, HiControlModeType currentType);
104 hi_void SetupTrflHumanModule(HiTrafficLightMode currentMode, HiControlModeType currentType);
105 hi_void SetupCleanTrflStatus(HiTrafficLightMode early_mode);
106 hi_void TrafficLightStatusReport(HiTrafficLightMode currentMode, TrflCallBackFunc msg_report);
107 hi_void EnvironmentStatusReport(HiEnvironmentMode currentMode, EnvCallBackFunc msg_report);
108 hi_void SetupEnvCombustibleGasModule(HiEnvironmentMode currentMode, HiControlModeType currentType);
109 hi_void SetupEnvHumidityModule(HiEnvironmentMode currentMode, HiControlModeType currentType);
110 hi_void SetupEnvTemperatureModule(HiEnvironmentMode currentMode, HiControlModeType currentType);
111 hi_void SetupEnvAllModule(HiEnvironmentMode currentMode, HiControlModeType currentType);
112 hi_void SetupClflControlModule(HiColorfulLightMode currentMode, HiControlModeType currentType);
113 hi_void SetupClflColorfulLightModule(HiColorfulLightMode currentMode, HiControlModeType currentType);
114 hi_void SetupClflPwmControlModule(HiColorfulLightMode currentMode, HiControlModeType currentType);
115 hi_void SetupClflBrightnessModule(HiColorfulLightMode currentMode, HiControlModeType currentType);
116 hi_void SetupClflHumanDetectModule(HiColorfulLightMode currentMode, HiControlModeType currentType);
117 hi_void SetupClflLightDetectModule(HiColorfulLightMode currentMode, HiControlModeType currentType);
118 hi_void SetupClflUnionDetectModule(HiColorfulLightMode currentMode, HiControlModeType currentType);
119 hi_void ColorfulLightStatusReport(HiColorfulLightMode currentMode,  ClflCallBackFunc msgReport);
120 hi_void ReportLedLightTimeCount(hi_void);
121 #endif