| | |
| | | import com.hdl.photovoltaic.uni.HDLUniMP; |
| | | import com.hdl.photovoltaic.uni.HDLUniMPSDKManager; |
| | | import com.hdl.photovoltaic.utils.AppManagerUtils; |
| | | import com.hdl.photovoltaic.utils.NetworkUtils; |
| | | import com.hdl.photovoltaic.utils.WifiUtils; |
| | | import com.hdl.sdk.link.common.exception.HDLLinkCode; |
| | | import com.hdl.sdk.link.common.exception.HDLLinkException; |
| | |
| | | switch (type) { |
| | | //创建电站 |
| | | case HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION: { |
| | | |
| | | //EventBus事件分发 |
| | | BaseEventBus baseEventBus = new BaseEventBus(); |
| | | baseEventBus.setTopic(HDLUniMP.UNI_EVENT_REPLY_HOME_MODEL); |
| | | baseEventBus.setType(HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION); |
| | | baseEventBus.setData(getKeyValue("data", data)); |
| | | EventBus.getDefault().post(baseEventBus); |
| | |
| | | //EventBus事件分发 |
| | | BaseEventBus baseEventBus = new BaseEventBus(); |
| | | baseEventBus.setType(HDLUniMP.UNI_EVENT_REPLY_HOME_CLOSE_HOME_DETAILS_PAGE); |
| | | baseEventBus.setData(getKeyValue("data", data)); |
| | | EventBus.getDefault().post(baseEventBus); |
| | | } |
| | | break; |
| | | //住宅【电站】编辑 |
| | | case HDLUniMP.UNI_EVENT_REPLY_HOME_EDIT: { |
| | | //EventBus事件分发 |
| | | BaseEventBus baseEventBus = new BaseEventBus(); |
| | | baseEventBus.setTopic(HDLUniMP.UNI_EVENT_REPLY_HOME_MODEL); |
| | | baseEventBus.setType(HDLUniMP.UNI_EVENT_REPLY_HOME_EDIT); |
| | | baseEventBus.setData(getKeyValue("data", data)); |
| | | EventBus.getDefault().post(baseEventBus); |
| | | } |
| | |
| | | } |
| | | |
| | | } else if (HDLUniMP.UNI_EVENT_REPLY_WIFI_MODEL.equals(topic)) { |
| | | WifiUtils wifiUtils = new WifiUtils(HDLApp.getInstance()); |
| | | WifiUtils wifiUtils = WifiUtils.getInstance(); |
| | | //wifi模块 |
| | | switch (type) { |
| | | //获取wifi列表 |
| | |
| | | break; |
| | | } |
| | | } |
| | | HdlLogLogic.print("uni===原生接收uni发来的数据===大类->" + topic + "\r\n" + data, true); |
| | | HdlLogLogic.print("uni发来的数据--->大类-->" + topic + "\r\n" + data, true); |
| | | } catch (Exception e) { |
| | | HdlLogLogic.print("uni===原生接收uni发来的数据===" + e.getMessage(), true); |
| | | HdlLogLogic.print("uni发来的数据--->" + e.getMessage(), true); |
| | | } |
| | | |
| | | } |
| | |
| | | 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); |
| | | HdlLogLogic.print("uni--->组装uni发送数据格式--->" + json, false); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public void onSuccess(Boolean b) { |
| | | if (b) { |
| | | HdlLogLogic.print("本地升级--->", true); |
| | | //本地 |
| | | //1,建立本地服务; |
| | | //2,告诉网关手机ip和端口; |
| | |
| | | } |
| | | String md5 = HDLMD5Utils.encodeMD5(data);//网关固件需要 |
| | | //升级固件文件地址 |
| | | String upgradeFileLocalPathUrl = "http://" + AppManagerUtils.getAppManager().getIPAddress(HDLApp.getInstance()) + ":" + MyNanoHttpServer.HTTP_PORT + firmwarePathFileName; |
| | | String upgradeFileLocalPathUrl = "http://" + NetworkUtils.getInstance().getIPAddress(HDLApp.getInstance()) + ":" + MyNanoHttpServer.HTTP_PORT + firmwarePathFileName; |
| | | //通知给网关升级固件文件地址等信息 |
| | | HdlOtaLogic.getInstance().pushUpgradePacketInfo(deviceMac, oid, module, version, data.length + "", upgradeFileLocalPathUrl, md5, new LinkCallBack<String>() { |
| | | @Override |
| | |
| | | } |
| | | }); |
| | | } else { |
| | | HdlLogLogic.print("在线升级--->", true); |
| | | //远程升级需要检测在逆变器有没有连接上云 |
| | | HdlDeviceLogic.getInstance().checkInverterConnectedCloud(deviceMac, new CloudCallBeak<CloudInverterDeviceBean>() { |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | HdlLogLogic.print("在线升级--->", true); |
| | | //远程升级需要检测在逆变器有没有连接上云 |
| | | HdlDeviceLogic.getInstance().checkInverterConnectedCloud(deviceMac, new CloudCallBeak<CloudInverterDeviceBean>() { |
| | | @Override |
| | |
| | | * 向云端发起【设备驱动下载】指令 |
| | | */ |
| | | private void uniGatewayDriverDownload(Object data, DCUniMPJSCallback callback) { |
| | | |
| | | String deviceOid = getKeyValue("oid", getKeyValue("data", data));//逆变器设备oid |
| | | String driverCode = getKeyValue("driverCode", getKeyValue("data", data));//驱动编码 |
| | | String imageId = getKeyValue("imageId", getKeyValue("data", data));//驱动镜像id |
| | |
| | | @Override |
| | | public void onSuccess(Boolean b) { |
| | | if (b) { |
| | | HdlLogLogic.print("本地升级--->", true); |
| | | //本地 |
| | | //1,建立本地服务; |
| | | // 2,告诉网关手机ip和端口; |
| | |
| | | } |
| | | String md5 = HDLMD5Utils.encodeMD5(data);//网关驱动需要 |
| | | //升级驱动文件地址 |
| | | String upgradeFileLocalPathUrl = "http://" + AppManagerUtils.getAppManager().getIPAddress(HDLApp.getInstance()) + ":" + MyNanoHttpServer.HTTP_PORT + drivePathFileName; |
| | | String upgradeFileLocalPathUrl = "http://" + NetworkUtils.getInstance().getIPAddress(HDLApp.getInstance()) + ":" + MyNanoHttpServer.HTTP_PORT + drivePathFileName; |
| | | //通知给网关升级驱动文件地址等信息 |
| | | HdlOtaLogic.getInstance().pushUpgradePacketInfo(deviceMac, deviceOid, module, version, data.length + "", upgradeFileLocalPathUrl, md5, new LinkCallBack<String>() { |
| | | @Override |
| | |
| | | } |
| | | }); |
| | | } else { |
| | | HdlLogLogic.print("在线升级--->", true); |
| | | //远程升级需要【检测】在逆变器有没有连接上云 |
| | | HdlDeviceLogic.getInstance().checkInverterConnectedCloud(deviceMac, new CloudCallBeak<CloudInverterDeviceBean>() { |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | HdlLogLogic.print("在线升级--->", true); |
| | | //远程升级需要【检测】在逆变器有没有连接上云 |
| | | HdlDeviceLogic.getInstance().checkInverterConnectedCloud(deviceMac, new CloudCallBeak<CloudInverterDeviceBean>() { |
| | | @Override |
| | |
| | | * @param callback uni回调 |
| | | */ |
| | | private void uniGetCurrentHomeLocalAndCloudGatewayList(DCUniMPJSCallback callback) { |
| | | HdlDeviceLogic.getInstance().getCurrentHomeLocalAndCloudGatewayList(new CloudCallBeak<List<GatewayBean>>() { |
| | | HdlDeviceLogic.getInstance().getCurrentHomeLocalAndCloudGatewayList(UserConfigManage.getInstance().getHomeId(), new CloudCallBeak<List<GatewayBean>>() { |
| | | @Override |
| | | public void onSuccess(List<GatewayBean> list) { |
| | | if (callback != null) { |
| | |
| | | * |
| | | * @return JSONObject |
| | | */ |
| | | private JSONObject getJSONObject(Object obj) { |
| | | public JSONObject getJSONObject(Object obj) { |
| | | try { |
| | | if (obj == null) { |
| | | return new JSONObject(); |
| | |
| | | * @param obj - |
| | | * @return value |
| | | */ |
| | | private String getKeyValue(String key, Object obj) { |
| | | public String getKeyValue(String key, Object obj) { |
| | | try { |
| | | JSONObject jsonObject = this.getJSONObject(obj); |
| | | if (jsonObject.has(key)) { |