10a7ce71fSopenharmony_ci/*
20a7ce71fSopenharmony_ci * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED.
30a7ce71fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
40a7ce71fSopenharmony_ci * you may not use this file except in compliance with the License.
50a7ce71fSopenharmony_ci * You may obtain a copy of the License at
60a7ce71fSopenharmony_ci *
70a7ce71fSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
80a7ce71fSopenharmony_ci *
90a7ce71fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
100a7ce71fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
110a7ce71fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
120a7ce71fSopenharmony_ci * See the License for the specific language governing permissions and
130a7ce71fSopenharmony_ci * limitations under the License.
140a7ce71fSopenharmony_ci */
150a7ce71fSopenharmony_ci
160a7ce71fSopenharmony_ci#ifndef IOT_PROFILE_H
170a7ce71fSopenharmony_ci#define IOT_PROFILE_H
180a7ce71fSopenharmony_ci
190a7ce71fSopenharmony_ci#include <hi_types_base.h>
200a7ce71fSopenharmony_ci#include "iot_config.h"
210a7ce71fSopenharmony_ci
220a7ce71fSopenharmony_ci#define OC_BEEP_STATUS_ON       ((hi_u8) 0x01)
230a7ce71fSopenharmony_ci#define OC_BEEP_STATUS_OFF      ((hi_u8) 0x00)
240a7ce71fSopenharmony_ci
250a7ce71fSopenharmony_ci// < enum all the data type for the oc profile
260a7ce71fSopenharmony_citypedef enum {
270a7ce71fSopenharmony_ci    EN_IOT_DATATYPE_INT = 0,
280a7ce71fSopenharmony_ci    EN_IOT_DATATYPE_LONG,
290a7ce71fSopenharmony_ci    EN_IOT_DATATYPE_FLOAT,
300a7ce71fSopenharmony_ci    EN_IOT_DATATYPE_DOUBLE,
310a7ce71fSopenharmony_ci    EN_IOT_DATATYPE_STRING,           // < must be ended with '\0'
320a7ce71fSopenharmony_ci    EN_IOT_DATATYPE_LAST,
330a7ce71fSopenharmony_ci}IoTDataType_t;
340a7ce71fSopenharmony_ci
350a7ce71fSopenharmony_citypedef enum {
360a7ce71fSopenharmony_ci    OC_LED_ON = 1,
370a7ce71fSopenharmony_ci    OC_LED_OFF
380a7ce71fSopenharmony_ci}OcLedValue;
390a7ce71fSopenharmony_ci
400a7ce71fSopenharmony_citypedef struct {
410a7ce71fSopenharmony_ci    void                            *nxt; // < ponit to the next key
420a7ce71fSopenharmony_ci    const char                      *key;
430a7ce71fSopenharmony_ci    const char                      *value;
440a7ce71fSopenharmony_ci    hi_u32                          iValue;
450a7ce71fSopenharmony_ci    IoTDataType_t                   type;
460a7ce71fSopenharmony_ci}IoTProfileKV_t;
470a7ce71fSopenharmony_ci
480a7ce71fSopenharmony_citypedef struct {
490a7ce71fSopenharmony_ci    void *nxt;
500a7ce71fSopenharmony_ci    char *serviceID;
510a7ce71fSopenharmony_ci    char *eventTime;
520a7ce71fSopenharmony_ci    IoTProfileKV_t *serviceProperty;
530a7ce71fSopenharmony_ci}IoTProfileService_t;
540a7ce71fSopenharmony_ci
550a7ce71fSopenharmony_citypedef struct {
560a7ce71fSopenharmony_ci    int  retCode;           // < response code, 0 success while others failed
570a7ce71fSopenharmony_ci    const char   *respName; // < response name
580a7ce71fSopenharmony_ci    const char   *requestID; // < specified by the message command
590a7ce71fSopenharmony_ci    IoTProfileKV_t  *paras; // < the command paras
600a7ce71fSopenharmony_ci}IoTCmdResp_t;
610a7ce71fSopenharmony_ci
620a7ce71fSopenharmony_citypedef struct {
630a7ce71fSopenharmony_ci    const char *subState;
640a7ce71fSopenharmony_ci    const char *subReport;
650a7ce71fSopenharmony_ci    const char *reportVersion;
660a7ce71fSopenharmony_ci    const char *Token;
670a7ce71fSopenharmony_ci}WeChatProfileStatus;
680a7ce71fSopenharmony_ci
690a7ce71fSopenharmony_citypedef struct {
700a7ce71fSopenharmony_ci    int lightActionStatus;
710a7ce71fSopenharmony_ci    int motorActionStatus;
720a7ce71fSopenharmony_ci    int temperatureData;
730a7ce71fSopenharmony_ci    int humidityActionData;
740a7ce71fSopenharmony_ci    int lightIntensityActionData;
750a7ce71fSopenharmony_ci    const char *subDeviceActionLight;
760a7ce71fSopenharmony_ci    const char *subDeviceActionMotor;
770a7ce71fSopenharmony_ci    const char *subDeviceActionTemperature;
780a7ce71fSopenharmony_ci    const char *subDeviceActionHumidity;
790a7ce71fSopenharmony_ci    const char *subDeviceActionLightIntensity;
800a7ce71fSopenharmony_ci}WeChatProfileReporte;
810a7ce71fSopenharmony_ci
820a7ce71fSopenharmony_citypedef struct {
830a7ce71fSopenharmony_ci    const char *subscribeType;
840a7ce71fSopenharmony_ci    WeChatProfileStatus status;
850a7ce71fSopenharmony_ci    WeChatProfileReporte reportAction;
860a7ce71fSopenharmony_ci}WeChatProfile;
870a7ce71fSopenharmony_ci
880a7ce71fSopenharmony_ci/**
890a7ce71fSopenharmony_ci * use this function to report the property to the iot platform
900a7ce71fSopenharmony_ci*/
910a7ce71fSopenharmony_ciint IoTProfilePropertyReport(char *deviceID, WeChatProfile *payload);
920a7ce71fSopenharmony_civoid cJsonInit(void);
930a7ce71fSopenharmony_civoid WifiStaReadyWait(void);
940a7ce71fSopenharmony_ci#endif