刘卫锦
2023-08-14 bd80ca98ffb4f483ca2eba47051281fa69e790ac
app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
@@ -2,9 +2,11 @@
import android.text.TextUtils;
import android.util.Log;
import com.alibaba.fastjson.JSON;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.hdl.photovoltaic.HDLApp;
import com.hdl.photovoltaic.bean.BaseEventBus;
import com.hdl.photovoltaic.bean.ModBusBean;
@@ -27,6 +29,7 @@
import org.json.JSONObject;
import java.util.Arrays;
import java.util.List;
import io.dcloud.feature.unimp.DCUniMPJSCallback;
@@ -143,7 +146,7 @@
                    }
                    break;
                    case HDLUniMP.UNI_EVENT_REPLY_DEVICE_LIST: {
                    case HDLUniMP.UNI_EVENT_REPLY_DEVICE_NET_LIST: {
                        //网关搜索
                        HdlDeviceLogic.getInstance().searchGateway(new GatewayCallBack() {
                            @Override
@@ -159,10 +162,30 @@
                        });
                    }
                    break;
                    case HDLUniMP.UNI_EVENT_REPLY_DEVICE_LIST: {
                        //
                        HdlResidenceLogic.getInstance().getGatewayList(new CloudCallBeak<Boolean>() {
                            @Override
                            public void onSuccess(Boolean obj) {
                                if (callback != null) {
                                    uniCallbackData(HDLLinkLocalGateway.getInstance().getGatewayList(), callback);
                                }
                            }
                            @Override
                            public void onFailure(Exception exception) {
                                uniCallbackData(null, -2, exception.getMessage(), callback);
                            }
                        });
                    }
                    break;
                    case HDLUniMP.UNI_EVENT_REPLY_DEVICE_MODBUS_SEND: {
                        sendModBus(data, callback);
                    }
                    break;
                    case HDLUniMP.UNI_EVENT_REPLY_DEVICE_OID: {
                        //添加设备到云端
                        String mac = getKeyValue("mac", getKeyValue("data", data));
@@ -181,6 +204,7 @@
                            }
                        });
                    }
                    break;
                }
            } else if (HDLUniMP.UNI_EVENT_REPLY_WIFI_MODEL.equals(event)) {
@@ -232,7 +256,7 @@
//        modBusBean.setOid("0101050219D44A00");
//        modBusBean.setData(new byte[]{00,01,00,00,00,0x09,00,00,00,01,03,00,00,00,01});
        if (TextUtils.isEmpty(modBusBean.getOid())) {
            modBusBean.setOid("010105021775E400");
            modBusBean.setOid("0101050217BBC400");
        }
        if (modBusBean.getOid() == null || modBusBean.getData() == null) {
            HdlLogLogic.print("内容为空,oid=" + modBusBean.getOid() + " data=" + modBusBean.getData());
@@ -243,7 +267,8 @@
        //发送modbus协议
        HDLModBusConnect.getInstance().Send(modBusBean.getOid(), modBusBean.getData(), new ModbusCallBack() {
            @Override
            public void onSuccess(byte[] data) {
            public void onSuccess(int[] data) {
                Log.d("data", Arrays.toString(data));
                uniCallbackData(data, callback);
            }
@@ -336,6 +361,8 @@
            uniCallBackBaseBean.setData(obj);
            if (callback != null) {
                callback.invoke(getJSONObject(uniCallBackBaseBean));
//                callback.invoke(uniCallBackBaseBean);
            }
        } catch (Exception e) {
            HdlLogLogic.print("uni===组装uni发送数据格式", e.getMessage());