| | |
| | | import com.google.gson.JsonObject; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.hdl.linkpm.sdk.core.exception.HDLException; |
| | | import com.hdl.photovoltaic.bean.InverterBean; |
| | | import com.hdl.photovoltaic.bean.LocalResponse; |
| | | import com.hdl.photovoltaic.bean.PageNumberObject; |
| | | import com.hdl.photovoltaic.config.AppConfigManage; |
| | | import com.hdl.photovoltaic.config.UserConfigManage; |
| | |
| | | * @param mac 网关mac |
| | | * @param linkCallBack 回调 |
| | | */ |
| | | public void getGatewayInfo(String mac, LinkCallBack<GatewayBean> linkCallBack) { |
| | | public void getGatewayInfo(String mac, LinkCallBack<InverterBean> linkCallBack) { |
| | | String requestUrl = TopicApi.GET_GATEWAY_INFO; |
| | | JsonObject json = new JsonObject(); |
| | | json.addProperty("device_mac", mac); |
| | |
| | | } |
| | | |
| | | Gson gson = new Gson(); |
| | | Type typeOfT = new TypeToken<BaseLocalResponse<GatewayBean>>() { |
| | | Type typeOfT = new TypeToken<BaseLocalResponse<InverterBean>>() { |
| | | }.getType(); |
| | | BaseLocalResponse<GatewayBean> baseLocalResponse = gson.fromJson(json, typeOfT); |
| | | BaseLocalResponse<InverterBean> baseLocalResponse = gson.fromJson(json, typeOfT); |
| | | if (baseLocalResponse == null || baseLocalResponse.getObjects() == null) { |
| | | linkCallBack.onSuccess(new GatewayBean()); |
| | | linkCallBack.onSuccess(new InverterBean()); |
| | | } else { |
| | | linkCallBack.onSuccess(baseLocalResponse.getObjects()); |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 逆变器密码登录 |
| | | * |
| | | * @param mac 逆变器mac |
| | | * @param password 逆变器密码 |
| | | */ |
| | | public void getPasswordVerification(String mac, String password, LinkCallBack<LocalResponse> callBeak) { |
| | | String requestUrl = TopicApi.DELETING_GATEWAY_password_verifiy; |
| | | JsonObject json = new JsonObject(); |
| | | json.addProperty("password", password); |
| | | json.addProperty("mac", mac); |
| | | TcpClient.getInstance().sendDataToLinkGateway(mac, false, requestUrl, json, "", new HDLLinkCallBack() { |
| | | @Override |
| | | public void onSuccess(String msg) { |
| | | try { |
| | | |
| | | Gson gson = new Gson(); |
| | | LocalResponse localResponse = gson.fromJson(msg, LocalResponse.class); |
| | | if (localResponse == null) { |
| | | localResponse = new LocalResponse(); |
| | | } |
| | | if (callBeak != null) { |
| | | callBeak.onSuccess(localResponse); |
| | | } |
| | | } catch (Exception e) { |
| | | if (callBeak != null) { |
| | | callBeak.onSuccess(new LocalResponse()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onError(HDLLinkException e) { |
| | | if (callBeak != null) { |
| | | callBeak.onError(e); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 刷新逆变器缓存信息(包括设置mqtt秘钥) |
| | | * 注: //目的是为了获取拿到网关ID,mqtt通讯秘钥等信息,缓存本地逆变器列表里面,发送数据数据时自动去缓存列表里面去查找; |
| | | * 1:本地存在,更新信息即可; |