diff --git a/src/CMRI.cpp b/src/CMRI.cpp index e359b1e..a057b3a 100644 --- a/src/CMRI.cpp +++ b/src/CMRI.cpp @@ -61,17 +61,19 @@ void CMRI::set_init_handler(void (*handler)(const uint8_t *, int)) // reads in serial data, decodes packets // automatically responds to POLL requests -// returns packet type so if we got a SET request you know to update your outputs -bool CMRI::process() +// returns the packet type (CMRI::INIT, CMRI::SET or CMRI::POLL) so if we got a +// SET request you know to update your outputs, or NULL if no valid packet was +// received +char CMRI::process() { while (_serial.available() > 0) { if (process_char(_serial.read())) { - return true; + return _rx_packet_type; } } - return false; + return NOOP; } bool CMRI::process_char(char c) diff --git a/src/CMRI.h b/src/CMRI.h index 52b453a..2ad2bb0 100644 --- a/src/CMRI.h +++ b/src/CMRI.h @@ -36,7 +36,7 @@ class CMRI void set_address(unsigned int address); void set_init_handler(void (*handler)(const uint8_t *data, int len)); - bool process(); + char process(); bool process_char(char c); void transmit();