To give some context as to what I’m doing (if anyone’s interested I’ll publish all the code), I am writing a command line server for Arduino. This basically works as type thing and designed to establish a generic method for passing info in and out of a running arduino primarily via telnet but should work under serial too for debgugging.
I have this largely working for either Serial and over the network however what I would LOVE to do in order to either thin down my code or not have to maintain two libraries is to make Serial.print / println and Client.print / println totally interchangeable.
What I’d like to do is when I start up my CommandServer object it should take in a parameter which determines whether to use Serial.print() or Client.Print() (and ideally a reference to either one) and then in all of my functions I use this reference.
Serial and Client print functions are identical in function so for what I’m doing they are totally interchangeable so I’d like to be able to just use the defined one in all the functions which will then make that a lot more maintainable.
If anyone can give me any pointers or something in this respect I’d be greatly appreciated.