maximkulkin / esp-homekit

Apple HomeKit accessory server library for ESP-OPEN-RTOS
MIT License
1.1k stars 169 forks source link

Fix unsigned min/max range variables checking #106

Closed mzyy94 closed 4 years ago

mzyy94 commented 4 years ago

In 5d11ec273c3d96bff6dd6fe0d732fd3add641f19, change of range checking to signed int causes comparison bug. When a format of characteristic is homekit_format_uint64, max_value is 4294967295 but it's now signed int that means the value is actually -1. And the checking of value range fails.

>>> HomeKit: [Client 57] Update Characteristics
!!! HomeKit: [Client 57] Failed to update 1.11: value 3 is not in range 0..-1

So I fixed this using type-cast.

maximkulkin commented 4 years ago

Ok, I've merged a better fix for range checking and overall more support for various int flavors. Please check it out and let me know if you will have any more issues with it.

mzyy94 commented 4 years ago

very nice change :)