wjc
2023-06-29 dc785ad3133f7718ad7a096c70483b2eced94172
Merge branch 'hxb' into wjc
1个文件已添加
3个文件已修改
133 ■■■■■ 已修改文件
app/src/main/java/com/hdl/photovoltaic/HDLApp.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/photovoltaic/utils/ThroughUtils.java 117 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
local.properties 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/photovoltaic/HDLApp.java
@@ -108,4 +108,17 @@
        HDLUdpConnect.getInstance().initUdp();
    }
//    /**
//     * 初始化uni app mqtt
//     */
//    private void initUniMqtt() {
//        try {
//            Through.getInstance().setUni(false);
//            //IP 地址要根据实际的更改
//            UniAppMqtt.getInstance().initMqtt(this, "tcp://192.168.3.124:1883", "Android_" + android.os.Build.BRAND + "_" + this.hashCode(), new String[]{"PCToAndroid/#"});
//        } catch (Exception e) {
//            LogUtils.e("测试Mqtt连接服务端失败");
//        }
//    }
}
app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
@@ -113,6 +113,7 @@
                    }
                    break;
                    case HDLUniMP.UNI_EVENT_REPLY_DEVICE_MODBUS_SEND: {
                        //发送modbus协议
//                        HDLModBusConnect.getInstance().Send(uniToAndroidBean.getGatewayOid(), null, );
                    }
app/src/main/java/com/hdl/photovoltaic/utils/ThroughUtils.java
New file
@@ -0,0 +1,117 @@
//package com.hdl.photovoltaic.utils;
//
//import com.alibaba.fastjson.JSONObject;
//import com.hdl.photovoltaic.other.HdlUniLogic;
//import com.hdl.photovoltaic.uni.HDLUniMP;
//import com.hdl.photovoltaic.uni.HDLUniMPSDKManager;
//import com.hdl.sdk.link.common.event.EventListener;
//import com.hdl.sdk.link.core.bean.ZigbeeResponse;
//import com.hdl.sdk.link.core.connect.HDLZigbeeConnect;
//
///**
// * Created by hxb on 2022/1/18.
// * 原生透传到uni app
// */
//public class ThroughUtils {
//
//    final String tag = ThroughUtils.class.getName();
//
//    /**
//     * 是否uni方式,否则mqtt方式
//     */
//    private boolean isUni=true;
//
//
//    /**
//     * instance
//     */
//    private volatile static ThroughUtils instance;
//
//    /**
//     * getInstance
//     *
//     * @return Through
//     */
//    public static synchronized ThroughUtils getInstance() {
//        if (instance == null) {
//            synchronized (ThroughUtils.class) {
//                if (instance == null) {
//                    instance = new ThroughUtils();
//                }
//            }
//        }
//        return instance;
//    }
//
//    EventListener throughEventListener;
//
//    /**
//     * 注册新设备入网监听
//     */
//    public void registerThroughListener() {
//        //注册监听事件
//        if (throughEventListener == null) {
//            throughEventListener = new EventListener() {
//                @Override
//                public void onMessage(Object msg) {
//                    if (msg instanceof ZigbeeResponse) {
//                        ZigbeeResponse zigbeeResponse = (ZigbeeResponse) msg;
//                        try {
//                            HDLUniMP.UniCallBackBaseBean callBackBaseBean = new HDLUniMP.UniCallBackBaseBean();
//                            callBackBaseBean.setTopic(zigbeeResponse.getTopic());
//                            callBackBaseBean.setData(zigbeeResponse.getData());
//                            if (zigbeeResponse.getTopic().startsWith("ZbDataPassthrough")) {
//                                //如果不是使用mqtt方式,就使用uni app推送方式
//                                if (isUni()) {
//                                  HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, callBackBaseBean);
//                                    HDLUniMPSDKManager.getInstance().sendUniMPEvent(HDLUniMP.UNI_APP_ID, HDLUniMP.UNI_EVENT_ZigBeePassthrough, JSONObject.toJSON(callBackBaseBean));
//                                } else {//使用mqtt方式
//                                    //AndroidToPC/唯一标识/uni_event"
//                                    UniAppMqtt.getInstance().publish(String.format("AndroidToPC/%s/%s", System.currentTimeMillis(), HDLUniMP.UNI_EVENT_ZigBeePassthrough), JSONObject.toJSON(callBackBaseBean).toString());
//                                }
//                            }
//                            else if(zigbeeResponse.getTopic().contains("DeviceStatusReport/")){
//                                //如果不是使用mqtt方式,就使用uni app推送方式
//                                if (isUni()) {
//                                    HDLUniMPSDKManager.getInstance().sendUniMPEvent(HDLUniMP.UNI_APP_ID, HDLUniMP.EVENT_DeviceStatusReportPassthrough, JSONObject.toJSON(callBackBaseBean));
//                                } else {//使用mqtt方式
//                                    //AndroidToPC/唯一标识/uni_event"
//                                    UniAppMqtt.getInstance().publish(String.format("AndroidToPC/%s/%s", System.currentTimeMillis(), HDLUniMP.EVENT_DeviceStatusReportPassthrough), JSONObject.toJSON(callBackBaseBean).toString());
//                                }
//                            }
//
//                        } catch (Exception e) {
//
//                        }
//                    }
//                }
//            };
//            HDLZigbeeConnect.getInstance().registerListener(throughEventListener);
//        }
//    }
//
//    /**
//     * 移除全局监听
//     */
//    public void removeThroughListener()
//    {
//        HDLZigbeeConnect.getInstance().removeListener(throughEventListener);
//        throughEventListener=null;
//    }
//
//    /**
//     * 是否uni方式,否则mqtt方式
//     * @return
//     */
//    public boolean isUni() {
//        return isUni;
//    }
//
//    /**
//     * 是否uni方式,否则mqtt方式
//     * @param uni
//     */
//    public void setUni(boolean uni) {
//        isUni = uni;
//    }
//}
local.properties
@@ -5,4 +5,4 @@
# For customization when using a Version Control System, please read the
# header note.
#Wed Jun 28 17:38:10 CST 2023
sdk.dir=/Users/wenjucheng/Library/Android/sdk
sdk.dir=/Users/hdl/Library/Developer/Xamarin/android-sdk-macosx/platform-tools