Closed killobatt closed 4 years ago
Ok, I have built accessory with your services and it worked fine.
Then I decoded your accessories JSON and found this problem with CURRENT_TEMPERATURE characteristic:
{
"aid": 1,
"iid": 18,
"type": "00000011-0000-1000-8000-0026BB765291",
"perms": [
"pr",
"ev"
],
"ev": false,
"description": "Current Temperature",
"format": "float",
"unit": "celsius",
"minValue": 6.06114274642742e-39,
"maxValue": 1.69625058101164e-36,
"minStep": -1.62387431414683e-29,
"value": 25.7000007629395
}
Notice minValue, maxValue and minStep are all messed up (and thus current value is invalid). Same problem with CURRENT_HUMIDITY characteristic. You're probably initializing them in non-static context, and those characteristics need min/maxValue+minStep, which are defined as pointers (so you can opt in/out for those attributes), thus they are initialized with pointers to one-element arrays that are allocated on stack. Thus, when you copy data to proper structures, pointers remain pointers on stack and when you exit that subroutine they get garbage data.
To avoid that you should either initialize those characteristics in static context (e.g. global variable) thus those pointers will remain intact; or use NEW_HOMEKIT_CHARACTERISTIC() which will create A PROPER copy of characteristic (event if it is defined on stack).
That worked. Thanks!
Hi. I'm trying to create a garage door opener using ESP32, which is two light zones, temp + humidity sensor, and I'm planning to add a CO sensor in future.
However, I've found an issue with combining different services.
Here is my configuration:
When I'm commenting out temp/humidity sensor services, I can successfully pair with iOS Device (iOS 13.4.1).
When I'm trying to work in the config described above, iPhone unpairs just after reading the accessory status.
Here are the execution logs:
I initially assumed I did something wrong in the config, but when I create the same accessory config in the Homekit Accessory Simulator, iPhone is able to pair and control the simulated accessory.