123
Dependencies: FXAS21002 FXOS8700Q
Diff: main.cpp
- Revision:
- 5:f2123dc31d30
- Parent:
- 4:ec3c125c37bf
diff -r ec3c125c37bf -r f2123dc31d30 main.cpp --- a/main.cpp Tue Mar 26 13:56:38 2019 +0000 +++ b/main.cpp Wed Mar 27 17:49:40 2019 +0000 @@ -21,6 +21,33 @@ #include "simple-mbed-cloud-client.h" #include "FATFileSystem.h" #include "LittleFileSystem.h" + +// Default network interface object. Don't forget to change the WiFi SSID/password in mbed_app.json if you're using WiFi. +NetworkInterface *net = NetworkInterface::get_default_instance(); + +// Default block device available on the target board +BlockDevice *bd = BlockDevice::get_default_instance(); + +#if COMPONENT_SD || COMPONENT_NUSD +// Use FATFileSystem for SD card type blockdevices +FATFileSystem fs("fs"); +#else +// Use LittleFileSystem for non-SD block devices to enable wear leveling and other functions +LittleFileSystem fs("fs"); +#endif + +// Default User button for GET example and for resetting the storage +InterruptIn button(BUTTON1); +// Default LED to use for PUT/POST example +DigitalOut led(LED1, 0); + +// How often to fetch sensor data (in seconds) +#define SENSORS_POLL_INTERVAL 3.0 + +// Send all sensor data or just limited (useful for when running out of memory) +//#define SEND_ALL_SENSORS + +// Sensors related includes and initialization #include "FXOS8700Q.h" #include "FXAS21002.h" @@ -36,34 +63,12 @@ FXAS21002 sens_gyro(PTD9, PTD8, 0x20); #endif /* TARGET_K66F */ -#define SENSORS_POLL_INTERVAL 3.0 -#define SEND_ALL_SENSORS - -// Default network interface object. Don't forget to change the WiFi SSID/password in mbed_app.json if you're using WiFi. -NetworkInterface *net = NetworkInterface::get_default_instance(); - -// Default block device available on the target board -BlockDevice *bd = BlockDevice::get_default_instance(); - -#if COMPONENT_SD || COMPONENT_NUSD -// Use FATFileSystem for SD card type blockdevices -FATFileSystem fs("fs"); -#else -// Use LittleFileSystem for non-SD block devices to enable wear leveling and other functions -LittleFileSystem fs("fs"); -#endif - -#if USE_BUTTON == 1 -InterruptIn button(BUTTON1); -#endif /* USE_BUTTON */ - -// Default LED to use for PUT/POST example -DigitalOut led(LED1); - // Declaring pointers for access to Pelion Device Management Client resources outside of main() MbedCloudClientResource *res_button; MbedCloudClientResource *res_led; MbedCloudClientResource *res_post; + +// Additional resources for sensor readings #ifdef SEND_ALL_SENSORS MbedCloudClientResource *res_magnometer_x; MbedCloudClientResource *res_magnometer_y;