Is there a way to extend the HardwareSerial class? It appears it is initialized in the main arduino code and if I try to extend it I get a message stating there is no constructor for HardwareSerial. Since it is not like other Libraries there might just be a trick I am missing.
I am trying to build a class similar to...
public class MyClass : public HardwareSerial
{
private:
HardwareSerial* _serial;
public:
MyClass(HardwareSerial* serial);
...
My functions that also need to use the _serial object like print, println, etc...
...
};
When I make a constructor for myClass i get the error message HardwareSerial does not have a constructor.
I am using this on an custom board with a ATMEGA2560. Depending on if the board is controlled via a radio or a direct link to a raspberry pi determines at runtime which serial port gets used for sensor and control data. I am using of json data from the arduino and have several functions that send data. I could add a HardwareSerial *_serial in each function definition but that is not very elegant.
Is there a solution or would I have to manually extract HardwareSerial from the core and paste something together? I have searched google and even github hoping to find some examples/solutions but so far I have had no luck.