BLE Device Search by Customer ID
Discover BLE RainMaker devices that belong to a specific customer—useful for white-label apps.
信息
Requires a configured provisioning adapter. See Provisioning and Adapters.
备注
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
Comparison with prefix search
| Method | Filter |
|---|---|
searchESPBLEDevices(customerId) | Customer ID in manufacturer data |
searchESPDevices(prefix, transport) | Device name prefix |
Best Practices
- Source customer ID from config, not hardcoded values
- Stop scan when done —
stopESPDevicesSearch() - Handle empty results with a clear message
- Continue with Provisioning after selection
Related Resource
- API Reference: