Acquire Sensor data and email

Dependencies:   C12832_lcd EthernetInterface LM75B NTPClient SimpleSMTPClient TextLCD USBHost mbed

Fork of USBHost-MSD_HelloWorld by avnish aggarwal

main.cpp

Committer:
avnisha
Date:
2013-08-13
Revision:
9:3ca15106a7d1
Parent:
4:f8a5c8aa895a
Child:
10:0902b3dc4d96

File content as of revision 9:3ca15106a7d1:

#include "mbed.h"
#include "USBHostMSD.h"

DigitalOut led(LED1);

void msd_task(void const *) {
    
    USBHostMSD msd("usb");
    int i = 0;
    
    while(1) {
        
        // try to connect a MSD device
        while(!msd.connect()) {
            Thread::wait(500);
            printf("waiting\n");
        }
        
        // in a loop, append a file
        // if the device is disconnected, we try to connect it again
        while(1) {
            
            // append a file
            FILE * fp = fopen("/usb/test1.txt", "a");
        
            if (fp != NULL) {
                fprintf(fp, "Hello fun SD Card World: %d!\r\n", i++);
                printf("Goodbye World!\r\n");
                fclose(fp);
            } else {
                printf("FILE == NULL\r\n");
            }
            
            Thread::wait(500);
        
            // if device disconnected, try to connect again
            if (!msd.connected())
                break;
        }
            
    }
}


int main() {
    Thread msdTask(msd_task, NULL, osPriorityNormal, 1024 * 4);
    while(1) {
        led=!led;
        Thread::wait(500);
    }
}