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=0should deinitialize BLE and returnOK.AT+BLEINIT=1should initialize BLE in Client mode and returnOK.AT+BLEINIT=2should initialize BLE in Server mode and returnOK.
Actual behavior
AT+BLEINIT=0works correctly and returnsOK.AT+BLEINIT=1andAT+BLEINIT=2do 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();
}