I need to write an arduino library that can be instanciated multiple times, with different hardware serial ports as targets.
I've seen that libraries that are receive-only like TinyGPS go around the complexity by letting you handle the serial port in your main sketch and just expect you to push received chars to it. Mine however need to both read and write to the port, so that approach doesn't work, or it would be somewhat dirty to implement a function to get any pending bytes form the library and send them in the main sketch.
What would be the correct way to tell the port I want to use to the constructor of the class in my library?
I've seen that libraries that are receive-only like TinyGPS go around the complexity by letting you handle the serial port in your main sketch and just expect you to push received chars to it. Mine however need to both read and write to the port, so that approach doesn't work, or it would be somewhat dirty to implement a function to get any pending bytes form the library and send them in the main sketch.
What would be the correct way to tell the port I want to use to the constructor of the class in my library?