I've recently started to build Espressif devices. Until now I have been using Arduino IDE, but have just trying to learn ESP-IDF. For my first project, I am trying to experiment with the fan example from ESP-Homekit-SDK.
The Homekit specification describes the fan service as having a rotation speed characteristic. This characteristic accepts the percentage fan speed (0-100), but also accepts a step value. The step value allows configuration for e.g., 3-speed fans (step = 33.3%).
ESP-Homekit-SDK provides a method for configuring the rotation speed characteristic:
- /* components/esp_hap_apple_profiles/src/hap_apple_chars.c */
- /* Char: Rotation Speed */
- hap_char_t *hap_char_rotation_speed_create(float rotation_speed)
- {
- hap_char_t *hc = hap_char_float_create(HAP_CHAR_UUID_ROTATION_SPEED,
- HAP_CHAR_PERM_PR | HAP_CHAR_PERM_PW | HAP_CHAR_PERM_EV, rotation_speed);
- if (!hc) {
- return NULL;
- }
- hap_char_float_set_constraints(hc, 0.0, 100.0, 1);
- hap_char_add_unit(hc, HAP_CHAR_UNIT_PERCENTAGE);
- return hc;
- }
Code: Select all
hap_char_float_set_constraints(hc, 0.0, 100.0, 33.3);
Appreciate of someone can confirm that ESP-Homekit-SDK does not provide an api for setting the fan speed step.