public void run() {
while(true) {
Command cmd = null;
try {
cmd = queue.take();
<BUG>DeviceInterface device = deviceMap.get(cmd.getDeviceId());

if(device == null && cmd.getDeviceId().equals(this.gatewayId)) {

System.out.println("-->(GW) Got command for this gateway:: "+cmd);</BUG>
return;

public void run() {
while(true) {
Command cmd = null;
try {
cmd = queue.take();
DeviceInterface device = deviceMap.get(getKey(cmd));
if(device == null && cmd.getDeviceId().equals(this.gateway.getGWDeviceId()) &&
cmd.getDeviceType().equals(this.gateway.getGWDeviceType())) {
System.out.println("-->(GW) Got command for this gateway:: "+cmd);
return;
