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 {
23
23
void initializeAsRoot () { initialize (ArrayList<String>()); }
24
24
virtual T read () { return T (); }
25
25
virtual void write (const T &payload) {}
26
- virtual void update (T data) {}
26
+ virtual void update (const T & data) {}
27
27
virtual void close () {}
28
28
};
29
29
Original file line number Diff line number Diff line change @@ -24,12 +24,16 @@ String Peer::read() {
24
24
return " " ;
25
25
}
26
26
void 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
+ }
27
32
void Peer::refresh () {
28
33
String msg = read ();
29
34
if (msg == " " )
30
35
return ;
31
36
if (msg == " ic" )
32
37
return write (_tag);
33
- for (Device<String> d: _devices)
34
- d.update (msg);
38
+ update (msg);
35
39
}
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ class Peer : public Controller<String, String> {
15
15
void initialize (const ArrayList<String> &parentTags) override ;
16
16
String read () override ;
17
17
void write (const String &payload) override ;
18
+ void update (const String &data) override ;
18
19
void refresh ();
19
20
};
20
21
You can’t perform that action at this time.
0 commit comments