Skip to content

Additions to Mrf24j40 arduino library #4

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sivanovbg
Copy link

Hello, I added two additions into your library. Please see the comments for the corresponding files. The additions were useful in my projects so far.

Changes:
1. Added new 'Mrf24j::send16' function with third attribute - 'length' to be able to send binary data instead of string over 802.15.4 interface
2.Variable 'frame_length' moved onto a new position within 'Mrf24j:interrupt_handler' function before its usage. Old position is commented.
Added  void send16(word dest16, char * data, byte length); definition.
@@ -148,6 +149,41 @@ void Mrf24j::send16(word dest16, char * data) {
write_short(MRF_TXNCON, (1<<MRF_TXNACKREQ | 1<<MRF_TXNTRIG));
}

void Mrf24j::send16(word dest16, char * data, byte length) {
Copy link
Owner

Choose a reason for hiding this comment

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

THe right way of doing this is not to copy the whole function, but to make this new function be the "primary" function, and have the existing send16() function do the strlen() and then call this function. Duplication is never ok for this sort of thing.

@@ -219,11 +255,14 @@ void Mrf24j::interrupt_handler(void) {
// buffer data bytes
int rd_ptr = 0;
// from (0x301 + bytes_MHR) to (0x301 + frame_length - bytes_nodata - 1)

rx_info.frame_length = frame_length; // new position here

Copy link
Owner

Choose a reason for hiding this comment

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

What's this change for? This seems like a separate unrelated issue.

@@ -220,6 +220,8 @@ class Mrf24j
void set_palna(boolean enabled);

void send16(word dest16, char * data);

void send16(word dest16, char * data, byte length);
Copy link
Owner

Choose a reason for hiding this comment

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

You should make the header change in the same commit as the .cpp change. Each individual commit should contain what is needed for the change. By splitting the commits in two, you have a commit that doesn't compile properly.

You can use git rebase to squish them back into one commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants