File tree Expand file tree Collapse file tree 3 files changed +8
-3
lines changed
Expand file tree Collapse file tree 3 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ class Device {
2323 void initializeAsRoot () { initialize (ArrayList<String>()); }
2424 virtual T read () { return T (); }
2525 virtual void write (const T &payload) {}
26- virtual void update (T data) {}
26+ virtual void update (const T & data) {}
2727 virtual void close () {}
2828};
2929
Original file line number Diff line number Diff line change @@ -24,12 +24,16 @@ String Peer::read() {
2424 return " " ;
2525}
2626void Peer::write (const String &payload) { Serial.print (payload + _separator); }
27+ void Peer::update (const String &data) {
28+ for (Device<String> d: _devices)
29+ if (data.startsWith (d.tag () + " :" ))
30+ d.update (data.substring (d.tag ().length () + 1 ));
31+ }
2732void Peer::refresh () {
2833 String msg = read ();
2934 if (msg == " " )
3035 return ;
3136 if (msg == " ic" )
3237 return write (_tag);
33- for (Device<String> d: _devices)
34- d.update (msg);
38+ update (msg);
3539}
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ class Peer : public Controller<String, String> {
1515 void initialize (const ArrayList<String> &parentTags) override ;
1616 String read () override ;
1717 void write (const String &payload) override ;
18+ void update (const String &data) override ;
1819 void refresh ();
1920};
2021
You can’t perform that action at this time.
0 commit comments