panlili2024
2025-03-19 7c8ce9b9a7d3fc1aaa4a621e86415b25ad10a34f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
package com.hdl.sdk.connect.cloud;
 
import com.hdl.hdlhttp.HxHttp;
import com.hdl.hdlhttp.HxHttpBuilder;
import com.hdl.sdk.connect.bean.response.UpdateInfo;
import com.hdl.sdk.connect.cloud.bean.AiLoginInfo;
import com.hdl.sdk.connect.cloud.bean.GatewayInfo;
import com.hdl.sdk.connect.cloud.listener.GatewayListListener;
import com.hdl.sdk.connect.cloud.listener.GatewayListener;
import com.hdl.sdk.connect.cloud.listener.SibichiListener;
 
import java.util.List;
 
import io.reactivex.rxjava3.disposables.Disposable;
 
/**
 * Created by panlili on 2023/1/30
 * description:
 */
public class HdlCloudController {
 
    public static Disposable applyDeviceSecret(String supplier, String mac, String spk, CallBackListener callBack) {
        return HxHttp.builder()
                .url(HdlCloudApi.APPLY_DEVICE_SECRET)
                .params("supplier", supplier)
                .params("mac", mac)
                .params("spk", spk)
                .build()
                .post()
                .subscribeWith(new HDLResponse<String>() {
                    @Override
                    public void onResponse(String response) {
                        if (callBack != null) {
                            callBack.onSuccess(response);
                        }
                    }
 
                    @Override
                    public void onFailure(HDLException e) {
                        if (callBack != null) {
                            callBack.onError(e);
                        }
                    }
                });
    }
 
    /**
     * 检查app是否更新
     *
     * @return
     */
    public static Disposable checkAppVersion(String versionCode, String appCode, CheckAppVersionListener listener) {
        return HxHttp.builder()
                .url(HdlCloudApi.CHECK_APP_VERSION_URL)
                .params("version", versionCode)
                .params("appCode", appCode)
                .params("releaseSystem", "Android")
                .build()
                .post()
                .subscribeWith(new HDLResponse<UpdateInfo>() {
                    @Override
                    public void onResponse(UpdateInfo response) {
                        listener.onSuccess(response);
                    }
 
                    @Override
                    public void onFailure(HDLException e) {
                        listener.onError(e);
                    }
                });
    }
 
    /**
     * 获取思必驰token
     *
     * @return
     */
    public static Disposable getSibichiToken(String homeId, String clientId, SibichiListener listener) {
        return HxHttp.builder()
                .url(HdlCloudApi.GET_SIBICHI_TOKEN)
                .params("homeId", homeId)
                .params("clientId", clientId)
                .build()
                .post()
                .subscribeWith(new HDLResponse<AiLoginInfo>() {
                    @Override
                    public void onResponse(AiLoginInfo response) {
                        listener.onSuccess(response);
                    }
 
                    @Override
                    public void onFailure(HDLException e) {
                        listener.onError(e);
                    }
                });
    }
 
    /**
     * 获取主网关
     */
    public static Disposable syncMainGateway(String homeId, GatewayListener listener) {
        return syncGatewayList(homeId, new GatewayListListener() {
            @Override
            public void onSuccess(List<GatewayInfo> info) {
                if (listener != null) {
                    if (info == null || info.isEmpty()) {
                        listener.onError(new HDLException(-5000, "搜索网关失败"));
                    } else {
                        listener.onSuccess(info.get(0));
                    }
                }
 
            }
 
            @Override
            public void onError(HDLException e) {
                if (listener != null) {
                    listener.onError(e);
                }
            }
        });
    }
 
    /**
     * 同步获取网关列表
     */
    public static Disposable syncGatewayList(String homeId, GatewayListListener listener) {
        HxHttpBuilder httpBuilder = HxHttp.builder()
                .params("homeId", homeId)
                .url(HdlCloudApi.GET_GATEWAY_LIST);
        return httpBuilder.build().post().subscribeWith(new HDLResponse<List<GatewayInfo>>() {
            @Override
            public void onResponse(List<GatewayInfo> response) {
                if (listener != null) {
                    listener.onSuccess(response);
                }
            }
 
            @Override
            public void onFailure(HDLException e) {
                if (listener != null) {
                    listener.onError(e);
                }
            }
        });
    }
 
 
}