mac
2023-10-09 e10685706d2bacf0da27b8393c04a1f7a4df2bad
app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
@@ -6,7 +6,6 @@
import com.google.gson.Gson;
import com.hdl.linkpm.sdk.core.exception.HDLException;
import com.google.gson.JsonObject;
import com.hdl.photovoltaic.HDLApp;
import com.hdl.photovoltaic.bean.BaseEventBus;
import com.hdl.photovoltaic.bean.ModBusBean;
@@ -58,7 +57,7 @@
        return sHdlUniLogic;
    }
    //region ******【原生】和【小程序】通讯的方法 onOtherUniMPEventReceive();openUniMP();sendUni();******
    //region ******【原生】和【小程序】通讯的3个方法名 onOtherUniMPEventReceive();openUniMP();sendUni();******
    /**
     * 原生接收到uni发来的数据
@@ -78,16 +77,22 @@
            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.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: {
                        //关闭详情页
                    }
                    break;
@@ -162,8 +167,9 @@
                        });
                    }
                    break;
                    //获取逆变器列表
                    case HDLUniMP.UNI_EVENT_REPLY_DEVICE_LIST: {
                        //获取网关设备列表
                        HdlDeviceLogic.getInstance().getLocalGatewayList(new CloudCallBeak<Boolean>() {
                            @Override
                            public void onSuccess(Boolean obj) {
@@ -186,10 +192,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,33 +206,69 @@
                            @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) {
                            }
                            @Override
                            public void onError(HDLLinkException e) {
                            }
                        });
                    }
                    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) {
                            }
                        });
                    }
                    break;
                }
            } else if (HDLUniMP.UNI_EVENT_REPLY_WIFI_MODEL.equals(event)) {
                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;
@@ -255,17 +297,17 @@
//        ModBusBean modBusBean = new ModBusBean();
//        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("0101050217BBC400");
        }
        if (modBusBean.getOid() == null || modBusBean.getData() == null) {
            HdlLogLogic.print("内容为空,oid=" + modBusBean.getOid() + " data=" + modBusBean.getData());
//        if (TextUtils.isEmpty(modBusBean.getOid())) {
//            modBusBean.setOid("0101050217BBC400");
//        }
        if (modBusBean.getMac() == null || modBusBean.getData() == null) {
            HdlLogLogic.print("内容为空,oid=" + modBusBean.getMac() + " data=" + modBusBean.getData());
            return;
        }
        //发送modbus协议
        HDLModBusConnect.getInstance().Send(modBusBean.getOid(), modBusBean.getData(), new ModbusCallBack() {
        HDLModBusConnect.getInstance().Send(modBusBean.getMac(), modBusBean.getData(), new ModbusCallBack() {
            @Override
            public void onSuccess(int[] data) {
                Log.d("data", Arrays.toString(data));