This repository was archived by the owner on Apr 24, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +16
-15
lines changed Expand file tree Collapse file tree 1 file changed +16
-15
lines changed Original file line number Diff line number Diff line change @@ -208,22 +208,23 @@ class LedResource {
208
208
Thread blinky_thread;
209
209
BlinkArgs *blink_args;
210
210
void do_blink () {
211
- // blink the LED
212
- red_led = !red_led;
213
- // up the position, if we reached the end of the vector
214
- if (blink_args->position >= blink_args->blink_pattern .size ()) {
215
- // send delayed response after blink is done
216
- M2MObjectInstance* inst = led_object->object_instance ();
217
- M2MResource* led_res = inst->resource (" 5850" );
218
- led_res->send_delayed_post_response ();
219
- red_led = 1 ;
220
- status_ticker.attach_us (blinky, 250000 );
221
- return ;
211
+ for (;;) {
212
+ // blink the LED
213
+ red_led = !red_led;
214
+ // up the position, if we reached the end of the vector
215
+ if (blink_args->position >= blink_args->blink_pattern .size ()) {
216
+ // send delayed response after blink is done
217
+ M2MObjectInstance* inst = led_object->object_instance ();
218
+ M2MResource* led_res = inst->resource (" 5850" );
219
+ led_res->send_delayed_post_response ();
220
+ red_led = 1 ;
221
+ status_ticker.attach_us (blinky, 250000 );
222
+ return ;
223
+ }
224
+ // Wait requested time, then continue prosessing the blink pattern from next position.
225
+ Thread::wait (blink_args->blink_pattern .at (blink_args->position ));
226
+ blink_args->position ++;
222
227
}
223
- // Invoke same function after `delay_ms` (upping position)
224
- Thread::wait (blink_args->blink_pattern .at (blink_args->position ));
225
- blink_args->position ++;
226
- do_blink ();
227
228
}
228
229
};
229
230
You can’t perform that action at this time.
0 commit comments