Skip to content

Commit d9ffd61

Browse files
committed
Merge pull request arduino#42 from fallberg/development
MyDriver structure renamed to MyRFDriver
2 parents f1f8aec + 7d37cd9 commit d9ffd61

File tree

12 files changed

+59
-59
lines changed

12 files changed

+59
-59
lines changed

libraries/MySensors/MyConfig.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919

2020

2121
#ifdef MYSENSORS_RF_NRF24
22-
#include "MyDriverNRF24.h"
23-
typedef class MyDriverNRF24 MyDriverClass;
22+
#include "MyRFDriverNRF24.h"
23+
typedef class MyRFDriverNRF24 MyRFDriverClass;
2424
#endif
2525

2626
#ifdef MYSENSORS_RF_RF69
27-
#include "MyDriverRF69.h"
28-
typedef class MyDriverRF69 MyDriverClass;
27+
#include "MyRFDriverRF69.h"
28+
typedef class MyRFDriverRF69 MyRFDriverClass;
2929
#endif
3030

3131
/***

libraries/MySensors/MyDriver.cpp

Lines changed: 0 additions & 4 deletions
This file was deleted.

libraries/MySensors/MyRFDriver.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#include "MyRFDriver.h"
2+
3+
MyRFDriver::MyRFDriver() {
4+
}

libraries/MySensors/MyDriver.h renamed to libraries/MySensors/MyRFDriver.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef MyDriver_h
2-
#define MyDriver_h
1+
#ifndef MyRFDriver_h
2+
#define MyRFDriver_h
33

44
#include <stdint.h>
55

@@ -16,13 +16,13 @@
1616
#define GATEWAY_ADDRESS ((uint8_t)0)
1717
#define BROADCAST_ADDRESS ((uint8_t)0xFF)
1818

19-
class MyDriver
19+
class MyRFDriver
2020
{
2121
public:
22-
// MyDriver constructor
22+
// MyRFDriver constructor
2323
// different parameters would be needed depending on radio module (e.g. pins connected etc.)
2424
// keeping these parameters as #define's in MyConfig to streamline the driver interface
25-
MyDriver();
25+
MyRFDriver();
2626
// init()
2727
// different parameters would be needed depending on radio module (e.g. channel, power, crc, etc.)
2828
// keeping these parameters as #define's in MyConfig to streamline the driver interface

libraries/MySensors/MyDriverNRF24.cpp renamed to libraries/MySensors/MyRFDriverNRF24.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
#include "MyDriver.h"
2-
#include "MyDriverNRF24.h"
1+
#include "MyRFDriver.h"
2+
#include "MyRFDriverNRF24.h"
33

4-
MyDriverNRF24::MyDriverNRF24() : MyDriver() {
4+
MyRFDriverNRF24::MyRFDriverNRF24() : MyRFDriver() {
55
rf24 = new RF24(RF24_CE_PIN, RF24_CS_PIN);
66
}
77

8-
void MyDriverNRF24::init() {
8+
void MyRFDriverNRF24::init() {
99
// Start up the radio library
1010
rf24->begin();
1111

@@ -27,18 +27,18 @@ void MyDriverNRF24::init() {
2727
rf24->openReadingPipe(BROADCAST_PIPE, TO_ADDR(BROADCAST_ADDRESS));
2828
}
2929

30-
void MyDriverNRF24::setAddress(uint8_t address) {
30+
void MyRFDriverNRF24::setAddress(uint8_t address) {
3131
_address = address;
3232
rf24->openReadingPipe(WRITE_PIPE, TO_ADDR(address));
3333
rf24->openReadingPipe(CURRENT_NODE_PIPE, TO_ADDR(address));
3434
rf24->startListening();
3535
}
3636

37-
uint8_t MyDriverNRF24::getAddress() {
37+
uint8_t MyRFDriverNRF24::getAddress() {
3838
return _address;
3939
}
4040

41-
bool MyDriverNRF24::send(uint8_t to, const void* data, uint8_t len) {
41+
bool MyRFDriverNRF24::send(uint8_t to, const void* data, uint8_t len) {
4242
// Make sure radio has powered up
4343
rf24->powerUp();
4444
rf24->stopListening();
@@ -48,7 +48,7 @@ bool MyDriverNRF24::send(uint8_t to, const void* data, uint8_t len) {
4848
return ok;
4949
}
5050

51-
bool MyDriverNRF24::available(uint8_t *to) {
51+
bool MyRFDriverNRF24::available(uint8_t *to) {
5252
uint8_t pipe = 255;
5353
boolean avail = rf24->available(&pipe);
5454
if (pipe == CURRENT_NODE_PIPE)
@@ -58,11 +58,11 @@ bool MyDriverNRF24::available(uint8_t *to) {
5858
return (rf24->available() && pipe < 6);
5959
}
6060

61-
uint8_t MyDriverNRF24::receive(void* data) {
61+
uint8_t MyRFDriverNRF24::receive(void* data) {
6262
uint8_t len = rf24->getDynamicPayloadSize();
6363
rf24->read(data, len);
6464
}
6565

66-
void MyDriverNRF24::powerDown() {
66+
void MyRFDriverNRF24::powerDown() {
6767
rf24->powerDown();
6868
}

libraries/MySensors/MyDriverNRF24.h renamed to libraries/MySensors/MyRFDriverNRF24.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#ifndef MyCommDriver_h
2-
#define MyCommDriver_h
1+
#ifndef MyRFDriverNRF24_h
2+
#define MyRFDriverNRF24_h
33

44
#include "MyConfig.h"
5-
#include "MyDriver.h"
5+
#include "MyRFDriver.h"
66
#include <stdint.h>
77
#include "utility/RF24.h"
88
#include "utility/RF24_config.h"
@@ -37,10 +37,10 @@
3737
#define CURRENT_NODE_PIPE ((uint8_t)1)
3838
#define BROADCAST_PIPE ((uint8_t)2)
3939

40-
class MyDriverNRF24 : public MyDriver
40+
class MyRFDriverNRF24 : public MyRFDriver
4141
{
4242
public:
43-
MyDriverNRF24();
43+
MyRFDriverNRF24();
4444
void init();
4545
void setAddress(uint8_t address);
4646
uint8_t getAddress();
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
#include "MyDriver.h"
2-
#include "MyDriverRF69.h"
1+
#include "MyRFDriver.h"
2+
#include "MyRFDriverRF69.h"
33

4-
MyDriverRF69::MyDriverRF69() : MyDriver() {
4+
MyRFDriverRF69::MyRFDriverRF69() : MyRFDriver() {
55
radio = new RFM69();
66
}
77

8-
void MyDriverRF69::init() {
8+
void MyRFDriverRF69::init() {
99
// Start up the radio library
1010
radio->initialize(FREQUENCY,_address,NETWORKID);
1111
#ifdef IS_RFM69HW
@@ -15,25 +15,25 @@ void MyDriverRF69::init() {
1515

1616
}
1717

18-
void MyDriverRF69::setAddress(uint8_t address) {
18+
void MyRFDriverRF69::setAddress(uint8_t address) {
1919
_address = address;
2020
radio->setAddress(address);
2121
}
2222

23-
uint8_t MyDriverRF69::getAddress() {
23+
uint8_t MyRFDriverRF69::getAddress() {
2424
return _address;
2525
}
2626

27-
bool MyDriverRF69::send(uint8_t to, const void* data, uint8_t len) {
27+
bool MyRFDriverRF69::send(uint8_t to, const void* data, uint8_t len) {
2828
// Make sure radio has powered up
2929
return radio->sendWithRetry(to,data,len);
3030
}
3131

32-
bool MyDriverRF69::available(uint8_t *to) {
32+
bool MyRFDriverRF69::available(uint8_t *to) {
3333
return radio->receiveDone();
3434
}
3535

36-
uint8_t MyDriverRF69::receive(void* data) {
36+
uint8_t MyRFDriverRF69::receive(void* data) {
3737
// for (byte i = 0; i < radio->DATALEN; i++){
3838
// data[i]= (void)radio->DATA[i];
3939
// }
@@ -44,6 +44,6 @@ uint8_t MyDriverRF69::receive(void* data) {
4444
}
4545
}
4646

47-
void MyDriverRF69::powerDown() {
47+
void MyRFDriverRF69::powerDown() {
4848
radio->sleep();
4949
}

libraries/MySensors/MyDriverRF69.h renamed to libraries/MySensors/MyRFDriverRF69.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#ifndef MyCommDriver_h
2-
#define MyCommDriver_h
1+
#ifndef MyRFDriverRF69_h
2+
#define MyRFDriverRF69_h
33

44
#include "MyConfig.h"
5-
#include "MyDriver.h"
5+
#include "MyRFDriver.h"
66
#include <stdint.h>
77
#include "utility/RFM69.h"
88
#include <SPI.h>
@@ -25,10 +25,10 @@
2525
#define FLASH_SS 8 // and FLASH SS on D8
2626
#endif
2727

28-
class MyDriverRF69 : public MyDriver
28+
class MyRFDriverRF69 : public MyRFDriver
2929
{
3030
public:
31-
MyDriverRF69();
31+
MyRFDriverRF69();
3232
void init();
3333
void setAddress(uint8_t address);
3434
uint8_t getAddress();
@@ -37,7 +37,7 @@ class MyDriverRF69 : public MyDriver
3737
uint8_t receive(void* data);
3838
void powerDown();
3939
private:
40-
RFM69 *radio = NULL;
40+
RFM69 *radio;
4141
uint8_t _address;
4242
};
4343

libraries/MySensors/MySensor.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static inline bool isValidDistance( const uint8_t distance ) {
3434
}
3535

3636
MySensor::MySensor() {
37-
driver = (MyDriver*) new MyDriverClass();
37+
radio = (MyRFDriver*) new MyRFDriverClass();
3838
}
3939

4040

@@ -89,7 +89,7 @@ void MySensor::begin(void (*_msgCallback)(const MyMessage &), uint8_t _nodeId, b
8989
}
9090

9191
// Open reading pipe for messages directed to this node (set write pipe to same)
92-
driver->setAddress(nc.nodeId);
92+
radio->setAddress(nc.nodeId);
9393

9494
// Send presentation for this radio node (attach
9595
present(NODE_SENSOR_ID, repeaterMode? S_ARDUINO_REPEATER_NODE : S_ARDUINO_NODE);
@@ -105,7 +105,7 @@ void MySensor::begin(void (*_msgCallback)(const MyMessage &), uint8_t _nodeId, b
105105

106106
void MySensor::setupRadio() {
107107
failedTransmissions = 0;
108-
driver->init();
108+
radio->init();
109109
}
110110

111111
void MySensor::setupRepeaterMode(){
@@ -124,7 +124,7 @@ ControllerConfig MySensor::getConfig() {
124124

125125
void MySensor::requestNodeId() {
126126
debug(PSTR("req node id\n"));
127-
driver->setAddress(nc.nodeId);
127+
radio->setAddress(nc.nodeId);
128128
sendRoute(build(msg, nc.nodeId, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_ID_REQUEST, false).set(""));
129129
waitForReply();
130130
}
@@ -202,7 +202,7 @@ boolean MySensor::sendWrite(uint8_t next, MyMessage &message, const bool allowFi
202202
uint8_t length = mGetLength(message);
203203
message.last = nc.nodeId;
204204
mSetVersion(message, PROTOCOL_VERSION);
205-
bool ok = driver->send(next, &message, min(MAX_MESSAGE_LENGTH, HEADER_SIZE + length));
205+
bool ok = radio->send(next, &message, min(MAX_MESSAGE_LENGTH, HEADER_SIZE + length));
206206

207207
debug(PSTR("send: %d-%d-%d-%d s=%d,c=%d,t=%d,pt=%d,l=%d,st=%s:%s\n"),
208208
message.sender,message.last, next, message.destination, message.sensor, mGetCommand(message), message.type,
@@ -264,10 +264,10 @@ void MySensor::requestTime(void (* _timeCallback)(unsigned long)) {
264264

265265
boolean MySensor::process() {
266266
uint8_t to = 0;
267-
if (!driver->available(&to))
267+
if (!radio->available(&to))
268268
return false;
269269

270-
uint8_t len = driver->receive((uint8_t *)&msg);
270+
uint8_t len = radio->receive((uint8_t *)&msg);
271271

272272
// Add string termination, good if we later would want to print it.
273273
msg.data[mGetLength(msg)] = '\0';
@@ -351,7 +351,7 @@ boolean MySensor::process() {
351351
debug(PSTR("full\n"));
352352
while (1); // Wait here. Nothing else we can do...
353353
} else {
354-
driver->setAddress(nc.nodeId);
354+
radio->setAddress(nc.nodeId);
355355
eeprom_write_byte((uint8_t*)EEPROM_NODE_ID_ADDRESS, nc.nodeId);
356356
}
357357
debug(PSTR("id=%d\n"), nc.nodeId);
@@ -482,7 +482,7 @@ void MySensor::internalSleep(unsigned long ms) {
482482
void MySensor::sleep(unsigned long ms) {
483483
// Let serial prints finish (debug, log etc)
484484
Serial.flush();
485-
driver->powerDown();
485+
radio->powerDown();
486486
pinIntTrigger = 0;
487487
internalSleep(ms);
488488
}
@@ -491,7 +491,7 @@ bool MySensor::sleep(uint8_t interrupt, uint8_t mode, unsigned long ms) {
491491
// Let serial prints finish (debug, log etc)
492492
bool pinTriggeredWakeup = true;
493493
Serial.flush();
494-
driver->powerDown();
494+
radio->powerDown();
495495
attachInterrupt(interrupt, wakeUp, mode);
496496
if (ms>0) {
497497
pinIntTrigger = 0;
@@ -510,7 +510,7 @@ bool MySensor::sleep(uint8_t interrupt, uint8_t mode, unsigned long ms) {
510510
int8_t MySensor::sleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mode2, unsigned long ms) {
511511
int8_t retVal = 1;
512512
Serial.flush(); // Let serial prints finish (debug, log etc)
513-
driver->powerDown();
513+
radio->powerDown();
514514
attachInterrupt(interrupt1, wakeUp, mode1);
515515
attachInterrupt(interrupt2, wakeUp2, mode2);
516516
if (ms>0) {

libraries/MySensors/MySensor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#define MySensor_h
1414

1515
#include "Version.h" // Auto generated by bot
16-
#include "MyDriver.h"
16+
#include "MyRFDriver.h"
1717
#include "MyConfig.h"
1818
#include "MyMessage.h"
1919
#include <stddef.h>
@@ -232,7 +232,7 @@ class MySensor
232232
MyMessage msg; // Buffer for incoming messages.
233233
MyMessage ack; // Buffer for ack messages.
234234

235-
MyDriver *driver;
235+
MyRFDriver *radio;
236236

237237
void setupRepeaterMode();
238238
void setupRadio();

libraries/MySensors/examples/EthernetGateway/GatewayUtil.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef __GATEWAYUTIL_H__
22
#define __GATEWAYUTIL_H__
33

4-
#include <MyDriver.h>
4+
#include <MyRFDriver.h>
55

66

77
#ifdef ARDUINO

libraries/MySensors/examples/SerialGateway/GatewayUtil.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef __GATEWAYUTIL_H__
22
#define __GATEWAYUTIL_H__
33

4-
#include <MyDriver.h>
4+
#include <MyRFDriver.h>
55

66

77
#ifdef ARDUINO

0 commit comments

Comments
 (0)