cansat_B 2019 / Mbed 2 deprecated pic-xbee-completed-2

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include <stdio.h>
00003 #include <base64.h>
00004 
00005 LocalFileSystem local("local");
00006 
00007 Serial pc(USBTX,USBRX);
00008 Serial xbee(p13, p14);
00009 
00010 int main(){
00011     FILE *fp;
00012     base64 *bs;
00013     int c;
00014     
00015     xbee.printf("xbee connected!\r\n");
00016     bs = new base64();
00017     bs->Encode("/local/PICT001.jpg","/local/d.txt");
00018     
00019         if((fp=fopen("/local/d.txt","r"))!=NULL)
00020         {
00021             while ((c=fgetc(fp))!=EOF){ 
00022            xbee.printf("%c",c);
00023          
00024        }
00025        fclose(fp);
00026     }
00027     
00028     while(1) {
00029         
00030         int received_data = xbee.getc();
00031    
00032      if (received_data == 82 || received_data == 114){  //Rまたはr
00033         xbee.printf("_________________________________________________________________________________________________________________________________\r\n");
00034          if((fp=fopen("/local/d.txt","r"))!=NULL)
00035             {
00036                 while ((c=fgetc(fp))!=EOF){
00037                 xbee.printf("%c",c);                    //再送
00038                 
00039                 }
00040                 fclose(fp);
00041             }
00042         }
00043     }
00044    
00045    return 0;
00046 }
00047