Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
RF24
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
RF24
Commits
38392fa5
Commit
38392fa5
authored
Apr 30, 2011
by
maniacbug
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed ping/pong. Now tx just sends and rx just sends ack payload
parent
79628e78
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
64 deletions
+4
-64
examples/pingpair_pl/pingpair_pl.pde
examples/pingpair_pl/pingpair_pl.pde
+4
-64
No files found.
examples/pingpair_pl/pingpair_pl.pde
View file @
38392fa5
...
...
@@ -136,9 +136,6 @@ void loop(void)
if
(
role
==
role_ping_out
)
{
// First, stop listening so we can talk.
radio
.
stopListening
();
// Take the time, and send it. This will block until complete
unsigned
long
time
=
millis
();
printf
(
"Now sending %lu..."
,
time
);
...
...
@@ -149,45 +146,8 @@ void loop(void)
static
char
response
[
32
];
radio
.
read
(
response
,
32
);
printf
(
"Ack: [%s]"
,
response
);
// try flushing the rx buffer to get the ack packet out of the system ...
radio
.
flush_rx
();
}
// Now, continue listening
radio
.
startListening
();
// Wait here until we get a response, or timeout (250ms)
unsigned
long
started_waiting_at
=
millis
();
bool
timeout
=
false
;
while
(
!
radio
.
available
()
&&
!
timeout
)
if
(
millis
()
-
started_waiting_at
>
500
)
timeout
=
true
;
// Describe the results
if
(
timeout
)
{
printf
(
"Failed, response timed out.
\n\r
"
);
}
else
{
// Stop listening while we are clocking out the data
radio
.
stopListening
();
// Dump the payloads until we've gotten everything
unsigned
long
got_time
;
boolean
done
=
false
;
while
(
!
done
)
{
// Fetch the payload, and see if this was the last one.
done
=
radio
.
read
(
&
got_time
,
sizeof
(
unsigned
long
)
);
// Spew it
printf
(
"Got response %lu, round-trip delay: %lu
\n\r
"
,
got_time
,
millis
()
-
got_time
);
}
// Begin listening again
radio
.
startListening
();
}
}
printf
(
" OK
\n\r
"
);
// Try again later
digitalWrite
(
led_pin
,
HIGH
);
...
...
@@ -196,7 +156,7 @@ void loop(void)
}
//
// Pong back role. Receive each packet, dump it out, a
nd send it back
// Pong back role. Receive each packet, dump it out, a
dd ack payload for next time
//
if
(
role
==
role_pong_back
)
...
...
@@ -213,28 +173,9 @@ void loop(void)
done
=
radio
.
read
(
&
got_time
,
sizeof
(
unsigned
long
)
);
// Spew it
printf
(
"Got payload %lu
...
"
,
got_time
);
printf
(
"Got payload %lu
\n
"
,
got_time
);
}
// First, stop listening so we can talk
radio
.
stopListening
();
//delay(250);
// necessary to flush the ack packet out
// but kills the entire tx queue, which I might not
// want in the future!!
radio
.
flush_tx
();
// Send the final one back.
radio
.
write
(
&
got_time
,
sizeof
(
unsigned
long
)
);
printf
(
"Sent response.
\n\r
"
);
// Now, resume listening so we catch the next packets.
radio
.
startListening
();
//delay(250);
// Add an ack packet for the next time around
static
unsigned
id
=
0
;
static
char
pl_buffer
[
10
];
...
...
@@ -242,7 +183,6 @@ void loop(void)
pl_buffer
[
9
]
=
0
;
snprintf
(
pl_buffer
,
10
,
"id %04x"
,
id
++
);
radio
.
writeAckPayload
(
1
,
pl_buffer
,
10
);
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment