diff --git a/components/device-mgt-iot-arduino/org.wso2.carbon.device.mgt.iot.arduino.controller.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/ArduinoService.java b/components/device-mgt-iot-arduino/org.wso2.carbon.device.mgt.iot.arduino.controller.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/ArduinoService.java index 2fabc224e5..b29a0ffa32 100644 --- a/components/device-mgt-iot-arduino/org.wso2.carbon.device.mgt.iot.arduino.controller.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/ArduinoService.java +++ b/components/device-mgt-iot-arduino/org.wso2.carbon.device.mgt.iot.arduino.controller.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/ArduinoService.java @@ -280,7 +280,7 @@ public class ArduinoService { response.setStatus(HttpStatus.SC_NO_CONTENT); } else { try { - result = deviceControlList.remove(); //returns the head value + result = deviceControlList.remove(); response.setStatus(HttpStatus.SC_ACCEPTED); } catch (NoSuchElementException ex) { @@ -310,49 +310,16 @@ public class ArduinoService { @Context HttpServletRequest request) { String owner = dataMsg.owner; String deviceId = dataMsg.deviceId; - String deviceIp = dataMsg.reply; //TODO:: Get IP from request float temperature = dataMsg.value; - try { - DeviceValidator deviceValidator = new DeviceValidator(); - if (!deviceValidator.isExist(owner, SUPER_TENANT, new DeviceIdentifier(deviceId, - ArduinoConstants.DEVICE_TYPE))) { - response.setStatus(Response.Status.UNAUTHORIZED.getStatusCode()); - log.warn("Temperature data Received from unregistered Arduino device [" + deviceId + "] for owner [" + - owner + "]"); - return; - } - - String registeredIp = deviceToIpMap.get(deviceId); - - if (registeredIp == null) { - log.warn("Unregistered IP: Temperature Data Received from an un-registered IP " + deviceIp + - " for device ID - " + deviceId); - response.setStatus(Response.Status.PRECONDITION_FAILED.getStatusCode()); - return; - } else if (!registeredIp.equals(deviceIp)) { - log.warn("Conflicting IP: Received IP is " + deviceIp + ". Device with ID " + deviceId + - " is already registered under some other IP. Re-registration required"); - response.setStatus(Response.Status.CONFLICT.getStatusCode()); - return; - } - - if (log.isDebugEnabled()) { - log.debug("Received Pin Data Value: " + temperature + " degrees C"); - } - SensorDataManager.getInstance().setSensorRecord(deviceId, ArduinoConstants.SENSOR_TEMPERATURE, + SensorDataManager.getInstance().setSensorRecord(deviceId, ArduinoConstants.SENSOR_TEMPERATURE, String.valueOf(temperature), Calendar.getInstance().getTimeInMillis()); - if (!ArduinoServiceUtils.publishToDAS(dataMsg.owner, dataMsg.deviceId, dataMsg.value)) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - log.warn("An error occured whilst trying to publish temperature data of Arduino with ID [" + deviceId + + if (!ArduinoServiceUtils.publishToDAS(dataMsg.owner, dataMsg.deviceId, dataMsg.value)) { + response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); + log.warn("An error occured whilst trying to publish temperature data of Arduino with ID [" + deviceId + "] of owner [" + owner + "]"); - } - - } catch (DeviceManagementException e) { - String errorMsg = "Validation attempt for deviceId [" + deviceId + "] of owner [" + owner + "] failed.\n"; - log.error(errorMsg + Response.Status.INTERNAL_SERVER_ERROR.getReasonPhrase() + "\n" + e.getErrorMessage()); } } } diff --git a/components/device-mgt-iot-digitaldisplay/org.wso2.carbon.device.mgt.iot.digitaldisplay.controller.api/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/api/DigitalDisplayControllerService.java b/components/device-mgt-iot-digitaldisplay/org.wso2.carbon.device.mgt.iot.digitaldisplay.controller.api/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/api/DigitalDisplayControllerService.java index c5b8995835..20ae836b53 100644 --- a/components/device-mgt-iot-digitaldisplay/org.wso2.carbon.device.mgt.iot.digitaldisplay.controller.api/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/api/DigitalDisplayControllerService.java +++ b/components/device-mgt-iot-digitaldisplay/org.wso2.carbon.device.mgt.iot.digitaldisplay.controller.api/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/api/DigitalDisplayControllerService.java @@ -80,8 +80,6 @@ public class DigitalDisplayControllerService { @HeaderParam("sessionId") String sessionId, @Context HttpServletResponse response) { - log.info("Restart Browser : " + deviceId); - try { sendCommandViaMQTT(owner, deviceId, sessionId + "::" + DigitalDisplayConstants.RESTART_BROWSER_CONSTANT + ":", ""); response.setStatus(Response.Status.OK.getStatusCode()); @@ -113,8 +111,6 @@ public class DigitalDisplayControllerService { @HeaderParam("sessionId") String sessionId, @Context HttpServletResponse response) { - log.info("Close Browser : " + deviceId); - try { sendCommandViaMQTT(owner, deviceId, sessionId + "::" + DigitalDisplayConstants.CLOSE_BROWSER_CONSTANT + ":", ""); response.setStatus(Response.Status.OK.getStatusCode()); @@ -145,8 +141,6 @@ public class DigitalDisplayControllerService { @HeaderParam("sessionId") String sessionId, @Context HttpServletResponse response) { - log.info("Terminate Display : " + deviceId); - try { sendCommandViaMQTT(owner, deviceId, sessionId + "::" + DigitalDisplayConstants.TERMINATE_DISPLAY_CONSTANT + ":", ""); response.setStatus(Response.Status.OK.getStatusCode()); @@ -177,8 +171,6 @@ public class DigitalDisplayControllerService { @HeaderParam("sessionId") String sessionId, @Context HttpServletResponse response) { - log.info("Restart Display : " + deviceId); - try { sendCommandViaMQTT(owner, deviceId, sessionId + "::" + DigitalDisplayConstants.RESTART_DISPLAY_CONSTANT + ":", ""); response.setStatus(Response.Status.OK.getStatusCode()); @@ -215,8 +207,6 @@ public class DigitalDisplayControllerService { @HeaderParam("sessionId") String sessionId, @Context HttpServletResponse response) { - log.info("Edit Content Display Id - " + deviceId + " by " + owner); - try { String params = path + "|" + attribute + "|" + newValue; sendCommandViaMQTT(owner, deviceId, sessionId + "::" + DigitalDisplayConstants.EDIT_SEQUENCE_CONSTANT + ":", params); @@ -255,7 +245,6 @@ public class DigitalDisplayControllerService { @HeaderParam("sessionId") String sessionId, @Context HttpServletResponse response) { - log.info("Add Sequence : " + deviceId); String params; try { @@ -296,8 +285,6 @@ public class DigitalDisplayControllerService { @HeaderParam("sessionId") String sessionId, @Context HttpServletResponse response) { - log.info("Remove Resource : " + deviceId); - try { sendCommandViaMQTT(owner, deviceId, sessionId + "::" + DigitalDisplayConstants.REMOVE_RESOURCE_CONSTANT + ":", path); @@ -331,7 +318,6 @@ public class DigitalDisplayControllerService { @HeaderParam("sessionId") String sessionId, @Context HttpServletResponse response) { - log.info("Remove Directory : " + deviceId); try { sendCommandViaMQTT(owner, deviceId, sessionId + "::" + DigitalDisplayConstants.REMOVE_DIRECTORY_CONSTANT + ":", directoryName); @@ -367,7 +353,6 @@ public class DigitalDisplayControllerService { @HeaderParam("sessionId") String sessionId, @Context HttpServletResponse response) { - log.info("Remove Content : " + deviceId); try { String param = directoryName + "|" + content; sendCommandViaMQTT(owner, deviceId, sessionId + "::" + DigitalDisplayConstants.REMOVE_CONTENT_CONSTANT + ":", param); @@ -399,8 +384,6 @@ public class DigitalDisplayControllerService { @HeaderParam("sessionId") String sessionId, @Context HttpServletResponse response) { - log.info("Shut down display : " + deviceId); - try { sendCommandViaMQTT(owner, deviceId, sessionId + "::" + DigitalDisplayConstants.SHUTDOWN_DISPLAY_CONSTANT + ":", ""); response.setStatus(Response.Status.OK.getStatusCode()); @@ -425,14 +408,12 @@ public class DigitalDisplayControllerService { @Path("/get-status") @POST @Feature(code = "get-status", name = "Get Status", type="operation", - description = "Check specific digital display power ON of OFF") + description = "Check specific digital display power ON or OFF") public void getStatus(@HeaderParam("deviceId") String deviceId, @HeaderParam("owner") String owner, @HeaderParam("sessionId") String sessionId, @Context HttpServletResponse response) { - log.info("Status : " + deviceId); - try { sendCommandViaMQTT(owner, deviceId, sessionId + ":" + DigitalDisplayConstants.GET_STATUS_CONSTANT, ""); response.setStatus(Response.Status.OK.getStatusCode()); diff --git a/features/device-mgt-iot-arduino-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/configs/arduino.json b/features/device-mgt-iot-arduino-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/configs/arduino.json index 08b8166d24..9d2ba36826 100644 --- a/features/device-mgt-iot-arduino-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/configs/arduino.json +++ b/features/device-mgt-iot-arduino-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/configs/arduino.json @@ -12,7 +12,7 @@ "name": "cdmf.unit.analytics.line-chart", "data":[ {"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}}, - {"column": {"name":"ACCELEROMETER", "label":"Accelerometer", "ui-mapping":"y-axis"}} + {"column": {"name":"TEMPERATURE", "label":"temperature", "ui-mapping":"y-axis"}} ] } }