mac
2023-10-10 32b5f366ceaad4aa9a33eccf0b109eef24175495
app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
@@ -5,6 +5,7 @@
import android.util.Log;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.hdl.linkpm.sdk.core.exception.HDLException;
import com.hdl.photovoltaic.HDLApp;
import com.hdl.photovoltaic.bean.BaseEventBus;
@@ -23,6 +24,7 @@
import com.hdl.sdk.link.core.callback.GatewayCallBack;
import com.hdl.sdk.link.core.callback.ModbusCallBack;
import com.hdl.sdk.link.core.connect.HDLModBusConnect;
import com.hdl.sdk.link.core.utils.mqtt.MqttRecvClient;
import com.hdl.sdk.link.gateway.HDLLinkLocalGateway;
import org.greenrobot.eventbus.EventBus;
@@ -82,17 +84,23 @@
                        //EventBus事件分发
                        BaseEventBus baseEventBus = new BaseEventBus();
                        baseEventBus.setType(ConstantManage.EVENTBUS_POST_HOME_CREATED);
                        baseEventBus.setType(HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION);
                        baseEventBus.setData(getKeyValue("data", data));
                        EventBus.getDefault().post(baseEventBus);
                    }
                    break;
                    //读取详情
                    case HDLUniMP.UNI_EVENT_REPLY_HOME_DETAILS: {
                        //详情
                    }
                    break;
                    //关闭详情页
                    case HDLUniMP.UNI_EVENT_REPLY_HOME_CLOSE_HOME_DETAILS_PAGE: {
                        //关闭详情页
                        //EventBus事件分发
                        BaseEventBus baseEventBus = new BaseEventBus();
                        baseEventBus.setType(HDLUniMP.UNI_EVENT_REPLY_HOME_CLOSE_HOME_DETAILS_PAGE);
                        baseEventBus.setData(getKeyValue("data", data));
                        EventBus.getDefault().post(baseEventBus);
                    }
                    break;
@@ -103,8 +111,8 @@
            } else if (HDLUniMP.UNI_EVENT_REPLY_DEVICE_MODEL.equals(event)) {
                //设备模块
                switch (type) {
                    //添加逆变器到云端
                    case HDLUniMP.UNI_EVENT_REPLY_DEVICE_ADD: {
                        //添加设备到云端
                        String mac = getKeyValue("mac", getKeyValue("data", data));
                        HdlDeviceLogic.getInstance().setGatewayRemoteParam(mac, new LinkCallBack<Boolean>() {
                            @Override
@@ -151,8 +159,8 @@
                    }
                    break;
                    //局域网搜索逆变器列表
                    case HDLUniMP.UNI_EVENT_REPLY_DEVICE_NET_LIST: {
                        //网关搜索
                        HdlDeviceLogic.getInstance().searchGateway(new GatewayCallBack() {
                            @Override
                            public void onSuccess(List<GatewayBean> gatewayBeanList) {
@@ -169,12 +177,16 @@
                    break;
                    //获取逆变器列表
                    case HDLUniMP.UNI_EVENT_REPLY_DEVICE_LIST: {
                        HdlDeviceLogic.getInstance().getLocalGatewayList(new CloudCallBeak<Boolean>() {
                        HdlDeviceLogic.getInstance().getCurrentHomeLocalAndCloudGatewayList(new CloudCallBeak<List<GatewayBean>>() {
                            @Override
                            public void onSuccess(Boolean obj) {
                            public void onSuccess(List<GatewayBean> list) {
                                if (callback != null) {
                                    uniCallbackData(HdlDeviceLogic.getInstance().getGatewayList(), callback);
                                    uniCallbackData(list, callback);
                                    //EventBus事件分发
                                    BaseEventBus baseEventBus = new BaseEventBus();
                                    baseEventBus.setType(HDLUniMP.UNI_EVENT_REPLY_DEVICE_LIST);
                                    baseEventBus.setData(list);
                                    EventBus.getDefault().post(baseEventBus);
                                }
                            }
@@ -211,11 +223,9 @@
                        });
                    }
                    break;
                    //设备时间读取
                    //逆变器时间读取
                    case HDLUniMP.UNI_EVENT_REPLY_DEVICE_TIME: {
                        //添加设备到云端
                        String mac = getKeyValue("mac", getKeyValue("data", data));
                        //获取oid列表
                        HdlDeviceLogic.getInstance().getGatewayTime(mac, new LinkCallBack<Boolean>() {
                            @Override
                            public void onSuccess(Boolean obj) {
@@ -229,20 +239,10 @@
                        });
                    }
                    break;
                    //设备时间编辑
                    //逆变器时间编辑
                    case HDLUniMP.UNI_EVENT_REPLY_DEVICE_TIME_EDIT: {
                        String mac = getKeyValue("mac", getKeyValue("data", data));
                        HdlDeviceLogic.getInstance().getGatewayOidList(mac, new LinkCallBack<List<OidBean>>() {
                            @Override
                            public void onSuccess(List<OidBean> obj) {
                            }
                            @Override
                            public void onError(HDLLinkException e) {
                            }
                        });
                        HdlDeviceLogic.getInstance().editGatewayTime(mac, new JsonObject(), null);
                    }
                    break;