BLEMeshJS

Core Concepts

Build the mental model first, then every SDK call makes more sense.

Use this page when SDK APIs feel abstract. The goal is to give you a compact mental model you can carry into every guide.

Why this matters

Once you understand node -> element -> model, you can usually predict where an operation belongs before looking at the API reference.

The five concepts that unlock the SDK

TermWhat it isWhy you care
NodeOne physical mesh deviceThis is what you discover, provision, and manage
ElementA functional part inside a nodeLets one device expose multiple independently-addressable roles
ModelA behavior attached to an elementThis is where on/off, dimming, sensors, and vendor features live
ProvisioningThe secure join processTurns an untrusted device into part of your network
Publish / SubscribeHow messages move through the meshLets one sender target one device, one room, or many devices

Mental model in one diagram

Physical device (Node)
└─ Elements
  ├─ Element 0
  │  ├─ Generic OnOff model
  │  └─ Light Lightness model
  ├─ Element 1
  │  └─ Sensor model
  └─ Element 2
    └─ Vendor model

Most SDK calls follow that hierarchy: find node -> pick model -> send or read state.

Node: the device identity in your network

A node is a physical mesh device, such as a light, switch, sensor, or gateway-attached target.

You provision nodes, assign keys to nodes, and target node elements and models.

const node = mesh.configuredNodes?.[0];

At this point, you should think of a node as the outer container, not the behavior surface.

Element: independently addressable function blocks

An element is a functional block inside a node. One physical device can expose multiple elements.

Use different elements when different parts of the same hardware need separate addresses or model sets.

Model: behavior you can actually invoke

A model defines behavior, such as on/off, dimming, sensors, scenes, or vendor commands.

In SDK code, model extension is where behavior becomes ergonomic:

import { GenericOnOff, SigModelId } from "@blemeshjs/sdk";

const node = mesh.configuredNodes?.[0];
if (!node) throw new Error("No configured node available");

const model = mesh.getModel(node.uuid.uuidString, 0, SigModelId.genericOnOffServerModelId);
if (!model) throw new Error("Generic OnOff model not found");

const onOff = model.use(GenericOnOff);
await onOff.set(true, { acknowledged: true });

Provisioning: from nearby device to trusted node

Provisioning is the secure onboarding process that adds a device to your mesh network.

Unprovisioned device
  -> discover
  -> connect
  -> identify and exchange security data
  -> assign address + keys
  -> save network state
  -> provisioned node

Provisioning matters because it changes persistent network state, not just UI state.

Publish/subscribe: one-to-one and one-to-many messaging

Models publish messages to addresses. Models subscribe to addresses.

Those addresses can represent one target, a group, or a virtual destination.

This is what lets one action control many devices.

Common mistakes to avoid

⚠️ Gotcha

Treating a node and model as the same thing is the fastest way to get confused. The node is the container, the model is the behavior.

MistakeBetter approach
Provisioning is "just onboarding UI"Treat provisioning as a security + topology update
Sending one command per device for room controlUse group addressing for one-to-many control
Jumping into API reference firstBuild the node/element/model model first

✅ Best practice

When debugging, always ask: "Am I at the right layer?" Node issue, model issue, or address issue.

If this clicked, you are ready to move to guided workflows.

Next, you will want to follow Setup Runtime, then Provision a New Device.

On this page