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;
@@ -57,7 +59,7 @@
        return sHdlUniLogic;
    }
    //region ******【原生】和【小程序】通讯的方法 onOtherUniMPEventReceive();openUniMP();sendUni();******
    //region ******【原生】和【小程序】通讯的3个方法名 onOtherUniMPEventReceive();openUniMP();sendUni();******
    /**
     * 原生接收到uni发来的数据
@@ -77,17 +79,28 @@
            if (HDLUniMP.UNI_EVENT_REPLY_HOME_MODEL.equals(event)) {
                //住宅模块
                switch (type) {
                    //创建电站
                    case HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION: {
                        //创建
                        //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;
@@ -98,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
@@ -146,8 +159,8 @@
                    }
                    break;
                    //局域网搜索逆变器列表
                    case HDLUniMP.UNI_EVENT_REPLY_DEVICE_NET_LIST: {
                        //网关搜索
                        HdlDeviceLogic.getInstance().searchGateway(new GatewayCallBack() {
                            @Override
                            public void onSuccess(List<GatewayBean> gatewayBeanList) {
@@ -162,13 +175,18 @@
                        });
                    }
                    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);
                                }
                            }
@@ -186,10 +204,10 @@
                    }
                    break;
                    //获取oid列表
                    case HDLUniMP.UNI_EVENT_REPLY_DEVICE_OID: {
                        //添加设备到云端
                        String mac = getKeyValue("mac", getKeyValue("data", data));
                        //获取oid列表
                        HdlDeviceLogic.getInstance().getGatewayOidList(mac, new LinkCallBack<List<OidBean>>() {
                            @Override
                            public void onSuccess(List<OidBean> list) {
@@ -200,16 +218,14 @@
                            @Override
                            public void onError(HDLLinkException e) {
                                uniCallbackData(null, -2, e.getMessage(), callback);
                                uniCallbackData(null, -2, e.getMsg(), callback);
                            }
                        });
                    }
                    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) {
@@ -222,23 +238,11 @@
                            }
                        });
                    }
                    //设备时间编辑
                    break;
                    //逆变器时间编辑
                    case HDLUniMP.UNI_EVENT_REPLY_DEVICE_TIME_EDIT: {
                        //添加设备到云端
                        String mac = getKeyValue("mac", getKeyValue("data", data));
                        //获取oid列表
                        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;
@@ -248,22 +252,23 @@
                WifiUtils wifiUtils = new WifiUtils(HDLApp.getInstance());
                //wifi模块
                switch (type) {
                    //获取wifi列表
                    case HDLUniMP.UNI_EVENT_REPLY_WIFI_LIST: {
                        //获取wifi列表
                        if (callback != null) {
                            uniCallbackData(wifiUtils.getScanResult(), callback);
                        }
                    }
                    break;
                    //当前wifi详情
                    case HDLUniMP.UNI_EVENT_REPLY_WIFI_INFO: {
                        //当前wifi详情
                        if (callback != null) {
                            uniCallbackData(wifiUtils.getCurrentConnectWifiInfo(), callback);
                        }
                    }
                    break;
                    //wifi连接
                    case HDLUniMP.UNI_EVENT_REPLY_WIFI_CONNECT: {
                        //wifi连接
                    }
                    break;