Arduino Library
The RfLink Arduino library enables bi-directional communication between the Arduino and all the slave modules via radio frequency. The library interacts via TWI with the backpack controller (see [LINK]).
It differentiates between two modes:
- Master mode — the backpack is put into master mode which allows the Arduino to listen to all commands sent by remote sensors. All outgoing commands are sent with the origin device id of 0xF (master)
- Slave mode – the backpack is put into slave mode by initializing it with a device id. It only listens to commands send to it explicitly and all outgoing commands are sent with the set device id
Functions are provided to poll the backpack module as well as a pass-through mode which repeats the functionality of the backpack onto the serial port (i.e. to the computer via USB).
Functions
- begin(), begin(deviceId)
Initiates communication link between Arduino and backpack. Pass optional device id to put it into slave mode. - reset()
Reset the communication link and the backpack - onReceive(fx_ptr)
Register a function pointer to handle callbacks when a remote command is received (also see the “simple master” example below - sendData(targetDevice, data)
Send up to four bytes of data to a remote device. Returns the number of bytes sent - on(deviceId, port)
Turn on a port of a remote device. - off(deviceId,port)
Turn off a port of a remote device. - pulse(deviceId, port, duration)
Pulses a port (quick on-delay-off in one command) on a remote device for set duration. Durations up to 1650 ms are supported with 10ms resolution above 100ms. - lock(deviceId)
Locks are remote device — it will only listen to unlock commands thereon after - unlock(deviceId)
Unlock a remote device - reset(deviceId)
Reset a remote device (depends on firmware what this will do, usually resets all ports) - pollSlave()
This or passThrough() must be periodically called to retrieve any incoming data from the backpack — it currently implements a polling strategy. - passThrough(serial)
Pass in a pointer to a HardwareSerial and call it periodically. It will poll the backpack and relay any incoming/outgoing commands to/from the USB port making the Arduino a pass-through.
Examples
Download and Installation
Grab the latest release here or from subversion.
The files need to be placed into your Arduino installation into the hardware/libraries directory (untarring the tar file in this directory creates a new RfLink subdirectory). On a Mac, these files are to be found in /Applications/Arduino.app/Contents/Resources/Java/hardware/libraries.
Also check the Arduino Environment Guide for details.