Giter Club home page Giter Club logo

smarthomerapidprototype's Introduction

Smart Home Rapid Prototype

This project provides a rapid prototyping software middleware framework which can be used for quickly building up an integrated smart home platform.

The framework can communicate with a mobile device and a hardware platform via an open RESTful API and an open WebSocket API, which can be regarded as a uniform interface and can greatly reduce the dependency on a specific product brand.

The prototype provides a basic backend server framework for managing smart home users and smart home devices, and collecting and analysing sensor data and actuator data.

Required Tools

  • Java Development Kit (JDK) (version 1.7+ required)

    • Download Java SE here and install Java SE
    • Add JDK path to environment variable
  • Apache Tomcat (version 7.0+ required)

    • Download Apache Tomcat here and unzip the downloaded file
    • Configure Tomcat(e.g. port number in [tomcat_install_path]\conf/server.xml file; configuration for connecting Eclipse)
  • Oracle Database (required, version 11.2 used for development)

  • MongoDB (version 2.6 used for development)

    • Download MongoDB of the latest version here and install
    • Follow the manual offered by MongoDB here
  • Apache Maven (version 3.2 used for development)

  • Git (version 1.9 used for development)

    • Download Git of the latest version here and install Git

Environment Configuration

  • Now get the Open-source Rapid Prototype source code from Github.

      git init
    
      git pull https://github.com/potatolylc/SmartHomeRapidPrototype
    
  • Build project with Maven in the project folder

      mvn clean install
    
  • Start Tomcat server and get the index page, then you got it~

APIs

The open REST API can be referenced here, and the open WebSocket API can be referenced here.

JavaDoc

JavaDoc files are available at here

Arduino Code Template

The Arduino code templates provide WiFi and Ethernet connections to the sensor cloud for data collection.

Developers or users are expected to use the templates to add their own sensors/actuators to the code.

The code templates can be found here

Code Excerpts of STOMP Client

In this middleware, STOMP over WebSocket protocol was utilized for push services. Implementations in Android mobile applications and in Web browsers are slightly different. Here shows the server configurations and STOMP client requests in both Android mobile application development and Web development.

  • Server Configurations for WebSocket

Code for configuring WebSocket in Spring server can be referred to here

@Override

public void registerStompEndpoints(StompEndpointRegistry registry) {

	registry.addEndpoint("/socket");

	registry.addEndpoint("/webSocket").withSockJS();

}
  • Android Mobile Application

Java Library of STOMP client for Android mobile application can be found here

public void androidStompClientConnection() {

	Map<String, String> headers = new HashMap<String, String>();

	Stomp stompClient = new Stomp("ws://[host]:[port_number]/[service_name]/socket", headers, new ListenerWSNetwork() {

	......

	});
	
	androidStompClient.connect();

	androidStompClient.subscribe(new Subscription(...), new ListenerSubscription() {

		......

	}));

}	
  • Javascript

Javascript Library of STOMP client for Web browser can be found here

function jsStompClientConnection() {

	var socket = new SockJS("http://"[host]:[port_number]/[service_name]/webSocket");

	var jsStompClient = Stomp.over(socket);

	jsStompClient.connect({}, function(frame) {

		......

		jsStompClient.subscribe(..., function(message) {

			......

		}

	}

}

smarthomerapidprototype's People

Contributors

potatolylc avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.