mac
2024-02-01 d52d8e3ddeb4c0efba6f7a58edb9dbc34e25b320
app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
@@ -291,18 +291,10 @@
                    //设备取消驱动,固件下载升级文件
                    case HDLUniMP.UNI_EVENT_REPLY_OTA_DRIVER_CANCEL_DOWNLOAD: {
                        this.uniCancelDownloadingUpgradeFile(data, callback);
//                        HdlThreadLogic.runSubThread(new Runnable() {
//                            @Override
//                            public void run() {
//                                HdlLogLogic.print("当前线程名称取消下载====" + Thread.currentThread().getName());
//                                uniCancelDownloadingUpgradeFile(data, callback);
//                            }
//                        });
                    }
                    break;
                    //设备驱动,固件取消升级
                    case HDLUniMP.UNI_EVENT_REPLY_OTA_CANCEL_UPGRADE: {
                        this.uniCancelUpgrade(data, callback);
                    }
                    break;
@@ -335,11 +327,16 @@
                    case HDLUniMP.UNI_EVENT_REPLY_OTHER_LOCATION_INFO: {
                        this.uniGetLocationInfo(data, callback);
                    }
                    //专门收集uni日志
                    case HDLUniMP.UNI_EVENT_REPLY_OTHER_UNI_LOG: {
                        String customizeContentFormat = getKeyValue("customizeContentFormat", getKeyValue("data", data));
                        HdlLogLogic.print("uni--->log--->" + customizeContentFormat, true);
                    }
                }
            }
            HdlLogLogic.print("uni发来的数据--->大类--->" + topic + "\r\n" + data, true);
            HdlLogLogic.print("uni--->发来的数据--->大类--->" + topic + "\r\n" + data, true);
        } catch (Exception e) {
            HdlLogLogic.print("uni发来的数据--->" + e.getMessage(), true);
            HdlLogLogic.print("uni--->发来的数据--->" + e.getMessage(), true);
        }
    }
@@ -395,24 +392,28 @@
        //ACCESS_COARSE_LOCATION   允许使用WIFI热点或基站来获取粗略的定位
        if (ActivityCompat.checkSelfPermission(HDLApp.getInstance(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(HDLApp.getInstance(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
            jsonObject.addProperty("result", -2);//没有位置信息权限
            jsonObject.addProperty("des", HDLApp.getInstance().getString(R.string.exception_no_location_information_permission));
            uniCallbackData(jsonObject.toString(), callback);
            return;
        }
        // 判断设备是否支持定位功能
        if (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
            jsonObject.addProperty("result", -1);//不支持定位功能
            //提示用户打开定位功能或者引导用户去系统设置页面打开定位功能
            jsonObject.addProperty("result", -1);//没开启定位功能
            jsonObject.addProperty("des", HDLApp.getInstance().getString(R.string.exception_the_location_function_is_not_enabled));
            //todo 提示用户打开定位功能或者引导用户去系统设置页面打开定位功能
            uniCallbackData(jsonObject.toString(), callback);
            return;
        }
        Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
        if (location == null) {
            jsonObject.addProperty("result", -3);//没有位置信息权限
            jsonObject.addProperty("des", HDLApp.getInstance().getString(R.string.exception_the_location_function_is_not_enabled));
            uniCallbackData(jsonObject.toString(), callback);
            return;
        }
        jsonObject.addProperty("result", 0);//不支持定位功能
        jsonObject.addProperty("result", 0);
        jsonObject.addProperty("des", HDLApp.getInstance().getString(R.string.succeed));
        jsonObject.addProperty("longitude", location.getLongitude());//经度
        jsonObject.addProperty("latitude", location.getLatitude());//纬度
        uniCallbackData(jsonObject.toString(), callback);
@@ -1064,7 +1065,8 @@
        String mac = getKeyValue("mac", getKeyValue("data", data));
        String date = getKeyValue("date", getKeyValue("data", data));
        String time = getKeyValue("time", getKeyValue("data", data));
        HdlDeviceLogic.getInstance().editGatewayTime(mac, date, time, new LinkCallBack<Boolean>() {
        String timezone = getKeyValue("timezone", getKeyValue("data", data));
        HdlDeviceLogic.getInstance().editGatewayTime(mac, date, time, timezone, new LinkCallBack<Boolean>() {
            @Override
            public void onSuccess(Boolean obj) {
                uniCallbackData(true, callback);
@@ -1201,6 +1203,8 @@
     * @param callback uni回调
     */
    private void uniSearchGateway(DCUniMPJSCallback callback) {
        HdlDeviceLogic.getInstance().searchCurrentHomeGateway(new GatewayCallBack() {
            @Override
            public void onSuccess(List<GatewayBean> gatewayBeanList) {
@@ -1211,6 +1215,7 @@
            public void onError(HDLLinkException e) {
                //发送失败
                uniCallbackData(null, e.getCode(), e.getMsg(), callback);
            }
        });
@@ -1283,22 +1288,24 @@
//            modBusBean.setOid("0101050217BBC400");
//        }
        if (modBusBean.getMac() == null || modBusBean.getData() == null) {
            HdlLogLogic.print("内容为空--->oid--->" + modBusBean.getMac() + " data--->" + Arrays.toString(modBusBean.getData()), false);
            HdlLogLogic.print("uni--->发送--->ModBus--->发送失败,(mac或者oid)为空." + Arrays.toString(modBusBean.getData()), true);
            return;
        }
        HdlLogLogic.print("uni--->发送--->ModBus--->" + Arrays.toString(modBusBean.getData()), true);
        //发送modbus协议
        HDLModBusConnect.getInstance().Send(modBusBean.getMac(), modBusBean.getData(), new ModbusCallBack() {
            @Override
            public void onSuccess(int[] data) {
                Log.d("data", Arrays.toString(data));
                uniCallbackData(data, callback);
                HdlLogLogic.print("uni--->接收--->ModBus--->" + Arrays.toString(data), true);
            }
            @Override
            public void onError(HDLLinkException e) {
                uniCallbackData(null, e.getCode(), e.getMsg(), callback);
                HdlLogLogic.print("uni--->异常--->ModBus--->" + e.getMsg() + "(" + e.getCode() + ")", true);
            }
        });
    }