diff --git a/components/device-mgt-iot-raspberrypi/org.wso2.carbon.device.mgt.iot.raspberrypi.controller.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/RaspberryPiService.java b/components/device-mgt-iot-raspberrypi/org.wso2.carbon.device.mgt.iot.raspberrypi.controller.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/RaspberryPiService.java index 756b9a2c36..0167576357 100644 --- a/components/device-mgt-iot-raspberrypi/org.wso2.carbon.device.mgt.iot.raspberrypi.controller.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/RaspberryPiService.java +++ b/components/device-mgt-iot-raspberrypi/org.wso2.carbon.device.mgt.iot.raspberrypi.controller.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/RaspberryPiService.java @@ -85,8 +85,7 @@ public class RaspberryPiService { /** * @param raspberryPiMQTTSubscriber */ - public void setRaspberryPiMQTTSubscriber( - final RaspberryPiMQTTSubscriber raspberryPiMQTTSubscriber) { + public void setRaspberryPiMQTTSubscriber(final RaspberryPiMQTTSubscriber raspberryPiMQTTSubscriber) { this.raspberryPiMQTTSubscriber = raspberryPiMQTTSubscriber; /*if (MqttConfig.getInstance().isEnabled()) { Runnable xmppStarter = new Runnable() { @@ -254,12 +253,9 @@ public class RaspberryPiService { } String temperatureValue = RaspberrypiServiceUtils.sendCommandViaHTTP(deviceHTTPEndpoint, - RaspberrypiConstants - .TEMPERATURE_CONTEXT, - false); + RaspberrypiConstants.TEMPERATURE_CONTEXT, false); SensorDataManager.getInstance().setSensorRecord(deviceId, RaspberrypiConstants.SENSOR_TEMPERATURE, - temperatureValue, - Calendar.getInstance().getTimeInMillis()); + temperatureValue, Calendar.getInstance().getTimeInMillis()); sensorRecord = SensorDataManager.getInstance().getSensorRecord(deviceId, RaspberrypiConstants.SENSOR_TEMPERATURE); } catch (DeviceManagementException | DeviceControllerException e) { diff --git a/features/device-mgt-iot-raspberrypi-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/RaspberryAgent.py b/features/device-mgt-iot-raspberrypi-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/RaspberryAgent.py index 956d1fb0cf..188eca4513 100644 --- a/features/device-mgt-iot-raspberrypi-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/RaspberryAgent.py +++ b/features/device-mgt-iot-raspberrypi-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/RaspberryAgent.py @@ -55,8 +55,8 @@ LOG_LEVEL = logging.INFO # Could be e.g. "DEBUG" or "WARNING" # Python version # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if sys.version_info<(2,7,0): - sys.stderr.write("You need python 2.7.0 or later to run this script\n") - exit(1) + sys.stderr.write("You need python 2.7.0 or later to run this script\n") + exit(1) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -120,7 +120,7 @@ class IOTLogger(object): ### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# Configure logging to log to a file, +# Configure logging to log to a file, # making a new file at midnight and keeping the last 3 day's data # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def configureLogger(loggerName): @@ -143,8 +143,11 @@ def configureLogger(loggerName): # This method registers the DevieIP in the Device-Cloud # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def registerDeviceIP(): - ssl.wrap_socket = sslwrap(ssl.wrap_socket) # using the overridden sslwrap that uses TLSv1 - dcConncection = httplib.HTTPSConnection(host=DC_IP, port=DC_PORT) + ssl.wrap_socket = sslwrap(ssl.wrap_socket) # using the overridden sslwrap that uses TLSv1 + if sys.version_info<(2,7,9): + dcConncection = httplib.HTTPSConnection(host=DC_IP, port=DC_PORT) + else: + dcConncection = httplib.HTTPSConnection(host=DC_IP, port=DC_PORT, context=ssl._create_unverified_context()) #TODO need to get server certificate when initializing https connection dcConncection.set_debuglevel(1) dcConncection.connect() @@ -172,7 +175,11 @@ def registerDeviceIP(): # This method connects to the Device-Cloud and pushes data # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def connectAndPushData(): - dcConnection = httplib.HTTPSConnection(host=DC_IP, port=DC_PORT) + if sys.version_info<(2,7,9): + dcConnection = httplib.HTTPSConnection(host=DC_IP, port=DC_PORT) + else: + dcConnection = httplib.HTTPSConnection(host=DC_IP, port=DC_PORT, context=ssl._create_unverified_context()) + dcConnection.set_debuglevel(1) dcConnection.connect() request = dcConnection.putrequest('POST', PUSH_ENDPOINT) @@ -289,7 +296,7 @@ signal.signal(signal.SIGTERM, sigterm_handler) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# The Main method of the RPi Agent +# The Main method of the RPi Agent # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def main(): configureLogger("WSO2IOT_RPiStats")