From 1499d0daa1f8c65f7af1fefd4efed59eb55ca152 Mon Sep 17 00:00:00 2001 From: GIT Admin Date: Mon, 15 Aug 2022 20:28:34 +0100 Subject: [PATCH] Added rf12_set_sender_id to allow senderID to be switched without having to rf12_initialise again fixed rf12_send_start to allow destId to be set correctly on sending --- RF12.cpp | 12 +++++++++++- RF12.h | 6 +++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/RF12.cpp b/RF12.cpp index add7bc5f..e37047e2 100644 --- a/RF12.cpp +++ b/RF12.cpp @@ -14,6 +14,11 @@ #endif #if RF12_COMPAT +/* +#define rf12_rawlen rf12_buf[1] +#define rf12_dest (rf12_buf[2] & RF12_HDR_MASK) +#define rf12_orig (rf12_buf[3] & RF12_HDR_MASK) +*/ #define rf12_rawlen rf12_buf[1] #define rf12_dest (rf12_buf[2] & RF12_HDR_MASK) #define rf12_orig (rf12_buf[3] & RF12_HDR_MASK) @@ -497,7 +502,8 @@ void rf12_sendStart (uint8_t hdr) { uint8_t parity = group ^ (group << 4); parity = (parity ^ (parity << 2)) & 0xC0; // the lower 6 bits are the destination, or zer of broadcasting - rf12_dst = parity | (hdr & RF12_HDR_DST ? hdr & RF12_HDR_MASK : 0); + //rf12_dst = parity | (hdr & RF12_HDR_DST ? hdr & RF12_HDR_MASK : 0); + rf12_dst = parity | ( hdr & RF12_HDR_MASK ); // the header byte has the two flag bits and the origin address rf12_hdr = (hdr & ~RF12_HDR_MASK) + (nodeid & NODE_ID); #else @@ -694,6 +700,10 @@ uint8_t rf12_initialize (uint8_t id, uint8_t band, uint8_t g, uint16_t f) { return nodeid; } +void rf12_sender_id (uint8_t id) { + nodeid = id ; +} + /// @details /// This can be used to send out slow bit-by-bit On Off Keying signals to other /// devices such as remotely controlled power switches operating in the 433, diff --git a/RF12.h b/RF12.h index 3e9786d6..62a0c9fb 100644 --- a/RF12.h +++ b/RF12.h @@ -8,8 +8,9 @@ // Modify the RF12 driver in such a way that it can inter-operate with RFM69 // modules running in "native" mode. This affects packet layout and some more. -#define RF12_COMPAT 0 +#define RF12_COMPAT 1 + // #include /// RFM12B Protocol version. @@ -94,6 +95,9 @@ uint8_t rf12_initialize(uint8_t id, uint8_t band, uint8_t group=0xD4, uint16_t f /// Initialize the RFM12B module from settings stored in EEPROM by "RF12demo" /// don't call rf12_initialize() if you init the hardware with rf12_config(). /// @return the node ID as 1..31, or 0 if there is no config on EEPROM. +/// +void rf12_sender_id(uint8_t id) ; + uint8_t rf12_configSilent(); /// Call this to send a description of the EEPROM settings to the serial port. void rf12_configDump();