AT+BLEINIT=1/2 returns "ready" instead of "OK" on RAK11160 (ESP32-C2 AT firmware)

I am using the RAK11160 module in an application that requires both LoRaWAN and BLE .

For BLE, I flashed the ESP32-C2 with the esp32c2-2mb-ble-at.bin firmware provided by Espressif and communicate with it from an STM32 using AT commands.

I am experiencing an issue with the AT+BLEINIT command.

Expected behavior

  • AT+BLEINIT=0 should deinitialize BLE and return OK .
  • AT+BLEINIT=1 should initialize BLE in Client mode and return OK .
  • AT+BLEINIT=2 should initialize BLE in Server mode and return OK .

Actual behavior

  • AT+BLEINIT=0 works correctly and returns OK .
  • AT+BLEINIT=1 and AT+BLEINIT=2 do not initialize BLE. Instead, the module immediately responds with:
ready

After this, AT+BLEINIT? still reports:

+BLEINIT:0
OK

indicating that BLE was not initialized.

Subsequent BLE commands such as AT+BLEGATTSSRVCRE , AT+BLEGATTSSRVSTART , and AT+BLEADVSTART all return ERROR .

If I completely erase the ESP32-C2 flash and reprogram it with esp32c2-2mb-ble-at.bin , AT+BLEINIT=1 /2 works correctly for some time and returns OK . However, after some time (without reflashing), the same commands start returning ready again.

[TX] AT
[RX] AT
OK
[TX] ATE0
[RX] ATE0
OK
[TX] AT+CWMODE?
[RX] 
ERROR
[TX] AT+BLEINIT?
[RX] +BLEINIT:0
OK
[TX] AT+BLENAME?
[RX] +BLENAME:RAK-MAC-CFG
OK
[TX] AT+BLEINIT=2
[RX] 
ready
[TX] AT+BLEINIT?
[RX] AT+BLEINIT?
+BLEINIT:0
OK
[TX] AT+BLEGATTSSRVCRE
[RX] AT+BLEGATTSSRVCRE
ERROR
[TX] AT+BLEGATTSSRVSTART
[RX] AT+BLEGATTSSRVSTART
ERROR
[TX] AT+BLEGATTSSRV?
[RX] AT+BLEGATTSSRV?
ERROR
[TX] AT+BLEGATTSCHAR?
[RX] AT+BLEGATTSCHAR?
ERROR
[TX] AT+BLENAME="RAK-MAC-CFG"
[RX] AT+BLENAME="RAK-MAC-CFG"
ERROR
[TX] AT+BLEADVSTART
[RX] AT+BLEADVSTART
ERROR

Second Code Response

[RX] AT
OK
[TX] AT+BLEINIT=0
[RX] AT+BLEINIT=0
OK
[TX] AT+BLEINIT=1
[RX] AT+BLEINIT=1
ready
[TX] AT+BLEINIT?
[RX] AT+BLEINIT?
+BLEINIT:0
OK

Firmware

sendRaw("AT");                            delay(1000);  printAll();
sendRaw("AT+BLEINIT=0");        delay(2000);  printAll();
sendRaw("AT+BLEINIT=2");        delay(2000);  printAll();
sendRaw("AT+BLEINIT?");          delay(1000);  printAll();

void sendRaw(const char* cmd)
{
    delay(200);
    while (Serial1.available()) Serial1.read();
    Serial.print("\n[TX] ");
    Serial.println(cmd);
    Serial1.print(cmd);
    Serial1.print("\r\n");
}

void printAll()
{
    delay(500);
    Serial.print("[RX] ");
    while (Serial1.available()) Serial.write(Serial1.read());
    Serial.println();
}

Hi @abubakar ,

Few things to check.

  1. Is the IO control of STM32 on RAK11160 established well on ESP32C2? This is done via PA0 digitalWrite(PA0, HIGH); // or setEspPowerMode(POWER_ON);. Is there any possibility that this pin goes low?
  2. I am not sure if it can help but you can force to shutdown the Wi-Fi stack using AT+CWMODE=0 on ESP32C2.
  3. Is the power supply stable at 3.3V? What is your supply source?

Hello @carlrowan,

Thanks for you reply,

  1. Yes, PA0 is set to high. This is the code i am uisng;
#define WB_ESP8684 PA0

void setup()
{
    Serial.begin(115200);
    Serial1.begin(115200);

    pinMode(WB_ESP8684, OUTPUT);
    digitalWrite(WB_ESP8684, HIGH);
    delay(5000);
    // while (Serial1.available()) Serial1.read();

    sendRaw("AT");           delay(1000);      printAll();

    sendRaw("AT+CWMODE=0");       delay(1000); printAll();

    // sendRaw("AT+BLEINIT?");         delay(1000);  printAll();
    // sendRaw("AT+BLENAME?");         delay(2000); printAll();
    sendRaw("AT+BLEINIT=0");        delay(2000); printAll();
    sendRaw("AT+BLEINIT=2");        delay(2000); printAll();
    sendRaw("AT+BLEGATTSSRV?");     delay(2000); printAll();
    sendRaw("AT+BLEGATTSCHAR?");    delay(2000); printAll();
    sendRaw("AT+BLEINIT?");         delay(1000); printAll();
    sendRaw("AT+BLEGATTSSRVCRE");   delay(2000); printAll();
    sendRaw("AT+BLEGATTSSRVSTART"); delay(2000); printAll();   // <-- this was missing
    sendRaw("AT+BLENAME=\"RAK-MAC-CFG\""); delay(1000); printAll();
    sendRaw("AT+BLEADVSTART");      delay(1000); printAll();

}

  1. Yes, the voltages are stable at 3.3V. I am applying voltages from usb-ttl serial converter