| | |
| | | /** |
| | | * 发送数据到Link网关 |
| | | * |
| | | * @param ip 网关IP |
| | | * @param mac 网关mac |
| | | * @param isEncrypt 是否加密 |
| | | * @param topic 请求主题 |
| | | * @param jObject 负载数据<没有填null></> |
| | | * @param sendPath 发送路径<类名+方法名>class->methodName</> |
| | | */ |
| | | public void sendDataToLinkGateway(String ip, String mac, boolean isEncrypt, |
| | | public void sendDataToLinkGateway(String mac, boolean isEncrypt, |
| | | String topic, Object jObject, String sendPath, HDLLinkCallBack callBack) { |
| | | String topicSend = topic.replace("%s", mac); |
| | | GatewayBean gatewayBean = this.getLocalGateway(mac); |
| | | if (gatewayBean == null) { |
| | | callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); |
| | | return; |
| | | } |
| | | String topicSend = topic.replace("%s", gatewayBean.getOid()); |
| | | //组装需要发送的数据 |
| | | String sendStr = createSendData(jObject); |
| | | // LogUtils.i("sendDataToLinkGateway->" + sendPath + "->本地发送\r\n" + topicSend + "\r\n" + sendStr); |
| | | LinkRequest message = new LinkRequest(topicSend, sendStr, isEncrypt); |
| | | GatewayBean gatewayBean = this.getLocalGateway(mac); |
| | | if (gatewayBean != null) { |
| | | message.setCloudTopic(topic.replace("%s", gatewayBean.getGatewayId())); |
| | | } |
| | | new HDLConnectHelper(ip, message, new HDLConnectHelper.HdlSocketListener() { |
| | | message.setCloudTopic(topic.replace("%s", gatewayBean.getGatewayId())); |
| | | new HDLConnectHelper(gatewayBean.getIp_address(), message, new HDLConnectHelper.HdlSocketListener() { |
| | | @Override |
| | | public void onSucceed(Object msg) { |
| | | if (callBack == null) return; |