-
-
Save KonradIT/545560edeac49c3bad021040e3ee4a91 to your computer and use it in GitHub Desktop.
Processing sketch to keep the GoPro alive
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
import java.net.Socket; | |
import java.io.BufferedReader; | |
import java.io.BufferedWriter; | |
import java.io.InputStream; | |
import java.io.InputStreamReader; | |
import java.io.OutputStream; | |
import java.io.OutputStreamWriter; | |
void setup() { | |
thread("keepAlive"); | |
} | |
void draw() { | |
} | |
void keepAlive() { | |
String UDP_IP = "10.5.5.9"; | |
int UDP_PORT = 8554; | |
int KEEP_ALIVE_PERIOD = 2500; | |
while (true) { | |
Socket socket = null; | |
try { | |
socket = new Socket(UDP_IP, UDP_PORT); | |
//Send the message to the server | |
OutputStream os = socket.getOutputStream(); | |
OutputStreamWriter osw = new OutputStreamWriter(os); | |
BufferedWriter bw = new BufferedWriter(osw); | |
String sendMessage = "_GPHD_:0:0:2:0.000000\n"; | |
bw.write(sendMessage); | |
bw.flush(); | |
} | |
catch (Exception exception) { | |
exception.printStackTrace(); | |
} | |
finally { | |
//Closing the socket | |
try { | |
if (socket != null) socket.close(); | |
} | |
catch(Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
delay(KEEP_ALIVE_PERIOD); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment