Skip to main content

BLE Device Search by Customer ID

Discover BLE RainMaker devices that belong to a specific customer—useful for white-label apps.

info

Requires a configured provisioning adapter. See Provisioning and Adapters.

note

The userInstance refers to ESPRMUser from User Sign in.

What This Module Does ?

searchESPBLEDevices(customerId) scans BLE devices and returns only those whose 16-bit customer ID matches the value in manufacturer advertisement data.

Use this for white-label or multi-tenant apps with a known customer ID from profile or deployment config.

Use searchESPDevices instead for general discovery by name prefix (BLE or SoftAP).

Expected outcome: ESPDevice instances ready for connect() and Provisioning.

Common Workflows

Scan by customer ID

const customerId = 1; // From profile or deployment config
const devices = await userInstance.searchESPBLEDevices(customerId);

console.log(`Found ${devices.length} devices`);
devices.forEach((device) => console.log(device.name));

Discover, connect, and provision

const devices = await userInstance.searchESPBLEDevices(customerId);
if (!devices.length) return;

const device = devices[0];
await device.connect();
await device.scanWifiList();
await device.provision(ssid, passphrase, onProgress);

Device picker UI

const devices = await userInstance.searchESPBLEDevices(customerId);
const selected = devices[userSelectionIndex];
await selected.connect();

Error Handling

try {
const devices = await userInstance.searchESPBLEDevices(customerId);
if (!devices.length) {
// Empty result is not always an error
return;
}
} catch (error) {
console.error("BLE scan failed:", error);
}

Advanced Concepts

Filter pipeline

MethodFilter
searchESPBLEDevices(customerId)Customer ID in manufacturer data
searchESPDevices(prefix, transport)Device name prefix

Best Practices

  1. Source customer ID from config, not hardcoded values
  2. Stop scan when donestopESPDevicesSearch()
  3. Handle empty results with a clear message
  4. Continue with Provisioning after selection

On this page