switch back to returning pointer in findProtocol - only this works with derived classes
This commit is contained in:
parent
f668beeca2
commit
c2395e8bde
@ -31,16 +31,16 @@ void setup() {
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
Protocol& findProtocol(unsigned int protocol) {
|
||||
Protocol* findProtocol(unsigned int protocol) {
|
||||
switch (protocol) {
|
||||
case PROTOCOL_1:
|
||||
return protocol1;
|
||||
return &protocol1;
|
||||
case PROTOCOL_2:
|
||||
return protocol2;
|
||||
return &protocol2;
|
||||
case PROTOCOL_13:
|
||||
return doorbell;
|
||||
return &doorbell;
|
||||
default:
|
||||
return fallbackProtocol.setProtocol(protocol);
|
||||
return &fallbackProtocol.setProtocol(protocol);
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ void readRcSwitch() {
|
||||
|
||||
StaticJsonDocument<128> jsonDoc;
|
||||
auto p = findProtocol(mySwitch.getReceivedProtocol());
|
||||
p.toJson(value, jsonDoc);
|
||||
p->toJson(value, jsonDoc);
|
||||
if (!jsonDoc.isNull()) {
|
||||
serializeJson(jsonDoc, Serial);
|
||||
Serial.println();
|
||||
@ -84,7 +84,7 @@ void runJsonCommand(char* cmd) {
|
||||
if (jsonDoc.containsKey("rcSwitch")) {
|
||||
JsonObjectConst rcSwitch = jsonDoc["rcSwitch"];
|
||||
auto p = findProtocol(rcSwitch["protocol"]);
|
||||
p.fromJson(rcSwitch, mySwitch);
|
||||
p->fromJson(rcSwitch, mySwitch);
|
||||
serializeJson(jsonDoc, Serial);
|
||||
Serial.println();
|
||||
Board::publishResponse(jsonDoc);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user