|
|
@ -36,6 +36,7 @@ import org.wso2.carbon.device.mgt.iot.exception.DeviceControllerException;
|
|
|
|
import org.wso2.carbon.device.mgt.iot.sensormgt.SensorDataManager;
|
|
|
|
import org.wso2.carbon.device.mgt.iot.sensormgt.SensorDataManager;
|
|
|
|
import org.wso2.carbon.device.mgt.iot.sensormgt.SensorRecord;
|
|
|
|
import org.wso2.carbon.device.mgt.iot.sensormgt.SensorRecord;
|
|
|
|
import org.wso2.carbon.device.mgt.iot.transport.TransportHandlerException;
|
|
|
|
import org.wso2.carbon.device.mgt.iot.transport.TransportHandlerException;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.iot.DeviceManagement;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import javax.ws.rs.Consumes;
|
|
|
|
import javax.ws.rs.Consumes;
|
|
|
@ -64,14 +65,37 @@ public class ConnectedCupControllerService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setconnectedCupMQTTConnector(
|
|
|
|
public void setconnectedCupMQTTConnector(
|
|
|
|
ConnectedCupMQTTConnector connectedCupMQTTConnector) {
|
|
|
|
final ConnectedCupMQTTConnector connectedCupMQTTConnector) {
|
|
|
|
ConnectedCupControllerService.connectedCupMQTTConnector = connectedCupMQTTConnector;
|
|
|
|
|
|
|
|
if (MqttConfig.getInstance().isEnabled()) {
|
|
|
|
Runnable connector = new Runnable() {
|
|
|
|
connectedCupMQTTConnector.connect();
|
|
|
|
public void run() {
|
|
|
|
} else {
|
|
|
|
if (waitForServerStartup()) {
|
|
|
|
log.warn("MQTT disabled in 'devicemgt-config.xml'. " +
|
|
|
|
return;
|
|
|
|
"Hence, DigitalDisplayMqttCommunicationHandler not started.");
|
|
|
|
}
|
|
|
|
|
|
|
|
ConnectedCupControllerService.connectedCupMQTTConnector = connectedCupMQTTConnector;
|
|
|
|
|
|
|
|
if (MqttConfig.getInstance().isEnabled()) {
|
|
|
|
|
|
|
|
connectedCupMQTTConnector.connect();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
log.warn("MQTT disabled in 'devicemgt-config.xml'. " +
|
|
|
|
|
|
|
|
"Hence, ConnectedCupMQTTConnector not started.");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Thread connectorThread = new Thread(connector);
|
|
|
|
|
|
|
|
connectorThread.setDaemon(true);
|
|
|
|
|
|
|
|
connectorThread.start();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean waitForServerStartup() {
|
|
|
|
|
|
|
|
while (!DeviceManagement.isServerReady()) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Thread.sleep(1000);
|
|
|
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|