This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
InetSocketAddress socketAddress | |
= new InetSocketAddress(InetAddress.getByName("239.255.255.250"), 1900) | |
MulticastSocket socket = new MulticastSocket(null) | |
try { | |
socket.bind(new InetSocketAddress("192.168.1.150", 1901)) | |
StringBuilder packet = new StringBuilder() | |
packet.append( "M-SEARCH * HTTP/1.1\r\n" ) | |
packet.append( "HOST: 239.255.255.250:1900\r\n" ) | |
packet.append( "MAN: \"ssdp:discover\"\r\n" ) | |
packet.append( "MX: ").append( "5" ).append( "\r\n" ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MulticastSocket recSocket = new MulticastSocket(null) | |
recSocket.bind(new InetSocketAddress(InetAddress.getByName("0.0.0.0"), 1901)) | |
recSocket.setTimeToLive(10) | |
recSocket.setSoTimeout(1000) | |
recSocket.joinGroup(InetAddress.getByName("239.255.255.250")) | |
while (inService) { //inService is a variable controlled by a thread to stop the listener | |
byte[] buf = new byte[2048] | |
DatagramPacket input = new DatagramPacket(buf, buf.length) | |
try { | |
recSocket.receive(input) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//router | |
HTTP/1.1 200 OK | |
CACHE-CONTROL: max-age=1801 | |
DATE: Wed, 19 Mar 2014 08:33:08 GMT | |
EXT: | |
LOCATION: http://192.168.1.1:49152/wps_device.xml | |
SERVER: Unspecified, UPnP/1.0, Unspecified | |
ST: upnp:rootdevice | |
USN: uuid:bbbbbbb-aaaa-zzzz-yyyy-xxxxxxxxxx::upnp:rootdevice |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<root xmlns="urn:Belkin:device-1-0"> | |
<device> | |
<deviceType>urn:Belkin:device:controllee:1</deviceType> | |
<friendlyName>Livingroom Lamp</friendlyName> | |
<modelDescription>Belkin Plugin Socket 1.0</modelDescription> | |
<modelName>Socket</modelName> | |
<binaryState>0</binaryState> | |
<serviceList> | |
<service> | |
<serviceType>urn:Belkin:service:basicevent:1</serviceType> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<scpd xmlns="urn:Belkin:service-1-0"> | |
<specVersion> | |
<major>1</major> | |
<minor>0</minor> | |
</specVersion> | |
<actionList> | |
<action> | |
<name>GetBinaryState</name> | |
<argumentList> | |
<argument> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HTTPBuilder http = new HTTPBuilder("http://192.168.1.120:49153/upnp/control/basicevent1") | |
http.request(Method.POST, ContentType.XML) { | |
body = '<?xml version="1.0" encoding="utf-8"?>' + | |
'<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">' + | |
'<s:Body>' + | |
'<u:GetBinaryState xmlns:u="urn:Belkin:service:basicevent:1">' + | |
'<BinaryState>1</BinaryState>' + | |
'</u:GetBinaryState>' + | |
'</s:Body>' + | |
'</s:Envelope>' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> | |
<s:Body> | |
<u:GetBinaryStateResponse xmlns:u="urn:Belkin:service:basicevent:1"> | |
<BinaryState>0</BinaryState> | |
</u:GetBinaryStateResponse> | |
</s:Body> | |
</s:Envelope> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HTTPBuilder http = new HTTPBuilder("http://192.168.1.120:49153/upnp/control/basicevent1") | |
http.request(Method.POST, ContentType.XML) { | |
body = '<?xml version="1.0" encoding="utf-8"?>' + | |
'<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">' + | |
'<s:Body>' + | |
'<u:SetBinaryState xmlns:u="urn:Belkin:service:basicevent:1">' + | |
'<BinaryState>1</BinaryState>' + | |
'</u:SetBinaryState>' + | |
'</s:Body>' + | |
'</s:Envelope>' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> | |
<s:Body> | |
<u:GetBinaryStateResponse xmlns:u="urn:Belkin:service:basicevent:1"> | |
<BinaryState>1</BinaryState> | |
</u:GetBinaryStateResponse> | |
</s:Body> | |
</s:Envelope> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Install GVM if you haven't already | |
curl -s get.gvmtool.net | bash | |
#Install Lazybones using GVM | |
gvm install lazybones | |
#Setup the project | |
lazybones create ratpack myapp | |
#Go into the project directory | |
cd myapp | |
#Startup the application using the gradle wrapper | |
./gradlew run |
OlderNewer