recepcion xbee imagen

Dependencies:   SDFileSystem mbed

main.cpp

Committer:
FelipeVR
Date:
2018-09-10
Revision:
0:2ffd2225af4e

File content as of revision 0:2ffd2225af4e:


#include "mbed.h"
#include "SDFileSystem.h"

Serial xbee(PA_15, PB_7); //TX, RX
Serial pc(SERIAL_TX,SERIAL_RX);
SDFileSystem sd_(PA_7, PA_6, PA_5, PB_6, "sd"); // MOSI, MISO, SCK, CS

int Str;
FILE *data = NULL;

int main()
{
    while(1)
    {
        if(xbee.readable())
        {
            data = fopen("/sd/image.jpg", "wb+");
            xbee.scanf("%b",&Str);
            if (data == NULL) 
            { 
                pc.printf("Error al crear el archivo imagen");
                while (1) 
                {
                    wait(100);
                }
            }
            fprintf(data,"%b",Str);
            fclose(data);
        }
    }
}