| | |
| | | //registerListener(String.format(TopicConstant.NATIVE_ZIGBEE_UP_SLAVE, "+", "+"), eventListener); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 发送原生数据 |
| | | * |
| | |
| | | * @param baseCallBack 结果回调 |
| | | */ |
| | | public void Send(String gatewayOidOrGatewayId, byte[] payload, final ModbusCallBack baseCallBack) { |
| | | Send(gatewayOidOrGatewayId, payload, 5, baseCallBack); |
| | | } |
| | | |
| | | /** |
| | | * 发送原生数据 |
| | | * |
| | | * @param gatewayOidOrGatewayId 目标网关的oid或者网关Id |
| | | * @param payload 发送数据 |
| | | * @param timeout 超时时间(s) |
| | | * @param baseCallBack 结果回调 |
| | | */ |
| | | public void Send(String gatewayOidOrGatewayId, byte[] payload, int timeout, final ModbusCallBack baseCallBack) { |
| | | if (payload == null || payload.length == 0) { |
| | | if (baseCallBack != null) { |
| | | baseCallBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_DATA_NULL_ERROR)); |
| | | System.out.println("发送数据时负载数据是空的--->"); |
| | | } |
| | | return; |
| | | } |
| | | //如果本地有链接这个网关,则用本地连接 |
| | | GatewayBean gatewayBean = HDLLinkLocalGateway.getInstance().getGatewayByOidOrGatewayId(gatewayOidOrGatewayId); |
| | | if (null == gatewayBean) { |
| | |
| | | // request.setCloudTopic(String.format(TopicConstant.NATIVE_MODBUS_DOWN_SLAVE, HDLLinkConfig.getInstance().getGatewayId(), gatewayOidOrGatewayId)); |
| | | // } |
| | | request.setReplyTopic("Modbus" + payload[0] + payload[1]); |
| | | long timeout = 5 * 1000; |
| | | long awaitTime = timeout * 1000L; |
| | | |
| | | new HDLConnectHelper(timeout, 1, gatewayBean.getIp_address(), 8586, request, new HDLConnectHelper.HdlSocketListener() { |
| | | new HDLConnectHelper(awaitTime, 1, gatewayBean.getIp_address(), 8586, request, new HDLConnectHelper.HdlSocketListener() { |
| | | @Override |
| | | public void onSucceed(Object msg) { |
| | | if (msg instanceof int[]) { |
| | |
| | | } |
| | | }, true).send(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |