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
|
||||||
#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
|
// Start MySensors in repeater mode
|
||||||
MySensor::begin(_msgCallback, GATEWAY_ADDRESS, true, GATEWAY_ADDRESS);
|
MySensor::begin(_msgCallback, GATEWAY_ADDRESS, true, GATEWAY_ADDRESS);
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ public:
|
|||||||
// MyProtocol constructor
|
// MyProtocol constructor
|
||||||
MyGatewayTransport(MyProtocol &protocol = *new MyProtocolDefault());
|
MyGatewayTransport(MyProtocol &protocol = *new MyProtocolDefault());
|
||||||
|
|
||||||
|
// initialize the transport driver
|
||||||
|
virtual bool begin() = 0;
|
||||||
|
|
||||||
// Send message to controller
|
// Send message to controller
|
||||||
virtual bool send(MyMessage &message) = 0;
|
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) {
|
bool MyGatewayTransportSerial::send(MyMessage &message) {
|
||||||
Serial.print(protocol.format(message));
|
Serial.print(protocol.format(message));
|
||||||
// Serial print is always successful
|
// Serial print is always successful
|
||||||
|
|||||||
@@ -33,6 +33,9 @@ public:
|
|||||||
// MyGateway constructor
|
// MyGateway constructor
|
||||||
MyGatewayTransportSerial(MyProtocol &protocol = *new MyProtocolDefault());
|
MyGatewayTransportSerial(MyProtocol &protocol = *new MyProtocolDefault());
|
||||||
|
|
||||||
|
// initialize the transport driver
|
||||||
|
bool begin();
|
||||||
|
|
||||||
// Send message to controller
|
// Send message to controller
|
||||||
bool send(MyMessage &message);
|
bool send(MyMessage &message);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user