Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Based on [esp-homekit](https://github.com/maximkulkin/esp-homekit).

## Menuconfig settings

Before compiling, you need to alter several settings in **menuconfig**:
Before compiling, you need to alter several settings in **menuconfig**, follow configuration prompts `make menuconfig`:
* Serial flasher config
* Default serial port
* Flash size = **4 MB**
Expand All @@ -49,6 +49,7 @@ Before compiling, you need to alter several settings in **menuconfig**:
* ESP32 HomeKit Camera
* WiFi SSID
* WiFi Password
* Device hostname
* Select Camera Pinout
* Select Camera Pinout = *your variant of module*
* LED Pin
Expand All @@ -65,6 +66,8 @@ Before compiling, you need to alter several settings in **menuconfig**:
* HomeKit Device model name
* HomeKit Device model number
* HomeKit Device Serial number
* Use WIFI MAC address as serial number
* Note: this takes precedence over static serial number setting above
* HomeKit Device Firmware version


Expand Down
12 changes: 12 additions & 0 deletions main/Kconfig.projbuild
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ config ESP_WIFI_PASSWORD
help
WiFi password (WPA or WPA2) for the example to use.

config ESP_HOSTNAME
string "Device hostname"
default "esp-cam"
help
Device hostname for the example to use.

config XCLK_FREQ
int "XCLK Frequency"
default "20000000"
Expand Down Expand Up @@ -230,6 +236,12 @@ config ESP_HOMEKIT_DEVICE_SERIAL_NUMBER
help
HomeKit serial number the example to use.

config ESP_HOMEKIT_DEVICE_SERIAL_NUMBER_MAC
bool "Use WIFI MAC address as serial number"
default n
help
HomeKit serial number the example to use. Takes precedence over static serial.

config ESP_HOMEKIT_DEVICE_FIRMWARE_VERSION
string "HomeKit Device Firmware version"
default "0.1"
Expand Down
16 changes: 14 additions & 2 deletions main/accessory.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


static ip4_addr_t ip_address;

static char wifi_mac_address[32];

void camera_accessory_set_ip_address(ip4_addr_t ip) {
ip_address = ip;
Expand Down Expand Up @@ -567,7 +567,13 @@ homekit_accessory_t *accessories[] = {
HOMEKIT_SERVICE(ACCESSORY_INFORMATION, .characteristics=(homekit_characteristic_t*[]){
HOMEKIT_CHARACTERISTIC(NAME, CONFIG_ESP_HOMEKIT_DEVICE_MODEL_NAME),
HOMEKIT_CHARACTERISTIC(MANUFACTURER, CONFIG_ESP_HOMEKIT_DEVICE_MANUFACTURER),
HOMEKIT_CHARACTERISTIC(SERIAL_NUMBER, CONFIG_ESP_HOMEKIT_DEVICE_SERIAL_NUMBER),

#if CONFIG_ESP_HOMEKIT_DEVICE_SERIAL_NUMBER_MAC
HOMEKIT_CHARACTERISTIC(SERIAL_NUMBER, wifi_mac_address),
#else
HOMEKIT_CHARACTERISTIC(SERIAL_NUMBER, CONFIG_ESP_HOMEKIT_DEVICE_SERIAL_NUMBER),
#endif

HOMEKIT_CHARACTERISTIC(MODEL, CONFIG_ESP_HOMEKIT_DEVICE_MODEL_NUMBER),
HOMEKIT_CHARACTERISTIC(FIRMWARE_REVISION, CONFIG_ESP_HOMEKIT_DEVICE_FIRMWARE_VERSION),
HOMEKIT_CHARACTERISTIC(IDENTIFY, camera_identify),
Expand Down Expand Up @@ -631,6 +637,12 @@ void camera_accessory_init() {
esp_log_level_set("*", ESP_LOG_INFO);
esp_log_level_set("camera", ESP_LOG_VERBOSE);

// get WIFI MAC address & store it for later use
uint8_t mac[6] = {0};
esp_read_mac(mac, ESP_MAC_WIFI_STA);
sprintf(wifi_mac_address, "%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
ESP_LOGI(TAG, "Device WIFI mac_address=\"%s\"", wifi_mac_address);

/* IO13, IO14 is designed for JTAG by default,
* to use it as generalized input,
* firstly declair it as pullup input */
Expand Down
1 change: 1 addition & 0 deletions main/app_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) {

static void wifi_init() {
tcpip_adapter_init();
ESP_ERROR_CHECK(tcpip_adapter_set_hostname(TCPIP_ADAPTER_IF_STA, CONFIG_ESP_HOSTNAME));
ESP_ERROR_CHECK(esp_event_loop_init(event_handler, NULL));

wifi_init_config_t wifi_init_config = WIFI_INIT_CONFIG_DEFAULT();
Expand Down