Page 1 of 2

GoPro Script - Hero5 Session

Posted: Tue May 23, 2017 8:42 pm
by dyip
Has anybody successfully communicated with the Hero5 Session? I used the example script and although I can get some communications happening, the camera does not start/stop when commanded.

I get the following:

[GoPro WiFi] Initializing
Ready for GoPro
[GoPro Wifi] Start GoPro

but then nothing happens. Actually, I only get the "Ready for GoPro" about 50% of the time, the other times I get:

Could not connect to GoPro

Posted: Wed May 24, 2017 3:37 am
by boggie1688
GoPro changed the commands for the hero 5.

There is a thread here that has a link to a wiki that includes all commands for all gopros. You'll need to modify the script to use the new commands for the 5.

Posted: Sat Jun 03, 2017 12:26 am
by dyip
I've been frustrated at my attempts to start/stop video on the Hero5 Session via Lua script. Part of it is I do not fully understand the operation of the Wi-Fi module and the responses from it to scipt commands.. Hopefully Brent and crew can step in here. I bought the Hero when I bought the RCP3. I had no idea that the Go-Pro support was only for the Hero3 and lower. The Hero3 has not been for sale for over 1 year now. Either the RCP3 sales documenation should be changed, or all Go-Pro cameras fully supported.

I can get a successful Wi-Fi connection to the camera, but get a "busy P...." back when I try to start the camera.

I have had success communicting with the camera via the Firefox Browser on my Samsung phone. You can obtain the Wi-Fi password once you have successfully connected the camera with the Go-Pro app. Unlike the Hero3, commands do not have the GoPro SSID or Password embedded.

To start video: http://10.5.5.9/gp/gpControl/command/shutter?p=1
To stop video: http://10.5.5.9/gp/gpControl/command/shutter?p=0.

You can obtain camera status, or set any of the camera variables via http commands as well. The camera has to be powered up to accept these commands.

Posted: Sat Jun 03, 2017 2:17 am
by boggie1688
There are some unique things you have to do to the RCP before even running the script. One of which is actually disabling the WIFI. However, I'm not sure the script in the wiki can be used for the Hero 5. You'll need to do your own testing and customizing of the script to work with the 5.

Alternatively, Brent has said GoPro control and integration will be added in the upcoming firmware release. Timeline is unknown, but they are working on it.

In any case, it is only a matter of time before you'll get what you are looking for. Hang in there!

Posted: Sun Jun 04, 2017 11:33 pm
by brentp
We do have it on our list to test with the Hero 5.

It should be a minor modification to the existing script - however, I understand it requires another step to put the camera into command mode?

Doug, when you tested it manually, did it respond to those URL commands after power up without any other special actions?

Posted: Mon Jun 05, 2017 5:40 am
by dyip
There are no additional commands required to put it into command mode. Once my phone is connected to the GoPro, it will respond immediately to a URL request.

Posted: Thu Jun 08, 2017 6:23 am
by brentp
Update; I have a Gopro Hero 5 for testing. Will update as I discover more. :)

Posted: Thu Jun 08, 2017 3:59 pm
by dyip
Excellent! Do you have a Hero5 Black or Session?

Konrad has done an amazing job of documenting commands.
https://github.com/KonradIT/goprowifihack

However, I was not able to use the numeric control commands to turn video on/off - just the shutter?p=x command.

The Lua script you currently have is able to make the wi-fi connection, but I can't get any further.

One issue will be keeping the camera alive long enough so that the RCP can turn video on before the camera goes to sleep. There appears to be a couple of levels of "sleep". After the display turns off, the RCP can connect via wi-fi for a short period of time. The Go-Pro App can still connect after a longer period of time, but eventually it cannot connect either. I believe it uses the WOL (Wake-up On LAN) capability of the camera which involves sending the MAC address to the camera. Another solution to keeping the camera awake might be to send periodic status requests.

Posted: Thu Jun 08, 2017 4:04 pm
by brentp
It is the Hero 5 black.

I'll check out those docs. I remember someone mentioning a wake-up command with the Hero5, so that might be related.

Posted: Sun Jun 11, 2017 9:29 pm
by jeffmcaffer
Hey Brent, you may be thinking of me and the WoL discussion. At least some of the GoPros (session in particular) need WoL before you can talk to them. See https://github.com/KonradIT/goprowifiha ... Session.md

A while ago I poked about trying to get this to work but you need to send a UDP packet and the Lua on the RCP did not have that module. The latest firmware 2.11.0 still does not have UDP it seems as
udp = assert(socket.udp())
causes the script to fail loading.

Check out https://gist.github.com/maiconio/2865500 for an example of WoL from Lua. Basically need to do something like (not tested)
local macChars = ''
for w in string.gmatch(mac, "[0-9A-Za-z][0-9A-Za-z]") do
macChars = macChars .. string.char(tonumber(w, 16))
end
cameraPowerTime = getUptime()
cameraStatus = 1
local udp = require("socket").udp()
udp:settimeout(1)
udp:setoption("broadcast", true)
udp:sendto(string.char(0xff):rep(6) .. macChars:rep(16), '10.5.5.9', 9)

It would be great if this could be baked into the firmware or if UDP could be exposed. Given the short timeouts on the camera, WoL is the only practical way the RCP can control these GoPros.

Posted: Tue Jun 13, 2017 4:08 pm
by brentp
Thanks, Jeff - we're looking at it this week, I'll dig in to those examples.

We already send UDP broadcasts as part of the beacon to the RaceCapture app, internal to the firmware. we'll see what we can do to for the GoPro support as well.

One outstanding question might be, how will we get the MAC address of the camera so we can send the WOL?

Posted: Tue Jun 13, 2017 5:00 pm
by jeffmcaffer
Yeah, that (getting the MAC address) is not pretty. There must be a dance for this. Something like when you pair the remote with a camera.

The other thing to look at is how to control multiple cameras. Waking them all and giving them all IP addresses etc.

Posted: Tue Jun 13, 2017 5:17 pm
by brentp
Drastic measures, like described near the end of this thread might be required: https://community.gopro.com/t5/Cameras/ ... td-p/21986

Posted: Tue Jun 13, 2017 5:38 pm
by jeffmcaffer
Yikes?! there should be a better way of doing that. If you have a computer on the same subnet "arp" might help. I suspect that WIFI tools like WIFI analyzer should give you insight into the devices on the net. Either way, not super friendly but...

Posted: Mon Jul 17, 2017 3:24 am
by jeffmcaffer
I got something working for WoL and the GP Session. Here is the rough outline.

After joining the camera's network you tell the camera to wake up using

function wakeGoPro()
local macChars = ''
for w in string.gmatch(mac, "[0-9A-Za-z][0-9A-Za-z]") do
macChars = macChars .. string.char(tonumber(w, 16))
end
local magicPacket = string.char(0xff):rep(6) .. macChars:rep(16);
logMsg('Waking GoPro')
sendAt('AT+CIPSTART="UDP","10.5.5.9",9')
sleep(500)
sendAt('AT+CIPSEND=' ..toInt(#magicPacket))
sleep(100)
sendRaw(magicPacket)
sleep(100)
sendAt("AT+CIPCLOSE")
sleep(2000)
end

If the session is in standby mode, it should wake up.

The thing that messed me up was that the camera's access point is live even though the camera is "sleeping". I kept thinking that the WoL had to be sent first...

I'm working on a better implementation of the whole shebang but am running into some other problems but that's for a separate thread.