mac
2023-09-23 b8209d15d915f72d9abe3a68b76e1f4cfd21eac3
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
package com.hdl.photovoltaic.other;
 
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
import com.hdl.hdlhttp.HxHttp;
import com.hdl.linkpm.sdk.core.exception.HDLException;
import com.hdl.photovoltaic.bean.HttpResponsePack;
import com.hdl.photovoltaic.internet.HttpClient;
import com.hdl.photovoltaic.internet.api.HttpApi;
import com.hdl.photovoltaic.listener.BaseSuccessFailureCallBeak;
import com.hdl.photovoltaic.listener.CloudCallBeak;
import com.hdl.photovoltaic.ui.bean.CloudInverterChildDeviceBean;
 
import java.lang.reflect.Type;
import java.util.List;
 
import io.reactivex.rxjava3.disposables.Disposable;
 
/**
 * mqtt的逻辑
 */
public class HdlMqttLogic {
    private static volatile HdlMqttLogic sHdlMqttLogic;
 
    /**
     * 获取当前对象
     *
     * @return HdlAccountLogic
     */
    public static synchronized HdlMqttLogic getInstance() {
        if (sHdlMqttLogic == null) {
            synchronized (HdlMqttLogic.class) {
                if (sHdlMqttLogic == null) {
                    sHdlMqttLogic = new HdlMqttLogic();
                }
            }
 
        }
        return sHdlMqttLogic;
    }
 
    /**
     * 获取逆变器(获取设备远程通讯信息)
     *
     * @param homeId        住宅Id
     * @param spk           spk
     * @param mac           设备mac
     * @param cloudCallBeak 回调
     */
    public void getDeviceRemoteInfo(String homeId, String spk, String mac, CloudCallBeak<String> cloudCallBeak) {
        String requestUrl = HttpApi.POST_Device_remoteInfo;
        JsonObject json = new JsonObject();
        json.addProperty("homeId", homeId);
        json.addProperty("spk", spk);
        json.addProperty("mac", mac);
        HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() {
            @Override
            public void onSuccess(String jsonStr) {
//                if (httpResponsePack != null && httpResponsePack.getData() != null) {
//                    Gson gson = new Gson();
//                    String json = gson.toJson(httpResponsePack.getData());
//                    Type typeOfT = new TypeToken<List<CloudInverterChildDeviceBean>>() {
//                    }.getType();
//                    if (cloudCallBeak != null) {
//                        cloudCallBeak.onSuccess("list");
//                    }
//                }
            }
 
            @Override
            public void onFailure(HDLException e) {
                if (cloudCallBeak != null) {
                    cloudCallBeak.onFailure(e);
                }
            }
        });
 
    }
}