Rename RFDriver to Transport
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#include "MyParser.h"
|
||||
#include "MyParserSerial.h"
|
||||
#include "MyRFDriver.h"
|
||||
#include "MyTransport.h"
|
||||
|
||||
MyParserSerial::MyParserSerial() : MyParser() {}
|
||||
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
#include "MyRFDriver.h"
|
||||
|
||||
MyRFDriver::MyRFDriver() {
|
||||
}
|
||||
@@ -37,7 +37,7 @@ static inline bool isValidDistance( const uint8_t distance ) {
|
||||
return distance != DISTANCE_INVALID;
|
||||
}
|
||||
|
||||
MySensor::MySensor(MyRFDriver &_radio, MySigningDriver &_signer)
|
||||
MySensor::MySensor(MyTransport &_radio, MySigningDriver &_signer)
|
||||
:
|
||||
radio(_radio),
|
||||
signer(_signer)
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
#define MySensor_h
|
||||
|
||||
#include "Version.h" // Auto generated by bot
|
||||
#include "MyRFDriver.h"
|
||||
#include "MyRFDriverNRF24.h"
|
||||
#include "MyTransport.h"
|
||||
#include "MyTransportNRF24.h"
|
||||
#include "MyParser.h"
|
||||
#include "MySigningDriver.h"
|
||||
#include "MySigningDriverNone.h"
|
||||
@@ -81,7 +81,7 @@ class MySensor
|
||||
* Creates a new instance of Sensor class.
|
||||
*
|
||||
*/
|
||||
MySensor(MyRFDriver &radio =*new MyRFDriverNRF24(), MySigningDriver &signer=*new MySigningDriverNone());
|
||||
MySensor(MyTransport &radio =*new MyTransportNRF24(), MySigningDriver &signer=*new MySigningDriverNone());
|
||||
|
||||
/**
|
||||
* Begin operation of the MySensors library
|
||||
@@ -249,7 +249,7 @@ class MySensor
|
||||
MyMessage tmpMsg ; // Buffer for temporary messages (acks and nonces among others).
|
||||
MyMessage msgSign; // Buffer for message to sign.
|
||||
|
||||
MyRFDriver& radio;
|
||||
MyTransport& radio;
|
||||
MySigningDriver& signer;
|
||||
|
||||
void setupRepeaterMode();
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
#include "MyTransport.h"
|
||||
|
||||
MyTransport::MyTransport() {
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef MyRFDriver_h
|
||||
#define MyRFDriver_h
|
||||
#ifndef MyTransport_h
|
||||
#define MyTransport_h
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
#define GATEWAY_ADDRESS ((uint8_t)0)
|
||||
#define BROADCAST_ADDRESS ((uint8_t)0xFF)
|
||||
|
||||
class MyRFDriver
|
||||
class MyTransport
|
||||
{
|
||||
public:
|
||||
// MyRFDriver constructor
|
||||
// MyTransport constructor
|
||||
// different parameters would be needed depending on radio module (e.g. pins connected etc.)
|
||||
// keeping these parameters as #define's in MyConfig to streamline the driver interface
|
||||
MyRFDriver();
|
||||
MyTransport();
|
||||
// init()
|
||||
// different parameters would be needed depending on radio module (e.g. channel, power, crc, etc.)
|
||||
// keeping these parameters as #define's in MyConfig to streamline the driver interface
|
||||
+11
-11
@@ -1,15 +1,15 @@
|
||||
#include "MyRFDriver.h"
|
||||
#include "MyRFDriverNRF24.h"
|
||||
#include "MyTransport.h"
|
||||
#include "MyTransportNRF24.h"
|
||||
|
||||
MyRFDriverNRF24::MyRFDriverNRF24(uint8_t ce, uint8_t cs, uint8_t paLevel)
|
||||
MyTransportNRF24::MyTransportNRF24(uint8_t ce, uint8_t cs, uint8_t paLevel)
|
||||
:
|
||||
MyRFDriver(),
|
||||
MyTransport(),
|
||||
rf24(ce, cs),
|
||||
_paLevel(paLevel)
|
||||
{
|
||||
}
|
||||
|
||||
void MyRFDriverNRF24::init() {
|
||||
void MyTransportNRF24::init() {
|
||||
// Start up the radio library
|
||||
rf24.begin();
|
||||
|
||||
@@ -31,18 +31,18 @@ void MyRFDriverNRF24::init() {
|
||||
rf24.openReadingPipe(BROADCAST_PIPE, TO_ADDR(BROADCAST_ADDRESS));
|
||||
}
|
||||
|
||||
void MyRFDriverNRF24::setAddress(uint8_t address) {
|
||||
void MyTransportNRF24::setAddress(uint8_t address) {
|
||||
_address = address;
|
||||
rf24.openReadingPipe(WRITE_PIPE, TO_ADDR(address));
|
||||
rf24.openReadingPipe(CURRENT_NODE_PIPE, TO_ADDR(address));
|
||||
rf24.startListening();
|
||||
}
|
||||
|
||||
uint8_t MyRFDriverNRF24::getAddress() {
|
||||
uint8_t MyTransportNRF24::getAddress() {
|
||||
return _address;
|
||||
}
|
||||
|
||||
bool MyRFDriverNRF24::send(uint8_t to, const void* data, uint8_t len) {
|
||||
bool MyTransportNRF24::send(uint8_t to, const void* data, uint8_t len) {
|
||||
// Make sure radio has powered up
|
||||
rf24.powerUp();
|
||||
rf24.stopListening();
|
||||
@@ -52,7 +52,7 @@ bool MyRFDriverNRF24::send(uint8_t to, const void* data, uint8_t len) {
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool MyRFDriverNRF24::available(uint8_t *to) {
|
||||
bool MyTransportNRF24::available(uint8_t *to) {
|
||||
uint8_t pipe = 255;
|
||||
boolean avail = rf24.available(&pipe);
|
||||
if (pipe == CURRENT_NODE_PIPE)
|
||||
@@ -62,12 +62,12 @@ bool MyRFDriverNRF24::available(uint8_t *to) {
|
||||
return (rf24.available() && pipe < 6);
|
||||
}
|
||||
|
||||
uint8_t MyRFDriverNRF24::receive(void* data) {
|
||||
uint8_t MyTransportNRF24::receive(void* data) {
|
||||
uint8_t len = rf24.getDynamicPayloadSize();
|
||||
rf24.read(data, len);
|
||||
return len;
|
||||
}
|
||||
|
||||
void MyRFDriverNRF24::powerDown() {
|
||||
void MyTransportNRF24::powerDown() {
|
||||
rf24.powerDown();
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
#ifndef MyRFDriverNRF24_h
|
||||
#define MyRFDriverNRF24_h
|
||||
#ifndef MyTransportNRF24_h
|
||||
#define MyTransportNRF24_h
|
||||
|
||||
#include "MyConfig.h"
|
||||
#include "MyRFDriver.h"
|
||||
#include "MyTransport.h"
|
||||
#include <stdint.h>
|
||||
#include "utility/RF24.h"
|
||||
#include "utility/RF24_config.h"
|
||||
@@ -13,10 +13,10 @@
|
||||
#define CURRENT_NODE_PIPE ((uint8_t)1)
|
||||
#define BROADCAST_PIPE ((uint8_t)2)
|
||||
|
||||
class MyRFDriverNRF24 : public MyRFDriver
|
||||
class MyTransportNRF24 : public MyTransport
|
||||
{
|
||||
public:
|
||||
MyRFDriverNRF24(uint8_t ce=RF24_CE_PIN, uint8_t cs=RF24_CS_PIN, uint8_t paLevel=RF24_PA_LEVEL);
|
||||
MyTransportNRF24(uint8_t ce=RF24_CE_PIN, uint8_t cs=RF24_CS_PIN, uint8_t paLevel=RF24_PA_LEVEL);
|
||||
void init();
|
||||
void setAddress(uint8_t address);
|
||||
uint8_t getAddress();
|
||||
@@ -1,14 +1,14 @@
|
||||
#include "MyRFDriver.h"
|
||||
#include "MyRFDriverRF69.h"
|
||||
#include "MyTransport.h"
|
||||
#include "MyTransportRF69.h"
|
||||
|
||||
MyRFDriverRF69::MyRFDriverRF69()
|
||||
MyTransportRF69::MyTransportRF69()
|
||||
:
|
||||
MyRFDriver(),
|
||||
MyTransport(),
|
||||
radio()
|
||||
{
|
||||
}
|
||||
|
||||
void MyRFDriverRF69::init() {
|
||||
void MyTransportRF69::init() {
|
||||
// Start up the radio library
|
||||
radio->initialize(FREQUENCY,_address,NETWORKID);
|
||||
#ifdef IS_RFM69HW
|
||||
@@ -18,21 +18,21 @@ void MyRFDriverRF69::init() {
|
||||
|
||||
}
|
||||
|
||||
void MyRFDriverRF69::setAddress(uint8_t address) {
|
||||
void MyTransportRF69::setAddress(uint8_t address) {
|
||||
_address = address;
|
||||
radio->setAddress(address);
|
||||
}
|
||||
|
||||
uint8_t MyRFDriverRF69::getAddress() {
|
||||
uint8_t MyTransportRF69::getAddress() {
|
||||
return _address;
|
||||
}
|
||||
|
||||
bool MyRFDriverRF69::send(uint8_t to, const void* data, uint8_t len) {
|
||||
bool MyTransportRF69::send(uint8_t to, const void* data, uint8_t len) {
|
||||
// Make sure radio has powered up
|
||||
return radio->sendWithRetry(to,data,len);
|
||||
}
|
||||
|
||||
bool MyRFDriverRF69::available(uint8_t *to) {
|
||||
bool MyTransportRF69::available(uint8_t *to) {
|
||||
if (radio->TARGETID == BROADCAST_ADDRESS)
|
||||
*to = BROADCAST_ADDRESS;
|
||||
else
|
||||
@@ -40,7 +40,7 @@ bool MyRFDriverRF69::available(uint8_t *to) {
|
||||
return radio->receiveDone();
|
||||
}
|
||||
|
||||
uint8_t MyRFDriverRF69::receive(void* data) {
|
||||
uint8_t MyTransportRF69::receive(void* data) {
|
||||
// for (byte i = 0; i < radio->DATALEN; i++){
|
||||
// data[i]= (void)radio->DATA[i];
|
||||
// }
|
||||
@@ -52,6 +52,6 @@ uint8_t MyRFDriverRF69::receive(void* data) {
|
||||
return radio->DATALEN;
|
||||
}
|
||||
|
||||
void MyRFDriverRF69::powerDown() {
|
||||
void MyTransportRF69::powerDown() {
|
||||
radio->sleep();
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
#ifndef MyRFDriverRF69_h
|
||||
#define MyRFDriverRF69_h
|
||||
#ifndef MyTransportRF69_h
|
||||
#define MyTransportRF69_h
|
||||
|
||||
#include "MyConfig.h"
|
||||
#include "MyRFDriver.h"
|
||||
#include "MyTransport.h"
|
||||
#include <stdint.h>
|
||||
#include "utility/RFM69.h"
|
||||
#include <SPI.h>
|
||||
@@ -25,10 +25,10 @@
|
||||
#define FLASH_SS 8 // and FLASH SS on D8
|
||||
#endif
|
||||
|
||||
class MyRFDriverRF69 : public MyRFDriver
|
||||
class MyTransportRF69 : public MyTransport
|
||||
{
|
||||
public:
|
||||
MyRFDriverRF69();
|
||||
MyTransportRF69();
|
||||
void init();
|
||||
void setAddress(uint8_t address);
|
||||
uint8_t getAddress();
|
||||
@@ -44,7 +44,7 @@
|
||||
#include <SPI.h>
|
||||
|
||||
#include <MySigningDriverNone.h>
|
||||
#include <MyRFDriverNRF24.h>
|
||||
#include <MyTransportNRF24.h>
|
||||
#include <MyParserSerial.h>
|
||||
#include <MySensor.h>
|
||||
#include <stdarg.h>
|
||||
@@ -72,7 +72,7 @@
|
||||
|
||||
|
||||
// NRFRF24L01 radio driver (set low transmit power by default)
|
||||
MyRFDriverNRF24 radio(RF24_CE_PIN, RF24_CS_PIN, RF24_PA_LEVEL_GW);
|
||||
MyTransportNRF24 radio(RF24_CE_PIN, RF24_CS_PIN, RF24_PA_LEVEL_GW);
|
||||
// Message signing driver (none default)
|
||||
MySigningDriverNone signer;
|
||||
// Construct MySensors library
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef __GATEWAYUTIL_H__
|
||||
#define __GATEWAYUTIL_H__
|
||||
|
||||
#include <MyRFDriver.h>
|
||||
#include <MyTransport.h>
|
||||
|
||||
|
||||
#ifdef ARDUINO
|
||||
|
||||
@@ -57,7 +57,7 @@ http://forum.mysensors.org/topic/303/mqtt-broker-gateway
|
||||
*/
|
||||
|
||||
#include <MySigningDriverNone.h>
|
||||
#include <MyRFDriverNRF24.h>
|
||||
#include <MyTransportNRF24.h>
|
||||
#include <SPI.h>
|
||||
#include <MySensor.h>
|
||||
#include <MsTimer2.h>
|
||||
@@ -92,7 +92,7 @@ uint8_t TCP_MAC[] = { 0x02, 0xDE, 0xAD, 0x00, 0x00, 0x42 }; // Mac-address - You
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
// NRFRF24L01 radio driver (set low transmit power by default)
|
||||
MyRFDriverNRF24 radio(RF24_CE_PIN, RF24_CS_PIN, RF24_PA_LEVEL_GW);
|
||||
MyTransportNRF24 radio(RF24_CE_PIN, RF24_CS_PIN, RF24_PA_LEVEL_GW);
|
||||
// Message signing driver (none default)
|
||||
MySigningDriverNone signer;
|
||||
// Construct MySensors library
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// This example will remember lock state even after power failure.
|
||||
|
||||
#include <MySigningDriverAtsha204Soft.h>
|
||||
#include <MyRFDriverNRF24.h>
|
||||
#include <MyTransportNRF24.h>
|
||||
#include <MySensor.h>
|
||||
#include <SPI.h>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#define LOCK_LOCK 1 // GPIO value to write to lock attached lock
|
||||
#define LOCK_UNLOCK 0 // GPIO value to write to unlock attached lock
|
||||
|
||||
MyRFDriverNRF24 radio; // NRFRF24L01 radio driver
|
||||
MyTransportNRF24 radio; // NRFRF24L01 radio driver
|
||||
MySigningDriverAtsha204Soft signer; // Message signing driver
|
||||
MySensor gw(radio, signer);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef __GATEWAYUTIL_H__
|
||||
#define __GATEWAYUTIL_H__
|
||||
|
||||
#include <MyRFDriver.h>
|
||||
#include <MyTransport.h>
|
||||
|
||||
|
||||
#ifdef ARDUINO
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#define NO_PORTB_PINCHANGES
|
||||
|
||||
#include <MySigningDriverNone.h>
|
||||
#include <MyRFDriverNRF24.h>
|
||||
#include <MyTransportNRF24.h>
|
||||
#include <SPI.h>
|
||||
#include <MyParserSerial.h>
|
||||
#include <MySensor.h>
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
|
||||
// NRFRF24L01 radio driver (set low transmit power by default)
|
||||
MyRFDriverNRF24 radio(RF24_CE_PIN, RF24_CS_PIN, RF24_PA_LEVEL_GW);
|
||||
MyTransportNRF24 radio(RF24_CE_PIN, RF24_CS_PIN, RF24_PA_LEVEL_GW);
|
||||
// Message signing driver (none default)
|
||||
MySigningDriverNone signer;
|
||||
// Construct MySensors library
|
||||
|
||||
Reference in New Issue
Block a user