From 239487d30a2ea132503169d53dd45a65a9097f6d Mon Sep 17 00:00:00 2001 From: savidude Date: Wed, 21 Jun 2017 19:42:54 +0530 Subject: [PATCH] Providing a client ID to the agent --- .../iot/raspberrypi/service/impl/RaspberryPiServiceImpl.java | 4 ++-- .../service/impl/constants/RaspberrypiConstants.java | 2 +- .../src/main/resources/agent/src/mqttConnector.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiServiceImpl.java b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiServiceImpl.java index fdd36862a..93999db63 100644 --- a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiServiceImpl.java +++ b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiServiceImpl.java @@ -112,8 +112,8 @@ public class RaspberryPiServiceImpl implements RaspberryPiService { @QueryParam("from") long from, @QueryParam("to") long to) { String fromDate = String.valueOf(from); String toDate = String.valueOf(to); - String query = "deviceId:" + deviceId + " AND deviceType:" + - RaspberrypiConstants.DEVICE_TYPE + " AND time : [" + fromDate + " TO " + toDate + "]"; + String query = "meta_deviceId:" + deviceId + " AND meta_deviceType:" + + RaspberrypiConstants.DEVICE_TYPE + " AND meta_time : [" + fromDate + " TO " + toDate + "]"; String sensorTableName = RaspberrypiConstants.TEMPERATURE_EVENT_TABLE; try { if (!APIUtil.getDeviceAccessAuthorizationService().isUserAuthorized(new DeviceIdentifier(deviceId, diff --git a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/constants/RaspberrypiConstants.java b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/constants/RaspberrypiConstants.java index 5936cfb35..c19928ab7 100644 --- a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/constants/RaspberrypiConstants.java +++ b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/constants/RaspberrypiConstants.java @@ -26,7 +26,7 @@ public class RaspberrypiConstants { public static final String BULB_CONTEXT = "BULB"; //sensor events summerized table name - public static final String TEMPERATURE_EVENT_TABLE = "DEVICE_TEMPERATURE_SUMMARY"; + public static final String TEMPERATURE_EVENT_TABLE = "IOT_PER_DEVICE_STREAM_RASPBERRYPI_TEMPERATURE"; //mqtt tranport related constants public static final String MQTT_ADAPTER_TOPIC_PROPERTY_NAME = "mqtt.adapter.topic"; diff --git a/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.backend.feature/src/main/resources/agent/src/mqttConnector.py b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.backend.feature/src/main/resources/agent/src/mqttConnector.py index ccfa6b067..f05d8e018 100644 --- a/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.backend.feature/src/main/resources/agent/src/mqttConnector.py +++ b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.backend.feature/src/main/resources/agent/src/mqttConnector.py @@ -101,7 +101,7 @@ def main(): print ("MQTT_LISTENER: MQTT_TOPIC is " + TOPIC_TO_SUBSCRIBE) global mqttClient - mqttClient = mqtt.Client() + mqttClient = mqtt.Client(client_id="RaspberryPi Agent") mqttClient.on_connect = on_connect mqttClient.on_message = on_message mqttClient.on_publish = on_publish