Closed Mrono closed 10 years ago
It looks like you are trying to reserve more than two 5-byte-wide addresses. Here's how I tried to explain it in the docs:
Basically for 'rx' pipes, pass a 3, 4 or 5 byte Buffer the first time you call it, and it will be assigned a hardware pipe number automatically. Subsequent calls should ideally be single-byte Buffers only, representing the least significant byte in the address of up to four more pipes. If you open another pipe with a 3/4/5-byte address instead (or additionally), be aware that you may miss packets in certain situations.
Put differently: you can only reserve 2 RX pipes with 5-byte addresses [only one is recommended, if you are also using TX]; the other RX pipes should be opened with a 1-byte buffer suffix only. The limitation is kind of weird, but comes from the hardware itself.
[The current workaround for #2 is to open pipes after a little setTimeout (e.g. 250ms or so); that's something I hope to fix relatively soon.]
I've found a way to work around this in the last 20min
var stream = require('stream'),
pipes = [0xF0F0F0A0A1, 0xA2, 0xA3, 0xA4, 0xA5],
nrf = require('nrf').connect('/dev/spidev0.0', 25, 24);
nrf.channel(0x07).dataRate('1Mbps').crcBytes(2).begin(function () {
pipes.forEach(function (pipe, id)
{
setTimeout(function() { nrf.openPipe('rx', pipe).on('data', function (d){ handle(d, id+1) });},id+'00');
});
});
function handle (d, id)
{
var data = JSON.parse(d.toString().split("").reverse().join("").replace(/(\0|\r|\n)?/g, ''));
data.id = id;
console.log(data);
}
Why is the 5byte address not an issue when using a C++ lib?
const uint64_t pipes[6] = { 0x7365727631LL, 0xF0F0F0A0A1LL, 0xF0F0F0A0A2LL, 0xF0F0F0A0A3LL, 0xF0F0F0A0A4, 0xF0F0F0A0A5 };
Perhaps the C++ library looks for the common prefix, that might be something we could do but I'm afraid it really wouldn't make the documentation for this limitation much simpler.
When I open the third I get
I'm also seeing the issue referenced in #2