konradit / gopro-rc Goto Github PK
View Code? Open in Web Editor NEWESP8266 based real Remote Control (RC mode, not APP mode) for GoPro HERO4+ cameras
ESP8266 based real Remote Control (RC mode, not APP mode) for GoPro HERO4+ cameras
Line 26 in 9645e65
wifi_set_macaddr(0, &mac[0]);
I have connected to camera hero 8 but look like camera cant reveive or handle command, plz help
serial messenge:
Total Connected Clients are = 1
HttpCode -1Trying... 10.71.79.100
Trying... 127.0.0.1
Hello, I'm trying to connect my Hero 5 to the NodeMCU. The camera connects to the AP. But she can not be controlled. She gets the IP 10.71.79.6, which I use for commands. Like "http://10.71.79.6/gp/gpControl/status". However, I always get the httpcode -1.
The goal is to control four cameras simultaneously.
Is there information about what the remote usually sends when a camera is connected? The camera normally displays "Smart Remote Connected". When connecting to the NodeMCU not.
Here is my current code (very messy):
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
extern "C" void preinit() {
uint8_t ap_mac[] = {0xD8, 0x96, 0x85, 0x03, 0x04, 0x05};
wifi_set_opmode(SOFTAP_MODE);
wifi_set_macaddr(SOFTAP_IF, ap_mac);
}
//
///* Set these to your desired credentials. */
const char *ssid = "HERO-RC-030405"; // my smart-remotes name is "HERO-RC-A1111425435131"
boolean conn = false;
const String SHUTTER_START = "command/shutter?p=1";
const String SHUTTER_STOP = "command/shutter?p=0";
const String STATUS_REQ = "status";
struct station_info *stat_info;
HTTPClient http;
#define MAX_CMD_LENGTH 60
void setup() {
WiFi.setAutoConnect(false);
WiFi.disconnect(true);
WiFi.softAPdisconnect(false);
Serial.begin(115200);
while (!Serial); // wait for serial attach
WiFi.hostname("Gopro");
Serial.println("");
Serial.println("");
Serial.println("Setup done.");
}
void loop() {
// Check for a command from the Serial Monitor
SubSerialMonitorCommand();
// Check client status
if (conn == true) {
client_status();
}
}
void startAP()
{
/* DCHP settings */
IPAddress ip(10, 71, 79, 1);
IPAddress gateway(10, 71, 79, 1);
IPAddress subnet(255, 255, 255, 0);
WiFi.softAPConfig(ip, gateway, subnet);
//Start AP
WiFi.softAP(ssid, "", 6);
WiFi.enableAP(true);
Serial.print("<rcMAC>");
Serial.print(WiFi.softAPmacAddress());
Serial.println("</rcMAC>");
Serial.print("<rcSSID>");
Serial.print(ssid);
Serial.println("</rcSSID>");
Serial.print("<rcIP>");
Serial.print(WiFi.softAPIP());
Serial.println("</rcIP>");
conn = true;
Serial.print("<rcConnected>");
Serial.print(conn);
Serial.println("</rcConnected>");
}
void stopAP()
{
WiFi.softAPdisconnect(true);
conn = false;
Serial.print("<rcConnected>");
Serial.print(conn);
Serial.println("</rcConnected>");
}
String IpAddress2String(const IPAddress& ipAddress){
return String(ipAddress[0]) + String(".") + \
String(ipAddress[1]) + String(".") + \
String(ipAddress[2]) + String(".") + \
String(ipAddress[3]) ;
}
unsigned char oldNumber_client = 0;
unsigned long oldTime = 0;
void client_status() {
unsigned char number_client;
struct ip4_addr *IPaddress;
IPAddress address;
number_client = wifi_softap_get_station_num();
stat_info = wifi_softap_get_station_info();
if (oldNumber_client != number_client || oldTime + 1000 <= millis()) {
Serial.print("<n_clients>");
Serial.print(number_client);
Serial.println("</n_clients>");
oldNumber_client = number_client;
delay(100);
}
}
byte ReadSerialMonitorString(char* sString)
{
// Declarations
byte nCount;
nCount = 0;
if (Serial.available() > 0)
{
Serial.setTimeout(20);
nCount = Serial.readBytes(sString, MAX_CMD_LENGTH);
}// end if
// Terminate the string
sString[nCount] = 0;
return nCount;
}
void sendReq(String req)
{
struct ip4_addr *IPaddress;
IPAddress address;
stat_info = wifi_softap_get_station_info();
int i = 1;
while (stat_info != NULL) {
IPaddress = &stat_info->ip;
address = IPaddress->addr;
String strAddr = IpAddress2String(address);
String testStr = "http://"+strAddr+"/gp/gpControl/command/system/locate?p=0";
http.begin(testStr); //check for comunication works
int httpCode = http.GET();
if (httpCode >= 0){
Serial.println("Requesting...");
makeReq(strAddr, req);
}else{
Serial.println("Error request " + strAddr);
}
stat_info = STAILQ_NEXT(stat_info, next);
i++;
Serial.println();
}
}
void makeReq(String addr, String cmd) {
String URI = "http://" + addr + "/gp/gpControl/" + cmd;
http.begin(URI);
Serial.println(URI);
int httpCode = http.GET();
if (httpCode > 0) {
String payload = http.getString();
Serial.println(payload);
Serial.println("Recording...");
}else{
Serial.println("Error during request!");
}
http.end();
}
void SubSerialMonitorCommand()
{
// Declarations
char sString[MAX_CMD_LENGTH + 1];
bool bError = true;
unsigned long nMsgID = 0xFFFF;
byte nMsgLen = 0;
byte nMsgBuffer[8];
// Check for command from Serial Monitor
int nLen = ReadSerialMonitorString(sString);
if (nLen > 0)
{
String str(sString);
if (str.indexOf("<openAP>") >= 0) {
//init softAP
startAP();
}else if (str.indexOf("<closeAP>") >= 0) {
//stop softAP
stopAP();
}
else if (str.indexOf("<rec>") >= 0) {
//send record command
sendReq(SHUTTER_START);
}
else if (str.indexOf("<stop>") >= 0) {
//send stop record command
sendReq(SHUTTER_STOP);
Serial.println("Recording stopped");
}else if (str.indexOf("<status>") >= 0) {
//send status command
sendReq(STATUS_REQ);
}
else if (str.indexOf("WhoAreYou") >= 0) {
//send stop record command
Serial.println("ItsMe");
}
else {
//undefiniert
unsigned long oldTime = 0;
}
}
}
PS: I use the NodeMCU in conjunction with a Windows application. This sends via serial commands such as and .
Please help me! And excuse my bad English, I'm from Germany. ;)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.