Skip to content
maniacbug edited this page Mar 19, 2011 · 1 revision

Table of Contents

RF24

Constructor. Creates a new instance of this driver. Before using, you create an instance and send in the unique pins that this chip is connected to.

Parameters:

  • _cepin: The pin attached to Chip Enable on the RF module
  • _cspin: The pin attached to Chip Select

begin

Begin operation of the chip. Call this in setup(), before calling any other methods.

setChannel

Set RF communication channel.

Parameters:

  • channel: Which RF channel to communicate on, 0-127

setPayloadSize

Set Payload Size. This implementation uses a pre-stablished fixed payload size for all transmissions.

Parameters:

  • size: The number of bytes in the payload

getPayloadSize

Get Payload Size.

Returns:

  • The number of bytes in the payload

printDetails

Print a giant block of debugging information to stdout.

Warning: Does nothing if stdout is not defined. See fdevopen in stdio.h

startListening

Start listening on the pipes opened for reading. Be sure to open some pipes for reading first. Do not call 'write' while in this mode, without first calling 'stopListening'.

stopListening

Stop listening for incoming messages. Necessary to do this before writing.

write

Write to the open writing pipe. This blocks until the message is successfully acknowledged by the receiver or the timeout/retransmit maxima are reached. In the current configuration, the max delay here is 60ms.

Parameters:

  • buf: Pointer to the data to be sent
Returns:
  • True if the payload was delivered successfully false if not

available

Test whether there are bytes available to be read.

Returns:

  • True if there is a payload available, false if none is

read

Read the payload. Return the last payload received

Parameters:

  • buf: Pointer to a buffer where the data should be written
Returns:
  • True if the payload was delivered successfully false if not

openWritingPipe

Open a pipe for writing. Addresses are 40-bit hex values, e.g.:

openWritingPipe(0xF0F0F0F0F0);

Parameters:

  • address: The 40-bit address of the pipe to open. This can be any value whatsoever, as# long as you are the only one writing to it and only one other radio is listening to it. Coordinate these pipe addresses amongst nodes on the network.

openReadingPipe

Open a pipe for reading.

Warning: all 5 reading pipes should share the first 32 bits. Only the least significant byte should be unique, e.g.

openReadingPipe(0xF0F0F0F0AA);
openReadingPipe(0xF0F0F0F066);

Parameters:

  • number: Which pipe# to open, 1-5.
  • address: The 40-bit address of the pipe to open.