Skip to content

Instantly share code, notes, and snippets.

@bendavis78
Created May 8, 2017 01:05
Show Gist options
  • Save bendavis78/577e3e870d65e4d01498ea8bb49ec59f to your computer and use it in GitHub Desktop.
Save bendavis78/577e3e870d65e4d01498ea8bb49ec59f to your computer and use it in GitHub Desktop.
const nrf = require('nrf');
const SPI_DEV = '/dev/spidev0.0';
const CE_PIN = 25;
const IRQ_PIN = 24;
const CHANNEL = 0x4c;
const DATA_RATE = '250kbps';
const CRC_BYTES = 1;
const TX_POWER = 'PA_MAX';
const P0_ADDR = 0xe7e7e7e7e7;
const radio = nrf.connect(SPI_DEV, CE_PIN, IRQ_PIN);
const opts = {
autoAck: true
};
radio
.channel(CHANNEL)
.dataRate(DATA_RATE)
.crcBytes(CRC_BYTES)
.transmitPower(TX_POWER)
.autoRetransmit({count: 15, delay: 4000});
radio.printDetails(() => {
radio.begin(() => {
console.log('Listening...');
const rx = radio.openPipe('rx', P0_ADDR, opts);
rx.on('data', function(d) {
const val = d.toString('utf-8');
console.log(`Received: ${val}`);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment