Skip to content
Draft
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
4 changes: 4 additions & 0 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,10 @@ jobs:
variant: 4M
version: v5.5.2
sdk: esp-idf
- platform: OpenESP32
variant: xiaomiCompact4
version: v5.5.2
sdk: esp-idf
- platform: OpenESP32C2
variant: 4M
version: v5.5.2
Expand Down
18 changes: 14 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ else ifeq ($(VARIANT),battery)
OBK_VARIANT = 7
else ifeq ($(VARIANT),btproxy)
OBK_VARIANT = 8
else ifeq ($(VARIANT),xiaomiCompact4)
OBK_VARIANT = 10
ESP_FSIZE = 4MB
else ifeq ($(VARIANT),2M)
OBK_VARIANT = 1
ESP_FSIZE = 2MB
Expand All @@ -47,6 +50,11 @@ OBK_VARIANT = 0
endif
$(info VARIANT is $(VARIANT), OBK_VARIANT is $(OBK_VARIANT))

ESP32_BUILD_DIR = platforms/ESP-IDF/build-32
ifeq ($(OBK_VARIANT), 10)
ESP32_BUILD_DIR = platforms/ESP-IDF/build-32-xiaomi
endif

#TARGET_PLATFORM ?= bk7231t
#APPS_BUILD_PATH ?= ../bk7231t_os
APPS_BUILD_CMD ?= build.sh
Expand Down Expand Up @@ -238,6 +246,8 @@ else ifeq ($(OBK_VARIANT), 2)
cp platforms/ESP-IDF/partitions-4mb.csv platforms/ESP-IDF/partitions.csv
else ifeq ($(OBK_VARIANT), 3)
cp platforms/ESP-IDF/partitions-2mb.csv platforms/ESP-IDF/partitions.csv
else ifeq ($(OBK_VARIANT), 10)
cp platforms/ESP-IDF/partitions-4mb.csv platforms/ESP-IDF/partitions.csv
endif
@if [ -e platforms/ESP-IDF/pre_build.sh ]; then \
echo "prebuild found for ESP-IDF"; \
Expand Down Expand Up @@ -562,11 +572,11 @@ OpenLN8825: prebuild_OpenLN8825 sdk/OpenLN8825/project/OpenBeken/app

.PHONY: OpenESP32
OpenESP32: prebuild_ESPIDF
IDF_TARGET="esp32" APP_VERSION=$(APP_VERSION) OBK_VARIANT=$(OBK_VARIANT) cmake platforms/ESP-IDF -B platforms/ESP-IDF/build-32
IDF_TARGET="esp32" APP_VERSION=$(APP_VERSION) OBK_VARIANT=$(OBK_VARIANT) cmake --build ./platforms/ESP-IDF/build-32 -j $(shell nproc)
IDF_TARGET="esp32" APP_VERSION=$(APP_VERSION) OBK_VARIANT=$(OBK_VARIANT) cmake platforms/ESP-IDF -B $(ESP32_BUILD_DIR)
IDF_TARGET="esp32" APP_VERSION=$(APP_VERSION) OBK_VARIANT=$(OBK_VARIANT) cmake --build ./$(ESP32_BUILD_DIR) -j $(shell nproc)
mkdir -p output/$(APP_VERSION)
python3 -m esptool -c esp32 merge_bin -o output/$(APP_VERSION)/OpenESP32_$(APP_VERSION).factory.bin --flash_mode dio --flash_size $(ESP_FSIZE) 0x1000 ./platforms/ESP-IDF/build-32/bootloader/bootloader.bin 0x8000 ./platforms/ESP-IDF/build-32/partition_table/partition-table.bin 0x10000 ./platforms/ESP-IDF/build-32/OpenBeken.bin
cp ./platforms/ESP-IDF/build-32/OpenBeken.bin output/$(APP_VERSION)/OpenESP32_$(APP_VERSION).img
python3 -m esptool -c esp32 merge_bin -o output/$(APP_VERSION)/OpenESP32_$(APP_VERSION).factory.bin --flash_mode dio --flash_size $(ESP_FSIZE) 0x1000 ./$(ESP32_BUILD_DIR)/bootloader/bootloader.bin 0x8000 ./$(ESP32_BUILD_DIR)/partition_table/partition-table.bin 0x10000 ./$(ESP32_BUILD_DIR)/OpenBeken.bin
cp ./$(ESP32_BUILD_DIR)/OpenBeken.bin output/$(APP_VERSION)/OpenESP32_$(APP_VERSION).img

.PHONY: OpenESP32C3
OpenESP32C3: prebuild_ESPIDF
Expand Down
13 changes: 12 additions & 1 deletion build_scripts/build_esp32.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,23 @@ set OBK_VARIANT=2
set ESP_FSIZE=4MB
set TARGET=esp32
set ACTION=build
set BUILD_VARIANT=4M

:: Check for target argument
if not "%~1"=="" set TARGET=%~1
if not "%~2"=="" set ACTION=%~2
if not "%~3"=="" set BUILD_VARIANT=%~3

if "%BUILD_VARIANT%"=="xiaomiCompact4" (
set OBK_VARIANT=10
)

if "%TARGET%"=="esp32" (
set BUILD_DIR=platforms\ESP-IDF\build-32
if "%BUILD_VARIANT%"=="xiaomiCompact4" (
set BUILD_DIR=platforms\ESP-IDF\build-32-xiaomi
) else (
set BUILD_DIR=platforms\ESP-IDF\build-32
)
set BOOTLOADER_ADDR=0x1000
) else if "%TARGET%"=="esp32c3" (
set BUILD_DIR=platforms\ESP-IDF\build-c3
Expand Down Expand Up @@ -47,6 +57,7 @@ echo Building OpenBeken ESP32 on Windows natively
echo Target: %TARGET%
echo Size: %ESP_FSIZE%
echo Variant (2=tuyaMCU/4MB): %OBK_VARIANT%
echo Build Variant: %BUILD_VARIANT%
echo Bootloader Addr: %BOOTLOADER_ADDR%
echo Build Directory: %BUILD_DIR%
echo Action: %ACTION%
Expand Down
3 changes: 3 additions & 0 deletions platforms/ESP-IDF/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
cmake_minimum_required(VERSION 3.16.0)
if("$ENV{IDF_TARGET}" STREQUAL "esp32" AND "$ENV{OBK_VARIANT}" STREQUAL "10")
set(SDKCONFIG_DEFAULTS "sdkconfig.defaults;sdkconfig.defaults.esp32;sdkconfig.defaults.xiaomi_compact4")
endif()
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
add_compile_definitions(PLATFORM_ESPIDF=1)
add_compile_definitions(LWIP_NOASSERT=1)
Expand Down
2 changes: 1 addition & 1 deletion platforms/ESP-IDF/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ if(ENABLE_MDNS_ESPIDF)
)
endif()
idf_component_register(SRCS ${PROJ_ALL_SRC} WHOLE_ARCHIVE
PRIV_REQUIRES mqtt lwip esp_wifi nvs_flash esp_driver_tsens esp_driver_gpio esp_pm esp_partition app_update esp_adc esp_driver_uart esp_driver_ledc spi_flash esp_driver_spi esp_driver_gptimer)
PRIV_REQUIRES mqtt lwip esp_wifi nvs_flash esp_driver_tsens esp_driver_gpio esp_pm esp_partition app_update esp_adc esp_driver_uart esp_driver_i2c esp_driver_ledc spi_flash esp_driver_spi esp_driver_gptimer)

target_compile_definitions(${COMPONENT_LIB} PRIVATE USER_SW_VER="$ENV{APP_VERSION}")
target_compile_definitions(${COMPONENT_LIB} PRIVATE OBK_VARIANT=$ENV{OBK_VARIANT})
2 changes: 1 addition & 1 deletion platforms/ESP-IDF/sdkconfig.defaults.esp32
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ CONFIG_PM_ENABLE=y
CONFIG_PM_DFS_INIT_AUTO=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_ESPTOOLPY_FLASHFREQ_40M=y
CONFIG_ESPTOOLPY_FLASHFREQ="40m"
CONFIG_ESPTOOLPY_FLASHFREQ="40m"
2 changes: 2 additions & 0 deletions platforms/ESP-IDF/sdkconfig.defaults.xiaomi_compact4
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_FREERTOS_UNICORE=y
CONFIG_ESP_MAC_IGNORE_MAC_CRC_ERROR=y
1 change: 1 addition & 0 deletions platforms/obk_main.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ set(OBKM_SRC
${OBK_SRCS}driver/drv_ucs1912.c
${OBK_SRCS}driver/drv_wemo.c
${OBK_SRCS}driver/drv_widget.c
${OBK_SRCS}driver/drv_xiaomi_compact4.c
${OBK_SRCS}i2c/drv_i2c_ads1115.c
${OBK_SRCS}i2c/drv_i2c_lcd_pcf8574t.c
${OBK_SRCS}i2c/drv_i2c_main.c
Expand Down
1 change: 1 addition & 0 deletions platforms/obk_main.mk
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ OBKM_SRC += $(OBK_SRCS)driver/drv_uart_tcp.c
OBKM_SRC += $(OBK_SRCS)driver/drv_ucs1912.c
OBKM_SRC += $(OBK_SRCS)driver/drv_wemo.c
OBKM_SRC += $(OBK_SRCS)driver/drv_widget.c
OBKM_SRC += $(OBK_SRCS)driver/drv_xiaomi_compact4.c
OBKM_SRC += $(OBK_SRCS)i2c/drv_i2c_ads1115.c
OBKM_SRC += $(OBK_SRCS)i2c/drv_i2c_lcd_pcf8574t.c
OBKM_SRC += $(OBK_SRCS)i2c/drv_i2c_main.c
Expand Down
11 changes: 11 additions & 0 deletions src/driver/drv_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,17 @@ void Drawers_QuickTick();
void HGS02_Init(void);
void HGS02_RunEverySecond(void);

void XiaomiCompact4_Init(void);
void XiaomiCompact4_RunEverySecond(void);
void XiaomiCompact4_RunQuickTick(void);
void XiaomiCompact4_Stop(void);
void XiaomiCompact4_OnChannelChanged(int ch, int value);
void XiaomiCompact4_AppendInformationToHTTPIndexPage(http_request_t *request, int bPreState);
bool XiaomiCompact4_ShouldSkipGenericHassDiscovery(int ch);
#if ENABLE_HA_DISCOVERY
void XiaomiCompact4_OnHassDiscovery(const char *topic);
#endif

void UART_TCP_Init(void);
void UART_TCP_Deinit(void);

Expand Down
21 changes: 21 additions & 0 deletions src/driver/drv_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "drv_ds1820_common.h"
#include "drv_ds3231.h"
#include "drv_hlw8112.h"
#include "drv_xiaomi_compact4.h"
#include "drv_DCF77.h"

void DRV_MQTTServer_Init();
Expand Down Expand Up @@ -175,6 +176,26 @@ static driver_t g_drivers[] = {
false, // loaded
},
#endif
#if ENABLE_DRIVER_XIAOMI_COMPACT4
//drvdetail:{"name":"XiaomiCompact4",
//drvdetail:"title":"Xiaomi Smart Air Purifier 4 Compact",
//drvdetail:"descr":"Device-specific driver for Xiaomi Smart Air Purifier 4 Compact (zhimi.airp.cpa4) on ESP32-WROOM-32D hardware.",
//drvdetail:"requires":"ESP32"}
{ "XiaomiCompact4", // Driver Name
XiaomiCompact4_Init, // Init
XiaomiCompact4_RunEverySecond, // onEverySecond
XiaomiCompact4_AppendInformationToHTTPIndexPage, // appendInformationToHTTPIndexPage
XiaomiCompact4_RunQuickTick, // runQuickTick
XiaomiCompact4_Stop, // stopFunction
XiaomiCompact4_OnChannelChanged, // onChannelChanged
#if ENABLE_HA_DISCOVERY
XiaomiCompact4_OnHassDiscovery, // onHassDiscovery
#else
NULL, // onHassDiscovery
#endif
false, // loaded
},
#endif
#if ENABLE_DRIVER_TESTSPIFLASH
//drvdetail:{"name":"TESTSPIFLASH",
//drvdetail:"title":"TODO",
Expand Down
Loading
Loading