Merge branch 'IoTS-1.0.0-M1' of https://github.com/wso2/carbon-device-mgt-plugins into IoTS-1.0.0-M1

charithag 9 years ago
commit b323dabf2c

@ -47,7 +47,6 @@ public class DigitalDisplayMqttCommunicationHandler extends MQTTTransportHandler
public void run() { public void run() {
while (!isConnected()) { while (!isConnected()) {
try { try {
log.info("Trying to Connect..");
connectToQueue(); connectToQueue();
subscribeToQueue(); subscribeToQueue();

@ -28,6 +28,8 @@ public class MqttConfig {
private boolean isEnabled; private boolean isEnabled;
private static final String MQTT_QUEUE_CONFIG_NAME = "MQTT"; private static final String MQTT_QUEUE_CONFIG_NAME = "MQTT";
private static final String LOCALHOST = "localhost";
private static final String PORT_OFFSET_PROPERTY = "portOffset";
private ControlQueue mqttControlQueue; private ControlQueue mqttControlQueue;
@ -58,14 +60,29 @@ public class MqttConfig {
} }
private MqttConfig() { private MqttConfig() {
mqttControlQueue = DeviceManagementConfigurationManager.getInstance().getControlQueue( mqttControlQueue = DeviceManagementConfigurationManager.getInstance().getControlQueue(MQTT_QUEUE_CONFIG_NAME);
MQTT_QUEUE_CONFIG_NAME);
mqttQueueEndpoint = mqttControlQueue.getServerURL() + ":" + mqttControlQueue.getPort(); int portOffset = Integer.parseInt(System.getProperty(PORT_OFFSET_PROPERTY));
String brokerURL = mqttControlQueue.getServerURL();
if (portOffset != 0 && brokerURL.contains(LOCALHOST)) {
// if using the internal MB (meaning URL is localhost and there is a portOffset)
// then increment port accordingly
int mqttPort = mqttControlQueue.getPort();
mqttPort = mqttPort + portOffset;
mqttQueueEndpoint = mqttControlQueue.getServerURL() + ":" + mqttPort;
} else {
mqttQueueEndpoint = mqttControlQueue.getServerURL() + ":" + mqttControlQueue.getPort();
}
mqttQueueUsername = mqttControlQueue.getUsername(); mqttQueueUsername = mqttControlQueue.getUsername();
mqttQueuePassword = mqttControlQueue.getPassword(); mqttQueuePassword = mqttControlQueue.getPassword();
isEnabled = mqttControlQueue.isEnabled(); isEnabled = mqttControlQueue.isEnabled();
} }
public static MqttConfig getInstance() { public static MqttConfig getInstance() {
return mqttConfig; return mqttConfig;
} }

@ -33,6 +33,14 @@ import java.util.Map;
public class ZipUtil { public class ZipUtil {
private static final String LOCAL_BIND_ADDRESS_PROPERTY = "carbon.local.ip";
private static final String HTTPS_PORT_PROPERTY = "httpsPort";
private static final String HTTP_PORT_PROPERTY = "httpPort";
private static final String LOCALHOST = "localhost";
private static final String HTTPS_PROTOCOL_APPENDER = "https://";
private static final String HTTP_PROTOCOL_APPENDER = "http://";
public ZipArchive createZipFile(String owner, String tenantDomain, String deviceType, public ZipArchive createZipFile(String owner, String tenantDomain, String deviceType,
String deviceId, String deviceName, String token, String deviceId, String deviceName, String token,
String refreshToken) String refreshToken)
@ -48,12 +56,12 @@ public class ZipUtil {
String templateSketchPath = sketchFolder + sep + deviceType; String templateSketchPath = sketchFolder + sep + deviceType;
String serverName = DeviceManagementConfigurationManager.getInstance().getDeviceManagementServerInfo().getName(); String serverName = DeviceManagementConfigurationManager.getInstance().getDeviceManagementServerInfo().getName();
String iotServerIP = System.getProperty("carbon.local.ip"); // bind.address String iotServerIP = System.getProperty(LOCAL_BIND_ADDRESS_PROPERTY); // bind.address
String httpsServerPort = System.getProperty("httpsPort"); String httpsServerPort = System.getProperty(HTTPS_PORT_PROPERTY);
String httpServerPort = System.getProperty("httpPort"); String httpServerPort = System.getProperty(HTTP_PORT_PROPERTY);
String httpsServerEP = "https://" + iotServerIP + ":" + httpsServerPort; String httpsServerEP = HTTPS_PROTOCOL_APPENDER + iotServerIP + ":" + httpsServerPort;
String httpServerEP = "http://" + iotServerIP + ":" + httpServerPort; String httpServerEP = HTTP_PROTOCOL_APPENDER + iotServerIP + ":" + httpServerPort;
String apimHost = String apimHost =
DeviceManagementConfigurationManager.getInstance().getDeviceCloudMgtConfig().getApiManager() DeviceManagementConfigurationManager.getInstance().getDeviceCloudMgtConfig().getApiManager()
@ -65,6 +73,11 @@ public class ZipUtil {
String apimEndpoint = apimHost + ":" + apimGatewayPort; String apimEndpoint = apimHost + ":" + apimGatewayPort;
String mqttEndpoint = MqttConfig.getInstance().getMqttQueueEndpoint(); String mqttEndpoint = MqttConfig.getInstance().getMqttQueueEndpoint();
if (mqttEndpoint.contains(LOCALHOST)) {
mqttEndpoint = mqttEndpoint.replace(LOCALHOST, iotServerIP);
}
String xmppEndpoint = XmppConfig.getInstance().getXmppEndpoint(); String xmppEndpoint = XmppConfig.getInstance().getXmppEndpoint();
int indexOfChar = xmppEndpoint.lastIndexOf(":"); int indexOfChar = xmppEndpoint.lastIndexOf(":");

@ -32,7 +32,8 @@
<Enabled>true</Enabled> <Enabled>true</Enabled>
<ControlClass>org.wso2.carbon.device.mgt.iot.controlqueue.mqtt.MqttControlPublisher</ControlClass> <ControlClass>org.wso2.carbon.device.mgt.iot.controlqueue.mqtt.MqttControlPublisher</ControlClass>
<Protocol>MQTT</Protocol> <Protocol>MQTT</Protocol>
<ServerURL>tcp://204.232.188.214</ServerURL> <!--<ServerURL>tcp://204.232.188.214</ServerURL>-->
<ServerURL>tcp://localhost</ServerURL>
<Port>1883</Port> <Port>1883</Port>
<Username>.</Username> <Username>.</Username>
<Password>.</Password> <Password>.</Password>
@ -58,9 +59,9 @@
<ApiManager> <ApiManager>
<Enabled>true</Enabled> <Enabled>true</Enabled>
<AccessTokenURL>https://localhost:9443/oauth2/token</AccessTokenURL> <AccessTokenURL>https://localhost:9443/oauth2/token</AccessTokenURL>
<ServerURL>http://localhost</ServerURL> <ServerURL>https://localhost</ServerURL>
<ServerPort>9763</ServerPort> <ServerPort>9443</ServerPort>
<GatewayPort>8280</GatewayPort> <GatewayPort>8243</GatewayPort>
<LoginURL>/api-store/site/blocks/user/login/ajax/login.jag</LoginURL> <LoginURL>/api-store/site/blocks/user/login/ajax/login.jag</LoginURL>
<SubscriptionListURL>/api-store/site/blocks/subscription/subscription-list/ajax/subscription-list.jag</SubscriptionListURL> <SubscriptionListURL>/api-store/site/blocks/subscription/subscription-list/ajax/subscription-list.jag</SubscriptionListURL>
<Username>admin</Username> <Username>admin</Username>

Loading…
Cancel
Save