jgromes / RadioLib

Universal wireless communication library for embedded devices
https://jgromes.github.io/RadioLib/
MIT License
1.52k stars 381 forks source link

[SX128x] Cannot transmit after sleep() #1249

Closed jacobeva closed 6 hours ago

jacobeva commented 8 hours ago

Describe the bug After putting the module into sleep mode, even if the module is woken up after by pulling SS LOW, all attempts to transmit will result in RADIOLIB_ERR_TX_TIMEOUT. In my example sketch below, the "transmitting..." line is never sent over serial if the call to sleep is not commented out.

To Reproduce

#include <Arduino.h>
#include "Adafruit_TinyUSB.h"
#include <SPI.h>
#include <variant.h>
#include <RadioLib.h>

    SX1280 radio = new Module(24, 15, 16, 25);

volatile bool packet_rx = false;
int packets = 0;

void setflag() {
    packet_rx = true;
}

void setup() {
    Serial.begin(115200);
    while(!Serial);
    uint8_t sf = 10;
      int state = radio.begin(2408, 1625, sf, 5);// 0x14 1, 30);
      radio.setRfSwitchPins(19, 20);
      radio.explicitHeader();
radio.setCRC(2);
      //radio.setSyncWord(0x14, 0x24);
  if (state == RADIOLIB_ERR_NONE) {
    Serial.println(F("success!"));
  } else {
    Serial.print(F("failed, code "));
    Serial.println(state);
    while (true) { delay(10); }
  }
  radio.sleep();
}

void loop() {
    digitalWrite(24, LOW);
    delay(1);
    digitalWrite(24, HIGH);
    delay(1);
    radio.standby();
    uint8_t data[255] = {0};
    for (int i = 0; i < 255; i++) {
        data[i] = i;
    }
    int16_t status;
    while (true) {
    status = radio.transmit(data, 255);
    //radio.transmit(data, 7);
    if (status == RADIOLIB_ERR_NONE) Serial.println("transmitting...");
    }
}

Expected behavior Transmitting after sleep should work as expected.

Additional info (please complete):

jgromes commented 6 hours ago

Resolved by merging #1250