
This is a simple mbed client example demonstrating, registration of a device with mbed Device Connector and reading and writing values as well as deregistering on different Network Interfaces including Ethernet, WiFi, 6LoWPAN ND and Thread respectively.
Fork of mbed-os-example-client by
Revision 49:10f84adec19e, committed 2016-12-21
- Comitter:
- mbed_official
- Date:
- Wed Dec 21 10:00:11 2016 +0000
- Parent:
- 48:bef96b79dec0
- Child:
- 50:ff7d04c93314
- Commit message:
- Fixed do_blink to use loop instead of recursive call. (#148)
* Fixed do_blink to use loop instead of recursive call.
.
Commit copied from https://github.com/ARMmbed/mbed-os-example-client
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Dec 20 14:45:09 2016 +0000 +++ b/main.cpp Wed Dec 21 10:00:11 2016 +0000 @@ -208,22 +208,23 @@ Thread blinky_thread; BlinkArgs *blink_args; void do_blink() { - // blink the LED - red_led = !red_led; - // up the position, if we reached the end of the vector - if (blink_args->position >= blink_args->blink_pattern.size()) { - // send delayed response after blink is done - M2MObjectInstance* inst = led_object->object_instance(); - M2MResource* led_res = inst->resource("5850"); - led_res->send_delayed_post_response(); - red_led = 1; - status_ticker.attach_us(blinky, 250000); - return; + for (;;) { + // blink the LED + red_led = !red_led; + // up the position, if we reached the end of the vector + if (blink_args->position >= blink_args->blink_pattern.size()) { + // send delayed response after blink is done + M2MObjectInstance* inst = led_object->object_instance(); + M2MResource* led_res = inst->resource("5850"); + led_res->send_delayed_post_response(); + red_led = 1; + status_ticker.attach_us(blinky, 250000); + return; + } + // Wait requested time, then continue prosessing the blink pattern from next position. + Thread::wait(blink_args->blink_pattern.at(blink_args->position)); + blink_args->position++; } - // Invoke same function after `delay_ms` (upping position) - Thread::wait(blink_args->blink_pattern.at(blink_args->position)); - blink_args->position++; - do_blink(); } };