260 likes | 371 Views
An Auto-Join Network of Things. Wong, H. and Wesson, B. bit.ly /TUT6256. Program Agenda. Introduction to the Internet of Things Install Java Embedded and the Oracle IoT Gateway Configure the “ lookup service ” Add liquid level and thermometer sensors
E N D
An Auto-Join Network of Things Wong, H. and Wesson, B. bit.ly/TUT6256 Oracle Confidential – Internal/Restricted/Highly Restricted
Program Agenda Introduction to the Internet of Things Install Java Embedded and the Oracle IoT Gateway Configure the “lookup service” Add liquid level and thermometer sensors View data analytics on the device and in the cloud 1 2 3 4 5
Managing Complexity Data, Insights, Actions at the Right Time
Acquireand Manage Integrate and Secure Internet of Things Analyzeand Act Oracle Confidential – Internal/Restricted/Highly Restricted 5
Acquire and Manage A Standards-based, Scalable and Secure Device Platform Oracle Confidential – Internal/Restricted/Highly Restricted 6
Integrate and Secure Reduce Cost and Complexityand Protect Your Investment Oracle Confidential – Internal/Restricted/Highly Restricted 7
Analyze and Act Extract Business Value and Take Action Oracle Confidential – Internal/Restricted/Highly Restricted 8
Motivation Towards Real-Time Everything* While Ensuring Accuracy, Efficiency, and Scale Acquire & Manage Acquire & Manage Integrate & Secure Integrate & Secure Reduced Time Business Value Analyze & Act Analyze & Act Increased Value Action Time *Richard Hackethorn’s Component’s of Action Time 9
Program Agenda Introduction to the Internet of Things Install the Java Embedded Runtime Configure the “lookup service” Add liquid level and thermometer sensors View data analytics on the device and in the cloud 1 2 3 4 5
Exercise 2 Install the Java Embedded Runtime Install RaspbianDebian Wheezy (September 2014 Version) including JDK 8* or install Java Embedded (oracle-java8-jdk) sudoapt-get update sudoapt-get install oracle-java8-jdk sudochmod +s /usr/lib/jvm/jdk-8-oracle-arm-vfp-hflt/bin/java • java –version • java version "1.8.0" • Java(TM) SE Runtime Environment (build 1.8.0-b132) • Java HotSpot(TM) Client VM (build 25.0-b70, mixed mode) * Not part of tutorial. Navigate to http://www.raspberrypi.org/downloads and choose RaspbianDebian Wheezy Version September 2014
Exercise 2 Configure Java Embedded Runtime • Oracle Java SE 8 • Java Programming Language • Lambda Expressions • Method references • Default methods • Repeating Annotations, Type Annotations • Compact Profiles - predefined subsets of the Java SE platform
Program Agenda Introduction to the Internet of Things Install the Oracle IoT Gateway Configure the “lookup service” Add liquid level and thermometer sensors View data analytics on the device and in the cloud 1 2 3 4 5
Exercise 3 Configure the “lookup service” Running a Simple Jini Lookup Service with Java Embedded • Provides the infrastructure for the Service-object-oriented architecture (SOOA). • Locating services is done through a lookup service • Services try to contact a lookup service (LUS), either by unicast interaction, when it knows the actual location of the lookup service • Clients use the lookup service to retrieve a proxy object to the service • Endpoint Registry
Exercise 3 Calling the Lookup Server // … // liquidLevelProbe has been discovered // … if (!liquidLevelProbeDiscoveredFlag) { System.out.println("liquidLevelProbe discovered"); joinLookUpService(LIQUID_LEVEL_PROBE); liquidLevelProbeDiscoveredFlag = true; }
Program Agenda Introduction to the Internet of Things Install the Oracle IoT Gateway Configure the “lookup service” Add liquid level and thermometer sensors View data analytics on the device and in the cloud 1 2 3 4 5
Exercise 4 Add liquid level sensor using IoT Auto-Join Add an eTape liquid level and thermometer sensors to Raspberry Pi • Writing a IoT Endpoint proxy object • Registering the IoT Endpoint proxy object with the IoT Gateway LUS • User plugs in the liquid level sensor to the Raspberry Pi and it is auto-discovered • Running the liquid level sensor java –jar iot-liquid-level-sensor.jar
Exercise 4 Add liquid level sensor using IoT Auto-Join // Open RandomAccessFile handle to each GPIO port raf= new RandomAccessFile("/sys/class/gpio/gpio" + gpioInputChannel + "/value", "r"); raf.seek(0); raf.read(inBytes); inLine = new String(inBytes); // Endpoint: liquidLevelProbe if (inLine.startsWith("1")) { commandChannels[1].write(GPIO_ON); commandChannels[1].flush(); if (!liquidLevelProbeDiscoveredFlag) { System.out.println("liquidLevelProbe discovered"); joinLookUpService(LIQUID_LEVEL_PROBE); liquidLevelProbeDiscoveredFlag = true; }
Exercise 4 Add thermometer using IoT Auto-Join Add a Go!Temp Temperature Probe to Your Raspberry Pi • Writing a IoT Endpoint proxy object • Registering the IoT Endpoint proxy object with the IoT Gateway LUS • User plugs in Go!Temp Temperature Probe to the Raspberry Pi and it is auto-discovered • Run the temperature probe • java –jar iot-temp-probe.jar
Exercise 4 Add thermometer using IoT Auto-Join // Endpoint: tempProbe File tempProbeCheck = new File("/dev/ldusb0"); if (tempProbeCheck.exists()) { commandChannels[0].write(GPIO_ON); commandChannels[0].flush(); if (!tempProbeDiscoveredFlag) { System.out.println("tempProbe discovered"); joinLookUpService(TEMP_PROBE); tempProbeDiscoveredFlag = true; }
Program Agenda Introduction to the Internet of Things Install the Oracle IoT Gateway Configure the “lookup service” Add liquid level and thermometer sensors View data analytics on the device and in the cloud 1 2 3 4 5
Exercise 5 Set-up data analytics on the Gateway Running Simple Analytics on the Gateway • Data Analytics on the Gateway • Local Analytics can be used to monitor the local devices and sensors • Local Java algorithms to watch for triggers • User is notified for anomalous events • Examining Analytics Running on the Raspberry Pi • Browse the Gateway URL for demo
Exercise 5 Set-up data analytics on the Gateway static void tempProbeAdapter() { System.out.println("liquidLevelProbe Adapter: storing data locally " + "and sending data to IoT Cloud"); // Store data locally // Upload data to the IoT Cloud CloudStorageConfigmyConfig = new CloudStorageConfig(); myConfig.setServiceName("myService-myIdentityDomain") .setUsername("myUsername") .setPassword("myPassword".toCharArray()) .setServiceUrl("https://storage.us2.oraclecloud.com"); CloudStoragemyConnection = CloudStorageFactory.getStorage(myConfig); FileInputStreamfis = new FileInputStream("iotcloud-liquid-level-data.txt"); myConnection.storeObject("MyContainer", "iotcloud-liquid-level-data.txt", "text/plain", fis); // Process data }
Exercise 5 Set-up data analytics on the Cloud Running a Global Analytics on the Cloud • Data Analytics in the Cloud • Global Analytics can be used to monitor the worldwide sets of devices and sensors • Global ruleset to watch for triggers • Administrator is notified for anomalous events • Examining Analytics Running in the Cloud • Browse the Cloud URL • http://iotcloud.x10host.com/autojoin/
Exercise 5 Set-up data analytics on the Cloud static void tempProbeAdapter() { System.out.println("liquidLevelProbe Adapter: storing data locally " + "and sending data to IoT Cloud"); // Store data locally // Upload data to the IoT Cloud CloudStorageConfigmyConfig = new CloudStorageConfig(); myConfig.setServiceName("myService-myIdentityDomain") .setUsername("myUsername") .setPassword("myPassword".toCharArray()) .setServiceUrl("https://storage.us2.oraclecloud.com"); CloudStoragemyConnection = CloudStorageFactory.getStorage(myConfig); FileInputStreamfis = new FileInputStream("iotcloud-liquid-level-data.txt"); myConnection.storeObject("MyContainer", "iotcloud-liquid-level-data.txt", "text/plain", fis); // Process data }