|
13 | 13 | import java.util.HashMap;
|
14 | 14 | import java.util.Map;
|
15 | 15 | import java.util.concurrent.ConcurrentHashMap;
|
| 16 | +import java.util.concurrent.ScheduledExecutorService; |
16 | 17 |
|
| 18 | +import com.zsmartsystems.zigbee.*; |
17 | 19 | import org.slf4j.Logger;
|
18 | 20 | import org.slf4j.LoggerFactory;
|
19 | 21 |
|
20 |
| -import com.zsmartsystems.zigbee.ExtendedPanId; |
21 |
| -import com.zsmartsystems.zigbee.IeeeAddress; |
22 |
| -import com.zsmartsystems.zigbee.ZigBeeChannel; |
23 |
| -import com.zsmartsystems.zigbee.ZigBeeStatus; |
24 | 22 | import com.zsmartsystems.zigbee.aps.ZigBeeApsFrame;
|
25 | 23 | import com.zsmartsystems.zigbee.dongle.cc2531.frame.ZdoActiveEndpoint;
|
26 | 24 | import com.zsmartsystems.zigbee.dongle.cc2531.frame.ZdoCallbackIncoming;
|
@@ -107,6 +105,8 @@ public class ZigBeeDongleTiCc2531
|
107 | 105 | */
|
108 | 106 | private String versionString = "Unknown";
|
109 | 107 |
|
| 108 | + private ScheduledExecutorService executorService = ZigBeeExecutors.newScheduledThreadPool(1, "CC2531Commands"); |
| 109 | + |
110 | 110 | /**
|
111 | 111 | * Constructor to configure the port interface.
|
112 | 112 | *
|
@@ -304,23 +304,26 @@ public void sendCommand(final int msgTag, final ZigBeeApsFrame apsFrame) {
|
304 | 304 | } else {
|
305 | 305 | sender = (short) getSendingEndpoint(apsFrame.getProfile());
|
306 | 306 | }
|
307 |
| - ZigBeeTransportProgressState state; |
308 |
| - |
309 |
| - // TODO: How to differentiate group and device addressing????? |
310 |
| - boolean groupCommand = false; |
311 |
| - if (!groupCommand) { |
312 |
| - messageIdMap.put(apsFrame.getApsCounter(), msgTag); |
313 |
| - ZToolPacket response = networkManager.sendCommand(new AF_DATA_REQUEST(apsFrame.getDestinationAddress(), |
314 |
| - (short) apsFrame.getDestinationEndpoint(), sender, apsFrame.getCluster(), |
315 |
| - apsFrame.getApsCounter(), (byte) (0x20 | (apsFrame.getAckRequest() ? 0x10 : 0)), (byte) apsFrame.getRadius(), apsFrame.getPayload())); |
316 |
| - state = (response == null || ((AF_DATA_SRSP)response).Status != 0) ? ZigBeeTransportProgressState.TX_NAK : ZigBeeTransportProgressState.TX_ACK; |
317 |
| - } else { |
318 |
| - ZToolPacket response = networkManager.sendCommand(new AF_DATA_REQUEST_EXT(apsFrame.getDestinationAddress(), sender, |
319 |
| - apsFrame.getCluster(), apsFrame.getApsCounter(), (byte) (0), (byte) 0, apsFrame.getPayload())); |
320 |
| - state = (response == null || ((AF_DATA_SRSP_EXT)response).getStatus() != 0) ? ZigBeeTransportProgressState.TX_NAK : ZigBeeTransportProgressState.TX_ACK; |
321 |
| - } |
322 | 307 |
|
323 |
| - zigbeeNetworkReceive.receiveCommandState(msgTag, state); |
| 308 | + executorService.execute(() -> { |
| 309 | + ZigBeeTransportProgressState state; |
| 310 | + |
| 311 | + // TODO: How to differentiate group and device addressing????? |
| 312 | + boolean groupCommand = false; |
| 313 | + if (!groupCommand) { |
| 314 | + messageIdMap.put(apsFrame.getApsCounter(), msgTag); |
| 315 | + ZToolPacket response = networkManager.sendCommand(new AF_DATA_REQUEST(apsFrame.getDestinationAddress(), |
| 316 | + (short) apsFrame.getDestinationEndpoint(), sender, apsFrame.getCluster(), |
| 317 | + apsFrame.getApsCounter(), (byte) (0x20 | (apsFrame.getAckRequest() ? 0x10 : 0)), (byte) apsFrame.getRadius(), apsFrame.getPayload())); |
| 318 | + state = (response == null || ((AF_DATA_SRSP)response).Status != 0) ? ZigBeeTransportProgressState.TX_NAK : ZigBeeTransportProgressState.TX_ACK; |
| 319 | + } else { |
| 320 | + ZToolPacket response = networkManager.sendCommand(new AF_DATA_REQUEST_EXT(apsFrame.getDestinationAddress(), sender, |
| 321 | + apsFrame.getCluster(), apsFrame.getApsCounter(), (byte) (0), (byte) 0, apsFrame.getPayload())); |
| 322 | + state = (response == null || ((AF_DATA_SRSP_EXT)response).getStatus() != 0) ? ZigBeeTransportProgressState.TX_NAK : ZigBeeTransportProgressState.TX_ACK; |
| 323 | + } |
| 324 | + |
| 325 | + zigbeeNetworkReceive.receiveCommandState(msgTag, state); |
| 326 | + }); |
324 | 327 | }
|
325 | 328 | }
|
326 | 329 |
|
|
0 commit comments