| | |
| | | import com.hdl.sdk.link.common.exception.HDLLinkCode; |
| | | import com.hdl.sdk.link.common.exception.HDLLinkException; |
| | | import com.hdl.sdk.link.core.bean.gateway.GatewayBean; |
| | | import com.hdl.sdk.link.core.bean.request.BaseLocalRequest; |
| | | import com.hdl.sdk.link.core.bean.response.BaseLocalResponse; |
| | | import com.hdl.sdk.link.core.callback.GatewayCallBack; |
| | | import com.hdl.sdk.link.core.callback.HDLLinkCallBack; |
| | | import com.hdl.sdk.link.gateway.HDLLinkLocalGateway; |
| | |
| | | import io.reactivex.rxjava3.disposables.Disposable; |
| | | |
| | | /** |
| | | * 设备逻辑的界面 |
| | | * 设备逻辑 |
| | | */ |
| | | public class HdlDeviceLogic { |
| | | private static volatile HdlDeviceLogic sHdlDeviceLogic; |
| | |
| | | GatewayBean gatewayBean = list.get(i); |
| | | if (gatewayBean.getMaster().equals("true") |
| | | && gatewayBean.getHomeId().equals(UserConfigManage.getInstance().getHomeId())) { |
| | | // if ("0101050217BBC400".equals(gatewayBean.getOid()))//测试时过滤掉无效的,这行后面代码要删除 |
| | | // continue; |
| | | newList.add(gatewayBean); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 网关时间读取 |
| | | * |
| | | * @param mac 设备mac |
| | | * @param linkCallBack 回调update |
| | | */ |
| | | public void getGatewayTime(String mac, LinkCallBack<Boolean> linkCallBack) { |
| | | String requestUrl = TopicApi.GET_GATEWAY_TIME; |
| | | TcpClient.getInstance().sendDataToLinkGateway(mac, requestUrl, null, "", new HDLLinkCallBack() { |
| | | @Override |
| | | public void onSuccess(String msg) { |
| | | if (linkCallBack != null) { |
| | | linkCallBack.onSuccess(true); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onError(HDLLinkException e) { |
| | | if (linkCallBack != null) { |
| | | linkCallBack.onError(e); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 网关时间修改 |
| | | * |
| | | * @param mac 设备mac |
| | | * @param linkCallBack 回调update |
| | | */ |
| | | public void editGatewayTime(String mac, JsonObject jsonObject, LinkCallBack<Boolean> linkCallBack) { |
| | | String requestUrl = TopicApi.SET_GATEWAY_TIME_EDIT; |
| | | // JsonObject json = new JsonObject(); |
| | | // json.addProperty("master", "true"); |
| | | // "objects": { |
| | | // "date": "2020-08-15", |
| | | // "time": "17:25:20" |
| | | // } |
| | | TcpClient.getInstance().sendDataToLinkGateway(mac, requestUrl, jsonObject, "", new HDLLinkCallBack() { |
| | | @Override |
| | | public void onSuccess(String msg) { |
| | | if (linkCallBack != null) { |
| | | linkCallBack.onSuccess(true); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onError(HDLLinkException e) { |
| | | if (linkCallBack != null) { |
| | | linkCallBack.onError(e); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 编辑网关参数 |
| | | * |
| | | * @param mac 设备mac |
| | |
| | | }); |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取网关详情信息 |
| | |
| | | return; |
| | | } |
| | | Gson gson = new Gson(); |
| | | Type typeOfT = new TypeToken<List<OidBean>>() { |
| | | Type typeOfT = new TypeToken<BaseLocalResponse<List<OidBean>>>() { |
| | | }.getType(); |
| | | List<OidBean> list = gson.fromJson(json, typeOfT); |
| | | if (linkCallBack != null) { |
| | | linkCallBack.onSuccess(list); |
| | | BaseLocalResponse<List<OidBean>> baseLocalResponse = gson.fromJson(json, typeOfT); |
| | | |
| | | if (linkCallBack == null) { |
| | | return; |
| | | } |
| | | if (baseLocalResponse == null || baseLocalResponse.getObjects() == null) { |
| | | linkCallBack.onSuccess(new ArrayList<>()); |
| | | } else { |
| | | linkCallBack.onSuccess(baseLocalResponse.getObjects()); |
| | | } |
| | | } |
| | | |
| | |
| | | HDLLinkLocalGateway.getInstance().getGatewayList().clear(); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CloudInverterDeviceBean cloudInverterDeviceBean = list.get(i); |
| | | //云端对象数据交换到本地对象 |
| | | GatewayBean gatewayBean = new GatewayBean(); |
| | | gatewayBean.setOid(cloudInverterDeviceBean.getOid()); |
| | | gatewayBean.setSid(cloudInverterDeviceBean.getSid()); |
| | | gatewayBean.setGatewayId(cloudInverterDeviceBean.getGatewayId()); |
| | | gatewayBean.setOnline(cloudInverterDeviceBean.isOnline()); |
| | | gatewayBean.setDevice_mac(cloudInverterDeviceBean.getOsn());//设备mac |
| | | gatewayBean.setDevice_name(cloudInverterDeviceBean.getGatewayName()); |
| | | gatewayBean.setHomeId(UserConfigManage.getInstance().getHomeId()); |
| | | gatewayBean.setLocalEncrypt(true); |