Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CC1101 Direct Mode getRSSI() only ever returns -74.0 #1077

Closed
Crsarmv7l opened this issue Apr 24, 2024 · 2 comments
Closed

CC1101 Direct Mode getRSSI() only ever returns -74.0 #1077

Crsarmv7l opened this issue Apr 24, 2024 · 2 comments
Labels
bug Something isn't working resolved Issue was resolved (e.g. bug fixed, or feature implemented)

Comments

@Crsarmv7l
Copy link
Contributor

Describe the bug
When using Direct Mode with CC1101 and attempting to get the RSSI with getRSSI(), only -74.0 is ever returned, even when txing right next to the receiver.

Some output with basic debug, let me know if you want one of the other debugs enabled:

RLB_DBG: RadioLib Debug Info
RLB_DBG: Version:  6.5.0.0
RLB_DBG: Platform: ESP32
RLB_DBG: Compiled: Apr 24 2024 16:50:28

RLB_DBG: M	CC1101
CC1101 Init: Success!
-74.00
-74.00
-74.00
-74.00
-74.00
-74.00
-74.00
-74.00
-74.00
-74.00
-74.00
-74.00
-74.00
-74.00
-74.00

To Reproduce

#include <RadioLib.h>

CC1101 radio = new Module(6, 16, RADIOLIB_NC, 17);

const int pin = 17;


void IRAM_ATTR readBit(void) {
  // read the data bit
  radio.readBit(pin);
}


void setup() {
  Serial.begin(19200);
  while (!Serial) {};

  int state = radio.begin();
  if (state == RADIOLIB_ERR_NONE) {
    Serial.println(F("CC1101 Init: Success!"));
  }
  else {
    Serial.print(F("CC1101 Failed: Code "));
    Serial.println(state);
    while (true);
  }
  state = radio.setFrequency(433.92);
  if (!state == RADIOLIB_ERR_NONE) {
    Serial.print(F("Freq Failed, Code "));
    Serial.println(state);
    while (true);
  }
  state = radio.setBitRate(8.00);
  if (!state == RADIOLIB_ERR_NONE) {
    Serial.print(F("Datarate Failed, Code "));
    Serial.println(state);
    while (true);
  }
  state = radio.setOOK(true);
  if (!state == RADIOLIB_ERR_NONE) {
    Serial.print(F("Modulation Failed, Code "));
    Serial.println(state);
    while (true);
  }
  state = radio.setRxBandwidth(58);
  if (!state == RADIOLIB_ERR_NONE) {
    Serial.print(F("Bandwidth Failed, Code "));
    Serial.println(state);
    while (true);
  }
  state = radio.setPromiscuousMode(true, true);
  if (!state == RADIOLIB_ERR_NONE) {
    Serial.print(F("Promiscuous Failed, Code "));
    Serial.println(state);
    while (true);
  }
  state = radio.setDirectSyncWord(0, 0);
  if (!state == RADIOLIB_ERR_NONE) {
    Serial.print(F("Direct SyncWord Failed, Code "));
    Serial.println(state);
    while (true);
  }
  radio.setDirectAction(readBit);
  radio.receiveDirect();
}

void loop() {
  if (radio.available() >= 61) {
    Serial.println(radio.getRSSI());
    while (radio.available()) {
      byte b = radio.read();
    }
  }
}

Expected behavior
RSSI should vary.

Additional info (please complete):

  • MCU: Adafruit Qt py ESP32-S2
  • Wireless module type: CC1101
  • Arduino IDE version: 1.8.19
  • Library version: Latest
jgromes added a commit that referenced this issue Apr 25, 2024
@jgromes
Copy link
Owner

jgromes commented Apr 25, 2024

Looks like the logic inside CC1101::getRSSI was inverted, returning the packet RSSI value in direct mode and the instantenous one in packet mode. Because you never received a packet in packet mode, the initial value was set to 0 from which offset of 74 dBm is subtracted, hence the -74 dBm return value.

I pushed a fix for this in the latest commit, thanks for reporting!

@jgromes jgromes closed this as completed Apr 25, 2024
@jgromes jgromes added bug Something isn't working resolved Issue was resolved (e.g. bug fixed, or feature implemented) labels Apr 25, 2024
@Crsarmv7l
Copy link
Contributor Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working resolved Issue was resolved (e.g. bug fixed, or feature implemented)
Projects
None yet
Development

No branches or pull requests

2 participants