Adaptation pour camera GOPRO HERO3 Projet BTS SN

Dependencies:   WiflyInterface mbed

Fork of Wifly_GOPRO_HelloWorld by Christian Dupaty

Committer:
cdupaty
Date:
Sat Apr 30 17:12:57 2016 +0000
Revision:
7:a28cdc8cd255
Parent:
6:ae0f0f16fe10
Adaptation pour camera GOPRO HERO3; Projet BTS SN

Who changed what in which revision?

UserRevisionLine numberNew contents of line
samux 0:90ba0f51aa64 1 #include "mbed.h"
samux 3:3b84102f022e 2 #include "WiflyInterface.h"
cdupaty 6:ae0f0f16fe10 3 //#include "stdio.h"
cdupaty 6:ae0f0f16fe10 4
cdupaty 6:ae0f0f16fe10 5 // ATTENTION IL FAUT PEUT ETRE REMPLACER LES $0a$0d par \r\n
cdupaty 6:ae0f0f16fe10 6
cdupaty 6:ae0f0f16fe10 7 const char GPOn1[]="GET /bacpac/PW?t=goprohero&p=%01 HTTP/1.0\n\r\n\r";
cdupaty 6:ae0f0f16fe10 8 const char GPOn2[]="GET /bacpac/PW?t=goprohero&p=%01 HTTP/1.0$0a$0d$0a$0d";
cdupaty 6:ae0f0f16fe10 9 const char GPOff1[]="GET /bacpac/PW?t=goprohero&p=%00 HTTP/1.0\n\r\n\r";
cdupaty 6:ae0f0f16fe10 10 const char GPOff2[]="GET /bacpac/PW?t=goprohero&p=%00 HTTP/1.0$0a$0d$0a$0d";
cdupaty 6:ae0f0f16fe10 11 const char GPStartCapt[]="GET /bacpac/SH?t=goprohero&p=%01 HTTP/1.0$0a$0d$0a$0d";
cdupaty 6:ae0f0f16fe10 12 const char GPStopCapt[]="GET /bacpac/SH?t=goprohero&p=%00 HTTP/1.0$0a$0d$0a$0d";
cdupaty 6:ae0f0f16fe10 13 const char GPCamera[]="GET /camera/CM?t=goprohero&p=%00 HTTP/1.0$0a$0d$0a$0d";
cdupaty 6:ae0f0f16fe10 14 const char GPPhoto[]="GET /camera/CM?t=goprohero&p=%01 HTTP/1.0$0a$0d$0a$0d";
cdupaty 6:ae0f0f16fe10 15
cdupaty 6:ae0f0f16fe10 16 #define brTX PA_9 // TX STM32
cdupaty 6:ae0f0f16fe10 17 #define brRX PA_10 // RX STM32
cdupaty 6:ae0f0f16fe10 18 #define brRESET PA_8 // RESET WiFly
cdupaty 6:ae0f0f16fe10 19 #define brTCP PB_10 // SENS7 Wifly
cdupaty 6:ae0f0f16fe10 20
cdupaty 6:ae0f0f16fe10 21 unsigned int modeOnOff1=0;
cdupaty 6:ae0f0f16fe10 22 unsigned int modeOnOff2=0;
cdupaty 6:ae0f0f16fe10 23 unsigned int modeSt=0;
cdupaty 6:ae0f0f16fe10 24 unsigned int modeMode=0;
cdupaty 6:ae0f0f16fe10 25
samux 1:49e1e9ed6e39 26
samux 1:49e1e9ed6e39 27 Serial pc(USBTX, USBRX);
cdupaty 6:ae0f0f16fe10 28 WiflyInterface wifly(brTX, brRX, brRESET, brTCP, "GOPRO-BP-D896855897e8", "goprohero", WPA);
samux 1:49e1e9ed6e39 29
samux 1:49e1e9ed6e39 30 /* wifly object where:
cdupaty 6:ae0f0f16fe10 31 * - "goprokekechose" is the ssid of the network
cdupaty 6:ae0f0f16fe10 32 * - "goprohero" is the password
samux 5:867d16e948eb 33 * - WPA is the security
samux 1:49e1e9ed6e39 34 */
cdupaty 6:ae0f0f16fe10 35
cdupaty 6:ae0f0f16fe10 36 void menu(void)
cdupaty 6:ae0f0f16fe10 37 {
cdupaty 6:ae0f0f16fe10 38 pc.printf("--------------------\n\r");
cdupaty 6:ae0f0f16fe10 39 pc.printf(" ON - OFF va : a \n\r");
cdupaty 6:ae0f0f16fe10 40 pc.printf(" ON - OFF vb : b \n\r");
cdupaty 6:ae0f0f16fe10 41 pc.printf(" PHOTO : s \n\r");
cdupaty 6:ae0f0f16fe10 42 pc.printf(" MODE : v \n\r");
cdupaty 6:ae0f0f16fe10 43 pc.printf(" DECONNEXION : d \n\r");
cdupaty 6:ae0f0f16fe10 44 pc.printf("--------------------\n\r");
cdupaty 6:ae0f0f16fe10 45 }
samux 0:90ba0f51aa64 46
cdupaty 6:ae0f0f16fe10 47 int main()
cdupaty 6:ae0f0f16fe10 48 {
cdupaty 6:ae0f0f16fe10 49 char c;
cdupaty 6:ae0f0f16fe10 50 pc.printf("Connexion au module WiFly\r\n");
cdupaty 6:ae0f0f16fe10 51 int s=wifly.init(); // use DHCP
cdupaty 6:ae0f0f16fe10 52 if( s != NULL ) {
cdupaty 6:ae0f0f16fe10 53 pc.printf( "Erreur d'initialisation!\n" );
cdupaty 6:ae0f0f16fe10 54 exit( 0 ); // Ou va t on ? Que fait on ?
cdupaty 6:ae0f0f16fe10 55 }
samux 3:3b84102f022e 56 while (!wifly.connect()); // join the network
cdupaty 6:ae0f0f16fe10 57
cdupaty 6:ae0f0f16fe10 58 pc.printf("IP Address is %s\n\r", wifly.getIPAddress());
cdupaty 6:ae0f0f16fe10 59 wifly.sendCommand("set ip host 10.5.5.9\r", "AOK");
cdupaty 6:ae0f0f16fe10 60 wifly.sendCommand("set ip remote 80\r", "AOK");
cdupaty 6:ae0f0f16fe10 61 wifly.sendCommand("set comm idle 5\r", "AOK");
cdupaty 6:ae0f0f16fe10 62 wifly.sendCommand("set comm remote 0\r", "AOK");
cdupaty 6:ae0f0f16fe10 63 wifly.sendCommand("set uart mode 2\r", "AOK");
cdupaty 6:ae0f0f16fe10 64 wifly.exit();
cdupaty 6:ae0f0f16fe10 65 menu();
cdupaty 6:ae0f0f16fe10 66 while(1) {
cdupaty 6:ae0f0f16fe10 67 if (pc.readable()) {
cdupaty 6:ae0f0f16fe10 68 c=pc.getc();
cdupaty 6:ae0f0f16fe10 69 switch(c) {
cdupaty 6:ae0f0f16fe10 70 case 'a' :
cdupaty 6:ae0f0f16fe10 71 if (modeOnOff1) wifly.send(GPOff1,sizeof(GPOff1));
cdupaty 6:ae0f0f16fe10 72 else wifly.send(GPOn1,sizeof(GPOn1));
cdupaty 6:ae0f0f16fe10 73 modeOnOff1=!modeOnOff1;
cdupaty 6:ae0f0f16fe10 74 pc.printf("modeOnOff1: %d\n\r",modeOnOff1);
cdupaty 6:ae0f0f16fe10 75 break;
cdupaty 6:ae0f0f16fe10 76
cdupaty 6:ae0f0f16fe10 77 case 'b' :
cdupaty 6:ae0f0f16fe10 78 if (modeOnOff2) wifly.send(GPOff2,sizeof(GPOff2));
cdupaty 6:ae0f0f16fe10 79 else wifly.send(GPOn2,sizeof(GPOn2));
cdupaty 6:ae0f0f16fe10 80 modeOnOff2=!modeOnOff2;
cdupaty 6:ae0f0f16fe10 81 pc.printf("modeOnOff2: %d\n\r",modeOnOff2);
cdupaty 6:ae0f0f16fe10 82 break;
cdupaty 6:ae0f0f16fe10 83
cdupaty 6:ae0f0f16fe10 84 case 's':
cdupaty 6:ae0f0f16fe10 85 if (modeSt) wifly.send(GPStartCapt,sizeof(GPStartCapt));
cdupaty 6:ae0f0f16fe10 86 else wifly.send(GPStopCapt,sizeof(GPStopCapt));
cdupaty 6:ae0f0f16fe10 87 modeSt=!modeSt;
cdupaty 6:ae0f0f16fe10 88 pc.printf("modeSt: %d\n\r",modeSt);
cdupaty 6:ae0f0f16fe10 89 break;
cdupaty 6:ae0f0f16fe10 90
cdupaty 6:ae0f0f16fe10 91 case 'm':
cdupaty 6:ae0f0f16fe10 92 if (modeMode) wifly.send(GPCamera,sizeof(GPCamera));
cdupaty 6:ae0f0f16fe10 93 else wifly.send(GPPhoto,sizeof(GPPhoto));
cdupaty 6:ae0f0f16fe10 94 modeMode=!modeMode;
cdupaty 6:ae0f0f16fe10 95 pc.printf("modeMode: %d\n\r",modeMode);
cdupaty 6:ae0f0f16fe10 96 break;
cdupaty 6:ae0f0f16fe10 97
cdupaty 6:ae0f0f16fe10 98 case 'd':
cdupaty 6:ae0f0f16fe10 99 wifly.disconnect();
cdupaty 6:ae0f0f16fe10 100 break;
cdupaty 6:ae0f0f16fe10 101 }
cdupaty 6:ae0f0f16fe10 102 menu();
cdupaty 6:ae0f0f16fe10 103 }
cdupaty 6:ae0f0f16fe10 104 }
cdupaty 6:ae0f0f16fe10 105
cdupaty 6:ae0f0f16fe10 106
cdupaty 6:ae0f0f16fe10 107
samux 1:49e1e9ed6e39 108 }