From 50e90fa8de7c9c119c9dcdd513f9a685911e5eed Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Fri, 23 Oct 2015 01:04:32 +0530 Subject: [PATCH 1/3] generalizing inmemory map into any sensor --- ...mperatureRecord.java => DeviceRecord.java} | 4 ++-- .../service/impl/dao/SensorRecord.java | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) rename modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/service/impl/dao/{TemperatureRecord.java => DeviceRecord.java} (92%) create mode 100644 modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/service/impl/dao/SensorRecord.java diff --git a/modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/service/impl/dao/TemperatureRecord.java b/modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/service/impl/dao/DeviceRecord.java similarity index 92% rename from modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/service/impl/dao/TemperatureRecord.java rename to modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/service/impl/dao/DeviceRecord.java index 3b3074c9..c4358ae2 100644 --- a/modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/service/impl/dao/TemperatureRecord.java +++ b/modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/service/impl/dao/DeviceRecord.java @@ -20,11 +20,11 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement -public class TemperatureRecord { +public class DeviceRecord { private double temperature; private long time; - public TemperatureRecord(double temperature, long time) { + public DeviceRecord(double temperature, long time) { this.temperature = temperature; this.time = time; } diff --git a/modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/service/impl/dao/SensorRecord.java b/modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/service/impl/dao/SensorRecord.java new file mode 100644 index 00000000..e52e722c --- /dev/null +++ b/modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/service/impl/dao/SensorRecord.java @@ -0,0 +1,24 @@ +package org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl.dao; + +import javax.xml.bind.annotation.XmlElement; + +public class SensorRecord { + private String sensorValue; + private long time; + + public SensorRecord(String sensorValue, long time) { + this.sensorValue = sensorValue; + this.time = time; + } + + @XmlElement + public String getSensorValue() { + return sensorValue; + } + + @XmlElement + public long getTime() { + return time; + } + +} \ No newline at end of file From e31fda92a695850471bb6633f3888531124907b1 Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Fri, 23 Oct 2015 01:04:55 +0530 Subject: [PATCH 2/3] generalizing inmemory map into any sensor --- .../Temperature_Sensor_Script.xml | 12 ++-- .../constants/VirtualFireAlarmConstants.java | 2 + .../service/impl/VirtualFireAlarmService.java | 50 ++++++++++++---- .../service/impl/dao/DeviceRecord.java | 21 +++---- .../service/impl/util/DataHolder.java | 59 +++++++++++++++---- .../util/VirtualFireAlarmMQTTSubscriber.java | 4 +- 6 files changed, 107 insertions(+), 41 deletions(-) diff --git a/modules/distribution/src/statistics/carbonapps/Temperature_Sensor/Sparkscripts_1.0.0/Temperature_Sensor_Script.xml b/modules/distribution/src/statistics/carbonapps/Temperature_Sensor/Sparkscripts_1.0.0/Temperature_Sensor_Script.xml index b604b5ab..ee6a7195 100644 --- a/modules/distribution/src/statistics/carbonapps/Temperature_Sensor/Sparkscripts_1.0.0/Temperature_Sensor_Script.xml +++ b/modules/distribution/src/statistics/carbonapps/Temperature_Sensor/Sparkscripts_1.0.0/Temperature_Sensor_Script.xml @@ -1,13 +1,13 @@ IoTServer_Sensor_Script - + + insert overwrite table DeviceTemperatureSummaryData select temperature, meta_deviceType as deviceType, meta_deviceId as deviceId, meta_owner as owner, cast(meta_time/1000 as BIGINT)as time from DeviceTemperatureData group by temperature, meta_deviceType, meta_deviceId, meta_owner, cast(meta_time/1000 as BIGINT); + 0 * * * * ? diff --git a/modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/plugin/constants/VirtualFireAlarmConstants.java b/modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/plugin/constants/VirtualFireAlarmConstants.java index e780ee83..64e9d8fe 100644 --- a/modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/plugin/constants/VirtualFireAlarmConstants.java +++ b/modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/plugin/constants/VirtualFireAlarmConstants.java @@ -27,4 +27,6 @@ public class VirtualFireAlarmConstants { public static final String BULB_CONTEXT = "/BULB/"; public static final String SONAR_CONTEXT = "/HUMIDITY/"; public static final String TEMPERATURE_CONTEXT = "/TEMPERATURE/"; + + public static final String SENSOR_TEMPERATURE = "temperature"; } diff --git a/modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/service/impl/VirtualFireAlarmService.java b/modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/service/impl/VirtualFireAlarmService.java index 6bc7fef4..403aabab 100644 --- a/modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/service/impl/VirtualFireAlarmService.java +++ b/modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/service/impl/VirtualFireAlarmService.java @@ -44,7 +44,8 @@ import org.wso2.carbon.device.mgt.iot.common.exception.DeviceControllerException import org.wso2.carbon.device.mgt.iot.common.util.ZipArchive; import org.wso2.carbon.device.mgt.iot.common.util.ZipUtil; import org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.plugin.constants.VirtualFireAlarmConstants; -import org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl.dao.TemperatureRecord; +import org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl.dao.DeviceRecord; +import org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl.dao.SensorRecord; import org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl.util.DataHolder; import org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl.dao.DeviceJSON; import org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl.util.VirtualFireAlarmMQTTSubscriber; @@ -246,8 +247,7 @@ public class VirtualFireAlarmService { device.setName(name); device.setType(VirtualFireAlarmConstants.DEVICE_TYPE); - boolean updated = deviceManagement.getDeviceManagementService().modifyEnrollment( - device); + boolean updated = deviceManagement.getDeviceManagementService().modifyEnrollment(device); if (updated) { response.setStatus(Response.Status.OK.getStatusCode()); @@ -312,7 +312,7 @@ public class VirtualFireAlarmService { } } - return userDevicesforFirealarm.toArray(new Device[]{}); + return userDevicesforFirealarm.toArray(new Device[] {}); } catch (DeviceManagementException e) { response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); return null; @@ -607,11 +607,11 @@ public class VirtualFireAlarmService { @GET @Consumes("application/json") @Produces("application/json") - public TemperatureRecord requestTemperature(@HeaderParam("owner") String owner, + public SensorRecord requestTemperature(@HeaderParam("owner") String owner, @HeaderParam("deviceId") String deviceId, @HeaderParam("protocol") String protocol, @Context HttpServletResponse response) { - TemperatureRecord temperatureRecord = null; + SensorRecord sensorRecord = null; DeviceValidator deviceValidator = new DeviceValidator(); try { @@ -636,8 +636,9 @@ public class VirtualFireAlarmService { response.setStatus(Response.Status.PRECONDITION_FAILED.getStatusCode()); } String tString = sendCommandViaHTTP(deviceHTTPEndpoint, VirtualFireAlarmConstants.TEMPERATURE_CONTEXT, false); - float temperature = Float.parseFloat(tString); - DataHolder.getThisInstance().setTemperature(deviceId, temperature, Calendar.getInstance().getTimeInMillis()); + String temperatureValue = tString; + DataHolder.getInstance().setSensorRecord(deviceId, VirtualFireAlarmConstants.SENSOR_TEMPERATURE, temperatureValue, + Calendar.getInstance().getTimeInMillis()); break; case MQTT_PROTOCOL: @@ -651,13 +652,13 @@ public class VirtualFireAlarmService { default: response.setStatus(Response.Status.NOT_ACCEPTABLE.getStatusCode()); } - temperatureRecord = DataHolder.getThisInstance().getTemperature(deviceId); + sensorRecord = DataHolder.getInstance().getSensorRecord(deviceId, VirtualFireAlarmConstants.SENSOR_TEMPERATURE); } catch (DeviceManagementException e) { response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); } response.setStatus(Response.Status.OK.getStatusCode()); - return temperatureRecord; + return sensorRecord; } @Path("controller/push_temperature") @@ -684,13 +685,38 @@ public class VirtualFireAlarmService { response.setStatus(Response.Status.CONFLICT.getStatusCode()); return; } - DataHolder.getThisInstance().setTemperature(deviceId, temperature, Calendar.getInstance().getTimeInMillis()); + DataHolder.getInstance().setSensorRecord(deviceId, + VirtualFireAlarmConstants.SENSOR_TEMPERATURE, + String.valueOf(temperature), + Calendar.getInstance().getTimeInMillis()); if (!publishToDAS(dataMsg.owner, dataMsg.deviceId, dataMsg.value)) { response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); } } + @Path("controller/set_sensor") + @POST + @Consumes("application/json") + @Produces("application/json") + public boolean setSensorReading(@HeaderParam("deviceId") String deviceId, + @HeaderParam("sensorName") String sensorName, + @HeaderParam("sensorValue") String sensorValue, + @Context HttpServletResponse response) { + + return DataHolder.getInstance().setSensorRecord(deviceId, sensorName, sensorValue, Calendar.getInstance().getTimeInMillis()); + } + + @Path("controller/read_sensor") + @GET + @Consumes("application/json") + @Produces("application/json") + public SensorRecord readSensorReading(@HeaderParam("deviceId") String deviceId, + @HeaderParam("sensorName") String sensorName, + @Context HttpServletResponse response) { + return DataHolder.getInstance().getSensorRecord(deviceId, sensorName); + } + private String sendCommandViaHTTP(final String deviceHTTPEndpoint, String urlContext, boolean fireAndForgot) throws DeviceManagementException { String responseMsg = ""; @@ -764,6 +790,8 @@ public class VirtualFireAlarmService { return responseMsg; } + + private boolean sendCommandViaMQTT(String deviceOwner, String deviceId, String resource, String state) throws DeviceManagementException { boolean result = false; diff --git a/modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/service/impl/dao/DeviceRecord.java b/modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/service/impl/dao/DeviceRecord.java index c4358ae2..49f679fd 100644 --- a/modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/service/impl/dao/DeviceRecord.java +++ b/modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/service/impl/dao/DeviceRecord.java @@ -18,24 +18,21 @@ package org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl.dao import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import java.util.HashMap; +import java.util.Map; @XmlRootElement public class DeviceRecord { - private double temperature; - private long time; + //all int, float, boolean should be converted into string + //when saving on the map + private Map sensorDataList = new HashMap<>(); - public DeviceRecord(double temperature, long time) { - this.temperature = temperature; - this.time = time; + public DeviceRecord(String sensorName, String sensorValue, long time) { + sensorDataList.put(sensorName, new SensorRecord(sensorValue, time)); } @XmlElement - public double getTemperature() { - return temperature; - } - - @XmlElement - public long getTime() { - return time; + public Map getSensorDataList() { + return sensorDataList; } } \ No newline at end of file diff --git a/modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/service/impl/util/DataHolder.java b/modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/service/impl/util/DataHolder.java index e7b9c8db..9d97902b 100644 --- a/modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/service/impl/util/DataHolder.java +++ b/modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/service/impl/util/DataHolder.java @@ -16,30 +16,69 @@ package org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl.util; -import org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl.dao.TemperatureRecord; +import org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl.dao.DeviceRecord; +import org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl.dao.SensorRecord; +import java.util.Collection; import java.util.HashMap; import java.util.Map; public class DataHolder { - private static DataHolder thisInstance = new DataHolder(); - private Map temperatureMap = new HashMap<>(); + private static DataHolder instance = new DataHolder(); + private Map deviceMap = new HashMap<>(); private DataHolder() { - } - public static DataHolder getThisInstance() { - return thisInstance; + public static DataHolder getInstance() { + return instance; } - public TemperatureRecord getTemperature(String deviceId) { - return temperatureMap.get(deviceId); + public boolean setSensorRecord(String deviceId, String sensorName, String sensorValue, long time){ + DeviceRecord deviceRecord = new DeviceRecord(sensorName, sensorValue, time); + deviceMap.put(deviceId, deviceRecord); + return true; } - public void setTemperature(String deviceId, double temperature, long time){ - temperatureMap.put(deviceId, new TemperatureRecord(temperature, time)); + /** + * Returns last updated sensor records list for a device + * @param deviceId + * @return + */ + public SensorRecord[] getSensorRecords(String deviceId){ + Collection list = deviceMap.get(deviceId).getSensorDataList().values(); + return list.toArray(new SensorRecord[list.size()]); + } + + /** + * Returns last updated sensor record for a device's sensor + * @param deviceId + * @param sensorName + * @return + */ + public SensorRecord getSensorRecord(String deviceId, String sensorName){ + return deviceMap.get(deviceId).getSensorDataList().get(sensorName); + } + + /** + * Returns last updated sensor value for a device's sensor + * @param deviceId + * @param sensorName + * @return + */ + public String getSensorRecordValue(String deviceId, String sensorName){ + return deviceMap.get(deviceId).getSensorDataList().get(sensorName).getSensorValue(); + } + + /** + * Returns last updated sensor value reading time for a device's sensor + * @param deviceId + * @param sensorName + * @return + */ + public long getSensorRecordTime(String deviceId, String sensorName){ + return deviceMap.get(deviceId).getSensorDataList().get(sensorName).getTime(); } } diff --git a/modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/service/impl/util/VirtualFireAlarmMQTTSubscriber.java b/modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/service/impl/util/VirtualFireAlarmMQTTSubscriber.java index 7a980700..08014b6c 100644 --- a/modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/service/impl/util/VirtualFireAlarmMQTTSubscriber.java +++ b/modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/service/impl/util/VirtualFireAlarmMQTTSubscriber.java @@ -66,8 +66,8 @@ public class VirtualFireAlarmMQTTSubscriber extends MqttSubscriber { } } else if (message.toString().contains("TEMPERATURE")) { log.info("MQTT: Reply Message [" + message.toString() + "] topic: [" + topic + "]"); - float temperature = Float.parseFloat(message.toString().split(":")[1]); - DataHolder.getThisInstance().setTemperature(deviceId, temperature, Calendar.getInstance().getTimeInMillis()); + String temperatureValue = message.toString().split(":")[1]; + DataHolder.getInstance().setSensorRecord(deviceId, VirtualFireAlarmConstants.SENSOR_TEMPERATURE, temperatureValue, Calendar.getInstance().getTimeInMillis()); } else { log.info("MQTT: Message [" + message.toString() + "] topic: [" + topic + "]"); } From 5625b83b648ffc9c0d4dee8d9cff65590ce93626 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Fri, 23 Oct 2015 07:42:25 +0530 Subject: [PATCH 3/3] added android sense service and required stream definitions --- modules/distribution/pom.xml | 6 +- .../EventReceiver_battery.xml | 8 ++ .../Eventreceiver_battery_1.0.0/artifact.xml | 4 + .../Eventstore_battery_1.0.0/artifact.xml | 4 + .../org_wso2_iot_devices_battery.xml | 44 +++++++++++ .../Eventstream_battery_1.0.0/artifact.xml | 5 ++ .../org.wso2.iot.devices.battery_1.0.0.json | 20 +++++ .../Battery_Sensor_Script.xml | 13 ++++ .../Battery/Sparkscripts_1.0.0/artifact.xml | 4 + .../carbonapps/Battery/artifacts.xml | 11 +++ .../EventReceiver_gps.xml | 8 ++ .../GPS/Eventreceiver_gps_1.0.0/artifact.xml | 4 + .../GPS/Eventstore_gps_1.0.0/artifact.xml | 4 + .../org_wso2_iot_devices_gps.xml | 51 +++++++++++++ .../GPS/Eventstream_gps_1.0.0/artifact.xml | 5 ++ .../org.wso2.iot.devices.gps_1.0.0.json | 23 ++++++ .../Sparkscripts_1.0.0/GPS_Sensor_Script.xml | 13 ++++ .../GPS/Sparkscripts_1.0.0/artifact.xml | 4 + .../statistics/carbonapps/GPS/artifacts.xml | 11 +++ .../EventReceiver_light.xml | 8 ++ .../Eventreceiver_light_1.0.0/artifact.xml | 4 + .../Light/Eventstore_light_1.0.0/artifact.xml | 4 + .../org_wso2_iot_devices_light.xml | 44 +++++++++++ .../Eventstream_light_1.0.0/artifact.xml | 5 ++ .../org.wso2.iot.devices.light_1.0.0.json | 20 +++++ .../Light_Sensor_Script.xml | 13 ++++ .../Light/Sparkscripts_1.0.0/artifact.xml | 4 + .../statistics/carbonapps/Light/artifacts.xml | 11 +++ .../EventReceiver_magnetic.xml | 8 ++ .../Eventreceiver_magnetic_1.0.0/artifact.xml | 4 + .../Eventstore_magnetic_1.0.0/artifact.xml | 4 + .../org_wso2_iot_devices_magnetic.xml | 44 +++++++++++ .../Eventstream_magnetic_1.0.0/artifact.xml | 5 ++ .../org.wso2.iot.devices.magnetic_1.0.0.json | 20 +++++ .../Magnetic_Sensor_Script.xml | 13 ++++ .../Magnetic/Sparkscripts_1.0.0/artifact.xml | 4 + .../carbonapps/Magnetic/artifacts.xml | 11 +++ .../src/statistics/carbonapps/build.xml | 18 +++++ .../impl/AndroidSenseControllerService.java | 2 +- .../impl/AndroidSenseManagerService.java | 10 ++- .../sense/service/impl/util/DeviceJSON.java | 5 +- .../sense/service/impl/util/SensorJSON.java | 16 ++++ modules/samples/sample_pom.xml | 2 +- .../pom.xml | 76 +++++++++++++++++++ 44 files changed, 584 insertions(+), 13 deletions(-) create mode 100644 modules/distribution/src/statistics/carbonapps/Battery/Eventreceiver_battery_1.0.0/EventReceiver_battery.xml create mode 100644 modules/distribution/src/statistics/carbonapps/Battery/Eventreceiver_battery_1.0.0/artifact.xml create mode 100644 modules/distribution/src/statistics/carbonapps/Battery/Eventstore_battery_1.0.0/artifact.xml create mode 100644 modules/distribution/src/statistics/carbonapps/Battery/Eventstore_battery_1.0.0/org_wso2_iot_devices_battery.xml create mode 100644 modules/distribution/src/statistics/carbonapps/Battery/Eventstream_battery_1.0.0/artifact.xml create mode 100644 modules/distribution/src/statistics/carbonapps/Battery/Eventstream_battery_1.0.0/org.wso2.iot.devices.battery_1.0.0.json create mode 100644 modules/distribution/src/statistics/carbonapps/Battery/Sparkscripts_1.0.0/Battery_Sensor_Script.xml create mode 100644 modules/distribution/src/statistics/carbonapps/Battery/Sparkscripts_1.0.0/artifact.xml create mode 100644 modules/distribution/src/statistics/carbonapps/Battery/artifacts.xml create mode 100644 modules/distribution/src/statistics/carbonapps/GPS/Eventreceiver_gps_1.0.0/EventReceiver_gps.xml create mode 100644 modules/distribution/src/statistics/carbonapps/GPS/Eventreceiver_gps_1.0.0/artifact.xml create mode 100644 modules/distribution/src/statistics/carbonapps/GPS/Eventstore_gps_1.0.0/artifact.xml create mode 100644 modules/distribution/src/statistics/carbonapps/GPS/Eventstore_gps_1.0.0/org_wso2_iot_devices_gps.xml create mode 100644 modules/distribution/src/statistics/carbonapps/GPS/Eventstream_gps_1.0.0/artifact.xml create mode 100644 modules/distribution/src/statistics/carbonapps/GPS/Eventstream_gps_1.0.0/org.wso2.iot.devices.gps_1.0.0.json create mode 100644 modules/distribution/src/statistics/carbonapps/GPS/Sparkscripts_1.0.0/GPS_Sensor_Script.xml create mode 100644 modules/distribution/src/statistics/carbonapps/GPS/Sparkscripts_1.0.0/artifact.xml create mode 100644 modules/distribution/src/statistics/carbonapps/GPS/artifacts.xml create mode 100644 modules/distribution/src/statistics/carbonapps/Light/Eventreceiver_light_1.0.0/EventReceiver_light.xml create mode 100644 modules/distribution/src/statistics/carbonapps/Light/Eventreceiver_light_1.0.0/artifact.xml create mode 100644 modules/distribution/src/statistics/carbonapps/Light/Eventstore_light_1.0.0/artifact.xml create mode 100644 modules/distribution/src/statistics/carbonapps/Light/Eventstore_light_1.0.0/org_wso2_iot_devices_light.xml create mode 100644 modules/distribution/src/statistics/carbonapps/Light/Eventstream_light_1.0.0/artifact.xml create mode 100644 modules/distribution/src/statistics/carbonapps/Light/Eventstream_light_1.0.0/org.wso2.iot.devices.light_1.0.0.json create mode 100644 modules/distribution/src/statistics/carbonapps/Light/Sparkscripts_1.0.0/Light_Sensor_Script.xml create mode 100644 modules/distribution/src/statistics/carbonapps/Light/Sparkscripts_1.0.0/artifact.xml create mode 100644 modules/distribution/src/statistics/carbonapps/Light/artifacts.xml create mode 100644 modules/distribution/src/statistics/carbonapps/Magnetic/Eventreceiver_magnetic_1.0.0/EventReceiver_magnetic.xml create mode 100644 modules/distribution/src/statistics/carbonapps/Magnetic/Eventreceiver_magnetic_1.0.0/artifact.xml create mode 100644 modules/distribution/src/statistics/carbonapps/Magnetic/Eventstore_magnetic_1.0.0/artifact.xml create mode 100644 modules/distribution/src/statistics/carbonapps/Magnetic/Eventstore_magnetic_1.0.0/org_wso2_iot_devices_magnetic.xml create mode 100644 modules/distribution/src/statistics/carbonapps/Magnetic/Eventstream_magnetic_1.0.0/artifact.xml create mode 100644 modules/distribution/src/statistics/carbonapps/Magnetic/Eventstream_magnetic_1.0.0/org.wso2.iot.devices.magnetic_1.0.0.json create mode 100644 modules/distribution/src/statistics/carbonapps/Magnetic/Sparkscripts_1.0.0/Magnetic_Sensor_Script.xml create mode 100644 modules/distribution/src/statistics/carbonapps/Magnetic/Sparkscripts_1.0.0/artifact.xml create mode 100644 modules/distribution/src/statistics/carbonapps/Magnetic/artifacts.xml create mode 100644 modules/samples/android_sense/src/org.wso2.carbon.device.mgt.iot.sample.android.sense.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/android/sense/service/impl/util/SensorJSON.java diff --git a/modules/distribution/pom.xml b/modules/distribution/pom.xml index fdb98b9d..2de47da5 100644 --- a/modules/distribution/pom.xml +++ b/modules/distribution/pom.xml @@ -340,11 +340,11 @@ file="target/wso2carbon-core-${carbon.kernel.version}/repository/conf/iot/iot-config.xml"/> + toFile="target/wso2carbon-core-${carbon.kernel.version}/samples/arduino/build.xml"/> + toFile="target/wso2carbon-core-${carbon.kernel.version}/samples/raspberrypi/build.xml"/> + toFile="target/wso2carbon-core-${carbon.kernel.version}/samples/virtual_firealarm/build.xml"/> diff --git a/modules/distribution/src/statistics/carbonapps/Battery/Eventreceiver_battery_1.0.0/EventReceiver_battery.xml b/modules/distribution/src/statistics/carbonapps/Battery/Eventreceiver_battery_1.0.0/EventReceiver_battery.xml new file mode 100644 index 00000000..640da303 --- /dev/null +++ b/modules/distribution/src/statistics/carbonapps/Battery/Eventreceiver_battery_1.0.0/EventReceiver_battery.xml @@ -0,0 +1,8 @@ + + + + false + + + + diff --git a/modules/distribution/src/statistics/carbonapps/Battery/Eventreceiver_battery_1.0.0/artifact.xml b/modules/distribution/src/statistics/carbonapps/Battery/Eventreceiver_battery_1.0.0/artifact.xml new file mode 100644 index 00000000..00f6cbca --- /dev/null +++ b/modules/distribution/src/statistics/carbonapps/Battery/Eventreceiver_battery_1.0.0/artifact.xml @@ -0,0 +1,4 @@ + + + EventReceiver_battery.xml + diff --git a/modules/distribution/src/statistics/carbonapps/Battery/Eventstore_battery_1.0.0/artifact.xml b/modules/distribution/src/statistics/carbonapps/Battery/Eventstore_battery_1.0.0/artifact.xml new file mode 100644 index 00000000..1ab97be0 --- /dev/null +++ b/modules/distribution/src/statistics/carbonapps/Battery/Eventstore_battery_1.0.0/artifact.xml @@ -0,0 +1,4 @@ + + + org_wso2_iot_devices_battery.xml + diff --git a/modules/distribution/src/statistics/carbonapps/Battery/Eventstore_battery_1.0.0/org_wso2_iot_devices_battery.xml b/modules/distribution/src/statistics/carbonapps/Battery/Eventstore_battery_1.0.0/org_wso2_iot_devices_battery.xml new file mode 100644 index 00000000..6f40ebb5 --- /dev/null +++ b/modules/distribution/src/statistics/carbonapps/Battery/Eventstore_battery_1.0.0/org_wso2_iot_devices_battery.xml @@ -0,0 +1,44 @@ + + + + org.wso2.iot.devices.battery:1.0.0 + + EVENT_STORE + + + meta_owner + true + true + false + STRING + + + meta_deviceType + true + true + false + STRING + + + meta_deviceId + true + true + false + STRING + + + meta_time + true + true + false + LONG + + + battery + false + false + false + FLOAT + + + \ No newline at end of file diff --git a/modules/distribution/src/statistics/carbonapps/Battery/Eventstream_battery_1.0.0/artifact.xml b/modules/distribution/src/statistics/carbonapps/Battery/Eventstream_battery_1.0.0/artifact.xml new file mode 100644 index 00000000..f3451427 --- /dev/null +++ b/modules/distribution/src/statistics/carbonapps/Battery/Eventstream_battery_1.0.0/artifact.xml @@ -0,0 +1,5 @@ + + + org.wso2.iot.devices.battery_1.0.0.json + + diff --git a/modules/distribution/src/statistics/carbonapps/Battery/Eventstream_battery_1.0.0/org.wso2.iot.devices.battery_1.0.0.json b/modules/distribution/src/statistics/carbonapps/Battery/Eventstream_battery_1.0.0/org.wso2.iot.devices.battery_1.0.0.json new file mode 100644 index 00000000..c0a2106f --- /dev/null +++ b/modules/distribution/src/statistics/carbonapps/Battery/Eventstream_battery_1.0.0/org.wso2.iot.devices.battery_1.0.0.json @@ -0,0 +1,20 @@ +{ + "name": "org.wso2.iot.devices.battery", + "version": "1.0.0", + "nickName": "battery Data", + "description": "battery data received from the Device", + "metaData": [ + {"name":"owner","type":"STRING"}, + {"name":"deviceType","type":"STRING"}, + {"name":"deviceId","type":"STRING"}, + {"name":"time","type":"LONG"} + ], + "payloadData": [ + { + "name": "battery","type": "FLOAT" + } + ] +} + + + diff --git a/modules/distribution/src/statistics/carbonapps/Battery/Sparkscripts_1.0.0/Battery_Sensor_Script.xml b/modules/distribution/src/statistics/carbonapps/Battery/Sparkscripts_1.0.0/Battery_Sensor_Script.xml new file mode 100644 index 00000000..005ab010 --- /dev/null +++ b/modules/distribution/src/statistics/carbonapps/Battery/Sparkscripts_1.0.0/Battery_Sensor_Script.xml @@ -0,0 +1,13 @@ + + + Battery_Sensor_Script + + 0 * * * * ? + diff --git a/modules/distribution/src/statistics/carbonapps/Battery/Sparkscripts_1.0.0/artifact.xml b/modules/distribution/src/statistics/carbonapps/Battery/Sparkscripts_1.0.0/artifact.xml new file mode 100644 index 00000000..1a1ad956 --- /dev/null +++ b/modules/distribution/src/statistics/carbonapps/Battery/Sparkscripts_1.0.0/artifact.xml @@ -0,0 +1,4 @@ + + + Battery_Sensor_Script.xml + diff --git a/modules/distribution/src/statistics/carbonapps/Battery/artifacts.xml b/modules/distribution/src/statistics/carbonapps/Battery/artifacts.xml new file mode 100644 index 00000000..b5514bd6 --- /dev/null +++ b/modules/distribution/src/statistics/carbonapps/Battery/artifacts.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/modules/distribution/src/statistics/carbonapps/GPS/Eventreceiver_gps_1.0.0/EventReceiver_gps.xml b/modules/distribution/src/statistics/carbonapps/GPS/Eventreceiver_gps_1.0.0/EventReceiver_gps.xml new file mode 100644 index 00000000..acda8f1a --- /dev/null +++ b/modules/distribution/src/statistics/carbonapps/GPS/Eventreceiver_gps_1.0.0/EventReceiver_gps.xml @@ -0,0 +1,8 @@ + + + + false + + + + diff --git a/modules/distribution/src/statistics/carbonapps/GPS/Eventreceiver_gps_1.0.0/artifact.xml b/modules/distribution/src/statistics/carbonapps/GPS/Eventreceiver_gps_1.0.0/artifact.xml new file mode 100644 index 00000000..da4b5802 --- /dev/null +++ b/modules/distribution/src/statistics/carbonapps/GPS/Eventreceiver_gps_1.0.0/artifact.xml @@ -0,0 +1,4 @@ + + + EventReceiver_gps.xml + diff --git a/modules/distribution/src/statistics/carbonapps/GPS/Eventstore_gps_1.0.0/artifact.xml b/modules/distribution/src/statistics/carbonapps/GPS/Eventstore_gps_1.0.0/artifact.xml new file mode 100644 index 00000000..04fe1f05 --- /dev/null +++ b/modules/distribution/src/statistics/carbonapps/GPS/Eventstore_gps_1.0.0/artifact.xml @@ -0,0 +1,4 @@ + + + org_wso2_iot_devices_gps.xml + diff --git a/modules/distribution/src/statistics/carbonapps/GPS/Eventstore_gps_1.0.0/org_wso2_iot_devices_gps.xml b/modules/distribution/src/statistics/carbonapps/GPS/Eventstore_gps_1.0.0/org_wso2_iot_devices_gps.xml new file mode 100644 index 00000000..98de2ba9 --- /dev/null +++ b/modules/distribution/src/statistics/carbonapps/GPS/Eventstore_gps_1.0.0/org_wso2_iot_devices_gps.xml @@ -0,0 +1,51 @@ + + + + org.wso2.iot.devices.gps:1.0.0 + + EVENT_STORE + + + meta_owner + true + true + false + STRING + + + meta_deviceType + true + true + false + STRING + + + meta_deviceId + true + true + false + STRING + + + meta_time + true + true + false + LONG + + + latitude + false + false + false + FLOAT + + + longitude + false + false + false + FLOAT + + + \ No newline at end of file diff --git a/modules/distribution/src/statistics/carbonapps/GPS/Eventstream_gps_1.0.0/artifact.xml b/modules/distribution/src/statistics/carbonapps/GPS/Eventstream_gps_1.0.0/artifact.xml new file mode 100644 index 00000000..5d0432ee --- /dev/null +++ b/modules/distribution/src/statistics/carbonapps/GPS/Eventstream_gps_1.0.0/artifact.xml @@ -0,0 +1,5 @@ + + + org.wso2.iot.devices.gps_1.0.0.json + + diff --git a/modules/distribution/src/statistics/carbonapps/GPS/Eventstream_gps_1.0.0/org.wso2.iot.devices.gps_1.0.0.json b/modules/distribution/src/statistics/carbonapps/GPS/Eventstream_gps_1.0.0/org.wso2.iot.devices.gps_1.0.0.json new file mode 100644 index 00000000..04d2b106 --- /dev/null +++ b/modules/distribution/src/statistics/carbonapps/GPS/Eventstream_gps_1.0.0/org.wso2.iot.devices.gps_1.0.0.json @@ -0,0 +1,23 @@ +{ + "name": "org.wso2.iot.devices.gps", + "version": "1.0.0", + "nickName": "GPS Data", + "description": "GPS data received from the Device", + "metaData": [ + {"name":"owner","type":"STRING"}, + {"name":"deviceType","type":"STRING"}, + {"name":"deviceId","type":"STRING"}, + {"name":"time","type":"LONG"} + ], + "payloadData": [ + { + "name": "latitude","type": "FLOAT" + }, + { + "name": "longitude","type": "FLOAT" + } + ] +} + + + diff --git a/modules/distribution/src/statistics/carbonapps/GPS/Sparkscripts_1.0.0/GPS_Sensor_Script.xml b/modules/distribution/src/statistics/carbonapps/GPS/Sparkscripts_1.0.0/GPS_Sensor_Script.xml new file mode 100644 index 00000000..8d67f805 --- /dev/null +++ b/modules/distribution/src/statistics/carbonapps/GPS/Sparkscripts_1.0.0/GPS_Sensor_Script.xml @@ -0,0 +1,13 @@ + + + IoTServer_Sensor_Script + + 0 * * * * ? + diff --git a/modules/distribution/src/statistics/carbonapps/GPS/Sparkscripts_1.0.0/artifact.xml b/modules/distribution/src/statistics/carbonapps/GPS/Sparkscripts_1.0.0/artifact.xml new file mode 100644 index 00000000..19a4f36d --- /dev/null +++ b/modules/distribution/src/statistics/carbonapps/GPS/Sparkscripts_1.0.0/artifact.xml @@ -0,0 +1,4 @@ + + + GPS_Sensor_Script.xml + diff --git a/modules/distribution/src/statistics/carbonapps/GPS/artifacts.xml b/modules/distribution/src/statistics/carbonapps/GPS/artifacts.xml new file mode 100644 index 00000000..8bf3d37c --- /dev/null +++ b/modules/distribution/src/statistics/carbonapps/GPS/artifacts.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/modules/distribution/src/statistics/carbonapps/Light/Eventreceiver_light_1.0.0/EventReceiver_light.xml b/modules/distribution/src/statistics/carbonapps/Light/Eventreceiver_light_1.0.0/EventReceiver_light.xml new file mode 100644 index 00000000..ef4ec04d --- /dev/null +++ b/modules/distribution/src/statistics/carbonapps/Light/Eventreceiver_light_1.0.0/EventReceiver_light.xml @@ -0,0 +1,8 @@ + + + + false + + + + diff --git a/modules/distribution/src/statistics/carbonapps/Light/Eventreceiver_light_1.0.0/artifact.xml b/modules/distribution/src/statistics/carbonapps/Light/Eventreceiver_light_1.0.0/artifact.xml new file mode 100644 index 00000000..a7d13f8d --- /dev/null +++ b/modules/distribution/src/statistics/carbonapps/Light/Eventreceiver_light_1.0.0/artifact.xml @@ -0,0 +1,4 @@ + + + EventReceiver_light.xml + diff --git a/modules/distribution/src/statistics/carbonapps/Light/Eventstore_light_1.0.0/artifact.xml b/modules/distribution/src/statistics/carbonapps/Light/Eventstore_light_1.0.0/artifact.xml new file mode 100644 index 00000000..b424b32d --- /dev/null +++ b/modules/distribution/src/statistics/carbonapps/Light/Eventstore_light_1.0.0/artifact.xml @@ -0,0 +1,4 @@ + + + org_wso2_iot_devices_light.xml + diff --git a/modules/distribution/src/statistics/carbonapps/Light/Eventstore_light_1.0.0/org_wso2_iot_devices_light.xml b/modules/distribution/src/statistics/carbonapps/Light/Eventstore_light_1.0.0/org_wso2_iot_devices_light.xml new file mode 100644 index 00000000..4ccd871b --- /dev/null +++ b/modules/distribution/src/statistics/carbonapps/Light/Eventstore_light_1.0.0/org_wso2_iot_devices_light.xml @@ -0,0 +1,44 @@ + + + + org.wso2.iot.devices.light:1.0.0 + + EVENT_STORE + + + meta_owner + true + true + false + STRING + + + meta_deviceType + true + true + false + STRING + + + meta_deviceId + true + true + false + STRING + + + meta_time + true + true + false + LONG + + + light + false + false + false + FLOAT + + + \ No newline at end of file diff --git a/modules/distribution/src/statistics/carbonapps/Light/Eventstream_light_1.0.0/artifact.xml b/modules/distribution/src/statistics/carbonapps/Light/Eventstream_light_1.0.0/artifact.xml new file mode 100644 index 00000000..39d09aff --- /dev/null +++ b/modules/distribution/src/statistics/carbonapps/Light/Eventstream_light_1.0.0/artifact.xml @@ -0,0 +1,5 @@ + + + org.wso2.iot.devices.light_1.0.0.json + + diff --git a/modules/distribution/src/statistics/carbonapps/Light/Eventstream_light_1.0.0/org.wso2.iot.devices.light_1.0.0.json b/modules/distribution/src/statistics/carbonapps/Light/Eventstream_light_1.0.0/org.wso2.iot.devices.light_1.0.0.json new file mode 100644 index 00000000..253f0b0c --- /dev/null +++ b/modules/distribution/src/statistics/carbonapps/Light/Eventstream_light_1.0.0/org.wso2.iot.devices.light_1.0.0.json @@ -0,0 +1,20 @@ +{ + "name": "org.wso2.iot.devices.light", + "version": "1.0.0", + "nickName": "light Data", + "description": "light data received from the Device", + "metaData": [ + {"name":"owner","type":"STRING"}, + {"name":"deviceType","type":"STRING"}, + {"name":"deviceId","type":"STRING"}, + {"name":"time","type":"LONG"} + ], + "payloadData": [ + { + "name": "light","type": "FLOAT" + } + ] +} + + + diff --git a/modules/distribution/src/statistics/carbonapps/Light/Sparkscripts_1.0.0/Light_Sensor_Script.xml b/modules/distribution/src/statistics/carbonapps/Light/Sparkscripts_1.0.0/Light_Sensor_Script.xml new file mode 100644 index 00000000..930fd26e --- /dev/null +++ b/modules/distribution/src/statistics/carbonapps/Light/Sparkscripts_1.0.0/Light_Sensor_Script.xml @@ -0,0 +1,13 @@ + + + Light_Sensor_Script + + 0 * * * * ? + diff --git a/modules/distribution/src/statistics/carbonapps/Light/Sparkscripts_1.0.0/artifact.xml b/modules/distribution/src/statistics/carbonapps/Light/Sparkscripts_1.0.0/artifact.xml new file mode 100644 index 00000000..30953886 --- /dev/null +++ b/modules/distribution/src/statistics/carbonapps/Light/Sparkscripts_1.0.0/artifact.xml @@ -0,0 +1,4 @@ + + + Light_Sensor_Script.xml + diff --git a/modules/distribution/src/statistics/carbonapps/Light/artifacts.xml b/modules/distribution/src/statistics/carbonapps/Light/artifacts.xml new file mode 100644 index 00000000..79bc08b5 --- /dev/null +++ b/modules/distribution/src/statistics/carbonapps/Light/artifacts.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/modules/distribution/src/statistics/carbonapps/Magnetic/Eventreceiver_magnetic_1.0.0/EventReceiver_magnetic.xml b/modules/distribution/src/statistics/carbonapps/Magnetic/Eventreceiver_magnetic_1.0.0/EventReceiver_magnetic.xml new file mode 100644 index 00000000..22e8e22f --- /dev/null +++ b/modules/distribution/src/statistics/carbonapps/Magnetic/Eventreceiver_magnetic_1.0.0/EventReceiver_magnetic.xml @@ -0,0 +1,8 @@ + + + + false + + + + diff --git a/modules/distribution/src/statistics/carbonapps/Magnetic/Eventreceiver_magnetic_1.0.0/artifact.xml b/modules/distribution/src/statistics/carbonapps/Magnetic/Eventreceiver_magnetic_1.0.0/artifact.xml new file mode 100644 index 00000000..2d595f4f --- /dev/null +++ b/modules/distribution/src/statistics/carbonapps/Magnetic/Eventreceiver_magnetic_1.0.0/artifact.xml @@ -0,0 +1,4 @@ + + + EventReceiver_magnetic.xml + diff --git a/modules/distribution/src/statistics/carbonapps/Magnetic/Eventstore_magnetic_1.0.0/artifact.xml b/modules/distribution/src/statistics/carbonapps/Magnetic/Eventstore_magnetic_1.0.0/artifact.xml new file mode 100644 index 00000000..d84e3fea --- /dev/null +++ b/modules/distribution/src/statistics/carbonapps/Magnetic/Eventstore_magnetic_1.0.0/artifact.xml @@ -0,0 +1,4 @@ + + + org_wso2_iot_devices_magnetic.xml + diff --git a/modules/distribution/src/statistics/carbonapps/Magnetic/Eventstore_magnetic_1.0.0/org_wso2_iot_devices_magnetic.xml b/modules/distribution/src/statistics/carbonapps/Magnetic/Eventstore_magnetic_1.0.0/org_wso2_iot_devices_magnetic.xml new file mode 100644 index 00000000..eefb1fb0 --- /dev/null +++ b/modules/distribution/src/statistics/carbonapps/Magnetic/Eventstore_magnetic_1.0.0/org_wso2_iot_devices_magnetic.xml @@ -0,0 +1,44 @@ + + + + org.wso2.iot.devices.magnetic:1.0.0 + + EVENT_STORE + + + meta_owner + true + true + false + STRING + + + meta_deviceType + true + true + false + STRING + + + meta_deviceId + true + true + false + STRING + + + meta_time + true + true + false + LONG + + + magnetic + false + false + false + FLOAT + + + \ No newline at end of file diff --git a/modules/distribution/src/statistics/carbonapps/Magnetic/Eventstream_magnetic_1.0.0/artifact.xml b/modules/distribution/src/statistics/carbonapps/Magnetic/Eventstream_magnetic_1.0.0/artifact.xml new file mode 100644 index 00000000..2d071139 --- /dev/null +++ b/modules/distribution/src/statistics/carbonapps/Magnetic/Eventstream_magnetic_1.0.0/artifact.xml @@ -0,0 +1,5 @@ + + + org.wso2.iot.devices.magnetic_1.0.0.json + + diff --git a/modules/distribution/src/statistics/carbonapps/Magnetic/Eventstream_magnetic_1.0.0/org.wso2.iot.devices.magnetic_1.0.0.json b/modules/distribution/src/statistics/carbonapps/Magnetic/Eventstream_magnetic_1.0.0/org.wso2.iot.devices.magnetic_1.0.0.json new file mode 100644 index 00000000..5cbe22ba --- /dev/null +++ b/modules/distribution/src/statistics/carbonapps/Magnetic/Eventstream_magnetic_1.0.0/org.wso2.iot.devices.magnetic_1.0.0.json @@ -0,0 +1,20 @@ +{ + "name": "org.wso2.iot.devices.magnetic", + "version": "1.0.0", + "nickName": "magnetic Data", + "description": "magnetic data received from the Device", + "metaData": [ + {"name":"owner","type":"STRING"}, + {"name":"deviceType","type":"STRING"}, + {"name":"deviceId","type":"STRING"}, + {"name":"time","type":"LONG"} + ], + "payloadData": [ + { + "name": "magnetic","type": "FLOAT" + } + ] +} + + + diff --git a/modules/distribution/src/statistics/carbonapps/Magnetic/Sparkscripts_1.0.0/Magnetic_Sensor_Script.xml b/modules/distribution/src/statistics/carbonapps/Magnetic/Sparkscripts_1.0.0/Magnetic_Sensor_Script.xml new file mode 100644 index 00000000..6293f817 --- /dev/null +++ b/modules/distribution/src/statistics/carbonapps/Magnetic/Sparkscripts_1.0.0/Magnetic_Sensor_Script.xml @@ -0,0 +1,13 @@ + + + IoTServer_Sensor_Script + + 0 * * * * ? + diff --git a/modules/distribution/src/statistics/carbonapps/Magnetic/Sparkscripts_1.0.0/artifact.xml b/modules/distribution/src/statistics/carbonapps/Magnetic/Sparkscripts_1.0.0/artifact.xml new file mode 100644 index 00000000..20cc0bbe --- /dev/null +++ b/modules/distribution/src/statistics/carbonapps/Magnetic/Sparkscripts_1.0.0/artifact.xml @@ -0,0 +1,4 @@ + + + magnetic_Sensor_Script.xml + diff --git a/modules/distribution/src/statistics/carbonapps/Magnetic/artifacts.xml b/modules/distribution/src/statistics/carbonapps/Magnetic/artifacts.xml new file mode 100644 index 00000000..8c013b5d --- /dev/null +++ b/modules/distribution/src/statistics/carbonapps/Magnetic/artifacts.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/modules/distribution/src/statistics/carbonapps/build.xml b/modules/distribution/src/statistics/carbonapps/build.xml index c9107aef..9494cf93 100644 --- a/modules/distribution/src/statistics/carbonapps/build.xml +++ b/modules/distribution/src/statistics/carbonapps/build.xml @@ -5,6 +5,10 @@ + + + + @@ -13,6 +17,20 @@ + + + + + + + + + + + + + + diff --git a/modules/samples/android_sense/src/org.wso2.carbon.device.mgt.iot.sample.android.sense.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/android/sense/service/impl/AndroidSenseControllerService.java b/modules/samples/android_sense/src/org.wso2.carbon.device.mgt.iot.sample.android.sense.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/android/sense/service/impl/AndroidSenseControllerService.java index 828367f3..146a4051 100644 --- a/modules/samples/android_sense/src/org.wso2.carbon.device.mgt.iot.sample.android.sense.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/android/sense/service/impl/AndroidSenseControllerService.java +++ b/modules/samples/android_sense/src/org.wso2.carbon.device.mgt.iot.sample.android.sense.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/android/sense/service/impl/AndroidSenseControllerService.java @@ -43,7 +43,7 @@ public class AndroidSenseControllerService { - String temperature = dataMsg.value; //TEMP + String temperature = dataMsg.owner; //TEMP log.info("Recieved Sensor Data Values: " + temperature); if (log.isDebugEnabled()) { diff --git a/modules/samples/android_sense/src/org.wso2.carbon.device.mgt.iot.sample.android.sense.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/android/sense/service/impl/AndroidSenseManagerService.java b/modules/samples/android_sense/src/org.wso2.carbon.device.mgt.iot.sample.android.sense.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/android/sense/service/impl/AndroidSenseManagerService.java index f1aaa122..986a067c 100644 --- a/modules/samples/android_sense/src/org.wso2.carbon.device.mgt.iot.sample.android.sense.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/android/sense/service/impl/AndroidSenseManagerService.java +++ b/modules/samples/android_sense/src/org.wso2.carbon.device.mgt.iot.sample.android.sense.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/android/sense/service/impl/AndroidSenseManagerService.java @@ -61,22 +61,24 @@ public class AndroidSenseManagerService { deviceIdentifier.setType(AndroidSenseConstants.DEVICE_TYPE); try { if (deviceManagement.getDeviceManagementService().isEnrolled(deviceIdentifier)) { + response.setStatus(Response.Status.CONFLICT.getStatusCode()); return true; } - Device device = new Device(); device.setDeviceIdentifier(deviceId); EnrolmentInfo enrolmentInfo = new EnrolmentInfo(); + enrolmentInfo.setDateOfEnrolment(new Date().getTime()); enrolmentInfo.setDateOfLastUpdate(new Date().getTime()); enrolmentInfo.setStatus(EnrolmentInfo.Status.ACTIVE); enrolmentInfo.setOwnership(EnrolmentInfo.OwnerShip.BYOD); - device.setEnrolmentInfo(enrolmentInfo); - - String name = "android_sense" + deviceId; + String name = owner + " android " + deviceId; device.setName(name); device.setType(AndroidSenseConstants.DEVICE_TYPE); + enrolmentInfo.setOwner(owner); + device.setEnrolmentInfo(enrolmentInfo); boolean added = deviceManagement.getDeviceManagementService().enrollDevice(device); + if (added) { response.setStatus(Response.Status.OK.getStatusCode()); } else { diff --git a/modules/samples/android_sense/src/org.wso2.carbon.device.mgt.iot.sample.android.sense.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/android/sense/service/impl/util/DeviceJSON.java b/modules/samples/android_sense/src/org.wso2.carbon.device.mgt.iot.sample.android.sense.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/android/sense/service/impl/util/DeviceJSON.java index 3e99dfd0..2a489fcf 100644 --- a/modules/samples/android_sense/src/org.wso2.carbon.device.mgt.iot.sample.android.sense.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/android/sense/service/impl/util/DeviceJSON.java +++ b/modules/samples/android_sense/src/org.wso2.carbon.device.mgt.iot.sample.android.sense.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/android/sense/service/impl/util/DeviceJSON.java @@ -11,8 +11,5 @@ import javax.xml.bind.annotation.XmlRootElement; public class DeviceJSON { @XmlElement(required = true) public String owner; @XmlElement(required = true) public String deviceId; - @XmlElement(required = true) public String reply; - @XmlElement public Long time; - @XmlElement public String key; - @XmlElement public String value; + @XmlElement public SensorJSON[] values; } diff --git a/modules/samples/android_sense/src/org.wso2.carbon.device.mgt.iot.sample.android.sense.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/android/sense/service/impl/util/SensorJSON.java b/modules/samples/android_sense/src/org.wso2.carbon.device.mgt.iot.sample.android.sense.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/android/sense/service/impl/util/SensorJSON.java new file mode 100644 index 00000000..b3593f34 --- /dev/null +++ b/modules/samples/android_sense/src/org.wso2.carbon.device.mgt.iot.sample.android.sense.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/android/sense/service/impl/util/SensorJSON.java @@ -0,0 +1,16 @@ +package org.wso2.carbon.device.mgt.iot.sample.android.sense.service.impl.util; + +import org.codehaus.jackson.annotate.JsonIgnoreProperties; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement + +@JsonIgnoreProperties(ignoreUnknown = true) +public class SensorJSON { + + @XmlElement public Long time; + @XmlElement public String key; + @XmlElement public String value; +} diff --git a/modules/samples/sample_pom.xml b/modules/samples/sample_pom.xml index 63193c3d..f54b5526 100644 --- a/modules/samples/sample_pom.xml +++ b/modules/samples/sample_pom.xml @@ -400,7 +400,7 @@ system - ${basedir}/../../../../repository/components/plugins/org.wso2.carbon.utils_4.4.1.jar + ${basedir}/../../../../repository/components/plugins/org.wso2.carbon.utils_4.4.2.jar diff --git a/modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/pom.xml b/modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/pom.xml index 3db470bd..dba89dc2 100644 --- a/modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/pom.xml +++ b/modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/pom.xml @@ -58,6 +58,16 @@ org.wso2.carbon.device.mgt.iot org.wso2.carbon.device.mgt.iot.common + + + org.igniterealtime.smack.wso2 + smack + + + org.igniterealtime.smack.wso2 + smackx + + org.wso2.carbon.device.mgt.iot.server.sample @@ -92,11 +102,77 @@ org.wso2.carbon org.wso2.carbon.utils + + + org.bouncycastle.wso2 + bcprov-jdk15on + + + org.wso2.carbon + org.wso2.carbon.user.api + + + org.wso2.carbon + org.wso2.carbon.queuing + + + org.wso2.carbon + org.wso2.carbon.base + + + org.apache.axis2.wso2 + axis2 + + + org.igniterealtime.smack.wso2 + smack + + + org.igniterealtime.smack.wso2 + smackx + + + jaxen + jaxen + + + commons-fileupload.wso2 + commons-fileupload + + + org.apache.ant.wso2 + ant + + + org.apache.ant.wso2 + ant + + + commons-httpclient.wso2 + commons-httpclient + + + org.eclipse.equinox + javax.servlet + + + org.wso2.carbon + org.wso2.carbon.registry.api + + org.wso2.carbon.devicemgt org.wso2.carbon.device.mgt.analytics + + org.igniterealtime.smack.wso2 + smack + + + org.igniterealtime.smack.wso2 + smackx +