Browse Source

Add send_str

master
CVR 2 months ago
parent
commit
05fe5d53f4
  1. 9
      src/mrf24j.cpp
  2. 3
      src/mrf24j.h
  3. 2
      test/tx/main.cpp

9
src/mrf24j.cpp

@ -104,12 +104,17 @@ word Mrf24j::address16_read(void) {
return a16h << 8 | read_short(MRF_SADRL);
}
void Mrf24j::send_str(word dest16, char * data) {
byte len = strlen(data); // get the length of the char* array
send(dest16, data, len);
}
/**
* Simple send 16, with acks, not much of anything.. assumes src16 and local pan only.
* @param data
*/
void Mrf24j::send16(word dest16, char * data) {
byte len = strlen(data); // get the length of the char* array
void Mrf24j::send(word dest16, char * data, int len) {
int i = 0;
write_long(i++, bytes_MHR); // header length
// +ignoreBytes is because some module seems to ignore 2 bytes after the header?!.

3
src/mrf24j.h

@ -227,7 +227,8 @@ class Mrf24j
*/
void set_palna(boolean enabled);
void send16(word dest16, char * data);
void send(word dest16, char * data, int len);
void send_str(word dest16, char * data);
void interrupt_handler(void);

2
test/tx/main.cpp

@ -47,7 +47,7 @@ int main() {
//mrf.wake();
sprintf(tmp,"Received %i\n\r", i);
mrf.send16(0x4202, tmp);
mrf.send_str(0x4202, tmp);
_delay_ms(2000);
}

Loading…
Cancel
Save