natevw / node-nrf

Pure-JavaScript nRF24L01 driver library
117 stars 31 forks source link

Radio won't receive data unless C++ initilizes it after reboot. #20

Closed Mrono closed 10 years ago

Mrono commented 10 years ago

When I rPI reboots I am unable to receive any transmissions from the radio until I run a C++ script first, like the scanner. It doesn't matter if I reboot and do the modprobe toggle, node will not receive any data. Once I run a C++ script, receive data, then switch back to node (after running the modprobe toggle) it works like a champ.

natevw commented 10 years ago

Interesting. Might there be any particular setting (e.g. CRC? channel?) that you've forgotten in the JS version of your code? I know I've had success receiving e.g. from an Arduino to the JS-only initialized Tessel port of this code. Can you set ._debug = true on your instance and gist a sample log?

Mrono commented 10 years ago

What is set to defaults, and what needs to be set manually? I currently am only setting channel and dataRate, I was under the assumption that anything else is set to defaults.

natevw commented 10 years ago

nrf.begin doesn't do a full reset-to-defaults (it mostly flushes the FIFOs, clears the IRQ bits, turns off any RX, and turns the chip on). You'll need to use nrf.reset if you need the power-on defaults:

radio.reset(cb) — Resets the transciever to its default settings and flushes its transmit/receive queues. Most of this (i.e. queue flushing and low-level settings) is done by .begin() and so calling reset is not necessary if the five transceiver configuration options below (channel/dataRate/transmitPower/crcBytes/autoRetransmit) are being written anyway.

[I.e. unless you're sure the radio just powered on, you should either set all five communications parameters or call .reset]

Mrono commented 10 years ago

Bingo, I manually set all the params and it works after reboot. Awesome!