Beispiel #1
0
IROM bool LedBlink::dispatch(Msg& msg) {
	PT_BEGIN()
	PT_WAIT_UNTIL(msg.is(0, SIG_INIT));
	init();
	while (true) {
		timeout(_msecInterval);
		PT_YIELD_UNTIL(
				msg.is(_src, SIG_CONNECTED) || msg.is(_src, SIG_DISCONNECTED)
						|| timeout());
		switch (msg.signal()) {
		case SIG_TICK: {
			gpio16_output_set(_isOn);
			_isOn = !_isOn;
			break;
		}
		case SIG_CONNECTED: {
			_msecInterval = 1000;
			break;
		}
		case SIG_DISCONNECTED: {
			_msecInterval = 200;
			break;
		}
		default: {
		}
		}

	}
	PT_END();
	return false;
}