Aypac / Arduino-TR-064-SOAP-Library

Arduino library for the TR-064 protocol, most commonly used by the Fritz!Box router API
Other
63 stars 21 forks source link

Allow user to pass stream object rather than hard-coded "Serial" #8

Open Aypac opened 5 years ago

Aypac commented 5 years ago

From https://www.arduino.cc/en/Reference/APIStyleGuide:

When using serial communication, allow the user to specify any Stream object, rather than hard-coding "Serial". This will make your library compatible all serial ports on Mega and the Due, and can also use alternate interfaces like SoftwareSerial. The Stream object can be passed to your library's constructor or to a begin() function (as a reference, not a pointer). See Firmata 2.3 or XBee 0.4 for examples of each approach.

When writing a library that provides byte-stream communication, inherit Arduino's Stream class, so your library can be used with all other libraries that accept Stream objects. If possible, buffer incoming data, so that read() immediately accesses data the buffer but does not wait for more data to arrive. If possible, your write() method should store data to a transmit buffer, but write() must wait if the buffer does not have enough space to immediately store all outgoing data. The yield() function should be called while waiting.

Here are a few libraries that are exemplary from Adafruit. She breaks the functions of the devices down into their high-level activities really well. https://github.com/adafruit/Adafruit-BMP085-Library https://github.com/adafruit/DHT-sensor-library

Aypac commented 5 years ago

Partially solved with #13

Aypac commented 5 years ago

We should also introduce a debug flag.