I'm trying to adapt Arduino's HardwareSerial and Print libraries so they print to my UDP. myudpSerial.print() and .println() work nicely, but calling myupdSerial.write(c) doesn't. Relevant code in Print.h:
class Print:
{
virtual ~Print() {}
virtual size_t write(uint8_t) = 0; // I suspect I have to do something with this
size_t write(const char *str)
{
if(str == NULL) {
return 0;
}
return write((const uint8_t *) str, strlen(str));
}
virtual size_t write(const uint8_t *buffer, size_t size);
size_t write(const char *buffer, size_t size)
{
return write((const uint8_t *) buffer, size);
}
}
My own class looks like this:
class UdpSerial: public HardwareSerial{
using HardwareSerial::HardwareSerial;
public:
size_t write(const uint8_t *buffer, size_t size) override;
//size_t write(uint8_t) override = 0; // I suspect I have to override this
};
That works because the Print class has overloads that all eventually use the write() function. But when I call myupdSerial.write('B');
it tells me
error: no matching fucntion call to 'myudpSerial::write(char&)'
and it suggests size_t write(const uint8_t *buffer, size_t size) override;
as a candidate.
As I commented, I suspect i have to override size_t write(uint8_t) = 0
, but the =0
at the end confuses me and I don't know how to do it, nor what that construction is called so I could google it.
Suggestions are welcome.