Skip to content

Commit 03740b2

Browse files
committed
Merge branch 'kolaf-development' into development
2 parents 8ec2ebd + db73e3c commit 03740b2

File tree

8 files changed

+1776
-4
lines changed

8 files changed

+1776
-4
lines changed

libraries/MySensors/MyConfig.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@
66
*/
77

88
// pick ONE of these - other board layouts can be easily added this way
9-
#define MYSENSORS_SENSOR
10-
//#define MYSENSORS_SERIAL_GATEWAY
9+
// #define MYSENSORS_SENSOR
10+
#define MYSENSORS_SERIAL_GATEWAY
1111
//#define MYSENSORS_ETHERNET_MQTT_GATEWAY
1212

1313
// Choose radio type by enabling one of the following
14-
#define MYSENSORS_RF_NRF24
14+
//#define MYSENSORS_RF_NRF24
15+
#define MYSENSORS_RF_RF69
16+
17+
1518

1619

1720

@@ -20,6 +23,11 @@
2023
typedef class MyDriverNRF24 MyDriverClass;
2124
#endif
2225

26+
#ifdef MYSENSORS_RF_RF69
27+
#include "MyDriverRF69.h"
28+
typedef class MyDriverRF69 MyDriverClass;
29+
#endif
30+
2331
/***
2432
* Enable/Disable debug logging
2533
*/

libraries/MySensors/MyDriverNRF24.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ void MyDriverNRF24::init() {
1515
}
1616
rf24->setAutoAck(1);
1717
rf24->setAutoAck(BROADCAST_PIPE,false); // Turn off auto ack for broadcast
18-
rf24->enableAckPayload();
1918
rf24->setChannel(RF24_CHANNEL);
2019
rf24->setPALevel(RF24_PA_LEVEL);
2120
rf24->setDataRate(RF24_DATARATE);
2221
rf24->setRetries(5,15);
2322
rf24->setCRCLength(RF24_CRC_16);
2423
rf24->enableDynamicPayloads();
24+
rf24->enableDynamicAck();
2525

2626
// All nodes listen to broadcast pipe (for FIND_PARENT_RESPONSE messages)
2727
rf24->openReadingPipe(BROADCAST_PIPE, TO_ADDR(BROADCAST_ADDRESS));

libraries/MySensors/MyDriverRF69.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#include <RHReliableDatagram.h>
2+
#include "MyDriver.h"
3+
#include "MyDriverRF69.h"
4+
5+
MyDriverRF69::MyDriverRF69() : MyDriver() {
6+
radio = new RFM69();
7+
}
8+
9+
void MyDriverRF69::init() {
10+
// Start up the radio library
11+
radio->initialize(FREQUENCY,_address,NETWORKID);
12+
#ifdef IS_RFM69HW
13+
radio->setHighPower(); //uncomment only for RFM69HW!
14+
#endif
15+
// radio->encrypt(ENCRYPTKEY);
16+
17+
}
18+
19+
void MyDriverRF69::setAddress(uint8_t address) {
20+
_address = address;
21+
radio->setAddress(address);
22+
}
23+
24+
uint8_t MyDriverRF69::getAddress() {
25+
return _address;
26+
}
27+
28+
bool MyDriverRF69::send(uint8_t to, const void* data, uint8_t len) {
29+
// Make sure radio has powered up
30+
return radio->sendWithRetry(to,data,len);
31+
}
32+
33+
bool MyDriverRF69::available(uint8_t *to) {
34+
return radio->receiveDone();
35+
}
36+
37+
uint8_t MyDriverRF69::receive(void* data) {
38+
// for (byte i = 0; i < radio->DATALEN; i++){
39+
// data[i]= (void)radio->DATA[i];
40+
// }
41+
memcpy(data,(const void *)radio->DATA, radio->DATALEN);
42+
if (radio->ACKRequested())
43+
{
44+
radio->sendACK();
45+
}
46+
}
47+
48+
void MyDriverRF69::powerDown() {
49+
radio->sleep();
50+
}

libraries/MySensors/MyDriverRF69.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#ifndef MyCommDriver_h
2+
#define MyCommDriver_h
3+
4+
#include "MyConfig.h"
5+
#include "MyDriver.h"
6+
#include <stdint.h>
7+
#include "RFM69.h"
8+
#include <SPI.h>
9+
10+
#define NODEID 2 //unique for each node on same network
11+
#define NETWORKID 100 //the same on all nodes that talk to each other
12+
#define GATEWAYID 1
13+
//Match frequency to the hardware version of the radio on your Moteino (uncomment one):
14+
// #define FREQUENCY RF69_433MHZ
15+
#define FREQUENCY RF69_868MHZ
16+
//#define FREQUENCY RF69_915MHZ
17+
#define ENCRYPTKEY "sampleEncryptKey" //exactly the same 16 characters/bytes on all nodes!
18+
//#define IS_RFM69HW //uncomment only for RFM69HW! Leave out if you have RFM69W!
19+
#define ACK_TIME 30 // max # of ms to wait for an ack
20+
#ifdef __AVR_ATmega1284P__
21+
#define LED 15 // Moteino MEGAs have LEDs on D15
22+
#define FLASH_SS 23 // and FLASH SS on D23
23+
#else
24+
#define LED 9 // Moteinos have LEDs on D9
25+
#define FLASH_SS 8 // and FLASH SS on D8
26+
#endif
27+
28+
class MyDriverRF69 : public MyDriver
29+
{
30+
public:
31+
MyDriverRF69();
32+
void init();
33+
void setAddress(uint8_t address);
34+
uint8_t getAddress();
35+
bool send(uint8_t to, const void* data, uint8_t len);
36+
bool available(uint8_t *to);
37+
uint8_t receive(void* data);
38+
void powerDown();
39+
private:
40+
RFM69 *radio = NULL;
41+
uint8_t _address;
42+
};
43+
44+
#endif

libraries/MySensors/MySensor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ boolean MySensor::process() {
275275
msg.sender, msg.last, msg.destination, msg.sensor, mGetCommand(msg), msg.type, mGetPayloadType(msg), mGetLength(msg), msg.getString(convBuf));
276276

277277
if(!(mGetVersion(msg) == PROTOCOL_VERSION)) {
278+
debug(PSTR("version: %d\n"),mGetVersion(msg));
278279
debug(PSTR("version mismatch\n"));
279280
return false;
280281
}

0 commit comments

Comments
 (0)