Add begin function to the GatewayTransport class
Signed-off-by: Tomas Hozza <thozza@gmail.com>
This commit is contained in:
@@ -73,6 +73,12 @@ void MyGateway::begin(void (*_msgCallback)(const MyMessage &)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// initialize the transport driver
|
||||
if (!transport.begin()) {
|
||||
debug(PSTR("transport driver init fail\n"));
|
||||
while(1); // Nothing more we can do
|
||||
}
|
||||
|
||||
// Start MySensors in repeater mode
|
||||
MySensor::begin(_msgCallback, GATEWAY_ADDRESS, true, GATEWAY_ADDRESS);
|
||||
|
||||
|
||||
@@ -30,6 +30,9 @@ public:
|
||||
// MyProtocol constructor
|
||||
MyGatewayTransport(MyProtocol &protocol = *new MyProtocolDefault());
|
||||
|
||||
// initialize the transport driver
|
||||
virtual bool begin() = 0;
|
||||
|
||||
// Send message to controller
|
||||
virtual bool send(MyMessage &message) = 0;
|
||||
|
||||
|
||||
@@ -25,6 +25,10 @@ MyGatewayTransportSerial::MyGatewayTransportSerial(MyProtocol &_protocol) : MyGa
|
||||
|
||||
}
|
||||
|
||||
bool MyGatewayTransportSerial::begin() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MyGatewayTransportSerial::send(MyMessage &message) {
|
||||
Serial.print(protocol.format(message));
|
||||
// Serial print is always successful
|
||||
|
||||
@@ -33,6 +33,9 @@ public:
|
||||
// MyGateway constructor
|
||||
MyGatewayTransportSerial(MyProtocol &protocol = *new MyProtocolDefault());
|
||||
|
||||
// initialize the transport driver
|
||||
bool begin();
|
||||
|
||||
// Send message to controller
|
||||
bool send(MyMessage &message);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user