Introduce constructors for ExposeMapping

This should allow the ExposeMapping struct to be changed without
constantly impacting its callers.
This commit is contained in:
Darell Tan
2024-11-24 15:25:17 +08:00
parent b11ab07fbb
commit d4daef7bce
8 changed files with 22 additions and 12 deletions

View File

@@ -22,10 +22,10 @@ func createContactServices(dev *Device) (byte, []*service.S, []*ExposeMapping, e
s := service.NewContactSensor()
svcs = append(svcs, s.S)
exposes = append(exposes, &ExposeMapping{&exp, s.ContactSensorState.C,
exposes = append(exposes, NewTranslatedExposeMapping(&exp, s.ContactSensorState.C,
&BoolTranslator{
characteristic.ContactSensorStateContactNotDetected,
characteristic.ContactSensorStateContactDetected}})
characteristic.ContactSensorStateContactDetected}))
}
}