mirror of
https://github.com/esphome/esphome.git
synced 2026-07-10 17:05:36 +00:00
111 lines
3.7 KiB
YAML
111 lines
3.7 KiB
YAML
esp32_ble_server:
|
|
id: ble_server
|
|
manufacturer_data: [0x72, 0x4, 0x00, 0x23]
|
|
manufacturer: ESPHome
|
|
appearance: 0x1
|
|
model: Test
|
|
on_connect:
|
|
- lambda: |-
|
|
ESP_LOGD("BLE", "Connection from %d", id);
|
|
on_disconnect:
|
|
- lambda: |-
|
|
ESP_LOGD("BLE", "Disconnection from %d", id);
|
|
services:
|
|
- uuid: 2a24b789-7aab-4535-af3e-ee76a35cc12d
|
|
advertise: false
|
|
characteristics:
|
|
- id: test_notify_characteristic
|
|
description: "Notify characteristic"
|
|
uuid: cad48e28-7fbe-41cf-bae9-d77a6c233423
|
|
read: true
|
|
notify: true
|
|
value: [1, 2, 3, 4]
|
|
descriptors:
|
|
- uuid: cad48e28-7fbe-41cf-bae9-d77a6c111111
|
|
on_write:
|
|
logger.log:
|
|
format: "Descriptor write id %u, data %s"
|
|
args: [id, 'format_hex_pretty(x.data(), x.size()).c_str()']
|
|
value:
|
|
data: "123.1"
|
|
type: float
|
|
endianness: BIG
|
|
- uuid: 2a24b789-7a1b-4535-af3e-ee76a35cc42d
|
|
advertise: false
|
|
characteristics:
|
|
- id: test_lambda_characteristic
|
|
uuid: 2a24b789-7a1b-4535-af3e-ee76a35cc12c
|
|
read: true
|
|
value: !lambda return { 1, 2 };
|
|
- id: test_change_characteristic
|
|
uuid: 2a24b789-7a1b-4535-af3e-ee76a35cc11c
|
|
read: true
|
|
value:
|
|
data: "Initial"
|
|
string_encoding: utf-8
|
|
description: Change characteristic
|
|
descriptors:
|
|
- uuid: 0x4414
|
|
id: test_change_descriptor
|
|
value: "Initial descriptor value"
|
|
- uuid: 0x2312
|
|
value:
|
|
data: 0x12
|
|
type: uint16_t
|
|
on_write:
|
|
- lambda: |-
|
|
ESP_LOGD("BLE", "Descriptor received: %s from %d", std::string(x.begin(), x.end()).c_str(), id);
|
|
- uuid: 2a24b789-7a1b-4535-af3e-ee76a35cc99a
|
|
write: true
|
|
on_write:
|
|
then:
|
|
- lambda: |-
|
|
ESP_LOGD("BLE", "Characteristic received: %s from %d", std::string(x.begin(), x.end()).c_str(), id);
|
|
- ble_server.characteristic.set_value:
|
|
id: test_change_characteristic
|
|
value: !lambda 'return bytebuffer::ByteBuffer::wrap({0x00, 0x01, 0x02}).get_data();'
|
|
- ble_server.characteristic.notify:
|
|
id: test_notify_characteristic
|
|
- ble_server.descriptor.set_value:
|
|
id: test_change_descriptor
|
|
value: !lambda return bytebuffer::ByteBuffer::wrap({0x03, 0x04, 0x05}).get_data();
|
|
- ble_server.characteristic.set_value:
|
|
id: test_change_characteristic
|
|
value:
|
|
data: [0xfc, 0xef, 0xfe, 0x86]
|
|
- ble_server.descriptor.set_value:
|
|
id: test_change_descriptor
|
|
value:
|
|
data: [0x01, 0x02, 0x03]
|
|
|
|
# Regression test for #17142: the set_value action used from a trigger that passes
|
|
# its argument by reference (climate on_control supplies ClimateCall&) previously
|
|
# failed to compile.
|
|
sensor:
|
|
- platform: template
|
|
id: ble_test_temp
|
|
lambda: "return 20.0;"
|
|
|
|
output:
|
|
- platform: template
|
|
id: ble_test_output
|
|
type: float
|
|
write_action:
|
|
- logger.log: "out"
|
|
|
|
climate:
|
|
- platform: pid
|
|
name: "BLE Test Climate"
|
|
id: ble_test_climate
|
|
sensor: ble_test_temp
|
|
default_target_temperature: 20
|
|
heat_output: ble_test_output
|
|
control_parameters:
|
|
kp: 0.1
|
|
ki: 0.001
|
|
kd: 0.1
|
|
on_control:
|
|
- ble_server.characteristic.set_value:
|
|
id: test_notify_characteristic
|
|
value: !lambda "return std::vector<uint8_t>{0, 1, 2};"
|