Coder Social home page Coder Social logo

gopro-rc's People

Contributors

konradit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

gopro-rc's Issues

Unable to update mac address

wifi_set_macaddr(0, const_cast<uint8*>(mac));

With the below line, I am unable to update the mac address.
wifi_set_macaddr(0, &mac[0]);
The first arg - 0, refers the station mode and since we are creating a softAP and trying to update its mac, I think we need to use 1.

cant send command to camera

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

can't send command

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. ;)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.