How to set date and time
phlegx opened this issue · comments
Any idea how to set date and time?
Good Question! I do find a command to set time and date, but haven't got time to test it. I will add it later.
Referring to joshvillbrandt/goprohero#5 , https://github.com/KonradIT/goprowifihack/blob/master/HERO4/gpControl-Hero4Silver.json#L2848 and some own captures on my mobile phone with the GoPro app setting the time for a Hero4, it works a as follows:
http://10.5.5.9/gp/gpControl/command/setup/date_time?p=%11%0b%06%11%2a%00
whereupon the numbers are hex-coded. So the above command sets time to %11= (20)17, %0b=11 => November, ...
Her also a short bash script to do so:
#!/bin/bash
TIME_STRING=$(printf "%%%02x%%%02x%%%02x%%%02x%%%02x%%%02x" $(date +%y_%m_%d_%H_%M_%S | sed 's/_/ /g'))
curl "http://10.5.5.9/gp/gpControl/command/setup/date_time?p=${TIME_STRING}"
For the C++ guys:
char time_string[18];
auto t = std::chrono::system_clock::now();
auto tm = std::localtime(&t);
std::sprintf(time_string, "%%%02x%%%02x%%%02x%%%02x%%%02x%%%02x", tm->tm_year % 100, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
curl_easy_setopt(curl, CURLOPT_URL, "http://10.5.5.9/gp/gpControl/command/setup/date_time?p=" + std::string(time_string));
Alternative command:
TIME_STRING=$(printf '%%%02x' $(date +'%_y %_m %_d %_H %_M %_S'))