Re-organize cpp code to avoid code-duplication for channel A and channel B
This is a suggestion to improve cpp code avoiding a lot of if's to select between channel. One idea would be to organize the code in a way that there is a channel class and it possible to select on constructor if is channel A or channel B, this way the same code could be used by both channels.