Add begin function to the GatewayTransport class

Signed-off-by: Tomas Hozza <thozza@gmail.com>
This commit is contained in:
Tomas Hozza
2015-05-23 21:41:53 +02:00
parent 01d13f0ca4
commit 2bfe5cc650
4 changed files with 16 additions and 0 deletions
+6
View File
@@ -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);
+3
View File
@@ -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);