Adaptation pour camera GOPRO HERO3 Projet BTS SN
Dependencies: WiflyInterface mbed
Fork of Wifly_GOPRO_HelloWorld by
main.cpp
00001 #include "mbed.h" 00002 #include "WiflyInterface.h" 00003 //#include "stdio.h" 00004 00005 // ATTENTION IL FAUT PEUT ETRE REMPLACER LES $0a$0d par \r\n 00006 00007 const char GPOn1[]="GET /bacpac/PW?t=goprohero&p=%01 HTTP/1.0\n\r\n\r"; 00008 const char GPOn2[]="GET /bacpac/PW?t=goprohero&p=%01 HTTP/1.0$0a$0d$0a$0d"; 00009 const char GPOff1[]="GET /bacpac/PW?t=goprohero&p=%00 HTTP/1.0\n\r\n\r"; 00010 const char GPOff2[]="GET /bacpac/PW?t=goprohero&p=%00 HTTP/1.0$0a$0d$0a$0d"; 00011 const char GPStartCapt[]="GET /bacpac/SH?t=goprohero&p=%01 HTTP/1.0$0a$0d$0a$0d"; 00012 const char GPStopCapt[]="GET /bacpac/SH?t=goprohero&p=%00 HTTP/1.0$0a$0d$0a$0d"; 00013 const char GPCamera[]="GET /camera/CM?t=goprohero&p=%00 HTTP/1.0$0a$0d$0a$0d"; 00014 const char GPPhoto[]="GET /camera/CM?t=goprohero&p=%01 HTTP/1.0$0a$0d$0a$0d"; 00015 00016 #define brTX PA_9 // TX STM32 00017 #define brRX PA_10 // RX STM32 00018 #define brRESET PA_8 // RESET WiFly 00019 #define brTCP PB_10 // SENS7 Wifly 00020 00021 unsigned int modeOnOff1=0; 00022 unsigned int modeOnOff2=0; 00023 unsigned int modeSt=0; 00024 unsigned int modeMode=0; 00025 00026 00027 Serial pc(USBTX, USBRX); 00028 WiflyInterface wifly(brTX, brRX, brRESET, brTCP, "GOPRO-BP-D896855897e8", "goprohero", WPA); 00029 00030 /* wifly object where: 00031 * - "goprokekechose" is the ssid of the network 00032 * - "goprohero" is the password 00033 * - WPA is the security 00034 */ 00035 00036 void menu(void) 00037 { 00038 pc.printf("--------------------\n\r"); 00039 pc.printf(" ON - OFF va : a \n\r"); 00040 pc.printf(" ON - OFF vb : b \n\r"); 00041 pc.printf(" PHOTO : s \n\r"); 00042 pc.printf(" MODE : v \n\r"); 00043 pc.printf(" DECONNEXION : d \n\r"); 00044 pc.printf("--------------------\n\r"); 00045 } 00046 00047 int main() 00048 { 00049 char c; 00050 pc.printf("Connexion au module WiFly\r\n"); 00051 int s=wifly.init(); // use DHCP 00052 if( s != NULL ) { 00053 pc.printf( "Erreur d'initialisation!\n" ); 00054 exit( 0 ); // Ou va t on ? Que fait on ? 00055 } 00056 while (!wifly.connect()); // join the network 00057 00058 pc.printf("IP Address is %s\n\r", wifly.getIPAddress()); 00059 wifly.sendCommand("set ip host 10.5.5.9\r", "AOK"); 00060 wifly.sendCommand("set ip remote 80\r", "AOK"); 00061 wifly.sendCommand("set comm idle 5\r", "AOK"); 00062 wifly.sendCommand("set comm remote 0\r", "AOK"); 00063 wifly.sendCommand("set uart mode 2\r", "AOK"); 00064 wifly.exit(); 00065 menu(); 00066 while(1) { 00067 if (pc.readable()) { 00068 c=pc.getc(); 00069 switch(c) { 00070 case 'a' : 00071 if (modeOnOff1) wifly.send(GPOff1,sizeof(GPOff1)); 00072 else wifly.send(GPOn1,sizeof(GPOn1)); 00073 modeOnOff1=!modeOnOff1; 00074 pc.printf("modeOnOff1: %d\n\r",modeOnOff1); 00075 break; 00076 00077 case 'b' : 00078 if (modeOnOff2) wifly.send(GPOff2,sizeof(GPOff2)); 00079 else wifly.send(GPOn2,sizeof(GPOn2)); 00080 modeOnOff2=!modeOnOff2; 00081 pc.printf("modeOnOff2: %d\n\r",modeOnOff2); 00082 break; 00083 00084 case 's': 00085 if (modeSt) wifly.send(GPStartCapt,sizeof(GPStartCapt)); 00086 else wifly.send(GPStopCapt,sizeof(GPStopCapt)); 00087 modeSt=!modeSt; 00088 pc.printf("modeSt: %d\n\r",modeSt); 00089 break; 00090 00091 case 'm': 00092 if (modeMode) wifly.send(GPCamera,sizeof(GPCamera)); 00093 else wifly.send(GPPhoto,sizeof(GPPhoto)); 00094 modeMode=!modeMode; 00095 pc.printf("modeMode: %d\n\r",modeMode); 00096 break; 00097 00098 case 'd': 00099 wifly.disconnect(); 00100 break; 00101 } 00102 menu(); 00103 } 00104 } 00105 00106 00107 00108 }
Generated on Wed Jul 13 2022 09:49:39 by 1.7.2