GoPro Script - Hero5 Session

Discussion on the Lua Scripting capabilities for RaceCapture/Pro. Also see the <a href="http://autosportlabs.net/RaceCapturePro_Lua_Scripting">Lua Scripting Guide</a>

Moderators: JeffC, stieg

dyip
Posts: 14
Joined: Mon May 08, 2017 3:35 pm
Location: Vancouver, BC

GoPro Script - Hero5 Session

Post 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

boggie1688
Posts: 138
Joined: Fri Apr 07, 2017 3:47 pm
Location: Oakland, CA

Post 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.

dyip
Posts: 14
Joined: Mon May 08, 2017 3:35 pm
Location: Vancouver, BC

Post 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.

boggie1688
Posts: 138
Joined: Fri Apr 07, 2017 3:47 pm
Location: Oakland, CA

Post 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!

brentp
Site Admin
Posts: 5986
Joined: Wed Jan 24, 2007 6:36 am

Post 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?
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter

dyip
Posts: 14
Joined: Mon May 08, 2017 3:35 pm
Location: Vancouver, BC

Post 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.

brentp
Site Admin
Posts: 5986
Joined: Wed Jan 24, 2007 6:36 am

Post by brentp »

Update; I have a Gopro Hero 5 for testing. Will update as I discover more. :)
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter

dyip
Posts: 14
Joined: Mon May 08, 2017 3:35 pm
Location: Vancouver, BC

Post 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.

brentp
Site Admin
Posts: 5986
Joined: Wed Jan 24, 2007 6:36 am

Post 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.
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter

jeffmcaffer
Posts: 31
Joined: Sat May 07, 2016 9:26 pm

Post 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.
Pro3 #24

brentp
Site Admin
Posts: 5986
Joined: Wed Jan 24, 2007 6:36 am

Post 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?
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter

jeffmcaffer
Posts: 31
Joined: Sat May 07, 2016 9:26 pm

Post 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.
Pro3 #24

brentp
Site Admin
Posts: 5986
Joined: Wed Jan 24, 2007 6:36 am

Post by brentp »

Drastic measures, like described near the end of this thread might be required: https://community.gopro.com/t5/Cameras/ ... td-p/21986
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter

jeffmcaffer
Posts: 31
Joined: Sat May 07, 2016 9:26 pm

Post 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...
Pro3 #24

jeffmcaffer
Posts: 31
Joined: Sat May 07, 2016 9:26 pm

Post 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.
Pro3 #24

Post Reply