goprowifihack
goprowifihack copied to clipboard
Bluetooth API for waking HERO5 from wifi-sleep
Problem: HERO5 wifi connection times out when cam not recording. Need guidance for how to re-awake the cam using Bluetooth.
Description: We are using GoPro professionally in the field doing interviews. To be able to sync in-field notes with the video, we have developed a Java program which runs on a PC and a Mac. It is based on https://github.com/DomDomHaas/gopro-wifi-API and works fine on HERO 3.
But after upgrading the Java API to comply with the HTTP API for HERO5, I discovered that HERO5 has a time-out on the wifi connection, when not recording. This happens even if I constantly poll the camera status. According to https://community.gopro.com/t5/Cameras/Hero5-Session-Wifi-vs-Bluetooth/td-p/30201 this is intended behaviour to save battery. It also states that Bluetooth is the mechanism to wake up the cam again.
But I am lacking a prescription for how to wake up the camera using Bluetooth. The API description only states how to do the pairing, but not how to actually re-awake the camera programatically.
I'm sure I'm not the only one facing this kind of issue. Any help would be much appreciated. Once the application is finished, i will of course share it.
- GoPro Camera(s): HERO5
- Firmware Version: latest (dec 2017)
- Steps to reproduce: any scenario not recording.
- Happens every time? yes
Same problem here. The Hero5B wifi is available for about 5 minutes after the camera has been turned off and WOL works fine during this time to turn on the gopro again, but after this period wifi is apparently turned off. I would love to see a solution which extends the wifi standby time rather than to use BT. Any solutions appreciated.
Yep - so would I. I have tried several ways to extend the wifi-connection time. I have tried (without success) every minute to:
- send WOL
- send http status request
- start/stop a recording (via http)
- disable + enable wifi connection (from the PC)
But no matter what I do, the gopro terminates the wifi session after 10 or so minutes. When this happens, it's like cutting the branch you sit on, and there is no way of getting wifi back, except using the re-connect UI on the camera itself.
I wonder if there is any way around using bluetooth?
I tested with my iPhone and the Gopro app connected.
- Wifi on, Bluetooth on: the GP5B stays connected forever
- Wifi on, Bluetooth off: after 10 min sharp, the Gopro awakens, switches to multishot, takes automatically one multishot, and then continues to stay on
- iPhone connected to Gopro wifi, app is closed: wifi connection shuts down exactly after 10 min. While the gopro is still turned on and gopro settings still shows wifi enabled, the gopro access point no longer visible in the iPhone settings. Connection can be reestablished only with bluetooth turned on via the gopro app.
So besides a parallel bluetooth connection, there seems to be a way to keep wifi awake by a mode change plus shutter release within the 10 minutes. Further testing needed....
Thanks. It inspired me, so what I do now is:
- Connect the PC to the cameras hotspot, and then my PC application to the camera.
- Right after (or before, doesn't really matter), connect to the camera with the GoPro app. Stay on that connection for at least 10 minutes. It seems like the app only needs to send the "keep alive" to the camera once, because you can close the app hereafter.
The trick is that the PC can operate the camera using HTTP commands while the cam is the same time connected to the phone (which keeps the cam's wifi alive).
It's simple...but really a messy solution. I simply wonder why GoPro has not implemented a "disable wifi timeout" setting for users who has the camera connected to an external power source.
It seems to work though. Thanks to mtbsteve's inspiration :-)
Well I don’t believe that this is a viable solution but rather a bug in the gopro firmware. I noticed that after connecting with the gopro app under some circumstances the gopro wifi did not switch off at all even after disabling the wifi in the camera. The only proper solution is with a combination of wifi and a BT connection in parallel.
@mtbsteve: I agree - this is not a real solution. It's a "hack" or work-around. @KonradIT: Interesting. My PC program is in Java, so I would need to port your KeepAlive.
Is this the relevant line? sock.sendto("GPHD:0:0:2:0.000000\n".encode(), (self.ip_addr, 8554))
And does it use a bluetooth connection? (sorry for my ignorance here, but I'm really not familiar with sockets and the syntax used here.
thanks :-)
yes that's the line.
OK, good. Can you elaborate what it does? Is there any documentation behind this? Do you use bluetooth or wifi?
wifi. look for keep alive on Wikipedia
Excellent-thanks @KonradIT Do I need to constantly send this message to keep it alive? What is the recommended interval?
Any explanation why that keep alive works?
@ratnick did you tried the code to Java? I need to use it in C#
Console.WriteLine($"Sending Keep alive, bytes sent: {new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp).SendTo(Encoding.UTF8.GetBytes("_GPHD_:0:0:2:0.000000\n"), new IPEndPoint(IPAddress.Parse("10.5.5.9"), 8554))}");
or
var m = Encoding.UTF8.GetBytes("_GPHD_:0:0:2:0.000000\n");
var c = new UdpClient(AddressFamily.InterNetwork);
Log($"Sending Keep alive, bytes sent: {c.Send(m, m.Length, "10.5.5.9", 8554)}");
c.Close();
An alternative I was trying to do is to use: http://10.5.5.9/gp/gpControl/command/wireless/ap/ssid?ssid=CURRENTSSIDNAME but I have had mixed results. Sometimes it stays alive weeks.
Hi @eried No - i did not try because I could not find any supporting documentation, and without that, it's just a big guess-work. So i stayed with the solution depicted in my post, i.e. letting a mobile phone app handle the keep-alive for the first 10 minutes. Hereafter it seems like the camera keeps itself alive. But admittedly - it's a crappy "solution". But the best i could do with the time I had for this.
@ratnick but do not you have issues after a while? like a couple hours? I am doing the same but for some reason my gopro stops answering my requests (after a day or so) until I connect via the phone again.
@eried what camera are you using? Bluetooth might be needed to ping the GoPro
@KonradIT Hero Session 5
You mean, on some cameras there is no way to keep them alive without bluetooth? I only need to shoot a photo every hour and retrieve the photo.
Yes @eried , you need to first send a Bluetooth message to wake it up.
But after the first message, can I keep it up with the UDP message you are sending in your wrapper? @KonradIT or I will need the phone all the time to wake it?
Also try to have a Magic Packet sent every few seconds like in here: http://github.com/konradit/gopro-py-api
@eried it seems to only need 10 minutes with the phone app. Aftern then, you can close the app and the gopro stays on. Tested on GoPro 5.
@eried @ratnick The wake on lan issue affects only the H5 session or H5 Black as well? I will try to "sniff" the Bluetooth wake message.
@KonradIT I only have the H5 session, and yes it sleeps after a while. However,
@ratnick you are totally right, thanks! after leaving my phone 15 mins with the app opened I have been running my script connected to the GoPro for 1 day without any issues!
Hey guys, I can wake up the camera using this app, we can even get fw info.
I cannot pair my GoPro to my laptop though
Just connecting to the camera?
Yes. My laptop's BT controller does not pair with the GoPro for some reason, but theoretically using bluetoothctl trust > pair > connect should work.
https://streamable.com/tjb3t
Here's a link to a full Java implementation for taking notes synchronised with GoPro videos for use in a professional interview setting. GoPro is remote controlled from the app, and it's easy to find the spot in the video corresponding to the note taken during the session. Supports GoPro 3, 4, 5, 6.
https://github.com/ratnick/GoPro-Notetaker-tool
A lot of credits to @KonradIT :-)
Hey, anyone figured out how to keep the HERO5 alive & connected to WiFi? Thanks!
I have some progress. I bought Raspberry Pi with BLE yesterday and I'm able to wake up the GoPro over Bluetooth. However still not figured out how to turn on the WiFi (but at least there is a way to turn GoPro off over WiFi and then turn it on over BLE).
@krystof-k Which RPI did you buy? Mi Pi Zero stopped working all of a sudden.