Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion smart-light/Matter/Matter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ extension Matter {
var lightConfig = esp_matter.endpoint.extended_color_light.config_t()
lightConfig.on_off.on_off = true
lightConfig.level_control.current_level = .init(64)
lightConfig.level_control.lighting.start_up_current_level = .init(64)
lightConfig.level_control_lighting.start_up_current_level = .init(64)
lightConfig.color_control.color_mode =
chip.app.Clusters.ColorControl.ColorMode.colorTemperature.rawValue
lightConfig.color_control.enhanced_color_mode =
Expand Down
11 changes: 7 additions & 4 deletions smart-light/Matter/Node.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,14 @@ struct Endpoint: MatterEndpoint {
}

func `as`<T: MatterConreteEndpoint>(_ type: T.Type) -> T? {
var count = UInt8(0)
let expected = T.deviceTypeId
let ids = esp_matter.endpoint.get_device_type_ids(endpoint, &count)
for id in UnsafeMutableBufferPointer(start: ids, count: Int(count)) {
if id == expected {
let count = esp_matter.endpoint.get_device_type_count(endpoint)
for i in 0..<count {
var deviceTypeId: UInt32 = 0
var deviceTypeVersion: UInt8 = 0
let err = esp_matter.endpoint.get_device_type_at_index(
endpoint, i, &deviceTypeId, &deviceTypeVersion)
if err == ESP_OK && deviceTypeId == expected {
return T(endpoint)
}
}
Expand Down
Loading