Mixiaoxiao / Arduino-HomeKit-ESP8266

Native Apple HomeKit accessory implementation for the ESP8266 Arduino core.
MIT License
1.48k stars 278 forks source link

Light Sensor pairing fails at Get Accessories #168

Closed DanMarkwood closed 2 years ago

DanMarkwood commented 2 years ago

I first tried the Switch example and that worked great. I then attempted to write a switch for a Light Sensor. When adding the sensor to the Home app, it fails at Get Accessories, log attached.

This is the contents of my-accessories.c. I am hoping you can help me find my error.

/*

include <homekit/homekit.h>

include <homekit/characteristics.h>

void my_accessory_identify(homekit_value_t _value) { printf("accessory identify\n"); }

// format: float; min 0.0001, max 100000 homekit_characteristic_t cha_light = HOMEKITCHARACTERISTIC(CURRENT_AMBIENT_LIGHT_LEVEL, 1); // format: string; HAP section 9.62; max length 64 homekit_characteristic_t cha_name = HOMEKITCHARACTERISTIC(NAME, "Light Sensor");

homekit_accessory_t accessories[] = { HOMEKIT_ACCESSORY(.id=4, .category=homekit_accessory_category_sensor, .services=(homekit_service_t[]) { HOMEKIT_SERVICE(ACCESSORY_INFORMATION, .characteristics=(homekit_characteristic_t[]) { HOMEKIT_CHARACTERISTIC(NAME, "Light Sensor"), HOMEKIT_CHARACTERISTIC(MANUFACTURER, "Arduino HomeKit"), HOMEKIT_CHARACTERISTIC(SERIAL_NUMBER, "0123456"), HOMEKIT_CHARACTERISTIC(MODEL, "ESP8266"), HOMEKIT_CHARACTERISTIC(FIRMWARE_REVISION, "1.0"), HOMEKIT_CHARACTERISTIC(IDENTIFY, my_accessory_identify), NULL }),
HOMEKIT_SERVICE(LIGHT_SENSOR, .primary=true, .characteristics=(homekit_characteristic_t
[]) { &cha_name, &cha_light, NULL }), NULL }),

NULL

};

homekit_server_config_t config = { .accessories = accessories, .password = "111-11-111" };

Log.txt

DanMarkwood commented 2 years ago

I got this to work.

tickietackie commented 2 years ago

@DanMarkwood How did you solve it?

It's crashing for me at the exact same step.