You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I'm trying to create a simple temperature sensor with your Homekit HAP but I'm not sure I fully understood the architecture: looking at Accessory.cpp it's pretty straightforward that the callback 'valueChangeFunctionCall' is invoked when the controller sets a new value for the characteristics but it's not clear (at least to me) what is the sibling 'read' callback.
The question is: is there a callback that is called whenever the controller asks for the current state? In the temperature example, I would like to return the current temperature (based on a call to an http server or whatever) but I wasn't able to do so.
I tried extending an intCharacteristics to my custom characteristics that override the constructor, value() and setValue() methods, to no avail: 'value()' is never changed...
Any hint on this?
Thanks!
The text was updated successfully, but these errors were encountered:
Since HomeKit is a framework for apps, there might be cases where the value of the characteristic being read rapidly, especially when there's multiple devices involved. In that case, you will perform lots of sensor reading, which could block the system and increase the latency, and potentially cause iOS to say the accessory is broken as the connection is dropped.
While I think you could just run a thread in the background that periodically update the value (which is the simplest solution), I think you can also just subclass the value() as subclass, although you will lost the notification feature.
That was my first idea, so I wired a value to test it: the problem is that only the first 'setValue()' (the one called after the object is instantiated) gets called and there will be no update. If, for example, I set say 12 with setValue, then override value() to return '13' (wired), I always get 12 on iOS. If I however omit the first setValue(), the client will always display '0', no matter what I return from my overridden value()...
Hi,
I'm trying to create a simple temperature sensor with your Homekit HAP but I'm not sure I fully understood the architecture: looking at Accessory.cpp it's pretty straightforward that the callback 'valueChangeFunctionCall' is invoked when the controller sets a new value for the characteristics but it's not clear (at least to me) what is the sibling 'read' callback.
The question is: is there a callback that is called whenever the controller asks for the current state? In the temperature example, I would like to return the current temperature (based on a call to an http server or whatever) but I wasn't able to do so.
I tried extending an intCharacteristics to my custom characteristics that override the constructor, value() and setValue() methods, to no avail: 'value()' is never changed...
Any hint on this?
Thanks!
The text was updated successfully, but these errors were encountered: