Skip to main content

OTA Updates

Check for, initiate, and monitor over-the-air firmware updates on RainMaker nodes.

note

node — from getUserNodes() or getNodeDetails() after User sign in.

What This Module Does ?

Remotely update node firmware: check for an available build, push the update with a job ID, poll status until complete or failed.

Use this when a new firmware version is available and the node is online — verify with Node Management connectivity first.

Expected outcome: Firmware download and install proceed on the device; status moves through pending → in progress → completed/failed.

Common Workflows

Check, push, and read status

const otaResponse = await node.checkOTAUpdate();

if (otaResponse.otaAvailable && otaResponse.otaJobId) {
await node.pushOTAUpdate(otaResponse.otaJobId);
const status = await node.getOTAUpdateStatus(otaResponse.otaJobId);
console.log("Status:", status.status);
}

Monitor until completion

async function waitForOTA(node, otaJobId, maxAttempts = 30) {
for (let i = 0; i < maxAttempts; i++) {
const { status } = await node.getOTAUpdateStatus(otaJobId);
if (status === "completed" || status === "failed") return status;
await new Promise((r) => setTimeout(r, 5000));
}
return "timeout";
}

const ota = await node.checkOTAUpdate();
if (ota.otaAvailable) {
await node.pushOTAUpdate(ota.otaJobId);
await waitForOTA(node, ota.otaJobId);
}

Error Handling

try {
const ota = await node.checkOTAUpdate();
if (!ota.otaAvailable || !ota.otaJobId) return;
await node.pushOTAUpdate(ota.otaJobId);
} catch (error) {
console.error("OTA failed:", error);
}

On failed status, show additionalInfo from the status response.

Advanced Concepts

Mental model

Check → push → poll status.

OTA flow

Best Practices

  1. Check connectivity before OTA
  2. Show firmware version before starting
  3. Poll with reasonable intervals
  4. Warn users not to power off during update

On this page