use of com.zsmartsystems.zigbee.dongle.cc2531.network.AsynchronousCommandListener in project com.zsmartsystems.zigbee by zsmartsystems.
the class CommandInterfaceImpl method notifySynchronousCommand.
/**
* Notifies listeners about synchronous command response.
*
* @param packet the received packet
*/
private void notifySynchronousCommand(final ZToolPacket packet) {
final DoubleByte cmdId = packet.getCMD();
synchronized (synchronousCommandListeners) {
final short id = (short) (cmdId.get16BitValue() & 0x1FFF);
final SynchronousCommandListener listener = synchronousCommandListeners.get(id);
if (listener != null) {
listener.receivedCommandResponse(packet);
synchronousCommandListeners.remove(id);
synchronousCommandListeners.notifyAll();
} else {
// Notify asynchronous command listeners of unclaimed asynchronous command responses.
final AsynchronousCommandListener[] listeners;
synchronized (asynchrounsCommandListeners) {
listeners = asynchrounsCommandListeners.toArray(new AsynchronousCommandListener[] {});
}
for (final AsynchronousCommandListener asynchronousCommandListener : listeners) {
try {
asynchronousCommandListener.receivedUnclaimedSynchronousCommandResponse(packet);
} catch (Throwable e) {
logger.error("Error in incoming asynchronous message processing: ", e);
}
}
}
}
}
use of com.zsmartsystems.zigbee.dongle.cc2531.network.AsynchronousCommandListener in project com.zsmartsystems.zigbee by zsmartsystems.
the class CommandInterfaceImpl method notifyAsynchronousCommand.
/**
* Notifies listeners about asynchronous message.
*
* @param packet the packet containing the message
*/
private void notifyAsynchronousCommand(final ZToolPacket packet) {
final AsynchronousCommandListener[] listeners;
synchronized (asynchrounsCommandListeners) {
listeners = asynchrounsCommandListeners.toArray(new AsynchronousCommandListener[] {});
}
logger.debug("Received Async Cmd: {}", packet);
for (final AsynchronousCommandListener listener : listeners) {
try {
listener.receivedAsynchronousCommand(packet);
} catch (Throwable e) {
logger.error("Error in incoming asynchronous message processing: ", e);
}
}
}
Aggregations