Fork of the espurna firmware for `mhsw` switches
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.5 KiB

  1. /**
  2. StreamString.cpp
  3. Copyright (c) 2015 Markus Sattler. All rights reserved.
  4. This file is part of the esp8266 core for Arduino environment.
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with this library; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  16. */
  17. #include <Arduino.h>
  18. #include "StreamString.h"
  19. size_t StreamString::write(const uint8_t *data, size_t size) {
  20. if (!size || !data) return 0;
  21. copy((const char*)data, size + 1);
  22. return size;
  23. }
  24. size_t StreamString::write(uint8_t data) {
  25. return concat((char) data);
  26. }
  27. int StreamString::available() {
  28. return length();
  29. }
  30. int StreamString::read() {
  31. if(length()) {
  32. char c = charAt(0);
  33. remove(0, 1);
  34. return c;
  35. }
  36. return -1;
  37. }
  38. int StreamString::peek() {
  39. if(length()) {
  40. char c = charAt(0);
  41. return c;
  42. }
  43. return -1;
  44. }
  45. void StreamString::flush() {
  46. }