Start in three steps
Read a virtual temperature sensor and write its setpoint through a BLE central. SPX supplies the model; a host companion service exposes the Bluetooth peripheral.
Before you start: Install SPX with the BLE package and SPX UI. Start spx-ble-adapter on a host with supported Bluetooth hardware. Have a BLE central/inspector ready and download the temperature sensor model. A container alone does not provide a radio.
1. Create the sensor and connect its adapter
Import the YAML in Models → Load model from file. Create an instance with ble_adapter_base_url set to the companion service. From Docker, the model default is http://host.docker.internal:8085. Start the instance and check Communication → ble.
2. Discover and read the peripheral
In your BLE client, connect to SpX Temperature Sensor. Open service 181a and read characteristic 2a6e. Decode it as UTF-8 text, as configured by this model. Expect 22.5°C at the default state.
3. Write and read back the setpoint
Write UTF-8 text 25.5 to f0c09111-8b3a-4e69-bdd0-9f0f613d1a90. Allow an adapter polling cycle. Success: the characteristic and SPX setpoint both represent 25.5°C. Restore 24°C, then stop the instance. This minimal model does not simulate temperature moving toward the setpoint.
Protocol communication
Use these settings and messages with the library’s BLE temperature sensor model.
- Companion service
- ble_adapter_base_url; default http://host.docker.internal:8085 from Docker
- Advertised device
- SpX Temperature Sensor; service 181a (Environmental Sensing)
- Value codec
- UTF-8 text in this model; select text decoding in your BLE client
Replace host placeholders with reachable addresses and use your published ports.
Swipe the table to see requests and replies.
| Address / message | Operation / payload | Expected reply |
|---|---|---|
Service 181a / characteristic 2a6e | Read; enable notifications for state changes | UTF-8 text 22.5 at defaults, representing °C |
Service 181a / f0c09111-8b3a-4e69-bdd0-9f0f613d1a90 | Read/write/notify setpoint; write UTF-8 text 25.5 | Initially 24.0; after writing, read 25.5 and check SPX setpoint |
Values describe this model’s nominal setup unless noted. Live measurements change as the simulation runs.
Example request and reply
Discover the advertised device, read 2a6e, then write text 25.5 to the custom setpoint UUID. Allow an adapter polling cycle, read it back, then restore 24.0. Change temperature in SPX to test notifications.
Connect: SpX Temperature Sensor
Read service 181a / characteristic 2a6e → UTF-8 "22.5"
Write custom setpoint UUID: UTF-8 "25.5"
→ bytes 32 35 2E 35 (hex)
After one adapter polling cycle, read setpoint
→ UTF-8 "25.5"; SPX setpoint = 25.5No reply or an unexpected value?
- 8085 is the companion’s HTTP control API, not a BLE address. Containers alone provide no Bluetooth radio. Confirm adapter health, advertising and host hardware.
- Despite the standard temperature UUID, this example uses UTF-8 text. Do not decode its bytes as the standard signed 16-bit temperature representation.
- Text 25.5 is hex bytes 32 35 2E 35. Enable notifications before changing temperature. This minimal model does not simulate thermal movement toward the setpoint.
What you can test next
- Enable temperature notifications, then change
temperaturein SPX Attributes. - Check the client’s behavior when the peripheral disconnects.
- Use the adapter guide for host setup and GATT configuration. This example checks the data contract; radio validation requires your hardware setup.
See the BLE adapter guide for configuration details.
