Rak11720 Bluetooth OTA

Hi,
I am having RAK11720. i need to develop a custom board which has the main controller as RAK11720. i like to use the Arduino IDE for custom firmware. i need to know that, is it possible to use the Bluetooth OTA Firmware update?

Is it possible means how to do it.

RUI3 supports BLE OTA DFU.
But our tool WisToolBox does not support update over BLE for the RAK11720 (yet).

Ambiq itself has a mobile application “Ambiq OTA” that can be used for BLE OTA DFU.

image

is there any functions to call on the program that initiates the OTA DFU or it is already enabled.
there is no any example for the ble ota in RUI3.

It is automatically enabled after restart for ~30 seconds.
If you keep BLE advertising alive, the device will be detected by the Ambiq application and you can start the upload.

But, we are not giving any guarantee for this application. In my experience, it is very slow, there is no documentation about it and it has a tendency to fail during the update.

But Ambiq did not release any documentation about the update protocol. RUI3 is using pre-compiled code from Ambiq for BLE-OTA DFU.

I just run a quick test:

i tried searching for the Ambiq OTA App for Android but i didnt get any. only showing the IOS version app. could you send me the apk you are using.

Hi @kamesh ,

You can get the APK here.

Hahaha, thanks @carlrowan
I was searching for Ambiq OTA and didn’t find anything.

Here is the one I extracted from my phone:
Ambiq OTA.zip (567.2 KB)

1 Like

I have Uploaded the below Program to RAK11720.
But in the app i tried scan devices no any device is showing in it.

/***
*

  • In this example, the device will create a BLE Uart characteristic.
  • When BLE receive data in specific pattern (“EE” or “BB” in ascii for example),
  • the device will send message both in Serial and BLE(Serial6).

***/
void setup()
{
//api.system.restoreDefault();
//If you want to read and write data through BLE API operations, you need to set BLE Serial (Serail6) to Custom Mode
Serial6.begin(115200, RAK_CUSTOM_MODE); // RAK_CUSTOM_MODE, RAK_AT_MODE
Serial.begin(115200);
delay(2000);

Serial.println("RAKwireless BLE UART Example");
Serial.println("------------------------------------------------------");

uint8_t pairing_pin[] = "123456";
Serial.println("Setting pairing PIN to:");
Serial.println((char *) pairing_pin);
api.ble.uart.setPIN(pairing_pin, 6);	//pairing_pin = 6-digit (digit 0..9 only)

// Set Permission to access BLE Uart is to require man-in-the-middle protection
// This will cause apps to perform pairing with static PIN we set above
// now support SET_ENC_WITH_MITM and SET_ENC_NO_MITM
api.ble.uart.setPermission(RAK_SET_ENC_WITH_MITM);
api.ble.uart.start(0);

}

void loop()
{
static uint16_t addr;
addr = 0;
while (api.ble.uart.available()) { // TRUE or FALSE

    if(addr>1){
        api.ble.uart.read();
        continue;
    }

    char str1[2];
    str1[addr] = api.ble.uart.read();

    const char *str2 = "EE";
    const char *str3 = "BB";

    if (strncmp(str1, str2, 2) == 0) {
        uint8_t data_array[] = "RAK_BLE_UART!!!";
        api.ble.uart.write(data_array, 15);
        Serial.println("RAK_BLE_UART!!!");
    } else if (strncmp(str1, str3, 2) == 0) {
        uint8_t rak_data[] = "HELLO RAK!";
        api.ble.uart.write(rak_data, 10);
        Serial.println("HELLO RAK!");
    }

    addr++;
}

}

All I do in my examples to have both BLE UART and OTA service available is:

	// If available, enable BLE advertising for 30 seconds and open the BLE UART channel
#if defined(_VARIANT_RAK3172_) || defined(_VARIANT_RAK3172_SIP_)
// No BLE
#else
	Serial6.begin(115200, RAK_AT_MODE);
	api.ble.advertise.start(30);
#endif

I am guessing your code is missing the api.ble.advertise.start(30);

Here is what I tired again, but no devices shown.

extern const char *sw_version;

void setup()
{
uint32_t baudrate = Serial.getBaudrate();
Serial.begin(baudrate);
Serial6.begin(baudrate, RAK_AT_MODE);

Serial.println("RAKwireless RAK11720");
Serial.println("------------------------------------------------------");
Serial.printf("Version: %s\r\n", sw_version);

// Start BLE UART advertisement for 30 seconds
api.ble.settings.blemode(RAK_BLE_UART_MODE);
api.ble.advertise.start(30);

}
void loop()
{
/* Destroy this busy loop and use timer to do what you want instead,
* so that the system thread can auto enter low power mode by api.system.lpm.set(1); */
// api.system.scheduler.task.destroy();
}

Remove the api.ble.settings.blemode(RAK_BLE_UART_MODE);
I am not using this, I am only using Serial6.begin(115200, RAK_AT_MODE); and I have BLE UART and BLE OTA

Tried it as you said still device not showing in Ambiq OTA app.
But i am able to use the BLE UART service through Serial Bluetooth Terminal App.

Did you click “Allow” to everything when you started Ambiq OTA the first time?
If not, the app is not allowed to scan for BLE devices.

My Bad i allowed the location permission but didn’t turn on the location service. Once i turned it on all bluetooth devices shown and i tried uploading the bin file.

But it got stuck at 100%.

in the serial monitor it shows “CRC verify failed”.

Screenshot from 2024-05-31 17-29-30

Again My mistake. i uploaded the “RAK11720.ino.bin” file instead of “RAK11720.ino_Nonsecure_OTA_Package_BLE.bin”.

Now the BLE OTA update is Done. But is is as you said it took more time to update for a simple program.

Anyway OTA is Done. Thanks for your Help.

just for reference, I use:

Serial6.begin(baudrate, RAK_AT_MODE);
api.ble.settings.advertiseInterval.set(5000);
api.ble.uart.start(0);

and I get the BLE DFU service when connecting to the advertising packet.