https://github.com/pochemuto/orvibo
Orvibo Java API
https://github.com/pochemuto/orvibo
java netty
Last synced: 10 months ago
JSON representation
Orvibo Java API
- Host: GitHub
- URL: https://github.com/pochemuto/orvibo
- Owner: pochemuto
- Created: 2016-11-17T18:12:48.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-11-24T20:09:08.000Z (about 9 years ago)
- Last Synced: 2024-11-16T17:19:42.838Z (about 1 year ago)
- Topics: java, netty
- Language: Java
- Homepage: http://pochemuto.com/2016-11-19-orvibo-java-sdk/
- Size: 104 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Orvibo Java API [](https://travis-ci.org/pochemuto/orvibo)
===============
Allow control your sockets from java code, terminal, or via http.
[Project blog](http://pochemuto.com/2016-11-19-orvibo-java-sdk/)
Using in code
-------------
Add dependency to your project:
```groovy
compile group: 'com.pochemuto', name: 'orvibo', version: '0.9.0'
```
Basic example:
```java
Orvibo orvibo = new Orvibo();
Thread.sleep(250); // wait for discovery responses
List devices = orvibo.getDevices();
for (Device device : devices) {
System.out.println(device.getMacAddress() + " : " + (device.isOn() ? "ON" : "OFF"));
}
if (!devices.isEmpty()) {
Device mySocket = devices.get(0);
orvibo.toggle(mySocket.getMacAddress());
Thread.sleep(5000); // just for example
orvibo.setPower(mySocket.getMacAddress(), false);
}
```
Basic terminal control
----------------------
```
java -cp orvibo-1.0-SNAPSHOT-all.jar com.pochemuto.orvibo.Orvibo
> list
0: ac cf 23 8d 9b 70: OFF
> toggle 0
done
> exit
```
Http interface
--------------
For using http interface run:
```bash
$ java -jar orvibo-1.0-SNAPSHOT-all.jar > /dev/null &
$ curl http://localhost:4352/list
0 accf238d9b70 OFF
$ curl http://localhost:4352/on/0
$ curl http://localhost:4352/state/0 -s | grep 1 -q && echo ON || echo OFF
ON
$ curl http://localhost:4352/toggle/0
$ curl http://localhost:4352/state/0 -s | grep 1 -q && echo ON || echo OFF
OFF
```