From 73ac57b92e9a39b0a9ac697c336a25304bc83496 Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期三, 12 六月 2024 15:47:31 +0800
Subject: [PATCH] Merge branch 'dev' into feature/v1.4.1
---
app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java | 250 ++++++++++++++++++++++++++++++++++---------------
1 files changed, 171 insertions(+), 79 deletions(-)
diff --git a/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java b/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
index f764262..4cc3c6e 100644
--- a/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
+++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
@@ -46,7 +46,7 @@
import com.hdl.photovoltaic.ui.bean.OidBean;
import com.hdl.photovoltaic.ui.bean.UnCountBean;
import com.hdl.photovoltaic.ui.me.AsRegardsActivity;
-import com.hdl.photovoltaic.ui.me.PersonalDataActivity;
+import com.hdl.photovoltaic.ui.me.CPersonalDataActivity;
import com.hdl.photovoltaic.ui.me.SetActivity;
import com.hdl.photovoltaic.ui.newC.MessageCenterList;
import com.hdl.photovoltaic.ui.newC.PowerStationsListEdit;
@@ -93,7 +93,7 @@
public class HdlUniLogic implements HDLUniMPSDKManager.IOnOtherUniMPEventCallBack {
private static volatile HdlUniLogic sHdlUniLogic;
- public final static String separator="---";
+ public final static String separator = "---";
/**
* 鑾峰彇褰撳墠瀵硅薄
@@ -202,6 +202,11 @@
} else if (HDLUniMP.UNI_EVENT_REPLY_DEVICE_MODEL.equals(topic)) {
//璁惧妯″潡
switch (type) {
+ //modBus鍗忚涓撶敤
+ case HDLUniMP.UNI_EVENT_REPLY_DEVICE_MODBUS_SEND: {
+ sendModBus(mode_type, data, callback);
+ }
+ break;
//娣诲姞閫嗗彉鍣ㄥ埌浜戠
case HDLUniMP.UNI_EVENT_REPLY_DEVICE_ADD: {
this.uniAddInverterDeviceToCloud(mode_type, data, callback);
@@ -225,11 +230,6 @@
//鑾峰彇閫嗗彉鍣ㄥ垪琛�
case HDLUniMP.UNI_EVENT_REPLY_DEVICE_LIST: {
this.uniGetCurrentHomeLocalAndCloudGatewayList(mode_type, data, callback);
- }
- break;
- //modBus鍗忚涓撶敤
- case HDLUniMP.UNI_EVENT_REPLY_DEVICE_MODBUS_SEND: {
- sendModBus(mode_type, data, callback);
}
break;
//鑾峰彇oid鍒楄〃
@@ -277,7 +277,16 @@
this.setInitializeGateway(mode_type, data, callback);
}
break;
-
+ //璇诲彇璁惧杩滅▼淇℃伅
+ case HDLUniMP.UNI_EVENT_REPLY_DEVICE_REMOTEINFO: {
+ this.setInverterDeviceRemoteInfo(mode_type, data, callback);
+ }
+ break;
+ //璁惧鍚嶇О淇敼(淇敼鏄簯绔痮id鍚嶇О锛岃澶囦娇鐢╩odbus鍗忚淇敼)
+ case HDLUniMP.UNI_EVENT_REPLY_DEVICE_EDIT_NAME: {
+ this.uniOidEditName(mode_type, data, callback);
+ }
+ break;
}
} else if (HDLUniMP.UNI_EVENT_REPLY_WIFI_MODEL.equals(topic)) {
@@ -423,7 +432,7 @@
case HDLUniMP.UNI_EVENT_REPLY_MINE_EDIT_USER_INFO: {
Intent intent = new Intent();
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.setClass(HDLApp.getInstance(), PersonalDataActivity.class);
+ intent.setClass(HDLApp.getInstance(), CPersonalDataActivity.class);
HDLApp.getInstance().startActivity(intent);
}
break;
@@ -457,6 +466,11 @@
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setClass(HDLApp.getInstance(), SetActivity.class);
HDLApp.getInstance().startActivity(intent);
+
+ }
+ break;
+ //鎴愬憳鍒楄〃
+ case HDLUniMP.UNI_EVENT_REPLY_MEMBER_LIST: {
}
break;
@@ -498,10 +512,7 @@
//uni涓婚〉鐐瑰嚮杩斿洖閫氱煡
case HDLUniMP.UNI_EVENT_REPLY_OTHER_BACK: {
//EventBus浜嬩欢鍒嗗彂
- BaseEventBus baseEventBus = new BaseEventBus();
- baseEventBus.setTopic(HDLUniMP.UNI_EVENT_REPLY_OTHER_MODEL);
- baseEventBus.setType(HDLUniMP.UNI_EVENT_REPLY_OTHER_BACK);
- EventBus.getDefault().post(baseEventBus);
+ HdlCommonLogic.getInstance().postEventBus(HDLUniMP.UNI_EVENT_REPLY_OTHER_MODEL, HDLUniMP.UNI_EVENT_REPLY_OTHER_BACK);
}
break;
@@ -529,6 +540,12 @@
public void openUniMP(String path, JSONObject jsonObject) {
JSONObject json = this.createdJSONObject(jsonObject, true);
HDLUniMPSDKManager.getInstance().openUniMP(HDLUniMP.UNI_APP_ID, path, json, HdlUniLogic.this);
+ HdlLogLogic.print("uni---缁勮uni鍙戦�佹暟鎹牸寮�---" + json, false);
+ }
+
+ public void openUniMPDelay(String path, JSONObject jsonObject) {
+ JSONObject json = this.createdJSONObject(jsonObject, true);
+ HDLUniMPSDKManager.getInstance().openUniMPDelay(HDLUniMP.UNI_APP_ID, path, json, HdlUniLogic.this);
HdlLogLogic.print("uni---缁勮uni鍙戦�佹暟鎹牸寮�---" + json, false);
}
@@ -563,6 +580,7 @@
*/
private void uniGetAndSetNetwork(String type, Object data, String TopicApi, DCUniMPJSCallback callback) {
String mac = getKeyValue("mac", getKeyValue("data", data));
+ JsonArray jsonArray = new JsonArray();
JsonObject jObject = null;
String attribute_data = getKeyValue("attribute_data", getKeyValue("data", data));
if (!TextUtils.isEmpty(attribute_data)) {
@@ -572,8 +590,9 @@
jObject = new JsonObject();
}
}
+ jsonArray.add(jObject);
//瑙e瘑璐熻浇鏁版嵁(鍐欏瘑閽ョ粰缃戝叧涓�瀹氭槸鏄庢枃锛屽洜涓洪偅鏃剁綉鍏宠繕娌℃湁瀵嗛挜)
- TcpClient.getInstance().sendDataToLinkGateway(mac, false, TopicApi, jObject, "", new HDLLinkCallBack() {
+ TcpClient.getInstance().sendDataToLinkGateway(mac, false, TopicApi, jsonArray, "", new HDLLinkCallBack() {
@Override
public void onSuccess(String msg) {
if (callback != null) {
@@ -792,7 +811,7 @@
String module = "FW#" + imageId;//妯″潡淇℃伅(HW锛氱‖浠�)
//鍗囩骇鏈湴浼樺厛->浜戠鍗囩骇
- HdlDeviceLogic.getInstance().isLocalConnect(deviceMac, new CloudCallBeak<Boolean>() {
+ HdlDeviceLogic.getInstance().isLocalConnect(homeId, deviceMac, new CloudCallBeak<Boolean>() {
@Override
public void onSuccess(Boolean b) {
if (b) {
@@ -1044,7 +1063,7 @@
String imageId = getKeyValue("imageId", getKeyValue("data", data));//鍥轰欢闀滃儚id
String module = driverCode + "#" + imageId;
//鍗囩骇鏈湴浼樺厛->浜戠鍗囩骇
- HdlDeviceLogic.getInstance().isLocalConnect(deviceMac, new CloudCallBeak<Boolean>() {
+ HdlDeviceLogic.getInstance().isLocalConnect(homeId, deviceMac, new CloudCallBeak<Boolean>() {
@Override
public void onSuccess(Boolean b) {
if (b) {
@@ -1489,7 +1508,7 @@
// com.alibaba.fastjson.JSONArray jsonArray = JSON.parseArray(data);
try {
String devices = getKeyValue("devices", getKeyValue("data", data));
- String homeId = UserConfigManage.getInstance().getHomeId(); //缁戝畾鎴愬姛涔嬪悗閫氱煡
+ String homeId = getKeyValue("homeId", getKeyValue("data", data));
Gson gson = new Gson();
Type typeOfT = new TypeToken<List<GatewayBean>>() {
}.getType();
@@ -1558,7 +1577,10 @@
*/
private void uniDelInverterDevice(String type, Object data, DCUniMPJSCallback callback) {
String deviceId = getKeyValue("deviceId", getKeyValue("data", data));
- String homeId = UserConfigManage.getInstance().getHomeId();
+ String homeId = getKeyValue("homeId", getKeyValue("data", data));
+ if (TextUtils.isEmpty(homeId)) {
+ homeId = UserConfigManage.getInstance().getHomeId();
+ }
HdlDeviceLogic.getInstance().delInverterDevice(homeId, deviceId, new CloudCallBeak<Boolean>() {
@Override
public void onSuccess(Boolean obj) {
@@ -1717,77 +1739,75 @@
* @param callback uni鍥炶皟
*/
public void startTcpThreadSendAccountAndPassword(String type, String ssid, String password, DCUniMPJSCallback callback) {
- new Thread(
- () -> {
- Socket socket = null;
- OutputStream outputStreamTcp = null;
- InputStream inputStreamTcp = null;
- try {
- socket = new Socket();
- socket.setTcpNoDelay(true);
- socket.setSoTimeout(10 * 1000);//10绉掕秴鏃�
- socket.connect(new InetSocketAddress("192.168.8.1", 8586));
- socket.setKeepAlive(true);
+ new Thread(() -> {
+ Socket socket = null;
+ OutputStream outputStreamTcp = null;
+ InputStream inputStreamTcp = null;
+ try {
+ socket = new Socket();
+ socket.setTcpNoDelay(true);
+ socket.setSoTimeout(10 * 1000);//10绉掕秴鏃�
+ socket.connect(new InetSocketAddress("192.168.8.1", 8586));
+ socket.setKeepAlive(true);
// logMessage("tcp杩炴帴鐘舵�佹垚鍔�", 0, "");
- outputStreamTcp = socket.getOutputStream();
- JsonObject jsonObject = new JsonObject();
- jsonObject.addProperty("id", "102030");
- jsonObject.addProperty("ssid", ssid);
- jsonObject.addProperty("password", password);
- jsonObject.addProperty("server_addr", HDLLinkPMUser.getInstance().getHomeRegionUrl());
- jsonObject.addProperty("homeId", UserConfigManage.getInstance().getHomeId());
- String sendData = "Topic:/user/id/custom/wifi/set\r\n";
- sendData += "Length:" + jsonObject.toString().getBytes().length + "\r\n\r\n";
- sendData += jsonObject.toString();
- outputStreamTcp.write(sendData.getBytes());
- outputStreamTcp.flush();
- Thread.sleep(200);
- inputStreamTcp = socket.getInputStream();
- byte[] bytes = new byte[1204 * 2];
- int len = inputStreamTcp.read(bytes);
- if (len != -1) {
- String str = new String(bytes, 0, bytes.length);
- String[] strings = str.split("\r\n\r\n");
- String[] topicAndLength = strings[0].split("\r\n");
- String topic = topicAndLength[0];
- JSONObject json = new JSONObject(strings[1]);
+ outputStreamTcp = socket.getOutputStream();
+ JsonObject jsonObject = new JsonObject();
+ jsonObject.addProperty("id", "102030");
+ jsonObject.addProperty("ssid", ssid);
+ jsonObject.addProperty("password", password);
+ jsonObject.addProperty("server_addr", HDLLinkPMUser.getInstance().getHomeRegionUrl());
+ jsonObject.addProperty("homeId", UserConfigManage.getInstance().getHomeId());
+ String sendData = "Topic:/user/id/custom/wifi/set\r\n";
+ sendData += "Length:" + jsonObject.toString().getBytes().length + "\r\n\r\n";
+ sendData += jsonObject.toString();
+ outputStreamTcp.write(sendData.getBytes());
+ outputStreamTcp.flush();
+ Thread.sleep(200);
+ inputStreamTcp = socket.getInputStream();
+ byte[] bytes = new byte[1204 * 2];
+ int len = inputStreamTcp.read(bytes);
+ if (len != -1) {
+ String str = new String(bytes, 0, bytes.length);
+ String[] strings = str.split("\r\n\r\n");
+ String[] topicAndLength = strings[0].split("\r\n");
+ String topic = topicAndLength[0];
+ JSONObject json = new JSONObject(strings[1]);
// logMessage("tcp鍥炲鏁版嵁", 0, strings[0] + "\r\n" + json.toString());
- if (topic.endsWith("wifi/set_reply") || topic.endsWith("wifi/result/notify")) {
- if (callback != null) {
- uniCallbackData(type, json, callback);
- }
- if (json.has("mac")) { //鍥炲鎴愬姛鍐嶆嬁璁惧mac
+ if (topic.endsWith("wifi/set_reply") || topic.endsWith("wifi/result/notify")) {
+ if (callback != null) {
+ uniCallbackData(type, json, callback);
+ }
+ if (json.has("mac")) { //鍥炲鎴愬姛鍐嶆嬁璁惧mac
// this.device_mac = json.getString("mac");
// this.isSucceedTcp = true;//琛ㄧず鎴愬姛
- }
- }
- }
-
- } catch (Exception ignored) {
- } finally {
- try {
- if (outputStreamTcp != null) {
- outputStreamTcp.close();
- outputStreamTcp = null;
- }
- if (inputStreamTcp != null) {
- inputStreamTcp.close();
- inputStreamTcp = null;
- }
- if (socket != null) {
- socket.close();
- socket = null;
- }
-
- } catch (Exception ignored) {
}
}
}
- ).start();
+
+ } catch (Exception ignored) {
+ } finally {
+ try {
+ if (outputStreamTcp != null) {
+ outputStreamTcp.close();
+ outputStreamTcp = null;
+ }
+ if (inputStreamTcp != null) {
+ inputStreamTcp.close();
+ inputStreamTcp = null;
+ }
+ if (socket != null) {
+ socket.close();
+ socket = null;
+ }
+
+ } catch (Exception ignored) {
+ }
+ }
+ }).start();
}
/**
- * 鍒濆鍖栦綘閫嗗彉鍣�
+ * 鍒濆鍖栭�嗗彉鍣�
*
* @param type 璐﹀彿
* @param data uni璇锋眰鏁版嵁
@@ -1808,6 +1828,78 @@
});
}
+ /**
+ * 鍒濆鍖栭�嗗彉鍣�
+ *
+ * @param type 璐﹀彿
+ * @param data uni璇锋眰鏁版嵁
+ * @param callback uni鍥炶皟
+ */
+ public void setInverterDeviceRemoteInfo(String type, Object data, DCUniMPJSCallback callback) {
+ String homeId = getKeyValue("homeId", getKeyValue("data", data));
+ String json = getKeyValue("list", getKeyValue("data", data));
+ List<CloudInverterDeviceBean> newList = new ArrayList<>();
+ try {
+ List<GatewayBean> list = new Gson().fromJson(json, new TypeToken<List<GatewayBean>>() {
+ }.getType());
+ if (list != null && list.size() > 0) {
+ for (int i = 0; i < list.size(); i++) {
+ GatewayBean gatewayBean = list.get(i);
+ CloudInverterDeviceBean inverterDeviceBean = new CloudInverterDeviceBean();
+ inverterDeviceBean.setCategorySecondName(gatewayBean.getCategorySecondName());
+ inverterDeviceBean.setOsn(gatewayBean.getDevice_mac());
+ inverterDeviceBean.setOmodel(gatewayBean.getDevice_model());
+ inverterDeviceBean.setOid(gatewayBean.getOid());
+ inverterDeviceBean.setAddresses(gatewayBean.getAddresses());
+ inverterDeviceBean.setSid(gatewayBean.getSid());
+ inverterDeviceBean.setDeviceId(gatewayBean.getDeviceId());
+ inverterDeviceBean.setName(gatewayBean.getDevice_name());
+ inverterDeviceBean.setDeviceStatus(gatewayBean.getDeviceStatus());
+ inverterDeviceBean.setSpk(gatewayBean.getSpk());
+ inverterDeviceBean.setDeviceType(gatewayBean.getDeviceType());
+ newList.add(inverterDeviceBean);
+ }
+ }
+ } catch (Exception ignored) {
+ }
+ HdlDeviceLogic.getInstance().setDeviceRemoteInfo(newList, homeId, new CloudCallBeak<List<GatewayBean>>() {
+ @Override
+ public void onSuccess(List<GatewayBean> obj) {
+ uniCallbackData(type, obj, callback);
+ }
+
+ @Override
+ public void onFailure(HDLException e) {
+ uniCallbackData(type, null, e.getCode(), e.getMsg(), callback);
+ }
+ });
+ }
+
+ /**
+ * 淇敼璁惧鍚嶇О閫嗗彉鍣˙MS鐢垫睜鍖�
+ *
+ * @param type 璐﹀彿
+ * @param data uni璇锋眰鏁版嵁
+ * @param callback uni鍥炶皟
+ */
+ public void uniOidEditName(String type, Object data, DCUniMPJSCallback callback) {
+ String homeId = getKeyValue("homeId", getKeyValue("data", data));
+ String deviceType = getKeyValue("deviceType", getKeyValue("data", data));
+ String deviceId = getKeyValue("deviceId", getKeyValue("data", data));
+ String name = getKeyValue("name", getKeyValue("data", data));
+ HdlDeviceLogic.getInstance().setRename(homeId, deviceType, deviceId, name, new CloudCallBeak<Boolean>() {
+ @Override
+ public void onSuccess(Boolean obj) {
+ uniCallbackData(type, obj, callback);
+ }
+
+ @Override
+ public void onFailure(HDLException e) {
+ uniCallbackData(type, null, e.getCode(), e.getMsg(), callback);
+ }
+ });
+ }
+
/**
* 鍙戦�乵odbus鍗忚鏁版嵁
--
Gitblit v1.8.0