Laser Communication Protocol developed during HEPTA-Sat training in Bulgaria, October 2017.
Dependencies: Hepta9axis HeptaBattery HeptaCamera_GPS HeptaTemp HeptaXbee SDFileSystem mbed
3daf572bcae1/main.cpp@1:f7206e74c970, 2017-11-17 (annotated)
- Committer:
- stoilivanov
- Date:
- Fri Nov 17 14:17:20 2017 +0000
- Revision:
- 1:f7206e74c970
- Parent:
- 0:95bf84c286f5
Submission from a team (Ivan Mihov, Stoil Ivanov, Zdravko Dimitrov) in HEPTA-Sat training, Bulgaria.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
stoilivanov | 1:f7206e74c970 | 1 | /*This is the RECEIVER code of Laser Communication Protocol v1.0 developed by |
stoilivanov | 1:f7206e74c970 | 2 | Ivan Mihov, Stoil Ivanov and Zdravko Dimitrov. The protocol was developed during |
stoilivanov | 1:f7206e74c970 | 3 | the HEPTA-Sat training held in the Faculty of Physics at Sofia University |
stoilivanov | 1:f7206e74c970 | 4 | "St. Kliment Ohridski", Bulgaria. The training was conducted from 24th to |
stoilivanov | 1:f7206e74c970 | 5 | 28th of October 2017 with instructors Dr. Masahiko Yamazaki, Mr. Takafumi |
stoilivanov | 1:f7206e74c970 | 6 | Umezawa and Mr. Riku Sato. |
stoilivanov | 1:f7206e74c970 | 7 | |
stoilivanov | 1:f7206e74c970 | 8 | For contacting the developers, please use e-mails: |
stoilivanov | 1:f7206e74c970 | 9 | ipmihov@gmail.com - Ivan Mihov |
stoilivanov | 1:f7206e74c970 | 10 | stoil.n.ivanov@gmail.com - Stoil Ivanov |
stoilivanov | 1:f7206e74c970 | 11 | z.dimitrov91@gmail.com - Zdravko Dimitrov |
stoilivanov | 1:f7206e74c970 | 12 | We will be glad to help!*/ |
stoilivanov | 1:f7206e74c970 | 13 | |
stoilivanov | 0:95bf84c286f5 | 14 | #include "mbed.h" |
stoilivanov | 0:95bf84c286f5 | 15 | #include "SDFileSystem.h" |
stoilivanov | 0:95bf84c286f5 | 16 | #include "HeptaXbee.h" |
stoilivanov | 0:95bf84c286f5 | 17 | #include "HeptaCamera_GPS.h" |
stoilivanov | 0:95bf84c286f5 | 18 | #include "Hepta9axis.h" |
stoilivanov | 0:95bf84c286f5 | 19 | #include "HeptaTemp.h" |
stoilivanov | 0:95bf84c286f5 | 20 | #include "HeptaBattery.h" |
stoilivanov | 0:95bf84c286f5 | 21 | #include <stdio.h> |
stoilivanov | 0:95bf84c286f5 | 22 | #include <string.h> |
stoilivanov | 0:95bf84c286f5 | 23 | #include <stdlib.h> |
stoilivanov | 0:95bf84c286f5 | 24 | |
stoilivanov | 0:95bf84c286f5 | 25 | |
stoilivanov | 0:95bf84c286f5 | 26 | Serial pc(USBTX,USBRX); |
stoilivanov | 0:95bf84c286f5 | 27 | SDFileSystem sd(p5, p6, p7, p8, "sd"); |
stoilivanov | 0:95bf84c286f5 | 28 | HeptaXbee xbee(p9,p10); |
stoilivanov | 0:95bf84c286f5 | 29 | HeptaCamera_GPS cam_gps(p13, p14,p25,p24); |
stoilivanov | 0:95bf84c286f5 | 30 | Hepta9axis n_axis(p28,p27,0xD0,0x18); |
stoilivanov | 0:95bf84c286f5 | 31 | HeptaTemp temp(p17); |
stoilivanov | 0:95bf84c286f5 | 32 | AnalogIn light(p18); |
stoilivanov | 0:95bf84c286f5 | 33 | PwmOut led(p21); |
stoilivanov | 0:95bf84c286f5 | 34 | HeptaBattery battery(p16,p26); |
stoilivanov | 0:95bf84c286f5 | 35 | DigitalOut myled(LED1); |
stoilivanov | 0:95bf84c286f5 | 36 | |
stoilivanov | 1:f7206e74c970 | 37 | |
stoilivanov | 1:f7206e74c970 | 38 | //Definition of MORSE and ASCII structure variables |
stoilivanov | 0:95bf84c286f5 | 39 | typedef struct { |
stoilivanov | 1:f7206e74c970 | 40 | char* morse; |
stoilivanov | 1:f7206e74c970 | 41 | char* ascii; |
stoilivanov | 0:95bf84c286f5 | 42 | } morse_table_t; |
stoilivanov | 0:95bf84c286f5 | 43 | |
stoilivanov | 0:95bf84c286f5 | 44 | int main() |
stoilivanov | 0:95bf84c286f5 | 45 | { |
stoilivanov | 0:95bf84c286f5 | 46 | |
stoilivanov | 1:f7206e74c970 | 47 | //Morse code dictionary |
stoilivanov | 1:f7206e74c970 | 48 | morse_table_t table[] = { {".-", "A"}, |
stoilivanov | 1:f7206e74c970 | 49 | {"-...", "B"}, |
stoilivanov | 1:f7206e74c970 | 50 | {"-.-.", "C"}, |
stoilivanov | 1:f7206e74c970 | 51 | {"-.." , "D"}, |
stoilivanov | 1:f7206e74c970 | 52 | {"." , "E"}, |
stoilivanov | 1:f7206e74c970 | 53 | {"..-." , "F"}, |
stoilivanov | 1:f7206e74c970 | 54 | {"--." , "G"}, |
stoilivanov | 1:f7206e74c970 | 55 | {"...." , "H"}, |
stoilivanov | 1:f7206e74c970 | 56 | {".." , "I"}, |
stoilivanov | 1:f7206e74c970 | 57 | {".---" , "J"}, |
stoilivanov | 1:f7206e74c970 | 58 | {"-.-" , "K"}, |
stoilivanov | 1:f7206e74c970 | 59 | {".-.." , "L"}, |
stoilivanov | 1:f7206e74c970 | 60 | {"--" , "M"}, |
stoilivanov | 1:f7206e74c970 | 61 | {"-." , "N"}, |
stoilivanov | 1:f7206e74c970 | 62 | {"---" , "O"}, |
stoilivanov | 1:f7206e74c970 | 63 | {".--." , "P"}, |
stoilivanov | 1:f7206e74c970 | 64 | {"--.-" , "Q"}, |
stoilivanov | 1:f7206e74c970 | 65 | {".-." , "R"}, |
stoilivanov | 1:f7206e74c970 | 66 | {"..." , "S"}, |
stoilivanov | 1:f7206e74c970 | 67 | {"-" , "T"}, |
stoilivanov | 1:f7206e74c970 | 68 | {"..-" , "U"}, |
stoilivanov | 1:f7206e74c970 | 69 | {"...-" , "V"}, |
stoilivanov | 1:f7206e74c970 | 70 | {".--" , "W"}, |
stoilivanov | 1:f7206e74c970 | 71 | {"-..-" , "X"}, |
stoilivanov | 1:f7206e74c970 | 72 | {"-.--" , "Y"}, |
stoilivanov | 1:f7206e74c970 | 73 | {"--.." "Z"}, |
stoilivanov | 1:f7206e74c970 | 74 | {"-----" ,"0"}, |
stoilivanov | 1:f7206e74c970 | 75 | {".----" ,"1"}, |
stoilivanov | 1:f7206e74c970 | 76 | {"..---" , "2"}, |
stoilivanov | 1:f7206e74c970 | 77 | {"...--" , "3"}, |
stoilivanov | 1:f7206e74c970 | 78 | {"....-" , "4"}, |
stoilivanov | 1:f7206e74c970 | 79 | {"....." , "5"}, |
stoilivanov | 1:f7206e74c970 | 80 | {"-...." ,"6"}, |
stoilivanov | 1:f7206e74c970 | 81 | {"--..." , "7"}, |
stoilivanov | 1:f7206e74c970 | 82 | {"---.." , "8"}, |
stoilivanov | 1:f7206e74c970 | 83 | {"----." , "9"}, |
stoilivanov | 1:f7206e74c970 | 84 | {"/" , " "} |
stoilivanov | 1:f7206e74c970 | 85 | }; |
stoilivanov | 1:f7206e74c970 | 86 | pc.baud(9600); |
stoilivanov | 0:95bf84c286f5 | 87 | |
stoilivanov | 1:f7206e74c970 | 88 | char symbol,space; |
stoilivanov | 1:f7206e74c970 | 89 | char mes[100]; |
stoilivanov | 1:f7206e74c970 | 90 | float count=0.0,count_on=0.0,count_off=0.0 ; |
stoilivanov | 1:f7206e74c970 | 91 | float current,vol,sig,lux; |
stoilivanov | 1:f7206e74c970 | 92 | |
stoilivanov | 1:f7206e74c970 | 93 | led = 1; |
stoilivanov | 0:95bf84c286f5 | 94 | |
stoilivanov | 1:f7206e74c970 | 95 | //Creating directory for storing the laser message on the SD card |
stoilivanov | 1:f7206e74c970 | 96 | mkdir("/sd/LaserComms", 0777); |
stoilivanov | 1:f7206e74c970 | 97 | |
stoilivanov | 1:f7206e74c970 | 98 | //Creating and opening a file 'for writing' the morse message |
stoilivanov | 1:f7206e74c970 | 99 | FILE *fp = fopen("/sd/LaserComms/message.txt", "w"); |
stoilivanov | 1:f7206e74c970 | 100 | if(fp == NULL) { |
stoilivanov | 1:f7206e74c970 | 101 | error("Could not open file for writing\r\n"); |
stoilivanov | 1:f7206e74c970 | 102 | } |
stoilivanov | 0:95bf84c286f5 | 103 | |
stoilivanov | 1:f7206e74c970 | 104 | //Sequence for 'start bit' |
stoilivanov | 1:f7206e74c970 | 105 | while (1) { |
stoilivanov | 1:f7206e74c970 | 106 | do { |
stoilivanov | 1:f7206e74c970 | 107 | vol = light.read(); |
stoilivanov | 1:f7206e74c970 | 108 | sig = 3.3*1.947*vol; |
stoilivanov | 1:f7206e74c970 | 109 | current = sig * 100; |
stoilivanov | 1:f7206e74c970 | 110 | lux = (current)*2; |
stoilivanov | 1:f7206e74c970 | 111 | |
stoilivanov | 1:f7206e74c970 | 112 | if (lux > 300) { |
stoilivanov | 1:f7206e74c970 | 113 | count = count + 0.1; |
stoilivanov | 1:f7206e74c970 | 114 | } else { |
stoilivanov | 1:f7206e74c970 | 115 | count = 0.0; |
stoilivanov | 1:f7206e74c970 | 116 | } |
stoilivanov | 0:95bf84c286f5 | 117 | |
stoilivanov | 1:f7206e74c970 | 118 | xbee.printf("lux= %f , current= %f ,vol= %f , count= %f \r\n",lux,current,vol,count); |
stoilivanov | 1:f7206e74c970 | 119 | wait (0.1); |
stoilivanov | 1:f7206e74c970 | 120 | } while (count <= 3.0); //Condition for 'start bit' |
stoilivanov | 0:95bf84c286f5 | 121 | |
stoilivanov | 1:f7206e74c970 | 122 | //'Start bit' received |
stoilivanov | 0:95bf84c286f5 | 123 | xbee.printf("LASER COMMUNICATION ESTABLISHED! RECEIVING MODE ON!\r\n"); |
stoilivanov | 0:95bf84c286f5 | 124 | |
stoilivanov | 1:f7206e74c970 | 125 | //Laser signal reading starts |
stoilivanov | 1:f7206e74c970 | 126 | lux=0; |
stoilivanov | 1:f7206e74c970 | 127 | while(1) { |
stoilivanov | 1:f7206e74c970 | 128 | count_on = 0.0; |
stoilivanov | 1:f7206e74c970 | 129 | count_off = 0.0; |
stoilivanov | 0:95bf84c286f5 | 130 | |
stoilivanov | 1:f7206e74c970 | 131 | //----------- While loop for 'spaces' in the message |
stoilivanov | 1:f7206e74c970 | 132 | while(lux < 300) { |
stoilivanov | 1:f7206e74c970 | 133 | xbee.printf("lux= %f, count_off= %f \r\n",lux,count_off); |
stoilivanov | 1:f7206e74c970 | 134 | count_off = count_off + 0.05; |
stoilivanov | 1:f7206e74c970 | 135 | wait(0.05); |
stoilivanov | 1:f7206e74c970 | 136 | vol = light.read(); |
stoilivanov | 1:f7206e74c970 | 137 | sig = 3.3*1.947*vol; |
stoilivanov | 1:f7206e74c970 | 138 | current = sig * 100; |
stoilivanov | 1:f7206e74c970 | 139 | lux = (current)*2; |
stoilivanov | 1:f7206e74c970 | 140 | } |
stoilivanov | 1:f7206e74c970 | 141 | |
stoilivanov | 1:f7206e74c970 | 142 | //Condition for defining the type of the 'space signal' |
stoilivanov | 1:f7206e74c970 | 143 | //Currently developed for single words only |
stoilivanov | 1:f7206e74c970 | 144 | if (count_off >= 0.5) { |
stoilivanov | 1:f7206e74c970 | 145 | space = 'x'; |
stoilivanov | 1:f7206e74c970 | 146 | fprintf(fp,"%c",space); |
stoilivanov | 1:f7206e74c970 | 147 | } |
stoilivanov | 0:95bf84c286f5 | 148 | |
stoilivanov | 1:f7206e74c970 | 149 | //Check for 'stop bit' |
stoilivanov | 1:f7206e74c970 | 150 | if (count_off > 3.0) { |
stoilivanov | 1:f7206e74c970 | 151 | break; |
stoilivanov | 1:f7206e74c970 | 152 | } |
stoilivanov | 0:95bf84c286f5 | 153 | |
stoilivanov | 1:f7206e74c970 | 154 | //----------- While loop for 'symbols' in the message |
stoilivanov | 1:f7206e74c970 | 155 | while(lux >= 300) { |
stoilivanov | 1:f7206e74c970 | 156 | xbee.printf("lux= %f, count_on= %f \r\n",lux,count_on); |
stoilivanov | 1:f7206e74c970 | 157 | count_on = count_on + 0.05; |
stoilivanov | 1:f7206e74c970 | 158 | wait(0.05); |
stoilivanov | 1:f7206e74c970 | 159 | vol = light.read(); |
stoilivanov | 1:f7206e74c970 | 160 | sig = 3.3*1.947*vol; |
stoilivanov | 1:f7206e74c970 | 161 | current = sig * 100; |
stoilivanov | 1:f7206e74c970 | 162 | lux = (current)*2; |
stoilivanov | 1:f7206e74c970 | 163 | } |
stoilivanov | 1:f7206e74c970 | 164 | |
stoilivanov | 1:f7206e74c970 | 165 | //Condition for defining the type of the 'symbol signal' |
stoilivanov | 1:f7206e74c970 | 166 | if (count_on >= 0.5) { |
stoilivanov | 1:f7206e74c970 | 167 | symbol = '-'; |
stoilivanov | 1:f7206e74c970 | 168 | fprintf(fp,"%c",symbol); |
stoilivanov | 1:f7206e74c970 | 169 | } else { |
stoilivanov | 1:f7206e74c970 | 170 | symbol = '.'; |
stoilivanov | 1:f7206e74c970 | 171 | fprintf(fp,"%c",symbol); |
stoilivanov | 1:f7206e74c970 | 172 | } |
stoilivanov | 0:95bf84c286f5 | 173 | |
stoilivanov | 1:f7206e74c970 | 174 | //Check for 'stop bit' |
stoilivanov | 1:f7206e74c970 | 175 | if (count_off > 3.0) { |
stoilivanov | 1:f7206e74c970 | 176 | break; |
stoilivanov | 1:f7206e74c970 | 177 | } |
stoilivanov | 1:f7206e74c970 | 178 | } |
stoilivanov | 0:95bf84c286f5 | 179 | |
stoilivanov | 1:f7206e74c970 | 180 | //At this point the 'stop bit' has been received |
stoilivanov | 1:f7206e74c970 | 181 | fclose(fp); |
stoilivanov | 0:95bf84c286f5 | 182 | |
stoilivanov | 1:f7206e74c970 | 183 | //The message was written in a file on the SD card |
stoilivanov | 0:95bf84c286f5 | 184 | |
stoilivanov | 1:f7206e74c970 | 185 | //Now we open the same file to read the message and store it in a string |
stoilivanov | 1:f7206e74c970 | 186 | fp = fopen("/sd/LaserComms/message.txt","r"); |
stoilivanov | 1:f7206e74c970 | 187 | fgets(mes,100,fp); |
stoilivanov | 1:f7206e74c970 | 188 | fclose(fp); |
stoilivanov | 0:95bf84c286f5 | 189 | |
stoilivanov | 1:f7206e74c970 | 190 | //Check if the message is not empty |
stoilivanov | 1:f7206e74c970 | 191 | if (mes != "\0") { |
stoilivanov | 1:f7206e74c970 | 192 | xbee.printf("Message accepted successfully! \r\n"); |
stoilivanov | 1:f7206e74c970 | 193 | xbee.printf("Morse: %s\r\n Translating... \r\n",mes); |
stoilivanov | 1:f7206e74c970 | 194 | } |
stoilivanov | 0:95bf84c286f5 | 195 | |
stoilivanov | 1:f7206e74c970 | 196 | //Definitiom of characters and strings for the Morse Code Translator |
stoilivanov | 1:f7206e74c970 | 197 | char* segment; |
stoilivanov | 1:f7206e74c970 | 198 | char final_mes[100]; |
stoilivanov | 1:f7206e74c970 | 199 | int i; |
stoilivanov | 0:95bf84c286f5 | 200 | |
stoilivanov | 1:f7206e74c970 | 201 | //Here we divide the message in 'segments' using the symbol for space 'x' |
stoilivanov | 1:f7206e74c970 | 202 | segment = strtok(mes, "x"); |
stoilivanov | 1:f7206e74c970 | 203 | |
stoilivanov | 1:f7206e74c970 | 204 | xbee.printf("Translated: "); |
stoilivanov | 1:f7206e74c970 | 205 | |
stoilivanov | 1:f7206e74c970 | 206 | //We create a file to store the final translated message |
stoilivanov | 1:f7206e74c970 | 207 | FILE *fh = fopen("/sd/LaserComms/final_message.txt", "w"); |
stoilivanov | 1:f7206e74c970 | 208 | if(fh == NULL) { |
stoilivanov | 1:f7206e74c970 | 209 | error("Could not open file for writing\r\n"); |
stoilivanov | 1:f7206e74c970 | 210 | } |
stoilivanov | 0:95bf84c286f5 | 211 | |
stoilivanov | 1:f7206e74c970 | 212 | //The Morse-to- text translation sequence starts |
stoilivanov | 1:f7206e74c970 | 213 | while(segment) { |
stoilivanov | 1:f7206e74c970 | 214 | for(i=0; i<37; ++i) { |
stoilivanov | 1:f7206e74c970 | 215 | //Here we compare the message segment with the defined Morse code dictionary |
stoilivanov | 1:f7206e74c970 | 216 | if (!strcmp(segment, table[i].morse)) { |
stoilivanov | 1:f7206e74c970 | 217 | //The translated message is sent to the Ground Station |
stoilivanov | 1:f7206e74c970 | 218 | xbee.printf("%s",(table[i].ascii)); |
stoilivanov | 1:f7206e74c970 | 219 | //The translated message is stored in a file on the SD card |
stoilivanov | 1:f7206e74c970 | 220 | fprintf(fh,"%s",(table[i].ascii)); |
stoilivanov | 1:f7206e74c970 | 221 | break; |
stoilivanov | 1:f7206e74c970 | 222 | } |
stoilivanov | 1:f7206e74c970 | 223 | } |
stoilivanov | 1:f7206e74c970 | 224 | segment = strtok(NULL, "x"); |
stoilivanov | 1:f7206e74c970 | 225 | } |
stoilivanov | 1:f7206e74c970 | 226 | fclose(fh); |
stoilivanov | 0:95bf84c286f5 | 227 | |
stoilivanov | 1:f7206e74c970 | 228 | //We open the file, which contains the translated message |
stoilivanov | 1:f7206e74c970 | 229 | fh = fopen("/sd/LaserComms/final_message.txt","r"); |
stoilivanov | 1:f7206e74c970 | 230 | //The file is read and the translated message is stored in a string |
stoilivanov | 1:f7206e74c970 | 231 | fgets(final_mes,100,fh); |
stoilivanov | 1:f7206e74c970 | 232 | fclose(fh); |
stoilivanov | 0:95bf84c286f5 | 233 | |
stoilivanov | 1:f7206e74c970 | 234 | //From here on we define few commands, depending on the message content |
stoilivanov | 0:95bf84c286f5 | 235 | |
stoilivanov | 1:f7206e74c970 | 236 | //------- TELEMETRY COMMAND |
stoilivanov | 1:f7206e74c970 | 237 | if (!strcmp(final_mes, "TELEMETRY")) { |
stoilivanov | 1:f7206e74c970 | 238 | xbee.printf("Telemetry requested!"); |
stoilivanov | 1:f7206e74c970 | 239 | cam_gps.gps_setting(); |
stoilivanov | 1:f7206e74c970 | 240 | float gx,gy,gz,ax,ay,az,mx,my,mz,bt,temper; |
stoilivanov | 1:f7206e74c970 | 241 | char ns='A',ew='B',aunit='m'; |
stoilivanov | 1:f7206e74c970 | 242 | float time=0.0,latitude=0.0,longitude=0.0,hacu=0.0,altitude=0.0; |
stoilivanov | 1:f7206e74c970 | 243 | int quality=0,stnum=0,gps_check=0; |
stoilivanov | 1:f7206e74c970 | 244 | for(int i = 0; i < 10; i++) { |
stoilivanov | 1:f7206e74c970 | 245 | n_axis.sen_gyro(&gx,&gy,&gz); |
stoilivanov | 1:f7206e74c970 | 246 | n_axis.sen_acc(&ax,&ay,&az); |
stoilivanov | 1:f7206e74c970 | 247 | n_axis.sen_mag(&mx,&my,&mz); |
stoilivanov | 1:f7206e74c970 | 248 | battery.vol(&bt); |
stoilivanov | 1:f7206e74c970 | 249 | temp.temp_sense(&temper); |
stoilivanov | 1:f7206e74c970 | 250 | cam_gps.gga_sensing(&time, &latitude, &ns, &longitude, &ew, &quality, &stnum, &hacu, &altitude, &aunit, &gps_check); |
stoilivanov | 1:f7206e74c970 | 251 | xbee.printf("gx = %f gy = %f gz = %f\r\n",gx,gy,gz); |
stoilivanov | 1:f7206e74c970 | 252 | xbee.printf("ax = %f ay = %f az = %f\r\n",ax,ay,az); |
stoilivanov | 1:f7206e74c970 | 253 | xbee.printf("mx = %f my = %f mz = %f\r\n",mx,my,mz); |
stoilivanov | 1:f7206e74c970 | 254 | xbee.printf("Temperature = %f\r\n",temper); |
stoilivanov | 1:f7206e74c970 | 255 | xbee.printf("Battery voltage: = %f[V]\r\n",bt); |
stoilivanov | 1:f7206e74c970 | 256 | xbee.printf("%f,%f,%c,%f,%c,%d,%d,%f,%f,%c\r\n\n",time,latitude,ns,longitude,ew,quality,stnum,hacu,altitude,aunit); |
stoilivanov | 1:f7206e74c970 | 257 | led = (i%2); |
stoilivanov | 1:f7206e74c970 | 258 | wait(1.0); |
stoilivanov | 1:f7206e74c970 | 259 | } |
stoilivanov | 1:f7206e74c970 | 260 | xbee.initialize(); |
stoilivanov | 1:f7206e74c970 | 261 | } |
stoilivanov | 0:95bf84c286f5 | 262 | |
stoilivanov | 1:f7206e74c970 | 263 | //------- PHOTO COMMAND |
stoilivanov | 1:f7206e74c970 | 264 | if (!strcmp(final_mes, "PHOTO")) { |
stoilivanov | 1:f7206e74c970 | 265 | //---------LED blinks several times |
stoilivanov | 1:f7206e74c970 | 266 | for(int i = 0; i < 7; i++) { |
stoilivanov | 1:f7206e74c970 | 267 | led = (i%2); |
stoilivanov | 1:f7206e74c970 | 268 | wait(0.2); |
stoilivanov | 1:f7206e74c970 | 269 | } |
stoilivanov | 0:95bf84c286f5 | 270 | |
stoilivanov | 1:f7206e74c970 | 271 | xbee.printf("Photo requested! \r\n Camera Snapshot Mode\r\n\n Please, smile! :) \r\n"); |
stoilivanov | 1:f7206e74c970 | 272 | cam_gps.Sync(); |
stoilivanov | 1:f7206e74c970 | 273 | cam_gps.initialize(HeptaCamera_GPS::Baud115200, HeptaCamera_GPS::JpegResolution640x480); |
stoilivanov | 1:f7206e74c970 | 274 | cam_gps.test_jpeg_snapshot_picture(1); |
stoilivanov | 1:f7206e74c970 | 275 | led = 1; |
stoilivanov | 1:f7206e74c970 | 276 | } |
stoilivanov | 0:95bf84c286f5 | 277 | |
stoilivanov | 1:f7206e74c970 | 278 | //------- SOS COMMAND |
stoilivanov | 1:f7206e74c970 | 279 | if (!strcmp(final_mes, "SOS")) { |
stoilivanov | 0:95bf84c286f5 | 280 | |
stoilivanov | 0:95bf84c286f5 | 281 | // LED blinks SOS message |
stoilivanov | 1:f7206e74c970 | 282 | xbee.printf("LEDs blinks SOS message! \r\n"); |
stoilivanov | 0:95bf84c286f5 | 283 | |
stoilivanov | 1:f7206e74c970 | 284 | led=0; |
stoilivanov | 1:f7206e74c970 | 285 | wait(0.2); |
stoilivanov | 0:95bf84c286f5 | 286 | |
stoilivanov | 1:f7206e74c970 | 287 | // 'S' letter: . . . |
stoilivanov | 1:f7206e74c970 | 288 | led = 1; |
stoilivanov | 1:f7206e74c970 | 289 | wait(0.2); |
stoilivanov | 1:f7206e74c970 | 290 | |
stoilivanov | 1:f7206e74c970 | 291 | led = 0; |
stoilivanov | 1:f7206e74c970 | 292 | wait(0.2); |
stoilivanov | 1:f7206e74c970 | 293 | |
stoilivanov | 1:f7206e74c970 | 294 | led = 1; |
stoilivanov | 1:f7206e74c970 | 295 | wait(0.2); |
stoilivanov | 1:f7206e74c970 | 296 | |
stoilivanov | 1:f7206e74c970 | 297 | led = 0; |
stoilivanov | 1:f7206e74c970 | 298 | wait(0.2); |
stoilivanov | 1:f7206e74c970 | 299 | |
stoilivanov | 1:f7206e74c970 | 300 | led = 1; |
stoilivanov | 1:f7206e74c970 | 301 | wait(0.2); |
stoilivanov | 1:f7206e74c970 | 302 | |
stoilivanov | 1:f7206e74c970 | 303 | //Space between letters |
stoilivanov | 1:f7206e74c970 | 304 | led = 0; |
stoilivanov | 1:f7206e74c970 | 305 | wait(0.7); |
stoilivanov | 0:95bf84c286f5 | 306 | |
stoilivanov | 1:f7206e74c970 | 307 | // 'O' letter: - - - |
stoilivanov | 1:f7206e74c970 | 308 | led = 1; |
stoilivanov | 1:f7206e74c970 | 309 | wait(0.7); |
stoilivanov | 1:f7206e74c970 | 310 | |
stoilivanov | 1:f7206e74c970 | 311 | led = 0; |
stoilivanov | 1:f7206e74c970 | 312 | wait(0.2); |
stoilivanov | 1:f7206e74c970 | 313 | |
stoilivanov | 1:f7206e74c970 | 314 | led = 1; |
stoilivanov | 1:f7206e74c970 | 315 | wait(0.7); |
stoilivanov | 1:f7206e74c970 | 316 | |
stoilivanov | 1:f7206e74c970 | 317 | led = 0; |
stoilivanov | 1:f7206e74c970 | 318 | wait(0.2); |
stoilivanov | 0:95bf84c286f5 | 319 | |
stoilivanov | 1:f7206e74c970 | 320 | led = 1; |
stoilivanov | 1:f7206e74c970 | 321 | wait(0.7); |
stoilivanov | 1:f7206e74c970 | 322 | |
stoilivanov | 1:f7206e74c970 | 323 | //Space between letters |
stoilivanov | 1:f7206e74c970 | 324 | led = 0; |
stoilivanov | 1:f7206e74c970 | 325 | wait(0.7); |
stoilivanov | 1:f7206e74c970 | 326 | |
stoilivanov | 1:f7206e74c970 | 327 | // 'S' letter: . . . |
stoilivanov | 1:f7206e74c970 | 328 | led = 1; |
stoilivanov | 1:f7206e74c970 | 329 | wait(0.2); |
stoilivanov | 1:f7206e74c970 | 330 | |
stoilivanov | 1:f7206e74c970 | 331 | led = 0; |
stoilivanov | 1:f7206e74c970 | 332 | wait(0.2); |
stoilivanov | 1:f7206e74c970 | 333 | |
stoilivanov | 1:f7206e74c970 | 334 | led = 1; |
stoilivanov | 1:f7206e74c970 | 335 | wait(0.2); |
stoilivanov | 1:f7206e74c970 | 336 | |
stoilivanov | 1:f7206e74c970 | 337 | led = 0; |
stoilivanov | 1:f7206e74c970 | 338 | wait(0.2); |
stoilivanov | 1:f7206e74c970 | 339 | |
stoilivanov | 1:f7206e74c970 | 340 | led = 1; |
stoilivanov | 1:f7206e74c970 | 341 | wait(0.2); |
stoilivanov | 1:f7206e74c970 | 342 | |
stoilivanov | 1:f7206e74c970 | 343 | led = 0; |
stoilivanov | 1:f7206e74c970 | 344 | xbee.printf("SOS message sent back the Earth with the LED! \r\n"); |
stoilivanov | 1:f7206e74c970 | 345 | } |
stoilivanov | 1:f7206e74c970 | 346 | } |
stoilivanov | 0:95bf84c286f5 | 347 | } |