jgromes / RadioLib

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

esp8266 llcc68 chips send data was out of time, and get error response -706 #645

Closed chcmq closed 1 year ago

chcmq commented 1 year ago

code

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include "lora_service.h"
#include "config.h"
#include <RadioLib.h>
// SX1262 has the following connections:
// NSS pin:   15
// DIO1 pin:  4
// NRST pin:  10
// BUSY pin:  5
LLCC68 radio = new Module(15, 4, 10, 5);

lora_service::lora_service() {}
lora_service::~lora_service() {}

/* =============================icache functions========================= */
void ICACHE_FLASH_ATTR lora_service::setup() {
// initialize SX1262 with default settings
  Serial.print(F("[SX1262] Initializing ... "));
  int state = radio.begin(433.0, 125.0, 9, 7, 0x12, 17, 8, 0, false);
  if (state == RADIOLIB_ERR_NONE) {
    Serial.println(F("success!"));
     // Some SX126x modules use DIO2 as RF switch. To enable
  // this feature, the following method can be used.
  // NOTE: As long as DIO2 is configured to control RF switch,
  //       it can't be used as interrupt pin!
  if (radio.setDio2AsRfSwitch() != RADIOLIB_ERR_NONE) {
    Serial.println(F("Failed to set DIO2 as RF switch!"));
    while (true);
  }

  Serial.println(F("All settings succesfully changed!"));
  } else {
    Serial.print(F("failed, code "));
    Serial.println(state);
    while (true);
  }

  Serial.println("begin LoRa radio init success");

}// end io setup

void ICACHE_FLASH_ATTR lora_service::loop()
{

  Serial.print(F("[SX1262] Transmitting packet ... "));

  // you can transmit C-string or Arduino string up to
  // 256 characters long
  // NOTE: transmit() is a blocking method!
  //       See example SX126x_Transmit_Interrupt for details
  //       on non-blocking transmission method.
  int state = radio.transmit("Hello World!");

  // you can also transmit byte array up to 256 bytes long
  /*
    byte byteArr[] = {0x01, 0x23, 0x45, 0x56, 0x78, 0xAB, 0xCD, 0xEF};
    int state = radio.transmit(byteArr, 8);
  */

  if (state == RADIOLIB_ERR_NONE) {
    // the packet was successfully transmitted
    Serial.println(F("success!"));

    // print measured data rate
    Serial.print(F("[SX1262] Datarate:\t"));
    Serial.print(radio.getDataRate());
    Serial.println(F(" bps"));

  } else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
    // the supplied packet was longer than 256 bytes
    Serial.println(F("too long!"));

  } else if (state == RADIOLIB_ERR_TX_TIMEOUT) {
    // timeout occured while transmitting packet
    Serial.println(F("timeout!"));

  } else {
    // some other error occurred
    Serial.print(F("failed, code "));
    Serial.println(state);

  }

  // Don't load RF module with continous transmit
  delay(3000);

}//end loop

/* ===========================end iram functions=========================== */
lora_service lora;

Debug

DATW    48      A2      65      A2      6C      A2      6C      A2      6F      A2  20       A2      57      A2      6F      A2      72      A2      6C      A2      64  A2       21      A2

CMD     C0
DATR    0       22      0       22

CMD     2
DATW    43      A2      FF      A2

CMD     C0
DATR    0       22      0       22

CMD     1D      8       89
DATR    0       A2      0       4

CMD     C0
DATR    0       22      0       22

CMD     11
DATR    0       A2      0       0

CMD     C0
DATR    0       22      0       22

CMD     D       8       89
DATW    4       A2

CMD     C0
DATR    0       22      0       22

CMD     83
DATW    0       A2      0       A2      0       A2

CMD     C0
DATR    0       B8      0       0

failed, code -706
jgromes commented 1 year ago
  1. Issue title is supposed to sum up the problem, it's not the first paragraph.
  2. Please follow the "Module not working" issue template - that includes a reproducible, minimum code example - what you have posted is neither reproducible, nor minimal. Start with the examples.
  3. You have not posted the entire debug log, but it seems to me that the failure occurs just as the LLCC68 is about to start transmitting. That may be caused by inappropriate power source - and that's exactly the reason why the issue template is asking for a hardware description.
chcmq commented 1 year ago

Sorry about without the template before but i got the trouble when i try to transmit data between lora.

=====

The picture is about the voltage I got. c1457800e0584ebba5f18fd737d680f

#include <RadioLib.h>
// SX1262 has the following connections:
// NSS pin:   15
// DIO1 pin:  4
// NRST pin:  10
// BUSY pin:  5
LLCC68 radio = new Module(15,  4, 10,5);
// save transmission state between loops
int transmissionState = RADIOLIB_ERR_NONE;
// flag to indicate that a packet was sent
volatile bool transmittedFlag = false;
void IRAM_ATTR setFlag(void);
// disable interrupt when it's not needed
volatile bool enableInterrupt = true;
lora_service::lora_service() {}
lora_service::~lora_service() {}

/* =============================icache functions========================= */
void ICACHE_FLASH_ATTR lora_service::setup() {
// initialize SX1262 with default settings
  Serial.print(F("[SX1262] Initializing ... "));
  int state = radio.begin(434.0, 125.0, 9, 7,0x34, 20, 8, 0, false);
  if (state == RADIOLIB_ERR_NONE) {
    Serial.println(F("success!"));
    // Some SX126x modules use DIO2 as RF switch. To enable
  // this feature, the following method can be used.
  // NOTE: As long as DIO2 is configured to control RF switch,
  //       it can't be used as interrupt pin!
  // if (radio.setDio2AsRfSwitch() != RADIOLIB_ERR_NONE) {
  //   Serial.println(F("Failed to set DIO2 as RF switch!"));
  //   while (true);
  // }

  // Serial.println(F("All settings succesfully changed!"));
  } else {
    Serial.print(F("failed, code "));
    Serial.println(state);
    while (true);
  }

  Serial.println("begin LoRa radio init success");
  // set the function that will be called
  // when packet transmission is finished
  radio.setDio1Action(setFlag);

  // start transmitting the first packet
  Serial.print(F("[SX1262] Sending first packet ... "));

  // you can transmit C-string or Arduino string up to
  // 256 characters long
  transmissionState = radio.startTransmit("Hello World!");
  Serial.print(F("[SX1262] transmissionState is :"));
  Serial.println(transmissionState);
  // you can also transmit byte array up to 256 bytes long
  /*
    byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
                      0x89, 0xAB, 0xCD, 0xEF};
    state = radio.startTransmit(byteArr, 8);
  */

}// end io setup

void IRAM_ATTR setFlag(void) {
  // check if the interrupt is enabled
  if(!enableInterrupt) {
    return;
  }

  // we sent a packet, set the flag
  transmittedFlag = true;
}

void ICACHE_FLASH_ATTR lora_service::loop()
{

 // check if the previous transmission finished
  if(transmittedFlag) {
    // disable the interrupt service routine while
    // processing the data
    enableInterrupt = false;

    // reset flag
    transmittedFlag = false;

    if (transmissionState == RADIOLIB_ERR_NONE) {
      // packet was successfully sent
      Serial.println(F("transmission finished!"));

      // NOTE: when using interrupt-driven transmit method,
      //       it is not possible to automatically measure
      //       transmission data rate using getDataRate()

    } else {
      Serial.print(F("failed, code "));
      Serial.println(transmissionState);

    }

    // clean up after transmission is finished
    // this will ensure transmitter is disabled,
    // RF switch is powered down etc.
    radio.finishTransmit();

    // wait a second before transmitting again
    delay(1000);

    // send another one
    Serial.print(F("[SX1262] Sending another packet ... "));

    // you can transmit C-string or Arduino string up to
    // 256 characters long
    transmissionState = radio.startTransmit("Hello World!");

    // you can also transmit byte array up to 256 bytes long
    /*
      byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
                        0x89, 0xAB, 0xCD, 0xEF};
      int state = radio.startTransmit(byteArr, 8);
    */

    // we're ready to send more packets,
    // enable interrupt service routine
    enableInterrupt = true;
  }

}//end loop

Debug log


[INFO] Yea SerialPort_PC System V2.4.3.F
serial_port

[INFO] S_Config file found
[INFO] Mounting FS...
[ERR] Failed to open config file
[INFO] There is no configuration file ...
fpm close 1 
mode : softAP(62:01:94:38:10:5a)
add if1
dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)
bcn 100
bcn 0
del if1
usl
add if1
dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)
bcn 100
---------------AP INFOS--------------------
[INFO] The AP ssid is: Yea_SerialPort_105A
[INFO] The password of the AP is: 12345678
[INFO] The IP address is: 192.168.5.1
[INFO] The netmask is: 255.255.255.0
[INFO] The DHCP status of the AP is: Enabled
-----------END AP INFOS--------------------
[INFO][DNS] All dns are hijacked!
[INFO] Web Server started!
[SX1262] Initializing ... M     SX126x
CMD     80
DATW    0       C0

CMD     C0
DATR    0       30      0       30

CMD     80
DATW    0       A2

CMD     C0
DATR    0       22      0       22

CMD     8F
DATW    0       A2      0       A2

CMD     C0
DATR    0       22      0       22

CMD     8A
DATW    1       A2

CMD     C0
DATR    0       22      0       22

CMD     93
DATW    20      A2

CMD     C0
DATR    0       22      0       22

CMD     88
DATW    3       A2      16      A2      A       A2      0       A2      0       A2  0A2      0       A2

CMD     C0
DATR    0       22      0       22

CMD     2
DATW    43      A2      FF      A2

CMD     C0
DATR    0       22      0       22

CMD     8
DATW    0       A2      0       A2      0       A2      0       A2      0       A2  0A2      0       A2      0       A2

CMD     C0
DATR    0       22      0       22

CMD     89
DATW    7F      A2

CMD     11
DATR    0       A2      0       1

CMD     C0
DATR    0       22      0       22

Symbol length: 1.02 ms
CMD     8B
DATW    9       A2      6       A2      3       A2      0       A2

CMD     C0
DATR    0       22      0       22

CMD     11
DATR    0       A2      0       1

CMD     C0
DATR    0       22      0       22

CMD     D       7       40
DATW    34      A2      44      A2

CMD     C0
DATR    0       22      0       22

CMD     11
DATR    0       A2      0       1

CMD     C0
DATR    0       22      0       22

CMD     1D      7       36
DATR    0       A2      0       D

CMD     C0
DATR    0       22      0       22

CMD     D       7       36
DATW    D       A2

CMD     C0
DATR    0       22      0       22

CMD     8C
DATW    0       A2      8       A2      0       A2      FF      A2      1       A2  0A2

CMD     C0
DATR    0       22      0       22

CMD     D       8       E7
DATW    18      A2

CMD     C0
DATR    0       22      0       22

CMD     9D
DATW    1       A2

CMD     C0
DATR    0       22      0       22

CMD     96
DATW    1       A2

CMD     C0
DATR    0       22      0       22

CMD     98
DATW    6B      A2      6F      A2

CMD     C0
DATR    0       22      0       22

CMD     86
DATW    1B      A2      20      A2      0       A2      0       A2

CMD     C0
DATR    0       22      0       22

CMD     11
DATR    0       A2      0       1

CMD     C0
DATR    0       22      0       22

Symbol length: 4.10 ms
CMD     8B
DATW    9       A2      4       A2      3       A2      0       A2

CMD     C0
DATR    0       22      0       22

CMD     11
DATR    0       A2      0       1

CMD     C0
DATR    0       22      0       22

Symbol length: 4.10 ms
CMD     8B
DATW    9       A2      4       A2      3       A2      0       A2

CMD     C0
DATR    0       22      0       22

CMD     1D      8       E7
DATR    0       A2      0       18

CMD     C0
DATR    0       22      0       22

CMD     95
DATW    4       A2      7       A2      0       A2      1       A2

CMD     C0
DATR    0       22      0       22

CMD     8E
DATW    14      A2      4       A2

CMD     C0
DATR    0       22      0       22

CMD     D       8       E7
DATW    18      A2

CMD     C0
DATR    0       22      0       22

CMD     1D      8       D8
DATR    0       A2      0       FE

CMD     C0
DATR    0       22      0       22

CMD     D       8       D8
DATW    FE      A2

CMD     C0
DATR    0       22      0       22

success!
begin LoRa radio init success
[SX1262] Sending first packet ... CMD   11
DATR    0       A2      0       1

CMD     C0
DATR    0       22      0       22

CMD     1D      7       36
DATR    0       A2      0       D

CMD     C0
DATR    0       22      0       22

CMD     D       7       36
DATW    D       A2

CMD     C0
DATR    0       22      0       22

CMD     8C
DATW    0       A2      8       A2      0       A2      C       A2      1       A2  0A2

CMD     C0
DATR    0       22      0       22

CMD     8
DATW    2       A2      1       A2      0       A2      1       A2      0       A2  0A2      0       A2      0       A2

CMD     C0
DATR    0       22      0       22

CMD     8F
DATW    0       A2      0       A2

CMD     C0
DATR    0       22      0       22

CMD     E       0
DATW    48      A2      65      A2      6C      A2      6C      A2      6F      A2  20       A2      57      A2      6F      A2      72      A2      6C      A2      64  A2       21      A2

CMD     C0
DATR    0       22      0       22

CMD     2
DATW    43      A2      FF      A2

CMD     C0
DATR    0       22      0       22

CMD     1D      8       89
DATR    0       A2      0       4

CMD     C0
DATR    0       22      0       22

CMD     11
DATR    0       A2      0       1

CMD     C0
DATR    0       22      0       22

CMD     D       8       89
DATW    4       A2

CMD     C0
DATR    0       22      0       22

CMD     83
DATW    0       A2      0       A2      0       A2

CMD     C0
DATR    0       C0      0       C0

[SX1262] transmissionState is :0
transmission finished!
CMD     2
DATW    43      A2      FF      A2

CMD     C0
DATR    0       22      0       22

CMD     80
DATW    0       A2

CMD     C0
DATR    0       22      0       22

[SX1262] Sending another packet ... CMD 11
DATR    0       A2      0       0

CMD     C0
DATR    0       22      0       22

CMD     8C
DATW    0       A2      0       A2      5       A2      0       A2      0       A2  0A2      C       A2      0       A2      0       A2

CMD     C0
DATR    0       22      0       22

CMD     8
DATW    2       A2      1       A2      0       A2      1       A2      0       A2  0A2      0       A2      0       A2

CMD     C0
DATR    0       22      0       22

CMD     8F
DATW    0       A2      0       A2

CMD     C0
DATR    0       22      0       22

CMD     E       0
DATW    48      A2      65      A2      6C      A2      6C      A2      6F      A2  20       A2      57      A2      6F      A2      72      A2      6C      A2      64  A2       21      A2

CMD     C0
DATR    0       22      0       22

CMD     2
DATW    43      A2      FF      A2

CMD     C0
DATR    0       22      0       22

CMD     1D      8       89
DATR    0       A2      0       4

CMD     C0
DATR    0       22      0       22

CMD     11
DATR    0       A2      0       0

CMD     C0
DATR    0       22      0       22

CMD     D       8       89
DATW    4       A2

CMD     C0
DATR    0       22      0       22

CMD     83
DATW    0       A2      0       A2      0       A2

CMD     C0
DATR    0       B8      0       0

failed, code -706
CMD     2
DATW    43      6B      FF      0

CMD     80
DATW    0       56

[SX1262] Sending another packet ... CMD 11
DATR    0       AC      0       AC
jgromes commented 1 year ago

2.7 V seems very low - I'm guessing you're powering it from the ESP8266 onboard LDO regulator, it should be 3.3V. If it's dropping by 0.6V in standby, I think it's safe to say it is not going to be able to handle the power needed for transmission. You should use an external power source for the LLCC68, e.g. a dedicated LDO.

jgromes commented 1 year ago

Closed due to inactivity.