Skip to content
This repository was archived by the owner on Apr 24, 2019. It is now read-only.

Fixed do_blink to use loop instead of recursive call. #148

Merged
merged 4 commits into from
Dec 21, 2016
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,22 +208,23 @@ class LedResource {
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(;;){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the same coding style as in rest of file, i.e. add space between "for" and "(" and before "{".

// 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();
}
};

Expand Down