When using the `radio.startWifiScan` function with the LR1121 module, an exception occurs, returning "failed, code -706".
Closed this issue · 4 comments
Control MCU in use:
ESP32S3 chip
Description:
When I tested the LR1121 module on the ESP32S3 platform using the official example "LR11x0_WiFi_Scan_Interrupt," I found that the LR1121 module could initialize normally. However, when reaching the function "radio.startWifiScan," it encountered an error, returning "failed, code -706." I tried modifying the onboard crystal type by setting "radio.XTAL = true," but this prevented the LR1121 from initializing. I also tried changing "radio.setTCXO(0)" or "radio.setTCXO(3.3)," but neither had any effect. Where could the issue be? Other examples, such as "LR11x0_GFSK_Modem" or "LR11x0_PingPong," work without issues.
Sketch:
/*
RadioLib LR11x0 WiFi scan Interrupt Example
This example performs a passive scan of WiFi networks.
The scan shows basic information about the networks,
such as the frequency, country code and SSID.
Other modules from LR11x0 family can also be used.
This example assumes Seeed Studio Wio WM1110 is used.
For other LR11x0 modules, some configuration such as
RF switch control may have to be adjusted.
Using blocking scan is not recommended, as depending
on the scan settings, the program may be blocked
for several seconds! Instead, interrupt scan is recommended.
For default module settings, see the wiki page
https://github.com/jgromes/RadioLib/wiki/Default-configuration#lr11x0---wifi-scan
For full API reference, see the GitHub Pages
https://jgromes.github.io/RadioLib/
*/
// include the library
#include <RadioLib.h>
#include "pin_config.h"
LR1121 radio = new Module(LR1121_CS, LR1121_INT, LR1121_RST, LR1121_BUSY, SPI);
// set RF switch configuration for Wio WM1110
// Wio WM1110 uses DIO5 and DIO6 for RF switching
// NOTE: other boards may be different!
static const uint32_t rfswitch_dio_pins[] = {
RADIOLIB_LR11X0_DIO5, RADIOLIB_LR11X0_DIO6,
RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC};
static const Module::RfSwitchMode_t rfswitch_table[] = {
// mode DIO5 DIO6
{LR11x0::MODE_STBY, {LOW, LOW}},
{LR11x0::MODE_RX, {HIGH, LOW}},
{LR11x0::MODE_TX, {HIGH, HIGH}},
{LR11x0::MODE_TX_HP, {LOW, HIGH}},
{LR11x0::MODE_TX_HF, {LOW, LOW}},
{LR11x0::MODE_GNSS, {LOW, LOW}},
{LR11x0::MODE_WIFI, {LOW, LOW}},
END_OF_MODE_TABLE,
};
void setup()
{
Serial.begin(115200);
Serial.println("Ciallo");
pinMode(RT9080_EN, OUTPUT);
digitalWrite(RT9080_EN, HIGH);
SPI.begin(LR1121_SCLK, LR1121_MISO, LR1121_MOSI);
// set RF switch control configuration
// this has to be done prior to calling begin()
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
// initialize LR1121 with default settings
Serial.print(F("[LR1121] Initializing ... "));
int state = radio.begin();
if (state == RADIOLIB_ERR_NONE)
{
Serial.println(F("success!"));
}
else
{
Serial.print(F("failed, code "));
Serial.println(state);
while (true)
;
}
// set the function that will be called
// when WiFi scan is complete
radio.setIrqAction(setFlag);
// scan all WiFi signals with default scan configuration
Serial.print(F("[LR1121] Starting passive WiFi scan ... "));
state = radio.startWifiScan('n', RADIOLIB_LR11X0_WIFI_ACQ_MODE_FULL_BEACON,
RADIOLIB_LR11X0_WIFI_ALL_CHANNELS, 16, 10000);
if (state == RADIOLIB_ERR_NONE)
{
Serial.println(F("success!"));
}
else
{
Serial.print(F("failed, code "));
Serial.println(state);
}
}
// flag to indicate that a scan was completed
volatile bool scanFlag = false;
// this function is called when a scan is completed
// IMPORTANT: this function MUST be 'void' type
// and MUST NOT have any arguments!
#if defined(ESP8266) || defined(ESP32)
ICACHE_RAM_ATTR
#endif
void setFlag(void)
{
// scan is complete, set the flag
scanFlag = true;
}
void loop()
{
// check if the flag is set
if (scanFlag)
{
// reset flag
scanFlag = false;
// get the number of scan results
uint8_t count = 0;
Serial.print(F("[LR1121] Reading WiFi scan results ... "));
int state = radio.getWifiScanResultsCount(&count);
if (state == RADIOLIB_ERR_NONE)
{
Serial.println(F("success!"));
// print the table header
Serial.print(F("[LR1121] Reading "));
Serial.print(count);
Serial.println(F(" scan results:"));
Serial.println(F(" # | WiFi type\t| Frequency\t| MAC Address\t | Country\t| RSSI [dBm]\t| SSID"));
// read all results one by one
// this result type contains the most information, including the SSID
LR11x0WifiResultExtended_t result;
for (int i = 0; i < count; i++)
{
if (i < 10)
{
Serial.print(" ");
}
Serial.print(i);
Serial.print(" | ");
state = radio.getWifiScanResult(&result, i);
if (state != RADIOLIB_ERR_NONE)
{
Serial.print(F("Failed to read result, code "));
Serial.println(state);
continue;
}
// print the basic information
Serial.print(F("802.11"));
Serial.print(result.type);
Serial.print("\t| ");
Serial.print(result.channelFreq);
Serial.print(" MHz\t| ");
// print MAC address
for (int j = 0; j < 6; j++)
{
if (result.mac[j] < 0x10)
{
Serial.print("0");
}
Serial.print(result.mac[j], HEX);
if (j < 5)
{
Serial.print(":");
}
}
Serial.print(" | ");
// print the two-letter country code
String country = result.countryCode;
Serial.print(country);
Serial.print(" \t| ");
// print the RSSI
Serial.print(result.rssi);
Serial.print("\t| ");
// print the network SSID
Serial.println((char *)result.ssid);
}
}
else
{
// some other error occurred
Serial.print(F("failed, code "));
Serial.println(state);
}
// start scanning again
Serial.print(F("[LR1121] Starting passive WiFi scan ... "));
state = radio.startWifiScan('*');
if (state == RADIOLIB_ERR_NONE)
{
Serial.println(F("success!"));
}
else
{
Serial.print(F("failed, code "));
Serial.println(state);
}
}
}
Debug Message:
[2024-10-25 17:35:09.800] ESP-ROM:esp32s3-20210327
[2024-10-25 17:35:09.800] Build:Mar 27 2021
[2024-10-25 17:35:09.800] rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
[2024-10-25 17:35:09.800] SPIWP:0xee
[2024-10-25 17:35:09.800] mode:DIO, clock div:1
[2024-10-25 17:35:09.800] load:0x3fce3808,len:0x44c
[2024-10-25 17:35:09.800] load:0x403c9700,len:0xbd8
[2024-10-25 17:35:09.800] load:0x403cc700,len:0x2a80
[2024-10-25 17:35:09.800] entry 0x403c98d0
[2024-10-25 17:35:09.800]
[2024-10-25 17:35:09.877] Ciallo
[2024-10-25 17:35:09.877] RLB_SPI: CMDW
[2024-10-25 17:35:09.877] RLB_SPI: SI 3 0 1 3 2 0 0 0
[2024-10-25 17:35:09.877] RLB_SPI: SO FF FF FF FF FF FF FF FF
[2024-10-25 17:35:09.877] [LR1121] Initializing ...
[2024-10-25 17:35:10.281] RLB_SPI: CMDW 1 1
[2024-10-25 17:35:10.281] RLB_SPI: SI
[2024-10-25 17:35:10.281] RLB_SPI: SO 5 13
[2024-10-25 17:35:10.281] RLB_SPI: CMDR
[2024-10-25 17:35:10.281] RLB_SPI: SI 0 0 0 0 0
[2024-10-25 17:35:10.281] RLB_SPI: SO 7 22 3 1 1
[2024-10-25 17:35:10.281] RLB_SPI: CMDW 1 1C
[2024-10-25 17:35:10.281] RLB_SPI: SI 0
[2024-10-25 17:35:10.281] RLB_SPI: SO 5 13 0
[2024-10-25 17:35:10.281] RLB_SPI: CMDR
[2024-10-25 17:35:10.281] RLB_SPI: SI 0 0 0 0 0 0
[2024-10-25 17:35:10.281] RLB_SPI: SO 5 13 0 80 0 0
[2024-10-25 17:35:10.281] RLB_SPI: CMDW 1 1C
[2024-10-25 17:35:10.281] RLB_SPI: SI 0
[2024-10-25 17:35:10.281] RLB_SPI: SO 5 13 0
[2024-10-25 17:35:10.281] RLB_SPI: CMDR
[2024-10-25 17:35:10.281] RLB_SPI: SI 0 0 0 0 0 0
[2024-10-25 17:35:10.281] RLB_SPI: SO 5 13 0 80 0 0
[2024-10-25 17:35:10.281] RLB_SPI: CMDW 1 D
[2024-10-25 17:35:10.281] RLB_SPI: SI
[2024-10-25 17:35:10.281] RLB_SPI: SO 5 13
[2024-10-25 17:35:10.281] RLB_SPI: CMDR
[2024-10-25 17:35:10.281] RLB_SPI: SI 0 0 0
[2024-10-25 17:35:10.281] RLB_SPI: SO 7 0 20
[2024-10-25 17:35:10.281] RLB_SPI: CMDW 1 E
[2024-10-25 17:35:10.281] RLB_SPI: SI
[2024-10-25 17:35:10.281] RLB_SPI: SO 5 13
[2024-10-25 17:35:10.281] RLB_SPI: CMDR
[2024-10-25 17:35:10.281] RLB_SPI: SI 0 0 0 0 0 0
[2024-10-25 17:35:10.281] RLB_SPI: SO 5 13 0 80 0 0
[2024-10-25 17:35:10.281] RLB_SPI: CMDW 1 17
[2024-10-25 17:35:10.281] RLB_SPI: SI 0 0 0 A3
[2024-10-25 17:35:10.281] RLB_SPI: SO 5 13 0 80 0 0
[2024-10-25 17:35:10.281] RLB_SPI: CMDR
[2024-10-25 17:35:10.281] RLB_SPI: SI 0 0 0 0 0 0
[2024-10-25 17:35:10.281] RLB_SPI: SO 5 13 0 80 0 0
[2024-10-25 17:35:10.281] RLB_SPI: CMDW 2 13
[2024-10-25 17:35:10.281] RLB_SPI: SI 1
[2024-10-25 17:35:10.281] RLB_SPI: SO 5 13 0
[2024-10-25 17:35:10.281] RLB_SPI: CMDR
[2024-10-25 17:35:10.281] RLB_SPI: SI 0 0 0 0 0 0
[2024-10-25 17:35:10.281] RLB_SPI: SO 5 13 0 80 0 0
[2024-10-25 17:35:10.281] RLB_SPI: CMDW 1 14
[2024-10-25 17:35:10.281] RLB_SPI: SI B F8 F FC
[2024-10-25 17:35:10.281] RLB_SPI: SO 5 13 0 80 0 0
[2024-10-25 17:35:10.281] RLB_SPI: CMDR
[2024-10-25 17:35:10.281] RLB_SPI: SI 0 0 0 0 0 0
[2024-10-25 17:35:10.281] RLB_SPI: SO 4 13 0 0 0 0
[2024-10-25 17:35:10.281] RLB_SPI: CMDW 1 13
[2024-10-25 17:35:10.281] RLB_SPI: SI 0 0 0 0 0 0 0 0
[2024-10-25 17:35:10.281] RLB_SPI: SO 4 13 0 0 0 0 0 0 0 0
[2024-10-25 17:35:10.281] RLB_SPI: CMDR
[2024-10-25 17:35:10.281] RLB_SPI: SI 0 0 0 0 0 0
[2024-10-25 17:35:10.281] RLB_SPI: SO 4 13 0 0 0 0
[2024-10-25 17:35:10.281]
[2024-10-25 17:35:10.562] RLB_SPI: CMDW 1 F
[2024-10-25 17:35:10.562] RLB_SPI: SI 3F
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13 0
[2024-10-25 17:35:10.562] RLB_SPI: CMDR
[2024-10-25 17:35:10.562] RLB_SPI: SI 0 0 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: CMDW 2 E
[2024-10-25 17:35:10.562] RLB_SPI: SI 2
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13 0
[2024-10-25 17:35:10.562] RLB_SPI: CMDR
[2024-10-25 17:35:10.562] RLB_SPI: SI 0 0 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: CMDW 2 2
[2024-10-25 17:35:10.562] RLB_SPI: SI
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13
[2024-10-25 17:35:10.562] RLB_SPI: CMDR
[2024-10-25 17:35:10.562] RLB_SPI: SI 0 0
[2024-10-25 17:35:10.562] RLB_SPI: SO 6 2
[2024-10-25 17:35:10.562] RLB_SPI: CMDW 2 F
[2024-10-25 17:35:10.562] RLB_SPI: SI 0 4 0 0
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: CMDR
[2024-10-25 17:35:10.562] RLB_SPI: SI 0 0 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: CMDW 2 2
[2024-10-25 17:35:10.562] RLB_SPI: SI
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13
[2024-10-25 17:35:10.562] RLB_SPI: CMDR
[2024-10-25 17:35:10.562] RLB_SPI: SI 0 0
[2024-10-25 17:35:10.562] RLB_SPI: SO 6 2
[2024-10-25 17:35:10.562] RLB_SPI: CMDW 2 F
[2024-10-25 17:35:10.562] RLB_SPI: SI 9 4 0 0
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: CMDR
[2024-10-25 17:35:10.562] RLB_SPI: SI 0 0 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: CMDW 2 2
[2024-10-25 17:35:10.562] RLB_SPI: SI
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13
[2024-10-25 17:35:10.562] RLB_SPI: CMDR
[2024-10-25 17:35:10.562] RLB_SPI: SI 0 0
[2024-10-25 17:35:10.562] RLB_SPI: SO 6 2
[2024-10-25 17:35:10.562] RLB_SPI: CMDW 2 F
[2024-10-25 17:35:10.562] RLB_SPI: SI 9 4 3 0
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: CMDR
[2024-10-25 17:35:10.562] RLB_SPI: SI 0 0 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: CMDW 2 2
[2024-10-25 17:35:10.562] RLB_SPI: SI
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13
[2024-10-25 17:35:10.562] RLB_SPI: CMDR
[2024-10-25 17:35:10.562] RLB_SPI: SI 0 0
[2024-10-25 17:35:10.562] RLB_SPI: SO 6 2
[2024-10-25 17:35:10.562] RLB_SPI: CMDW 2 2B
[2024-10-25 17:35:10.562] RLB_SPI: SI 12
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13 0
[2024-10-25 17:35:10.562] RLB_SPI: CMDR
[2024-10-25 17:35:10.562] RLB_SPI: SI 0 0 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: CMDW 2 2
[2024-10-25 17:35:10.562] RLB_SPI: SI
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13
[2024-10-25 17:35:10.562] RLB_SPI: CMDR
[2024-10-25 17:35:10.562] RLB_SPI: SI 0 0
[2024-10-25 17:35:10.562] RLB_SPI: SO 6 2
[2024-10-25 17:35:10.562] RLB_SPI: CMDW 2 10
[2024-10-25 17:35:10.562] RLB_SPI: SI 0 8 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13 0 0 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: CMDR
[2024-10-25 17:35:10.562] RLB_SPI: SI 0 0 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: CMDW 2 2
[2024-10-25 17:35:10.562] RLB_SPI: SI
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13
[2024-10-25 17:35:10.562] RLB_SPI: CMDR
[2024-10-25 17:35:10.562] RLB_SPI: SI 0 0
[2024-10-25 17:35:10.562] RLB_SPI: SO 6 2
[2024-10-25 17:35:10.562] RLB_SPI: CMDW 2 10
[2024-10-25 17:35:10.562] RLB_SPI: SI 0 8 0 0 1 0
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13 0 0 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: CMDR
[2024-10-25 17:35:10.562] RLB_SPI: SI 0 0 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: CMDW 2 2
[2024-10-25 17:35:10.562] RLB_SPI: SI
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13
[2024-10-25 17:35:10.562] RLB_SPI: CMDR
[2024-10-25 17:35:10.562] RLB_SPI: SI 0 0
[2024-10-25 17:35:10.562] RLB_SPI: SO 6 2
[2024-10-25 17:35:10.562] RLB_SPI: CMDW 2 10
[2024-10-25 17:35:10.562] RLB_SPI: SI 0 8 0 0 1 0
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13 0 0 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: CMDR
[2024-10-25 17:35:10.562] RLB_SPI: SI 0 0 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: CMDW 1 10
[2024-10-25 17:35:10.562] RLB_SPI: SI 0
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13 0
[2024-10-25 17:35:10.562] RLB_SPI: CMDR
[2024-10-25 17:35:10.562] RLB_SPI: SI 0 0 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: CMDW 1 11
[2024-10-25 17:35:10.562] RLB_SPI: SI 6B 6E
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13 0 0
[2024-10-25 17:35:10.562] RLB_SPI: CMDR
[2024-10-25 17:35:10.562] RLB_SPI: SI 0 0 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: CMDW 2 B
[2024-10-25 17:35:10.562] RLB_SPI: SI 19 DE 50 80
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: CMDR
[2024-10-25 17:35:10.562] RLB_SPI: SI 0 0 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: CMDW 2 15
[2024-10-25 17:35:10.562] RLB_SPI: SI 0 0 4 7
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: CMDR
[2024-10-25 17:35:10.562] RLB_SPI: SI 0 0 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: CMDW 2 11
[2024-10-25 17:35:10.562] RLB_SPI: SI A 2
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13 0 0
[2024-10-25 17:35:10.562] RLB_SPI: CMDR
[2024-10-25 17:35:10.562] RLB_SPI: SI 0 0 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13 0 0 0 0
[2024-10-25 17:35:10.562] success!
[2024-10-25 17:35:10.562] [LR1121] Starting passive WiFi scan ... RLB_SPI: CMDW 1 1C
[2024-10-25 17:35:10.562] RLB_SPI: SI 0
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13 0
[2024-10-25 17:35:10.562] RLB_SPI: CMDR
[2024-10-25 17:35:10.562] RLB_SPI: SI 0 0 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: CMDW 3 7
[2024-10-25 17:35:10.562] RLB_SPI: SI
[2024-10-25 17:35:10.562] RLB_SPI: SO 4 13
[2024-10-25 17:35:10.562] RLB_SPI: CMDR
[2024-10-25 17:35:10.562] RLB_SPI: SI 0 0 0 0 0 0
[2024-10-25 17:35:10.562] RLB_SPI: SO 3 13 0 40 0 0
[2024-10-25 17:35:10.562] failed, code -706
As far as I can tell, LR1121 does not support WiFi or GNSS scanning. Unlike LR1110 or LR1120, its datasheet does not mention it.
It doesn't - it's cut down to literally halve the price and is the target for the Modem-E stack which between the hardware reference design and the code gets you most of the way to certification - as in a lot less back & forth with compliance issues - apparently - we'll see!
As far as I can tell, LR1121 does not support WiFi or GNSS scanning. Unlike LR1110 or LR1120, its datasheet does not mention it.
@jgromes
Thank you for your response. I reviewed the datasheet and confirmed that the Wi-Fi functionality is indeed not supported. Additionally, I have another question. I am the designer of the LR1121, and due to design constraints, I have insufficient MCU pins. Can I use an external pull-up resistor of 10K ohms combined with a 10µF filter capacitor for the reset pin of the LR1121 in my hardware design? Would this approach negatively impact any of its functions?
Can I use an external pull-up resistor of 10K ohms combined with a 10µF filter capacitor for the reset pin of the LR1121 in my hardware design? Would this approach negatively impact any of its functions?
A good question to ask Semtech, unfortunately I can't help much there. For what it's worth, the LR11xx do have a reboot command, which we could use if RADIOLIB_NC
is provided instead of a reset pin. Though personally I always prefer to use a dedicated reset pin.