Skip to content

Instantly share code, notes, and snippets.

@KonradIT
Forked from codeanticode/GoProKeepAlive.pde
Created March 20, 2018 20:59
Show Gist options
  • Save KonradIT/545560edeac49c3bad021040e3ee4a91 to your computer and use it in GitHub Desktop.
Save KonradIT/545560edeac49c3bad021040e3ee4a91 to your computer and use it in GitHub Desktop.
Processing sketch to keep the GoPro alive
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