Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
main.cpp@1:3f0c5242bc32, 2019-11-28 (annotated)
- Committer:
- saeichi
- Date:
- Thu Nov 28 11:50:27 2019 +0000
- Revision:
- 1:3f0c5242bc32
- Parent:
- 0:0ef2fb2bea82
xbee_pic_re....
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
saeichi | 0:0ef2fb2bea82 | 1 | #include "mbed.h" |
saeichi | 0:0ef2fb2bea82 | 2 | #include <stdio.h> |
saeichi | 0:0ef2fb2bea82 | 3 | #include <base64.h> |
saeichi | 0:0ef2fb2bea82 | 4 | |
saeichi | 0:0ef2fb2bea82 | 5 | LocalFileSystem local("local"); |
saeichi | 0:0ef2fb2bea82 | 6 | |
saeichi | 0:0ef2fb2bea82 | 7 | Serial pc(USBTX,USBRX); |
saeichi | 0:0ef2fb2bea82 | 8 | Serial xbee(p13, p14); |
saeichi | 1:3f0c5242bc32 | 9 | |
saeichi | 1:3f0c5242bc32 | 10 | int main(){ |
saeichi | 0:0ef2fb2bea82 | 11 | FILE *fp; |
saeichi | 0:0ef2fb2bea82 | 12 | base64 *bs; |
saeichi | 0:0ef2fb2bea82 | 13 | int c; |
saeichi | 0:0ef2fb2bea82 | 14 | |
saeichi | 1:3f0c5242bc32 | 15 | xbee.printf("xbee connected!\r\n"); |
saeichi | 0:0ef2fb2bea82 | 16 | bs = new base64(); |
saeichi | 1:3f0c5242bc32 | 17 | bs->Encode("/local/PICT001.jpg","/local/d.txt"); |
saeichi | 0:0ef2fb2bea82 | 18 | |
saeichi | 1:3f0c5242bc32 | 19 | if((fp=fopen("/local/d.txt","r"))!=NULL) |
saeichi | 1:3f0c5242bc32 | 20 | { |
saeichi | 1:3f0c5242bc32 | 21 | while ((c=fgetc(fp))!=EOF){ |
saeichi | 0:0ef2fb2bea82 | 22 | xbee.printf("%c",c); |
saeichi | 1:3f0c5242bc32 | 23 | |
saeichi | 0:0ef2fb2bea82 | 24 | } |
saeichi | 0:0ef2fb2bea82 | 25 | fclose(fp); |
saeichi | 1:3f0c5242bc32 | 26 | } |
saeichi | 1:3f0c5242bc32 | 27 | |
saeichi | 1:3f0c5242bc32 | 28 | while(1) { |
saeichi | 1:3f0c5242bc32 | 29 | |
saeichi | 1:3f0c5242bc32 | 30 | int received_data = xbee.getc(); |
saeichi | 1:3f0c5242bc32 | 31 | |
saeichi | 1:3f0c5242bc32 | 32 | if (received_data == 82 || received_data == 114){ //Rまたはr |
saeichi | 1:3f0c5242bc32 | 33 | xbee.printf("_________________________________________________________________________________________________________________________________\r\n"); |
saeichi | 1:3f0c5242bc32 | 34 | if((fp=fopen("/local/d.txt","r"))!=NULL) |
saeichi | 1:3f0c5242bc32 | 35 | { |
saeichi | 1:3f0c5242bc32 | 36 | while ((c=fgetc(fp))!=EOF){ |
saeichi | 1:3f0c5242bc32 | 37 | xbee.printf("%c",c); //再送 |
saeichi | 1:3f0c5242bc32 | 38 | |
saeichi | 1:3f0c5242bc32 | 39 | } |
saeichi | 1:3f0c5242bc32 | 40 | fclose(fp); |
saeichi | 1:3f0c5242bc32 | 41 | } |
saeichi | 1:3f0c5242bc32 | 42 | } |
saeichi | 1:3f0c5242bc32 | 43 | } |
saeichi | 1:3f0c5242bc32 | 44 | |
saeichi | 0:0ef2fb2bea82 | 45 | return 0; |
saeichi | 0:0ef2fb2bea82 | 46 | } |
saeichi | 1:3f0c5242bc32 | 47 |