Mixiaoxiao / Arduino-HomeKit-ESP8266

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

Getting some errors for uploading #179

Closed miladgolchinpour closed 1 year ago

miladgolchinpour commented 1 year ago

I have just written a code that simply controls 2 light bulbs and an air conditioner. i got the following errors in console while uploading the code. CAN ANYONE HELP?

ERRORS:

In file included from /Users/milad/Documents/Arduino/libraries/HomeKit-ESP8266/src/homekit/homekit.h:4,
                 from /Users/milad/Documents/Arduino/smarthome/smarthome_accessory.c:8:
/Users/milad/Documents/Arduino/libraries/HomeKit-ESP8266/src/homekit/types.h:252:34: error: 'HOMEKIT_SERVICE_LIGHBULB' undeclared here (not in a function); did you mean 'HOMEKIT_SERVICE_LIGHTBULB'?
  252 |     &(homekit_service_t) { .type=HOMEKIT_SERVICE_ ## _type, ##__VA_ARGS__ }
      |                                  ^~~~~~~~~~~~~~~~
/Users/milad/Documents/Arduino/libraries/HomeKit-ESP8266/src/homekit/types.h:246:11: note: in expansion of macro 'HOMEKIT_SERVICE'
  246 |         ##__VA_ARGS__ \
      |           ^~~~~~~~~~~
/Users/milad/Documents/Arduino/smarthome/smarthome_accessory.c:24:3: note: in expansion of macro 'HOMEKIT_ACCESSORY'
   24 |   HOMEKIT_ACCESSORY(.id=1, .category=homekit_accessory_category_lightbulb, .services=(homekit_service_t*[]) {
      |   ^~~~~~~~~~~~~~~~~

exit status 1

Compilation error: exit status 1

FILE:

/*
 * smarthome_accessory.c
 *
 *  Created on: 2022-08-05
 *      Author: Milad Golchinpour
 */

#include <homekit/homekit.h>
#include <homekit/characteristics.h>
#include "homekit/types.h"
#include <Arduino.h>

homekit_characteristic_t wall_light = HOMEKIT_CHARACTERISTIC_(ON, false);
homekit_characteristic_t main_lights = HOMEKIT_CHARACTERISTIC_(ON, false);
homekit_characteristic_t ac_switch_on = HOMEKIT_CHARACTERISTIC_(ON, false);
homekit_characteristic_t ac_active = HOMEKIT_CHARACTERISTIC_(ACTIVE, 0);
homekit_characteristic_t ac_temp = HOMEKIT_CHARACTERISTIC_(CURRENT_TEMPERATURE, 21);

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

homekit_accessory_t *accessories[] = {
  HOMEKIT_ACCESSORY(.id=1, .category=homekit_accessory_category_lightbulb, .services=(homekit_service_t*[]) {
    HOMEKIT_SERVICE(ACCESSORY_INFORMATION, .characteristics=(homekit_characteristic_t*[]) {
      HOMEKIT_CHARACTERISTIC(NAME, "Lights"),
      HOMEKIT_CHARACTERISTIC(MANUFACTURER, "Unknown"),
      HOMEKIT_CHARACTERISTIC(SERIAL_NUMBER, "753987"),
      HOMEKIT_CHARACTERISTIC(MODEL, "Unknown"),
      HOMEKIT_CHARACTERISTIC(FIRMWARE_REVISION, "1.0"),
      HOMEKIT_CHARACTERISTIC(IDENTIFY, my_accessory_identify),
      NULL
    }),

    HOMEKIT_SERVICE(LIGHBULB, .characteristics=(homekit_characteristic_t*[]) {
    HOMEKIT_CHARACTERISTIC(NAME, "Wall Light"),
        &wall_light,
        NULL
    }),

    HOMEKIT_SERVICE(LIGHBULB, .primary=true, .characteristics=(homekit_characteristic_t*[]) {
    HOMEKIT_CHARACTERISTIC(NAME, "Main Lights"),
        &main_lights,
        NULL
    }),
    NULL
       }),

  HOMEKIT_ACCESSORY(.id=2, .category=homekit_accessory_category_air_conditioner, .services=(homekit_service_t*[]) {
    HOMEKIT_SERVICE(ACCESSORY_INFORMATION, .characteristics=(homekit_characteristic_t*[]) {
      HOMEKIT_CHARACTERISTIC(NAME, "AC"),
      HOMEKIT_CHARACTERISTIC(MANUFACTURER, "Unknown"),
      HOMEKIT_CHARACTERISTIC(SERIAL_NUMBER, "753987"),
      HOMEKIT_CHARACTERISTIC(MODEL, "Unknown"),
      HOMEKIT_CHARACTERISTIC(FIRMWARE_REVISION, "1.0"),
      HOMEKIT_CHARACTERISTIC(IDENTIFY, my_accessory_identify),
      NULL
    }),

    HOMEKIT_SERVICE(HEATER_COOLER, .primary=true, .characteristics=(homekit_characteristic_t*[]) {
    &ac_switch_on,
        &ac_temp,
    NULL
    }),
        NULL
    }),
  NULL
};

homekit_server_config_t config = {
    .accessories = accessories,
    .password = "111-94-055"
};
miladgolchinpour commented 1 year ago

Solved