loucks1 / Directolor

ESP32 + NRF24L01+ library to control Levolor blinds
GNU General Public License v3.0
10 stars 4 forks source link

Stuck in `Failure starting radio` loop #3

Closed sfraint closed 2 years ago

sfraint commented 2 years ago

Running the Directolor examples out-of-the-box, the radio is never able to start for me and I get stuck in an endless loop of:

Attempting to start radio
Failure starting radio
Attempting to start radio
Failure starting radio

Note: I was able to work around the issue by instantiating the Directolor object in the setup loop:

-Directolor directolor(22, 21);
+Directolor* directolor;
 void setup() {
   Serial.begin(115200);
+  directolor = new Directolor(22, 21);

Then change all obj refs to pointer refs directolor. to directolor->

loucks1 commented 2 years ago

Can you update with the following: (note delay and move radio init to end). Then update the case with the results.

Directolor::Directolor(uint16_t _cepin, uint16_t _cspin, uint32_t _spi_speed)
{
  messageIsSending = false;
  for (int i = 0; i < DIRECTOLOR_MAX_QUEUED_COMMANDS; i++)
  {
    commandItems[i].radioCodes = 0;
    commandItems[i].blindAction = directolor_stop;
    commandItems[i].channels = 0;
  }
  Serial.begin(115200);
  Serial.println("Starting delay");
  delay(15000);
  Serial.println("Ending delay");

  radio = RF24(_cepin, _cspin, _spi_speed);
}

Any chance you can try with Arduino 2.0?

sfraint commented 2 years ago

I tried with my old Arduino setup and after a long delay, I still hit the same failure-to-start loop:

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1184
load:0x40078000,len:12812
load:0x40080400,len:3032
entry 0x400805e4
Starting delay
E⸮⸮ ⸮⸮⸮⸮delay
Commands available:
(search) remote - enter Remote Search Mode
(dump) codes    - dump the remote code so you can put into directolor.h (only valid if you've captured a remote code using search)
(o)pen blind    - send open code for current channel(s)
(c)lose blind   - send close code for current channel(s)
(s)top blind    - send stop code for current channel(s)
(j)oin blind    - send join code for current channel
(r)emove blind  - send remove code for current channel
(remote #)      - set remote number
(channel #)     - set channel number
(help)          - show this screen

Remote = 1, Channel = 1
Attempting to start radio
Failure starting radio
Attempting to start radio
Failure starting radio
...

I will try to setup Arduino IDE 2.0 at some point and try that as well

note: it is also odd that the E??? delay text is weird and that message is shown before the delay is finished

loucks1 commented 2 years ago

What version of the RF24 library are you on? (I'm on 1.4.6) (RF24 by TMRh20)

Can you back out the above changes and put in the following (For testing, update your pins if needed).

bool radioInitialized = false;
/**
 * Sets the protocol to send.
 */
bool Directolor::radioStarted()
{
  if (!radioValid)
  {
    if (!radioInitialized)
    {
      Serial.println("Attempting to initialize radio");
      radio = RF24(22, 21);
      radioInitialized = true;
    }
sfraint commented 2 years ago
  1. Same behavior with Arduino IDE 2
  2. I was on RF24 1.4.2, I upgraded to 1.4.6 and same problem
  3. The radioInitialized addition in your last comment fixes the issue - GetBlindCodes now works as I'd expect:
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1184
load:0x40078000,len:13160
load:0x40080400,len:3036
entry 0x400805e4
Commands available:
(search) remote - enter Remote Search Mode
(dump) codes    - dump the remote code so you can put into directolor.h (only valid if you've captured a remote code using search)
(o)pen blind    - send open code for current channel(s)
(c)lose blind   - send close code for current channel(s)
(s)top blind    - send stop code for current channel(s)
(j)oin blind    - send join code for current channel
(r)emove blind  - send remove code for current channel
(remote #)      - set remote number
(channel #)     - set channel number
(help)          - show this screen

Remote = 1, Channel = 1
Attempting to initialize radio
Attempting to start radio
Radio started
Remote 1, Channels: 1-Open
...
loucks1 commented 2 years ago

I've pushed code that implements this. Can you grab the code from the repository and test it? Thanks for sticking with me on this one and all the feedback you've provided!

sfraint commented 2 years ago

Great, the latest revision works out of the box for me!

Thanks for all the fixes! 😁