Skip to content

Commit

Permalink
task: Add support for IDF 5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sanketwadekar committed Feb 9, 2023
1 parent f266c99 commit 1728fe2
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 42 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,9 @@ tools/factory_nvs_gen/*.csv

#CTags
tags

# Managed components
examples/**/managed_components/*

# Dependency lock files
dependencies.lock
80 changes: 52 additions & 28 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
7 changes: 6 additions & 1 deletion components/homekit/esp_hap_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}\"")
Expand Down
4 changes: 4 additions & 0 deletions components/homekit/esp_hap_core/idf_component.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ dependencies:
version: "~1.0.20"
rules:
- if: "idf_version >=5.0"
espressif/mdns:
rules:
- if: "idf_version >=5.0"

3 changes: 2 additions & 1 deletion components/homekit/esp_hap_core/src/esp_hap_char.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion components/homekit/esp_hap_core/src/esp_hap_ip_services.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions components/homekit/esp_hap_core/src/esp_hap_pair_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <inttypes.h>
#include <freertos/FreeRTOS.h>
#include <freertos/timers.h>
#include <mu_srp.h>
Expand All @@ -33,7 +34,6 @@
#include <hexdump.h>
#include <hap_platform_memory.h>
#include <hap_platform_os.h>

#include <esp_hap_ip_services.h>
#include <esp_hap_pair_common.h>
#include <esp_hap_pair_setup.h>
Expand Down Expand Up @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
#ifndef _HAP_WIFI_H_
#define _HAP_WIFI_H_
#include <esp_wifi_types.h>
#include <hap.h>
bool hap_is_network_configured();
void hap_wifi_restart();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <stdint.h>
#include <stdio.h>
#include <esp_idf_version.h>
#include <inttypes.h>

#ifdef __cplusplus
extern "C"{
Expand Down Expand Up @@ -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__); \
} \
}
Expand Down
7 changes: 6 additions & 1 deletion components/homekit/esp_hap_platform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
3 changes: 1 addition & 2 deletions components/homekit/hkdf-sha/upstream/hkdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -332,4 +332,3 @@ int hkdfResult(HKDFContext *context,
context->Computed = 1;
return context->Corrupted = ret;
}

3 changes: 1 addition & 2 deletions components/homekit/hkdf-sha/upstream/hmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -246,4 +246,3 @@ int hmacResult(HMACContext *context, uint8_t *digest)
context->Computed = 1;
return context->Corrupted = ret;
}

7 changes: 4 additions & 3 deletions examples/emulator/main/emulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <hap_apple_chars.h>
#include <string.h>
#include "emulator.h"
#include <inttypes.h>
#include "nvs.h"

int hap_factory_keystore_set(const char *name_space, const char *key, const uint8_t *val, size_t val_size);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 1728fe2

Please sign in to comment.