Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added rf12_set_sender_id to allow senderID to be switched without having #108

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion RF12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
#endif

#if RF12_COMPAT
/*
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this change do?

#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)
Expand Down Expand Up @@ -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 );
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't grasp what this change does.

// the header byte has the two flag bits and the origin address
rf12_hdr = (hdr & ~RF12_HDR_MASK) + (nodeid & NODE_ID);
#else
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion RF12.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Native mode on the RFM69 is not the default mode of operation.


//
#include <stdint.h>

/// RFM12B Protocol version.
Expand Down Expand Up @@ -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();
Expand Down