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.
-
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)
- Download Oracle Database here and install Oracle Database
- For detailed installation guide, refer to Oracle Database Online Documentation
-
MongoDB (version 2.6 used for development)
-
Apache Maven (version 3.2 used for development)
- Download Apache Maven here and unzip the downloaded file;
- If you are using Eclipse, you can install Maven Eclipse plugin via "Install New Software" in "Help" tab and add "http://download.eclipse.org/technology/m2e/releases"
-
Git (version 1.9 used for development)
- Download Git of the latest version here and install Git
-
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~
The open REST API can be referenced here, and the open WebSocket API can be referenced here.
JavaDoc files are available at here
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
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) {
......
}
}
}