diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/DataPublisherService.java b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/DataPublisherService.java index 51c7cb807b..0f852fd6c6 100644 --- a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/DataPublisherService.java +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/DataPublisherService.java @@ -23,6 +23,7 @@ import android.util.Log; import org.json.JSONArray; import org.json.JSONException; +import org.json.JSONObject; import org.wso2.carbon.iot.android.sense.data.publisher.mqtt.AndroidSenseMQTTHandler; import org.wso2.carbon.iot.android.sense.data.publisher.mqtt.transport.MQTTTransportHandler; import org.wso2.carbon.iot.android.sense.data.publisher.mqtt.transport.TransportHandlerException; @@ -149,7 +150,7 @@ public class DataPublisherService extends Service { for (Event event : events) { event.setOwner(user); event.setDeviceId(deviceId); - jsonArray.put(event.getEvent()); + jsonArray.put(new JSONObject().put("event", event.getEvent())); } MQTTTransportHandler mqttTransportHandler = AndroidSenseMQTTHandler.getInstance(context); if (!mqttTransportHandler.isConnected()) { diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/Event.java b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/Event.java index 554c38b12f..a8d936010f 100644 --- a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/Event.java +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/Event.java @@ -11,7 +11,7 @@ public class Event { private String owner; private String deviceId; private String type; - private float battery; + private int battery; private double gps[]; //lat,long private float accelerometer[]; //x,y,z private float magnetic[]; //x,y,z @@ -26,11 +26,11 @@ public class Event { private String wordStatus; private long timestamp; - private float getBattery() { + private int getBattery() { return battery; } - public void setBattery(float battery) { + public void setBattery(int battery) { this.type = "battery"; this.battery = battery; } diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/mqtt/AndroidSenseMQTTHandler.java b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/mqtt/AndroidSenseMQTTHandler.java index 5ae9b37391..989ad6d388 100644 --- a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/mqtt/AndroidSenseMQTTHandler.java +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/mqtt/AndroidSenseMQTTHandler.java @@ -104,7 +104,6 @@ public class AndroidSenseMQTTHandler extends MQTTTransportHandler { }; Thread connectorThread = new Thread(connector); - connectorThread.setDaemon(true); connectorThread.start(); } @@ -207,7 +206,6 @@ public class AndroidSenseMQTTHandler extends MQTTTransportHandler { }; Thread terminatorThread = new Thread(stopConnection); - terminatorThread.setDaemon(true); terminatorThread.start(); } diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/mqtt/transport/MQTTTransportHandler.java b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/mqtt/transport/MQTTTransportHandler.java index 689138d729..5fc5112d60 100644 --- a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/mqtt/transport/MQTTTransportHandler.java +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/mqtt/transport/MQTTTransportHandler.java @@ -81,8 +81,8 @@ public abstract class MQTTTransportHandler implements MqttCallback, TransportHan this.clientWillTopic = DISCONNECTION_WILL_TOPIC_PREFIX + SenseConstants.DEVICE_TYPE; this.mqttBrokerEndPoint = "tcp://" + LocalRegistry.getServerHost(context) + ":" + LocalRegistry.getMqttPort(context); this.timeoutInterval = DEFAULT_TIMEOUT_INTERVAL; - setUsernameAndPassword(LocalRegistry.getAccessToken(context), ""); this.initMQTTClient(); + setUsernameAndPassword(LocalRegistry.getAccessToken(context), ""); } /** @@ -308,7 +308,6 @@ public abstract class MQTTTransportHandler implements MqttCallback, TransportHan connect(); } }; - reconnectThread.setDaemon(true); reconnectThread.start(); } @@ -333,7 +332,6 @@ public abstract class MQTTTransportHandler implements MqttCallback, TransportHan } } }; - messageProcessorThread.setDaemon(true); messageProcessorThread.start(); } diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/ActivitySelectSensor.java b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/ActivitySelectSensor.java index 053b7e38ce..b93a3a6270 100644 --- a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/ActivitySelectSensor.java +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/ActivitySelectSensor.java @@ -180,6 +180,9 @@ public class ActivitySelectSensor extends AppCompatActivity LocalRegistry.removeUsername(getApplicationContext()); LocalRegistry.removeDeviceId(getApplicationContext()); LocalRegistry.removeServerURL(getApplicationContext()); + LocalRegistry.removeAccessToken(getApplicationContext()); + LocalRegistry.removeRefreshToken(getApplicationContext()); + LocalRegistry.removeMqttPort(getApplicationContext()); LocalRegistry.setExist(false); //Stop the current running background services. stopService(new Intent(this, SenseService.class)); //Stop sensor reading service diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/SenseClientAsyncExecutor.java b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/SenseClientAsyncExecutor.java index 79b3d740b8..c16759ee76 100644 --- a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/SenseClientAsyncExecutor.java +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/SenseClientAsyncExecutor.java @@ -95,6 +95,7 @@ public class SenseClientAsyncExecutor extends AsyncTask responseMap = new HashMap<>(); responseMap.put(STATUS, "200"); + AccessTokenInfo accessTokenInfo = null; try { //DynamicClientRegistraiton. DynamicClientRegistrationService dynamicClientRegistrationService = Feign.builder() @@ -116,7 +117,7 @@ public class SenseClientAsyncExecutor extends AsyncTask + android:paddingTop="@dimen/activity_vertical_margin" tools:context="org.wso2.carbon.iot.android.sense.RegisterActivity" + android:weightSum="1"> @@ -14,7 +15,8 @@ + android:fillViewport="false" + android:layout_weight="0.07"> @@ -37,43 +39,36 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/hostname" android:id="@+id/hostname" - android:text="https://localhost:9443" + android:text="https://10.10.10.149:9443" android:inputType="text" android:maxLines="1" android:singleLine="true"/> -