File tree Expand file tree Collapse file tree 3 files changed +88
-0
lines changed Expand file tree Collapse file tree 3 files changed +88
-0
lines changed Original file line number Diff line number Diff line change 12
12
13
13
// Choose radio type by enabling one of the following
14
14
#define MYSENSORS_RF_NRF24
15
+ #define MYSENSORS_RF_RF69
16
+
17
+
15
18
16
19
17
20
20
23
typedef class MyDriverNRF24 MyDriverClass ;
21
24
#endif
22
25
26
+ #ifdef MYSENSORS_RF_RF69
27
+ #include "MyDriverRF69.h"
28
+ typedef class MyDriverRF69 MyDriverClass ;
29
+ #endif
30
+
23
31
/***
24
32
* Enable/Disable debug logging
25
33
*/
Original file line number Diff line number Diff line change
1
+ #include " MyDriver.h"
2
+ #include " MyDriverRF69.h"
3
+
4
+ MyDriverRF69::MyDriverRF69 () : MyDriver() {
5
+ driver = new RH_RF69 (RF69_CS_PIN, RF69_INTERRUPT_PIN);
6
+ }
7
+
8
+ void MyDriverRF69::init () {
9
+ // Start up the radio library
10
+ manager = new RHReliableDatagram (*driver, _address);
11
+ driver->setFrequency (RF69_FREQUENCY);
12
+ driver->setTxPower (RF69_TRANSMIT_POWER)
13
+
14
+ }
15
+
16
+ void MyDriverRF69::setAddress (uint8_t address) {
17
+ _address = address;
18
+ manager->setThisAddress (_address);
19
+ }
20
+
21
+ uint8_t MyDriverRF69::getAddress () {
22
+ return _address;
23
+ }
24
+
25
+ bool MyDriverRF69::send (uint8_t to, const void * data, uint8_t len) {
26
+ // Make sure radio has powered up
27
+ uint8_t status = manager->sendtoWait ((uint8_t *) data, len, to);
28
+ if (status==RH_ROUTER_ERROR_NONE) {
29
+ return true ;
30
+ } else {
31
+ return false ;
32
+ }
33
+ }
34
+
35
+ bool MyDriverRF69::available (uint8_t *to) {
36
+ return manager->available ();
37
+ }
38
+
39
+ uint8_t MyDriverRF69::receive (void * data) {
40
+ uint8_t len = 256 ;
41
+ uint8_t from;
42
+ manager->recvfromAck ((uint8_t *) data, &len, &from);
43
+ }
44
+
45
+ void MyDriverRF69::powerDown () {
46
+ driver->sleep ();
47
+ }
Original file line number Diff line number Diff line change
1
+ #ifndef MyCommDriver_h
2
+ #define MyCommDriver_h
3
+
4
+ #include " MyConfig.h"
5
+ #include " MyDriver.h"
6
+ #include < stdint.h>
7
+ #include < RH_RF69.h>
8
+ #include < RHReliableDatagram.h>
9
+
10
+ #define RF69_FREQUENCY 868 ;
11
+ #define RF69_TRANSMIT_POWER 14 ;
12
+ #define RF69_MODEM_CONFIG RH_RF69::GFSK_Rb250Fd250;
13
+ #define RF69_INTERRUPT_PIN 2 ;
14
+ #define RF69_CS_PIN 10 ;
15
+
16
+ class MyDriverRF69 : public MyDriver
17
+ {
18
+ public:
19
+ MyDriverRF69 ();
20
+ void init ();
21
+ void setAddress (uint8_t address);
22
+ uint8_t getAddress ();
23
+ bool send (uint8_t to, const void * data, uint8_t len);
24
+ bool available (uint8_t *to);
25
+ uint8_t receive (void * data);
26
+ void powerDown ();
27
+ private:
28
+ RH_RF69 *driver = NULL ;
29
+ RHReliableDatagram *manager = NULL ;
30
+ uint8_t _address;
31
+ };
32
+
33
+ #endif
You can’t perform that action at this time.
0 commit comments