mac
2024-10-24 661fe3a7bf3a4c4f4200106540982268b260b4a1
app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
@@ -68,6 +68,7 @@
import com.hdl.sdk.link.core.callback.GatewayCallBack;
import com.hdl.sdk.link.core.callback.HDLLinkCallBack;
import com.hdl.sdk.link.core.callback.ModbusCallBack;
import com.hdl.sdk.link.core.config.HDLLinkConfig;
import com.hdl.sdk.link.core.connect.HDLModBusConnect;
import com.hdl.sdk.link.core.connect.HDLUdpConnect;
import com.hdl.sdk.link.gateway.HDLLinkLocalGateway;
@@ -153,7 +154,6 @@
                    break;
                    //用户本地缓存信息
                    case HDLUniMP.UNI_EVENT_REPLY_USER_LOCAL_INFO: {
                        HdlLogLogic.print("本地头像路径---->>>" + UserConfigManage.getInstance().getUserImageUrl());
                        JsonObject jsonObject = new JsonObject();
                        jsonObject.addProperty("user_name", UserConfigManage.getInstance().getUserName());
                        jsonObject.addProperty("user_image_url", UserConfigManage.getInstance().getUserImageUrl());
@@ -168,6 +168,7 @@
                        jsonObject.addProperty("appKey", AppConfigManage.getAppKey());
                        jsonObject.addProperty("appSecret", AppConfigManage.getAppSecret());
                        uniSuccessCallback(mode_type, jsonObject, callback);
                        HdlLogLogic.print("获取用户本地缓存信息---->>>" + jsonObject.toString());
                    }
                    break;
                }
@@ -179,10 +180,7 @@
                    case HDLUniMP.UNI_EVENT_REPLY_HOME_ADD: {
                        String url = getKeyValue("url", getKeyValue("data", data));
                        //EventBus事件分发
                        HdlCommonLogic.getInstance().postEventBusSticky(
                                HDLUniMP.UNI_EVENT_REPLY_HOME_ADD,
                                HDLUniMP.UNI_EVENT_REPLY_HOME_ADD,
                                url);
                        HdlCommonLogic.getInstance().postEventBusSticky(HDLUniMP.UNI_EVENT_REPLY_HOME_ADD, HDLUniMP.UNI_EVENT_REPLY_HOME_ADD, url);
                        if (callback != null) {
                            uniSuccessCallback(type, null, callback);
@@ -199,10 +197,7 @@
                    //创建电站
                    case HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION: {
                        //EventBus事件分发
                        HdlCommonLogic.getInstance().postEventBus(
                                HDLUniMP.UNI_EVENT_REPLY_HOME_MODEL,
                                HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION,
                                getKeyValue("data", data));
                        HdlCommonLogic.getInstance().postEventBus(HDLUniMP.UNI_EVENT_REPLY_HOME_MODEL, HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION, getKeyValue("data", data));
                        if (callback != null) {
                            uniSuccessCallback(type, null, callback);
                        }
@@ -237,10 +232,7 @@
                    //住宅【电站】编辑
                    case HDLUniMP.UNI_EVENT_REPLY_HOME_EDIT: {
                        //EventBus事件分发
                        HdlCommonLogic.getInstance().postEventBus(
                                HDLUniMP.UNI_EVENT_REPLY_HOME_MODEL,
                                HDLUniMP.UNI_EVENT_REPLY_HOME_EDIT,
                                getKeyValue("data", data));
                        HdlCommonLogic.getInstance().postEventBus(HDLUniMP.UNI_EVENT_REPLY_HOME_MODEL, HDLUniMP.UNI_EVENT_REPLY_HOME_EDIT, getKeyValue("data", data));
                        if (callback != null) {
                            uniSuccessCallback(type, null, callback);
                        }
@@ -671,6 +663,56 @@
                        HDLLinkPMUser.getInstance().logout(0);
                    }
                    break;
                    //本地密钥获取
                    case HDLUniMP.UNI_EVENT_REPLY_OTHER_LOCAL_ENCRYPT_GET: {
                        String localSecret = HDLLinkConfig.getInstance().getLocalSecret();
                        JsonObject jsonObject = new JsonObject();
                        jsonObject.addProperty("local_encrypt", localSecret);
                        if (callback != null) {
                            uniSuccessCallback(type, jsonObject, callback);
                        }
                        HdlLogLogic.print("uni---log---" + localSecret, true);
                    }
                    break;
                    //本地密钥设置
                    case HDLUniMP.UNI_EVENT_REPLY_OTHER_LOCAL_ENCRYPT_SET: {
                        String local_encrypt = getKeyValue("local_encrypt", getKeyValue("data", data));
                        //重新设置本地通讯秘钥
                        UserConfigManage.getInstance().setLocalSecret(local_encrypt);
                        UserConfigManage.getInstance().Save();
                        //配置本地通信的信息
                        HDLLinkConfig.getInstance().setLocalSecret(local_encrypt);
                        HdlLogLogic.print("uni---log---" + local_encrypt, true);
                    }
                    break;
                    //link进行密码验证
                    case HDLUniMP.UNI_EVENT_REPLY_OTHER_Password_verifiy: {
                        String password = getKeyValue("password", getKeyValue("data", data));
                        String mac = getKeyValue("mac", getKeyValue("data", data));
                        String requestUrl = TopicApi.DELETING_GATEWAY_password_verifiy;
                        JsonObject json = new JsonObject();
                        json.addProperty("password", password);
                        json.addProperty("mac", mac);
                        TcpClient.getInstance().sendDataToLinkGateway(mac, true, requestUrl, json, "", new HDLLinkCallBack() {
                            @Override
                            public void onSuccess(String msg) {
                                if (callback != null) {
                                    uniSuccessCallback(type, msg, callback);
                                }
                            }
                            @Override
                            public void onError(HDLLinkException e) {
                                if (callback != null) {
                                    uniCallbackData(type, null, e.getCode(), e.getMsg(), callback);
                                }
                            }
                        });
                    }
                    break;
                }
            }