Skip to content

Product To Device Closed Loop ​

Page Guide ​

ScenarioUse this flow when a new user needs to understand how FastBee organizes products, devices, thing models, and device messages.
PrerequisitesThe demo environment can be opened, and MQTTX or an equivalent MQTT client is available.
GoalCreate a product, define properties and functions, create a device, report data, and verify command delivery.

1. Overall Flow ​

2. Create A Product ​

Create a product first. The product determines the device type, protocol, networking mode, and thing-model template used by devices.

Product management

Recommended fields:

FieldRecommendation
Product nameUse a business-readable name, such as Demo Temperature Sensor.
Device typeChoose direct device, gateway, sub-device, video device, or other types according to the scenario.
ProtocolUse MQTT for the first verification.
Data formatKeep the platform default format unless the project has a custom protocol.

3. Define The Thing Model ​

Define properties, functions, and events before releasing the product.

Thing model

TypePurposeExample
PropertyDevice status or telemetryTemperature, humidity, switch status
FunctionPlatform command delivered to deviceTurn on relay, set threshold
EventImportant device eventAlarm, fault, offline notice

4. Create A Device ​

After the product is released, create a device and copy the MQTT credentials.

Create device

Pay attention to product ownership, device number, device secret, and status. Device credentials must match the MQTT access document exactly.

5. Verify With MQTTX ​

Use MQTTX to connect to the platform, report a property, and subscribe to command topics.

MQTTX connection

MQTTX reporting

After reporting data, check the device running status, logs, and latest property values in the console.

6. FAQ ​

MQTTX connection fails ​

Check first:

  1. Whether the product has been released.
  2. Whether the device is disabled.
  3. Whether the Client ID follows the S&deviceNumber&productId&userId format.
  4. Whether the product ID was filled in with the product number; they are not the same field.
  5. Whether the username and password come from the same product.
  6. When device authorization is enabled for the product, whether the auth code is appended to the password.
  7. Whether port 1883 on the server is open.

Device is online but data is not displayed ​

Check first:

  1. Whether the product ID and device number in the reporting topic are correct.
  2. Whether the JSON is in array format.
  3. Whether id exactly matches the thing-model identifier.
  4. Whether value matches the thing-model data type.
  5. Whether the product has been re-released and whether the device has inherited the latest thing model.

MQTTX does not receive messages after platform delivery ​

Check first:

  1. Whether MQTTX has subscribed to /{productId}/{deviceNum}/function/get.
  2. Whether the device stays online.
  3. Whether the thing model selected at the delivery entry is a writable function or a deliverable property.
  4. Whether permission control on the browser page disables the button.
  5. Whether the client subscription exists in the EMQX console.

Behavior is inconsistent after enabling device shadow ​

Device shadow caches platform commands when the device is offline. For the first integration test, it is recommended to disable device shadow and enable it only after the online delivery path is stable.

7. Development Entry ​

TypePath Or ModuleDescription
Frontend product pagevue3/src/views/iot/productProduct, thing model, release, and application configuration entry.
Frontend device pagevue3/src/views/iot/deviceDevice list, detail, running status, and command delivery.
Frontend APIvue3/src/api/iotRequest wrappers for products, devices, thing models, and more.
Backend product APIspringboot/fastbee-open-api/iot/product, /iot/model, and related APIs.
Backend device APIspringboot/fastbee-open-api/iot/device, device logs, device users, and related APIs.
MQTT authenticationspringboot/fastbee-open-api/iot/tool/mqtt/auth, EMQX webhook authentication entry.
Protocol parsingspringboot/fastbee-protocolDevice message codec and protocol extension.
Data servicespringboot/fastbee-iot-dataDevice running data and time-series data processing.

FastBee | fastbee.cn