Skip to main content

Transport Order

Configure whether the SDK uses local network or cloud first when sending parameter updates.

note

ESPRMBase is configured during SDK setup.

What This Module Does ?

Defines transport priority when you call setValue(): try local network, cloud, or a custom order—with automatic fallback if a route fails.

Use local-first for smart-home apps where users are usually on the same Wi-Fi (faster, lower latency). Use cloud-first for apps where users often control devices remotely.

Local transport requires populating availableTransports via Events and Subscriptions.

Expected outcome: Updates use the best available route without manual fallback in your app.

Common Workflows

Local-first (smart home)

import { ESPRMBase, ESPTransportMode } from "@espressif/rainmaker-base-sdk";

ESPRMBase.setTransportOrder([
ESPTransportMode.local,
ESPTransportMode.cloud,
]);

Cloud-first (remote access)

ESPRMBase.setTransportOrder([
ESPTransportMode.cloud,
ESPTransportMode.local,
]);

Local-first with discovery

import { ESPRMBase, ESPRMEventType, ESPTransportMode } from "@espressif/rainmaker-base-sdk";

ESPRMBase.setTransportOrder([ESPTransportMode.local, ESPTransportMode.cloud]);

userInstance.subscribe(ESPRMEventType.localDiscovery, ({ nodeId, transportDetails }) => {
const node = findNodeById(nodeId);
if (node) {
node.availableTransports = node.availableTransports || {};
node.availableTransports[transportDetails.type] = transportDetails;
}
});

await powerParam.setValue(true);

Error Handling

The SDK handles fallback automatically. When using local-first, always include ESPTransportMode.cloud as backup.

Advanced Concepts

Mental model

Routing preference: same Wi-Fi → talk locally; otherwise → cloud.

Transport selection

Populating availableTransports

Nodes learn local addresses from discovery events. Subscribe to ESPRMEventType.localDiscovery — see Events and Subscriptions.

Best Practices

  1. Set order at app startup
  2. Subscribe to discovery before control
  3. Local-first for responsive UI
  4. Always include cloud as fallback
  5. Test on-network and remote

On this page