Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Controlling GoPro with URL commands

Tags:

android

http

url

I have a GoPro Hero3 Black Edition and after reading their user forums, I got these 2 url commands that can control the shutter button while the GoPro is acting as a hotspot.

Record/shoot Command

On http://10.5.5.9:80/bacpac/SH?t=WIFIPASSWORD&p=%01

Off http://10.5.5.9:80/bacpac/SH?t=WIFIPASSWORD&p=%00

I have tried using the URLs in my Nexus 7's Chrome Browser but I want to integrate these 2 commands in a button in my Android app when my Nexus 7 connects via wifi to the GoPro.

How do I do this? Thanks in advance.

like image 351
jp.azcueta Avatar asked May 29 '13 15:05

jp.azcueta


1 Answers

It's not that tough. Create an activity class and a couple of buttons to fire the HTTP commands. Keep in mind that these are network calls and have to be made from a separate background thread (not the main thread).

btnToggle.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {     
                // Toggle the camera power
                new OperateCamera().execute();
            }
        });

Create a new AsyncTask class:

class OperateCamera extends AsyncTask<String, Void, Boolean> {

            protected Boolean doInBackground(String... urls) {
                return triggerShutter();
            }

            // Method to trigger the shutter
            boolean triggerShutter(){

                try {
                    // Make network call
                    return true;
                }
                catch (Exception e) {                    
                    return false;
                }
            }
    }
like image 91
ThePatelGuy Avatar answered Nov 18 '22 13:11

ThePatelGuy