Merge branch 'IoTS-1.0.0-M1' of https://github.com/wso2/carbon-device-mgt-plugins into IoTS-1.0.0-M1

Menaka Madushanka 9 years ago
commit 2f7a480864

@ -85,8 +85,7 @@ public class RaspberryPiService {
/** /**
* @param raspberryPiMQTTSubscriber * @param raspberryPiMQTTSubscriber
*/ */
public void setRaspberryPiMQTTSubscriber( public void setRaspberryPiMQTTSubscriber(final RaspberryPiMQTTSubscriber raspberryPiMQTTSubscriber) {
final RaspberryPiMQTTSubscriber raspberryPiMQTTSubscriber) {
this.raspberryPiMQTTSubscriber = raspberryPiMQTTSubscriber; this.raspberryPiMQTTSubscriber = raspberryPiMQTTSubscriber;
/*if (MqttConfig.getInstance().isEnabled()) { /*if (MqttConfig.getInstance().isEnabled()) {
Runnable xmppStarter = new Runnable() { Runnable xmppStarter = new Runnable() {
@ -254,12 +253,9 @@ public class RaspberryPiService {
} }
String temperatureValue = RaspberrypiServiceUtils.sendCommandViaHTTP(deviceHTTPEndpoint, String temperatureValue = RaspberrypiServiceUtils.sendCommandViaHTTP(deviceHTTPEndpoint,
RaspberrypiConstants RaspberrypiConstants.TEMPERATURE_CONTEXT, false);
.TEMPERATURE_CONTEXT,
false);
SensorDataManager.getInstance().setSensorRecord(deviceId, RaspberrypiConstants.SENSOR_TEMPERATURE, SensorDataManager.getInstance().setSensorRecord(deviceId, RaspberrypiConstants.SENSOR_TEMPERATURE,
temperatureValue, temperatureValue, Calendar.getInstance().getTimeInMillis());
Calendar.getInstance().getTimeInMillis());
sensorRecord = SensorDataManager.getInstance().getSensorRecord(deviceId, sensorRecord = SensorDataManager.getInstance().getSensorRecord(deviceId,
RaspberrypiConstants.SENSOR_TEMPERATURE); RaspberrypiConstants.SENSOR_TEMPERATURE);
} catch (DeviceManagementException | DeviceControllerException e) { } catch (DeviceManagementException | DeviceControllerException e) {

@ -55,8 +55,8 @@ LOG_LEVEL = logging.INFO # Could be e.g. "DEBUG" or "WARNING"
# Python version # Python version
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if sys.version_info<(2,7,0): if sys.version_info<(2,7,0):
sys.stderr.write("You need python 2.7.0 or later to run this script\n") sys.stderr.write("You need python 2.7.0 or later to run this script\n")
exit(1) 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 # making a new file at midnight and keeping the last 3 day's data
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def configureLogger(loggerName): def configureLogger(loggerName):
@ -143,8 +143,11 @@ def configureLogger(loggerName):
# This method registers the DevieIP in the Device-Cloud # This method registers the DevieIP in the Device-Cloud
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def registerDeviceIP(): def registerDeviceIP():
ssl.wrap_socket = sslwrap(ssl.wrap_socket) # using the overridden sslwrap that uses TLSv1 ssl.wrap_socket = sslwrap(ssl.wrap_socket) # using the overridden sslwrap that uses TLSv1
dcConncection = httplib.HTTPSConnection(host=DC_IP, port=DC_PORT) 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 #TODO need to get server certificate when initializing https connection
dcConncection.set_debuglevel(1) dcConncection.set_debuglevel(1)
dcConncection.connect() dcConncection.connect()
@ -172,7 +175,11 @@ def registerDeviceIP():
# This method connects to the Device-Cloud and pushes data # This method connects to the Device-Cloud and pushes data
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def connectAndPushData(): 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.set_debuglevel(1)
dcConnection.connect() dcConnection.connect()
request = dcConnection.putrequest('POST', PUSH_ENDPOINT) 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(): def main():
configureLogger("WSO2IOT_RPiStats") configureLogger("WSO2IOT_RPiStats")

Loading…
Cancel
Save