![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
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
Diff: main.cpp
- Revision:
- 49:10f84adec19e
- Parent:
- 44:2b472e66a942
- Child:
- 63:c73f78fd7982
diff -r bef96b79dec0 -r 10f84adec19e main.cpp --- 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(); } };