Skip to content

Instantly share code, notes, and snippets.

@natevw
Created December 3, 2013 07:11
Show Gist options
  • Save natevw/7765186 to your computer and use it in GitHub Desktop.
Save natevw/7765186 to your computer and use it in GitHub Desktop.
// see https://gist.github.com/natevw/5789019 for pins
var NRF24 = require("./index"),
spiDev = "/dev/spidev0.0",
cePin = 24, irqPin = 25, //var ce = require("./gpio").connect(cePin)
pipes = [0xF0F0F0F0E1, 0xF0F0F0F0D2];
var nrf = NRF24.connect(spiDev, cePin, irqPin);
nrf.channel(0x4c).transmitPower('PA_MAX').dataRate('1Mbps').crcBytes(2).autoRetransmit({count:15, delay:500}).begin(function () {
var rx = nrf.openPipe('rx', pipes[0]),
tx = nrf.openPipe('tx', pipes[1]);
rx.on('data', function (d) {
console.log("Got data, will respond", d.readUInt32BE(0));
tx.write(d);
});
tx.on('error', function (e) {
console.warn("Error sending reply.", e);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment