diff --git a/.gitignore b/.gitignore index 3d7f062..242a060 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,9 @@ tools/factory_nvs_gen/*.csv #CTags tags + +# Managed components +examples/**/managed_components/* + +# Dependency lock files +dependencies.lock \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a26e1fd..da65724 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,23 +1,29 @@ stages: - build -build_homekit_examples: +variables: + GIT_SUBMODULE_STRATEGY: recursive + +.build_template: stage: build - image: $CI_DOCKER_REGISTRY/$CI_IMAGE + image: espressif/idf:latest tags: - build - - variables: - IDF_PATH: "$CI_PROJECT_DIR/esp-idf" - GIT_STRATEGY: clone + variables: + EXAMPLES: "aws-iot bridge data_tlv8 emulator fan lightbulb smart_outlet" + EXAMPLE_TARGETS: "esp32" + artifacts: paths: - examples/fan/build/*.bin - examples/fan/build/*.elf - examples/fan/build/*.map - examples/fan/build/bootloader/*.bin - expire_in: 6 mos + artifacts: + paths: + - $CI_PROJECT_DIR/esp-homekit-sdk-bins-${CI_JOB_ID}.zip + expire_in: 3 mos before_script: - mkdir -p ~/.ssh @@ -27,31 +33,49 @@ build_homekit_examples: - chmod 600 ~/.ssh/id_rsa - echo -e "Host gitlab.espressif.cn\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config - script: - - git submodule update --init --recursive - # Cloning esp-idf - - git clone --recursive --single-branch --branch ${IDF_GIT_BRANCH} --depth 1 ${IDF_GIT_PATH}/esp-idf.git - - cd esp-idf - - ./install.sh - - . export.sh - - - cd ../examples/fan - - idf.py build - - cd ../bridge - - idf.py build - - cd ../lightbulb - - idf.py build - - cd ../smart_outlet - - idf.py build - - cd ../data_tlv8 - - idf.py build - - cd ../aws-iot + script: + - for EXAMPLE in $EXAMPLES; do + - cd $CI_PROJECT_DIR/examples/$EXAMPLE + - echo Building $EXAMPLE + - if [[ "$EXAMPLE" == "aws-iot" ]]; then - mkdir components - cd components + - echo Cloning esp-aws-iot - git clone --depth 1 -b release/v3.1.x --single-branch --recursive https://github.com/espressif/esp-aws-iot.git - export AWS_IOT_PATH=$PWD/esp-aws-iot - cd .. - touch main/certs/device.crt main/certs/device.key + - fi + - for TARGET in $EXAMPLE_TARGETS; do + - echo Building for $TARGET + - idf.py set-target $TARGET - idf.py build - - cd ../emulator - - idf.py build + - mkdir -p $CI_PROJECT_DIR/esp-homekit-sdk-bins-${CI_JOB_ID}/$EXAMPLE/$TARGET/ + - cp $CI_PROJECT_DIR/examples/$EXAMPLE/build/*.bin $CI_PROJECT_DIR/esp-homekit-sdk-bins-${CI_JOB_ID}/$EXAMPLE/$TARGET/ + - done + - echo Build Complete for $EXAMPLE + - done + # Generating zip file for binaries generated + - cd $CI_PROJECT_DIR + - echo Generating zip file for binaries generated + - tar -zcvf esp-homekit-sdk-bins-${CI_JOB_ID}.zip esp-homekit-sdk-bins-${CI_JOB_ID}/ + +build_idf_v4.1: + extends: .build_template + image: espressif/idf:release-v4.1 + +build_idf_v4.2: + extends: .build_template + image: espressif/idf:release-v4.2 + +build_idf_v4.3: + extends: .build_template + image: espressif/idf:release-v4.3 + +build_idf_v4.4: + extends: .build_template + image: espressif/idf:release-v4.4 + +build_idf_v5.0: + extends: .build_template + image: espressif/idf:release-v5.0 diff --git a/components/homekit/esp_hap_core/CMakeLists.txt b/components/homekit/esp_hap_core/CMakeLists.txt index 7d51f9c..9751536 100644 --- a/components/homekit/esp_hap_core/CMakeLists.txt +++ b/components/homekit/esp_hap_core/CMakeLists.txt @@ -48,10 +48,15 @@ if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER "4.1") list(APPEND priv_req esp_timer) endif() +if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER_EQUAL "5.0") + list(APPEND priv_req esp_wifi) + list(APPEND req esp_event) +endif() + idf_component_register(SRCS ${srcs} INCLUDE_DIRS "include" PRIV_INCLUDE_DIRS ${priv_includes} - REQUIRES + REQUIRES ${req} PRIV_REQUIRES ${priv_req}) component_compile_options(-Wno-unused-function) target_compile_definitions(${COMPONENT_TARGET} PRIVATE "-D MFI_VER=\"${MFI_VER}\"") diff --git a/components/homekit/esp_hap_core/idf_component.yml b/components/homekit/esp_hap_core/idf_component.yml index 54226eb..955f423 100644 --- a/components/homekit/esp_hap_core/idf_component.yml +++ b/components/homekit/esp_hap_core/idf_component.yml @@ -4,3 +4,7 @@ dependencies: version: "~1.0.20" rules: - if: "idf_version >=5.0" + espressif/mdns: + rules: + - if: "idf_version >=5.0" + diff --git a/components/homekit/esp_hap_core/src/esp_hap_char.c b/components/homekit/esp_hap_core/src/esp_hap_char.c index 9b712e3..d145ab3 100644 --- a/components/homekit/esp_hap_core/src/esp_hap_char.c +++ b/components/homekit/esp_hap_core/src/esp_hap_char.c @@ -180,8 +180,9 @@ int hap_char_update_val(hap_char_t *hc, hap_val_t *val) } __hap_char_t *_hc = (__hap_char_t *)hc; _hc->update_called = true; - if (hap_char_check_val_constraints(_hc, val) != HAP_SUCCESS) + if (hap_char_check_val_constraints(_hc, val) != HAP_SUCCESS) { return HAP_FAIL; + } /* Boolean to track if the value has changed. * This will be later used to decide if an event notification * is required or not. If the new and old values are same, diff --git a/components/homekit/esp_hap_core/src/esp_hap_ip_services.c b/components/homekit/esp_hap_core/src/esp_hap_ip_services.c index 1770501..85de93b 100644 --- a/components/homekit/esp_hap_core/src/esp_hap_ip_services.c +++ b/components/homekit/esp_hap_core/src/esp_hap_ip_services.c @@ -1594,7 +1594,7 @@ int hap_mdns_announce(bool first) mdns_txt_item_t txt[9]; int i = 0; - snprintf(config_num, sizeof(config_num), "%d", hap_priv.config_num); + snprintf(config_num, sizeof(config_num), "%" PRId32, hap_priv.config_num); txt[i].key = "c#"; txt[i++].value = config_num; diff --git a/components/homekit/esp_hap_core/src/esp_hap_pair_setup.c b/components/homekit/esp_hap_core/src/esp_hap_pair_setup.c index 1d4c1d8..f8b1aa7 100644 --- a/components/homekit/esp_hap_core/src/esp_hap_pair_setup.c +++ b/components/homekit/esp_hap_core/src/esp_hap_pair_setup.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -33,7 +34,6 @@ #include #include #include - #include #include #include @@ -144,7 +144,7 @@ static int hap_pair_setup_process_srp_start(pair_setup_ctx_t *ps_ctx, uint8_t *b int flags_len; if ((flags_len = get_value_from_tlv(buf, inlen, kTLVType_Flags, &ps_ctx->pairing_flags, sizeof(ps_ctx->pairing_flags))) > 0) { ps_ctx->pairing_flags_len = flags_len; - ESP_MFI_DEBUG(ESP_MFI_DEBUG_INFO, "Got pairing flags %x", ps_ctx->pairing_flags); + ESP_MFI_DEBUG(ESP_MFI_DEBUG_INFO, "Got pairing flags %" PRIx32, ps_ctx->pairing_flags); /* If the Split pairing flag is not set, it is an error */ if (!(ps_ctx->pairing_flags & PAIR_FLAG_SPLIT)) { diff --git a/components/homekit/esp_hap_core/src/priv_includes/esp_hap_wifi.h b/components/homekit/esp_hap_core/src/priv_includes/esp_hap_wifi.h index a82e59d..561ab35 100644 --- a/components/homekit/esp_hap_core/src/priv_includes/esp_hap_wifi.h +++ b/components/homekit/esp_hap_core/src/priv_includes/esp_hap_wifi.h @@ -23,6 +23,7 @@ */ #ifndef _HAP_WIFI_H_ #define _HAP_WIFI_H_ +#include #include bool hap_is_network_configured(); void hap_wifi_restart(); diff --git a/components/homekit/esp_hap_core/src/priv_includes/esp_mfi_debug.h b/components/homekit/esp_hap_core/src/priv_includes/esp_mfi_debug.h index c0a17f1..4a37a00 100644 --- a/components/homekit/esp_hap_core/src/priv_includes/esp_mfi_debug.h +++ b/components/homekit/esp_hap_core/src/priv_includes/esp_mfi_debug.h @@ -28,6 +28,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C"{ @@ -103,7 +104,7 @@ uint32_t esp_mfi_get_debug_level(uint32_t level, uint32_t *color); { \ uint32_t __color_LINE; \ if (l > esp_mfi_get_debug_level(l, &__color_LINE)) { \ - printf("\e[1;%dm" fmt "\e[0m" ESP_MFI_DEBUG_FL, \ + printf("\e[1;%" PRId32 "m" fmt "\e[0m" ESP_MFI_DEBUG_FL, \ __color_LINE, ##__VA_ARGS__); \ } \ } diff --git a/components/homekit/esp_hap_platform/CMakeLists.txt b/components/homekit/esp_hap_platform/CMakeLists.txt index 4e009b6..1486e3c 100644 --- a/components/homekit/esp_hap_platform/CMakeLists.txt +++ b/components/homekit/esp_hap_platform/CMakeLists.txt @@ -3,8 +3,13 @@ set(srcs src/esp_mfi_aes.c src/esp_mfi_base64.c src/esp_mfi_rand.c src/esp_mfi_s if(NOT CONFIG_IDF_TARGET_ESP8266) list(APPEND srcs src/esp_mfi_i2c.c) endif() + +if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER_EQUAL "5.0") + list(APPEND priv_req driver) +endif() + idf_component_register(SRCS ${srcs} INCLUDE_DIRS "include" REQUIRES esp_http_server - PRIV_REQUIRES mbedtls nvs_flash mdns esp_hap_core) + PRIV_REQUIRES ${priv_req} mbedtls nvs_flash mdns esp_hap_core) component_compile_options(-Wno-unused-function) diff --git a/components/homekit/hkdf-sha/upstream/hkdf.c b/components/homekit/hkdf-sha/upstream/hkdf.c index bd12ef2..dfc772f 100644 --- a/components/homekit/hkdf-sha/upstream/hkdf.c +++ b/components/homekit/hkdf-sha/upstream/hkdf.c @@ -315,7 +315,7 @@ int hkdfFinalBits(HKDFContext *context, uint8_t ikm_bits, int hkdfResult(HKDFContext *context, uint8_t prk[USHAMaxHashSize], const unsigned char *info, int info_len, - uint8_t okm[ ], int okm_len) + uint8_t okm[USHAMaxHashSize], int okm_len) { uint8_t prkbuf[USHAMaxHashSize]; int ret; @@ -332,4 +332,3 @@ int hkdfResult(HKDFContext *context, context->Computed = 1; return context->Corrupted = ret; } - diff --git a/components/homekit/hkdf-sha/upstream/hmac.c b/components/homekit/hkdf-sha/upstream/hmac.c index b09c50e..8b37ecd 100644 --- a/components/homekit/hkdf-sha/upstream/hmac.c +++ b/components/homekit/hkdf-sha/upstream/hmac.c @@ -218,7 +218,7 @@ int hmacFinalBits(HMACContext *context, * sha Error Code. * */ -int hmacResult(HMACContext *context, uint8_t *digest) +int hmacResult(HMACContext *context, uint8_t digest[USHAMaxHashSize]) { int ret; if (!context) return shaNull; @@ -246,4 +246,3 @@ int hmacResult(HMACContext *context, uint8_t *digest) context->Computed = 1; return context->Corrupted = ret; } - diff --git a/examples/emulator/main/emulator.c b/examples/emulator/main/emulator.c index db93391..2978a47 100644 --- a/examples/emulator/main/emulator.c +++ b/examples/emulator/main/emulator.c @@ -3,6 +3,7 @@ #include #include #include "emulator.h" +#include #include "nvs.h" int hap_factory_keystore_set(const char *name_space, const char *key, const uint8_t *val, size_t val_size); @@ -450,13 +451,13 @@ int emulator_write(hap_write_data_t write_data[], int count, static void emulator_print_char(hap_char_t *hc) { const hap_val_t *cval = hap_char_get_val(hc); - printf("C %d %s %s\n", hap_char_get_iid(hc), + printf("C %" PRId32 " %s %s\n", hap_char_get_iid(hc), hap_char_get_type_uuid(hc), emulator_print_value(hc, cval)); } static void emulator_print_serv(hap_serv_t *hs) { - printf("S %d %s\n", hap_serv_get_iid(hs), hap_serv_get_type_uuid(hs)); + printf("S %" PRId32 " %s\n", hap_serv_get_iid(hs), hap_serv_get_type_uuid(hs)); hap_char_t *hc; for (hc = hap_serv_get_first_char(hs); hc; hc = hap_char_get_next(hc)) { emulator_print_char(hc); @@ -465,7 +466,7 @@ static void emulator_print_serv(hap_serv_t *hs) static void emulator_print_acc(hap_acc_t *ha) { - printf("A %d\n", hap_acc_get_aid(ha)); + printf("A %" PRId32 "\n", hap_acc_get_aid(ha)); hap_serv_t *hs; for (hs = hap_acc_get_first_serv(ha); hs; hs = hap_serv_get_next(hs)) { emulator_print_serv(hs);