普通Arduino控制GoPro全系列
就是这些个小东西的随意组合
安装库
安装
成功
显示两个头文件
#include <GoPRO.h>
#define CONNECT_PRESSED 1
#define ON_PRESSED 2
#define CAPTURE_PRESSED 3
char ssid[] = "yourNetwork"; // your network SSID (name)
char pass[] = "yourPassword"; // your network password
const int buttonConnect = A1;
const int buttonOn = A2;
const int buttonCapture = A3;
const int connectLED = 3;
const int onLED = 4;
const int captureLED = 5;
bool onStatus = true;
bool captureStatus = false;
void setup()
{
pinMode(buttonConnect, INPUT_PULLUP);
pinMode(buttonOn, INPUT_PULLUP);
pinMode(buttonCapture, INPUT_PULLUP);
pinMode(connectLED, OUTPUT);
pinMode(onLED, OUTPUT);
pinMode(captureLED, OUTPUT);
digitalWrite(connectLED, LOW);
digitalWrite(onLED, HIGH);
digitalWrite(captureLED, LOW);
}
void loop()
{
switch (isButtonPressed())
{
default:
break;
case CONNECT_PRESSED:
if (!GoPRO.checkConnection())
{
if (GoPRO.begin(ssid, pass))
{
digitalWrite(connectLED, HIGH);
}
else
{
digitalWrite(connectLED, LOW);
}
}
else
{
digitalWrite(connectLED, HIGH);
}
break;
case ON_PRESSED:
if (GoPRO.checkConnection())
{
onStatus = !onStatus;
if (onStatus)
{
if (GoPRO.turnOn())
digitalWrite(onLED, HIGH);
}
else
{
if (GoPRO.turnOff())
digitalWrite(onLED, LOW);
}
}
break;
case CAPTURE_PRESSED:
if (GoPRO.checkConnection())
{
captureStatus = !captureStatus;
if (captureStatus)
{
if (GoPRO.startCapture())
digitalWrite(captureLED, HIGH);
}
else
{
if (GoPRO.stopCapture())
digitalWrite(captureLED, LOW);
}
}
break;
}
delay(100);
}
int isButtonPressed()
{
if (digitalRead(buttonConnect) == LOW)
return 1;
else if (digitalRead(buttonOn) == LOW)
return 2;
else if (digitalRead(buttonCapture) == LOW)
return 3;
else
return 0;
}
我把例子写这个地方了~
######################################
#GoPRO的语法着色图
######################################
######################################
#数据类型(KEYWORD1)
######################################
GoPRO关键字1
######################################
#方法和函数(KEYWORD2)
######################################
开始KEYWORD2
WiFiStatus关键字2
开启KEYWORD2
关闭KEYWORD2
startCapture KEYWORD2
stopCapture KEYWORD2
localizationOn KEYWORD2
localizationOff KEYWORD2
setTimeLapseInterval KEYWORD2
etContinuousShot KEYWORD2
setVideoMode KEYWORD2
deleteLastKEYWORD2
deleteAll KEYWORD2
checkConnection KEYWORD2
断开KEYWORD2
######################################
#常数(LITERAL1)
相机文字1
BACPAC文学
videoMode LITERAL1
photoMode LITERAL1
BurstMode LITERAL1
timelapseMode LITERAL1
timerMode LITERAL1
播放HDMI LITERAL1
orientationUp LITERAL1
directionDown LITERAL1
VRWVGA60文字1
VRWVGA120文字1
VRR720_30 LITERAL1
VR720_60 LITERAL1
VR960_30 LITERAL1
VR960_48 LITERAL1
VR1080_30 LITERAL1
FPS12文字1
FPS15文字1
FPS12p5文字1
FPS24文字1
FPS25文字1
FPS30文字1
FPS48文字1
FPS50文字1
FPS60文字1
FPS100文字1
FPS120文字1
FPS240文学1
广视角文学1
mediumFOV LITERAL1
窄FOV文学1
photo11mpW文字1
photo8mpW文字1
photo5mpW文学1
photo5mpM文字1
photo12mpW文字1
photo7mpW文字1
photo7mpM文字1
NTSC文学1
PAL文学
######################################
#######################################
#GoPRO的语法着色图
#######################################
#######################################
#数据类型(KEYWORD1)
#######################################
GoPRO关键字1
#######################################
#方法和函数(KEYWORD2)
#######################################
开始KEYWORD2
WiFi状态KEYWORD2
开启KEYWORD2
关闭KEYWORD2
开始Capture KEYWORD2
停止捕获KEYWORD2
在KEYWORD2上本地化
本地化关闭KEYWORD2
设置时间间隔间隔KEYWORD2
设置连拍KEYWORD2
设置视频模式KEYWORD2
删除最后一个KEYWORD2
删除所有KEYWORD2
检查连接KEYWORD2
断开KEYWORD2
#######################################
#常数(LITERAL1)
相机文字1
BACPAC文学
影片模式LITERAL1
照片模式LITERAL1
突发模式LITERAL1
eMode LITERAL1
时间rMode LITERAL1
播放HDMI LITERAL1
方向向上LITERAL1
方向向下LITERAL1
VRWVGA60文字1
VRWVGA120文字1
VRR720_30 LITERAL1
VR720_60 LITERAL1
VR960_30 LITERAL1
VR960_48 LITERAL1
VR1080_30 LITERAL1
FPS12文字1
FPS15文字1
FPS12p5文字1
FPS24文字1
FPS25文字1
FPS30文字1
FPS48文字1
FPS50文字1
FPS60文字1
FPS100文字1
FPS120文字1
FPS240文学1
宽视野文学1
中型FOV LITERAL1
FOV LITERAL1
photo11mpW文字1
photo8mpW文字1
photo5mpW文学1
photo5mpM文字1
photo12mpW文字1
photo7mpW文字1
photo7mpM文字1
NTSC文学1
PAL文学
#######################################
上面是Arduino里面的头文件的着色描述定义
上面是单词之间连着
下面是我分开以后又翻译了一下,大家可以学下这个的定义
缺一个开发板,这边推荐esp32
参考的链接就好
这个怎么运作
库依赖于以下事实:摄像机(在AP模式下)和开发板之间存在连接。
该库具有尝试连接的方法GoPRO.begin(ssid, pass)
。实际上,如果以其他方式建立连接,则此函数返回。true
false
代码与三个按钮相互作用:
连接/断开(连接到A1);
打开/关闭相机(连接到A2);
开始/停止捕获(附加到A3);
这个地方按照自己的开发板的引脚设置
上面是三个按钮的链接引脚,知道怎么改了吗?
按下按钮以这种方式反映三个LED的状态:
蓝色LED:按下连接按钮时,评估板尝试与相机建立连接。如果连接成功,则LED将点亮。如果再按一次,连接将停止并且LED熄灭;
绿色LED:按下“打开/关闭”按钮时,如果LED处于关闭状态,则面板发送命令,否则;
turnOn()
turnOff()
红色LED:按下“开始/停止捕获”按钮时,
startCapture()
如果LED熄灭,则主机将发送命令;否则,该命令将发送stopCapture()
命令;上面是三个灯的链接引脚,知道怎么改了吗?
这个是bool变量,储存状态
注意:只有在主板和摄像机之间的连接仍处于活动状态时,才会发送每个命令。可以使用如果连接处于活动状态则返回true的方法进行检查,否则checkConnection()
返回false 。
loop里面主要写了按键与亮灯的逻辑
这个switch语句就是在检测按键的状态
它先写了默认的状态,break跳出
我们先把一个语句缩进起来看看是什么样的
看到是做了三个判断
第一个是进行与机器的链接
链接上以后,控制灯亮
否则不亮
这个地方是按下按钮以后的故事
先把标志位取反
如果是成立的条件就执行里面的代码,GoPro开关打开,小灯变亮
否则就是关闭的状态,小灯关闭
这个地方是Bool型的变量,存状态
在库内的文件里面可以找到函数的定义
我们在追逐一个connected变量的流转
这里
这里
这个代码是连接相机的核心代码
我这里不想讲
这个地方是控制开始拍摄
函数实现
这里看看URL有多少,可以看到很多
都是URL通信,有必要研究这个计算机网络了
登录相机的wifi网络后,请打开计算机上的所有旧版Web浏览器,然后访问以下URL:
http://10.5.5.9/gp/gpControl/info
此URL应将一串信息打印到Web浏览器中看起来像这样:
{“ model_number” 21,
“ model_name”:
“ HERO5Session”,
“ firmware_version”:
“ HD5.03.02.51.00”,
“ serial_number”:
“ C3212365684485”,
“ board_type”:
“ 0x05”,
“ ap_mac”:
“ 0641631510c4”,
“ ap_ssid”:
“ GP54688615”,
“ ap_has_default_credentials”:
“ 0”,“ capabilities”:
“ 16”}
如果没有打开,请确保您的相机已打开并且仍连接到wifi。
我们感兴趣的字符串中的位是“ ap_mac:”后面的数字字符串。这个由12位数字组成的字符串是MAC地址。就我而言,这是0641631510c4。
确定地址后,每两个字符将其分开,并按照以下格式设置地址:
0x06、0x41、0x63、0x15、0x10、0xC4
#include <SPI.h>
#include <WiFi101.h>
#include <WiFiUdp.h>
int状态= WL_IDLE_STATUS;
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//在此处输入您的WIFI名称和密码
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
char ssid [] =“ XXXXXXXXXXXX”; //您的网络SSID(名称)
char pass [] =“ XXXXXXXXXXXX”; //您的网络密码(用于WPA,或用作WEP密钥)
WiFiClient客户端;
const char * host =“ 10.5.5.9”;
const int httpPort = 80;
void setup(){
//初始化串行并等待端口打开:
Serial.begin(115200);
//检查wifi模块是否存在:
如果(WiFi.status()== WL_NO_SHIELD){
Serial.println(“ WiFi不存在”);
//不要继续:
而(true);
}
//尝试连接到Wifi网络:
while(status!= WL_CONNECTED){
Serial.print(“尝试连接到SSID:”);
Serial.println(ssid);
//连接到WPA / WPA2网络。如果使用开放或WEP网络,请更改此行:
状态= WiFi.begin(ssid,pass);
//等待8秒钟进行连接:
延迟(8000);
}
Serial.println(“已连接到wifi”);
printWifiStatus();
//起始密码
StartPin();
延迟(10000);
//完成PIN
FinishPin();
}
无效循环(){
//无所事事!
延迟(1000);
}
无效的StartPin(){
Serial.print(“正在连接”);
Serial.println(主机);
如果(!client.connect(“ 10.5.5.9”,httpPort)){
Serial.println(“连接失败”);
返回;
}
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//在这里输入您的PIN码XXXX
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
字符串StartUrl =“ / gpPair?c = start&pin = XXXX&mode = 0”;
Serial.print(“请求网址:”);
Serial.println(StartUrl);
client.print(String(“ GET”)+ StartUrl +“ HTTP / 1.1 \ r \ n” +
“主机:” +主机+“ \ r \ n” +
“ Connection:close \ r \ n \ r \ n”);
Serial.println(“ Started”);
}
无效FinishPin(){
Serial.print(“正在连接”);
Serial.println(主机);
如果(!client.connect(“ 10.5.5.9”,httpPort)){
Serial.println(“连接失败”);
返回;
}
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//在这里输入您的PIN码XXXX
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
字符串StopUrl =“ 10.5.5.9/gpPair?c=finish&pin=XXXX&mode=0”;
Serial.print(“请求网址:”);
Serial.println(StopUrl);
client.print(String(“ GET”)+ StopUrl +“ HTTP / 1.1 \ r \ n” +
“主机:” +主机+“ \ r \ n” +
“ Connection:close \ r \ n \ r \ n”);
Serial.println(“完成”);
}
void printWifiStatus(){
//打印您所连接的网络的SSID:
Serial.print(“ SSID:”);
Serial.println(WiFi.SSID());
//打印您的WiFi防护板的IP地址:
IP地址ip = WiFi.localIP();
Serial.print(“ IP地址:”);
Serial.println(ip);
//打印接收到的信号强度:
长rssi = WiFi.RSSI();
Serial.print(“ signal strength(RSSI):”);
Serial.print(rssi);
Serial.println(“ dBm”);
}
这个地方是另一份的链接代码,我基本上把伪代码写了出来
#include <WiFi101.h>
#include <WiFiUdp.h>
int status = WL_IDLE_STATUS;
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//在此处输入您的WIFI名称和密码
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
char ssid[] =“ XXXXXXXXXXXX”; //您的网络SSID(名称)
char pass[] =“ XXXXXXXXXXXX”; //您的网络密码(用于WPA,或用作WEP密钥)
WiFiClient client;
const char *host = "10.5.5.9";
const int httpPort = 80;
void setup()
{
//Initialize serial and wait for port to open:
Serial.begin(115200);
// check for the presence of the wifi module:
if (WiFi.status() == WL_NO_SHIELD)
{
Serial.println("WiFi not present");
// don't continue:
while (true)
;
}
// attempt to connect to Wifi network:
while (status != WL_CONNECTED)
{
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.begin(ssid, pass);
// wait 8 seconds for connection:
delay(8000);
}
Serial.println("Connected to wifi");
printWifiStatus();
// START PIN
StartPin();
delay(10000);
// FINISH PIN
FinishPin();
}
void loop()
{
//Nothing to do here!
delay(1000);
}
void StartPin()
{
Serial.print("connecting to ");
Serial.println(host);
if (!client.connect("10.5.5.9", httpPort))
{
Serial.println("connection failed");
return;
}
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//ENTER YOUR PIN HERE WHERE IT SAYS XXXX
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
String StartUrl = "/gpPair?c=start&pin=XXXX&mode=0";
Serial.print("Requesting URL: ");
Serial.println(StartUrl);
client.print(String("GET ") + StartUrl + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");
Serial.println("Started");
}
void FinishPin()
{
Serial.print("connecting to ");
Serial.println(host);
if (!client.connect("10.5.5.9", httpPort))
{
Serial.println("connection failed");
return;
}
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//ENTER YOUR PIN HERE WHERE IT SAYS XXXX
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
String StopUrl = "10.5.5.9/gpPair?c=finish&pin=XXXX&mode=0";
Serial.print("Requesting URL: ");
Serial.println(StopUrl);
client.print(String("GET ") + StopUrl + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");
Serial.println("Finished");
}
void printWifiStatus()
{
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
// print your WiFi shield's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print("signal strength (RSSI):");
Serial.print(rssi);
Serial.println(" dBm");
}
唤醒GoPro的更好方法是使用WOL数据包或“魔术数据包”。此首字母缩写词代表“局域网唤醒”,是用于将计算机从睡眠模式远程唤醒的协议。它需要使用UDP协议从Arduino向GoPro发送字节以将其唤醒。这有点令人讨厌,因为它是与发送所有其他控制命令不同的协议。代码也不那么漂亮,如果您是编程新手,则处理起来会更加复杂。
然而,当它起作用时,它的确像魔术一样起作用。通过从Arduino发送命令来唤醒我的相机,它永远不会令我感到惊奇。
WOL命令(CameraInitiate()代码中的函数)必须在大多数其他命令之前发送,并且通常应在1-2秒后进行延迟。本质上,您需要在可能需要唤醒相机的任何时间(大多数情况下)发送它。发送命令后,您需要暂停片刻,以使相机真正唤醒。
//打开和关闭相机,然后重试。
}
无效循环(){
//无所事事!
延迟(1000);
}
//唤醒相机的功能
无效的CameraInitiate(){
//开始UDP通信
Udp.begin(localPort);
//发送魔术包将GoPro唤醒
delay(2000);
SendMagicPacket();
延迟(5000);
//清空UDP垃圾端口以进行Wifi客户端通信绝对必要
Udp.flush();
延迟(1000);
//停止UDP通讯
Udp.stop();
延迟(1000);
}
//创建和发送魔术包的功能
//从这里获取并翻译:
// https://www.logicaprogrammabile.it/wol-accendere-computer-arduino-wake-on-lan/
无效SendMagicPacket(){
//创建一个102字节的数组
字节magicPacket [102];
//遍历数组的变量
int Cycle = 0,CycleMacAdd = 0,IndexArray = 0;
//这个for循环遍历数组
for(Cycle = 0; Cycle <6; Cycle ++){
//将数组的前6个字节设置为值0xFF
magicPacket [IndexArray] = 0xFF;
//增加数组索引
IndexArray ++;
}
//现在,我们遍历数组以添加GoPro地址
for(Cycle = 0; Cycle <16; Cycle ++){
// eseguo un每个备忘录的周期为6字节del
//MAC地址
for(CycleMacAdd = 0; CycleMacAdd <6; CycleMacAdd ++){
magicPacket [IndexArray] = remote_MAC_ADD [CycleMacAdd];
//增加数组索引
IndexArray ++;
}
}
//魔术包现在广播到GoPro IP地址和端口
Udp.beginPacket(broadCastIp,wolPort);
udp.write(magicPacket,sizeof magicPacket);
Udp.endPacket();
}
void printWifiStatus(){
//打印您所连接的网络的SSID:
Serial.print(“ SSID:”);
Serial.println(WiFi.SSID());
//打印您的WiFi防护板的IP地址:
IP地址ip = WiFi.localIP();
Serial.print(“ IP地址:”);
Serial.println(ip);
//打印接收到的信号强度:
长rssi = WiFi.RSSI();
Serial.print(“ signal strength(RSSI):”);
Serial.print(rssi);
Serial.println(“ dBm”);
}
#include <SPI.h>
#include <WiFi101.h>
#include <WiFiUdp.h>
int status = WL_IDLE_STATUS;
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//ENTER YOUR WIFI NAME AND PASSWORD HERE
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
char ssid[] = "XXXXXXXXXXXX"; // your network SSID (name)
char pass[] = "XXXXXXXXXXXX"; // your network password (use for WPA, or use as key for WEP)
int localPort = 7;
byte broadCastIp[] = { 10,5,5,9 };
//!!!!!!!!!!!!!!!!!!!!!!!!!!!
//ENTER YOUR MAC ADDRESS HERE
//!!!!!!!!!!!!!!!!!!!!!!!!!!!
byte remote_MAC_ADD[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
int wolPort = 9;
WiFiUDP Udp;
WiFiClient client;
const char* host = "10.5.5.9";
const int httpPort = 80;
void setup(){
//Initialize serial and wait for port to open:
Serial.begin(115200);
// check for the presence of the wifi module:
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("WiFi not present");
// don't continue:
while (true);
}
// attempt to connect to Wifi network:
while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.begin(ssid, pass);
// wait 8 seconds for connection:
delay(8000);
}
Serial.println("Connected to wifi");
printWifiStatus();
delay(1000);
// WAKE UP YOUR SLEEPY CAMERA!
CameraInitiate(){
// NOTE: If this does not seem to be working,
// turn your camera on and off and try again.
}
void loop(){
//Nothing to do here!
delay(1000);
}
// FUNCTION TO WAKE UP THE CAMERA
void CameraInitiate(){
//Begin UDP communication
Udp.begin(localPort);
//Send the magic packet to wake up the GoPro out of sleep
delay(2000);
SendMagicPacket();
delay(5000);
// Absolutely necessary to flush port of UDP junk for Wifi client communication
Udp.flush();
delay(1000);
//Stop UDP communication
Udp.stop();
delay(1000);
}
// Function to create and send magic packet
// Taken and translated from here:
// https://www.logicaprogrammabile.it/wol-accendere-computer-arduino-wake-on-lan/
void SendMagicPacket(){
//Create a 102 byte array
byte magicPacket[102];
// Variables for cycling through the array
int Cycle = 0, CycleMacAdd = 0, IndexArray = 0;
// This for loop cycles through the array
for( Cycle = 0; Cycle < 6; Cycle++){
// The first 6 bytes of the array are set to the value 0xFF
magicPacket[IndexArray] = 0xFF;
// Increment the array index
IndexArray++;
}
// Now we cycle through the array to add the GoPro address
for( Cycle = 0; Cycle < 16; Cycle++ ){
//eseguo un Cycle per memorizzare i 6 byte del
//mac address
for( CycleMacAdd = 0; CycleMacAdd < 6; CycleMacAdd++){
magicPacket[IndexArray] = remote_MAC_ADD[CycleMacAdd];
// Increment the array index
IndexArray++;
}
}
//The magic packet is now broadcast to the GoPro IP address and port
Udp.beginPacket(broadCastIp, wolPort);
Udp.write(magicPacket, sizeof magicPacket);
Udp.endPacket();
}
void printWifiStatus() {
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
// print your WiFi shield's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print("signal strength (RSSI):");
Serial.print(rssi);
Serial.println(" dBm");
}
在上面的示例中,WOL函数在设置中被调用,因此它只会在您第一次运行它时唤醒你的相机。
https://github.com/KonradIT/goprowifihack/blob/master/HERO4/WifiCommands.md
https://github.com/KonradIT/goprowifihack
上面的代码是具体的控制代码
// Code by <a href="https://www.instructables.com/member/nes3dprinting/
//https://www.instructables.com/member/nes3dprintin
//https://www.instructables.com/member/nes3dprintin
// This is for an ESP8266, not the MKR1000
// Made this for a GoPro Hero+. Should work for Hero4- Latest(Hero7)
//https://github.com/KonradIT/goprowifihack/blob/master/HERO/CameraStatus.md
#include <ESP8266WiFi.h>
// ArduinoJson Version 5.13
#include <ArduinoJson.h>
#include <ESP8266HTTPClient.h>
//########################## Enter GoPro WiFi Details Here #############################
const char *ssid = "GoProHero+";
const char *pass = "GoProHero+";
//######################################################################################</p><p>const char* host = "10.5.5.9";
const int httpPort = 80;
</ p><p> void setup()
{
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, pass);
}
void loop()
{
if (WiFi.status() == WL_CONNECTED)
{
// Prints the Current Mode of the Camera: Video-0, Photo-1, MultiShot-2
// https://github.com/KonradIT/goprowifihack/blob/master/HERO/CameraStatus.md"
//https://www.instructables.com/member/nes3dprintin.
//https://www.instructables.com/member/nes3dprintin..
// Pick desired status from function below
GetStatus();
}
}
</ p><p> void GetStatus()
{
//Serial.println("Getting Status Updates");
HTTPClient http; //Object of class HTTPClient
http.begin("http://10.5.5.9/gp/gpControl/status");
int httpCode = http.GET();
//Serial.print("httpCode: ");
//Serial.println(httpCode);
//Check the returning code
if (httpCode > 0)
{
// Parsing - Created Using ArduinoJson Assistant
// <a href="https://arduinojson.org/v5/assistant/"> <a href="https://www.instructables.com/member/nes3dprintin...</a"> https://www.instructables.com/member/nes3dprintin...</a>>
const size_t bufferSize = JSON_OBJECT_SIZE(2) + JSON_OBJECT_SIZE(55) + JSON_OBJECT_SIZE(64) + 730;
DynamicJsonBuffer jsonBuffer(bufferSize);
String str = http.getString();
//Serial.println(str);
JsonObject &root = jsonBuffer.parseObject(str);
JsonObject &status = root["status"];
int status_1 = status["1"]; // 1
int status_2 = status["2"]; // 4
int status_3 = status["3"]; // 0
int status_4 = status["4"]; // 0
int status_6 = status["6"]; // 0
int status_8 = status["8"]; // 0
int status_9 = status["9"]; // 0
int status_10 = status["10"]; // 0
int status_11 = status["11"]; // 0
int status_13 = status["13"]; // 0
int status_14 = status["14"]; // 0
int status_15 = status["15"]; // 0
int status_16 = status["16"]; // 0
int status_17 = status["17"]; // 1
int status_19 = status["19"]; // 0
int status_20 = status["20"]; // 0
int status_21 = status["21"]; // 0
int status_22 = status["22"]; // 0
int status_23 = status["23"]; // 0
int status_24 = status["24"]; // 0
int status_26 = status["26"]; // 0
int status_27 = status["27"]; // 0
int status_28 = status["28"]; // 0
const char *status_29 = status["29"]; // ""
const char *status_30 = status["30"]; // "GoProHero+"
int status_31 = status["31"]; // 0
int status_32 = status["32"]; // 0
int status_33 = status["33"]; // 0
int status_34 = status["34"]; // 4431
int status_35 = status["35"]; // 4860
int status_36 = status["36"]; // 0
int status_37 = status["37"]; // 0
int status_38 = status["38"]; // 0
int status_39 = status["39"]; // 1
const char *status_40 = status["40"]; // "%12%0B%0C%17%1E%08"
int status_41 = status["41"]; // 0
int status_42 = status["42"]; // 0
int status_43 = status["43"]; // 1
int status_44 = status["44"]; // 0
int status_45 = status["45"]; // 0
int status_46 = status["46"]; // 0
int status_47 = status["47"]; // 0
int status_48 = status["48"]; // 0
int status_49 = status["49"]; // 0
long status_54 = status["54"]; // 15899787264
int status_55 = status["55"]; // 1
int status_56 = status["56"]; // 4
int status_57 = status["57"]; // 0
int status_58 = status["58"]; // 0
int status_59 = status["59"]; // 0
int status_60 = status["60"]; // 500
int status_61 = status["61"]; // 2
int status_62 = status["62"]; // 0
int status_63 = status["63"]; // 0
int status_64 = status["64"]; // 2215
JsonObject &settings = root["settings"];
int settings_1 = settings["1"]; // 0
int settings_2 = settings["2"]; // 11
int settings_3 = settings["3"]; // 5
int settings_4 = settings["4"]; // 0
int settings_5 = settings["5"]; // 0
int settings_6 = settings["6"]; // 1
int settings_7 = settings["7"]; // 0
int settings_8 = settings["8"]; // 0
int settings_9 = settings["9"]; // 0
int settings_10 = settings["10"]; // 0
int settings_11 = settings["11"]; // 0
int settings_12 = settings["12"]; // 0
int settings_13 = settings["13"]; // 0
int settings_14 = settings["14"]; // 4
int settings_15 = settings["15"]; // 0
int settings_16 = settings["16"]; // 0
int settings_17 = settings["17"]; // 0
int settings_18 = settings["18"]; // 0
int settings_19 = settings["19"]; // 0
int settings_20 = settings["20"]; // 0
int settings_21 = settings["21"]; // 0
int settings_22 = settings["22"]; // 0
int settings_23 = settings["23"]; // 0
int settings_24 = settings["24"]; // 0
int settings_25 = settings["25"]; // 0
int settings_26 = settings["26"]; // 0
int settings_27 = settings["27"]; // 0
int settings_28 = settings["28"]; // 0
int settings_29 = settings["29"]; // 3
int settings_30 = settings["30"]; // 0
int settings_31 = settings["31"]; // 0
int settings_32 = settings["32"]; // 10
int settings_33 = settings["33"]; // 0
int settings_34 = settings["34"]; // 0
int settings_35 = settings["35"]; // 0
int settings_36 = settings["36"]; // 0
int settings_37 = settings["37"]; // 0
int settings_38 = settings["38"]; // 0
int settings_39 = settings["39"]; // 0
int settings_49 = settings["49"]; // 100
int settings_50 = settings["50"]; // 0
int settings_51 = settings["51"]; // 2
int settings_52 = settings["52"]; // 1
int settings_53 = settings["53"]; // 1
int settings_54 = settings["54"]; // 0
int settings_55 = settings["55"]; // 3
int settings_56 = settings["56"]; // 0
int settings_57 = settings["57"]; // 0
int settings_58 = settings["58"]; // 0
int settings_59 = settings["59"]; // 0
int settings_60 = settings["60"]; // 8
int settings_61 = settings["61"]; // 1
long settings_62 = settings["62"]; // 700000
int settings_63 = settings["63"]; // 1
int settings_64 = settings["64"]; // 2
int settings_68 = settings["68"]; // 0
int settings_69 = settings["69"]; // 0
int settings_70 = settings["70"]; // 0
int settings_72 = settings["72"]; // 0
int settings_73 = settings["73"]; // 0
int settings_74 = settings["74"]; // 0
int settings_75 = settings["75"]; // 0
int settings_76 = settings["76"]; // 0
int settings_77 = settings["77"]; // 0</p><p>//########################### Set Desired State to Update Here ##########################################
Serial.print("The Current State is: ");
Serial.println(status_43);
//######################################################################################################
}
else
{
Serial.println("No Response From Camera");
}
}
这个是ESP8266用json解析控制代码
https://cam-do.com/products/blink-gopro-time-lapse-controller
https://cam-do.com/blogs/camdo-blog/gopro-shutter-control-with-a-radio-control-rc-interface
https://cam-do.com/pages/camdo-blink-firmware
https://cam-do.com/blogs/camdo-blog/how-to-interface-your-gopro-to-a-microcontroller-arduino-esp8266-etc-using-blink
目标是仿照一个
这个是文章或是控制的一切的源泉
就是WiFi链接至相机->UDP通信->发送控制命令
就是这么个情况,完成什么样子是自己的能力了