Mbed Cloud Example Project - LPC546xx (Completed Version)
Fork of mbed-cloud-example-lpc546xx by
Diff: main.cpp
- Revision:
- 10:f30cd412e968
- Parent:
- 9:582d0ef3b83b
--- a/main.cpp Thu Oct 11 15:25:26 2018 +0000 +++ b/main.cpp Thu Oct 11 18:59:07 2018 +0000 @@ -39,7 +39,6 @@ // Pointer declaration for Rate Resource static MbedCloudClientResource* rate_ptr; - static bool button_pressed = false; void button_press() { button_pressed = true; @@ -71,8 +70,6 @@ } - - int main(void) { // Requires DAPLink 245+ (https://github.com/ARMmbed/DAPLink/pull/364) @@ -129,25 +126,23 @@ // To-Do #1: Add Mbed Cloud Client resources // Setup Mbed Cloud Client Resources - MbedCloudClientResource *button = mbedClient.create_resource("3200/0/5501", "button_resource"); + MbedCloudClientResource *button = mbedClient.create_resource("3200/0/5501", "button_resource"); // Digital Input / Instance / Counter button->set_value("0"); button->methods(M2MMethod::GET); button->observable(true); button->attach_notification_callback(button_callback); - MbedCloudClientResource *rate = mbedClient.create_resource("3201/0/5853", "blink_rate_resource"); + MbedCloudClientResource *rate = mbedClient.create_resource("3201/0/5521", "blink_rate_resource"); // Digital Output / Instance / Delay Duration rate->set_value("500"); rate->methods(M2MMethod::GET | M2MMethod::PUT); rate->observable(false); rate->attach_put_callback(blink_rate_updated); rate_ptr = rate; - MbedCloudClientResource *blink = mbedClient.create_resource("3201/0/5850", "blink_enable_resource"); + MbedCloudClientResource *blink = mbedClient.create_resource("3201/0/5823", "blink_enable_resource"); // Digital Output / Instance / Event ID blink->methods(M2MMethod::POST); blink->attach_post_callback(blink_enable_callback); - - // Mbed Cloud Register Client and Connect mbedClient.register_and_connect(); @@ -159,12 +154,12 @@ // Setup LED and Push BUtton timer.attach(&led_toggle, 0.5); sw2.fall(&button_press); - + // 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 Pressed %d time(s).\r\n",(++button_count));