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: simple-mbed-cloud-client LM75B MMA7660
Fork of mbed-cloud-connect-example-wifi by
Diff: main.cpp
- Revision:
- 15:64d7f2f1f341
- Parent:
- 14:30fde4120a4d
--- a/main.cpp Sun Jul 01 02:53:57 2018 +0000
+++ b/main.cpp Sun Jul 01 03:45:58 2018 +0000
@@ -33,19 +33,18 @@
/* The following app uses Mbed Cloud with SD Card storage, button, & led */
+#if !defined(TARGET_K64F)
+#error "This example only works with FRDM-K64F platform."
+#endif
+
// Placeholder to hardware that trigger events (timer, button, etc)
-/* K64 & K66 */
InterruptIn sw2(SW2);
DigitalOut led2(LED2);
ESP8266Interface net(D1, D0);
-/* */
-
// Placeholder for storage
-/* K64 & K66 */
SDBlockDevice sd(PTE3, PTE1, PTE2, PTE4);
FATFileSystem fs("sd");
-/* */
// Pointers to the resources that will be created in main_application().
static MbedCloudClientResource* pattern_ptr;
@@ -112,9 +111,6 @@
// Do nothing.
}
-
-
-
int main(void)
{
// Requires DAPLink 245+ (https://github.com/ARMmbed/DAPLink/pull/364)
@@ -160,6 +156,7 @@
}
SimpleMbedCloudClient mbedClient(&net);
+
// Save pointer to mbedClient so that other functions can access it.
client = &mbedClient;
@@ -222,11 +219,9 @@
}
printf("\n\n");
- // Placeholder for callback to update local resource when GET comes.
- //timer.attach(&button_press, 5.0);
- sw2.mode(PullUp);
- sw2.fall(button_press);
- button_count = 0;
+ sw2.mode(PullUp);
+ sw2.fall(button_press);
+ button_count = 0;
// For sensors
LM75B lm75b(I2C_SDA, I2C_SCL); // temperature
@@ -236,17 +231,13 @@
Timer timer;
timer.start();
-
// Check if client is registering or registered, if true sleep and repeat.
while (mbedClient.is_register_called()) {
- //static int button_count = 0;
wait_ms(100);
if (button_pressed) {
button_pressed = false;
- //printf("button clicked %d times\r\n", ++button_count);
- //button->set_value(button_count);
printf("button clicked %d times\r\n", button_count);
}
if( timer.read() > measurementPeriod) {
@@ -255,7 +246,6 @@
const unsigned int buf_size = 20;
char buf[buf_size];
-
mma7660.readData(acc);
for(int i=0; i < NUM_AXIS; i++) {
snprintf(buf, buf_size, "%f", acc[i]);
@@ -268,8 +258,8 @@
temp->set_value(buf);
printf("temp: %s\n", buf);
}
+ }
- }
// Client unregistered, exit program.
return 0;
}
