Skip to content

Commit

Permalink
Merge branch 'feat/sensor_hub_update' into 'master'
Browse files Browse the repository at this point in the history
feat(sensor_hub): make sensor_hub a separate component

Closes AEG-2059

See merge request ae_group/esp-iot-solution!1165
  • Loading branch information
YanKE01 committed Dec 23, 2024
2 parents 1f4206c + c6015b0 commit 350117f
Show file tree
Hide file tree
Showing 73 changed files with 1,882 additions and 1,474 deletions.
1 change: 1 addition & 0 deletions .github/workflows/upload_component.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ jobs:
components/sensors/power_monitor/ina236;
components/sensors/pressure/bme280;
components/sensors/radar/at581x;
components/sensors/sensor_hub;
components/spi_bus;
components/touch/touch_proximity_sensor;
components/usb/esp_msc_ota;
Expand Down
8 changes: 8 additions & 0 deletions .gitlab/ci/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1327,6 +1327,14 @@ build_components_sensors_radar_at581x_test_apps:
variables:
EXAMPLE_DIR: components/sensors/radar/at581x/test_apps

build_components_sensor_hub_test_apps:
extends:
- .build_examples_template
- .rules:build:components_sensors_sensor_hub_test_apps
- .build_idf_active_release_version
variables:
EXAMPLE_DIR: components/sensors/sensor_hub/test_apps

build_components_spi_bus_test_apps:
extends:
- .build_examples_template
Expand Down
3 changes: 2 additions & 1 deletion .gitlab/ci/rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@

.patterns-components_sensors_sensor_hub: &patterns-components_sensors_sensor_hub
- "components/sensors/sensor_hub/**/*"
- "tools/cmake_utilities/package_manager.cmake"

.patterns-components_spi_bus: &patterns-components_spi_bus
- "components/spi_bus/**/*"
Expand Down Expand Up @@ -2121,7 +2122,7 @@
- <<: *if-dev-push
changes: *patterns-components_sensors_pressure_bme280

.rules:build:components_sensors_sensor_hub_test:
.rules:build:components_sensors_sensor_hub_test_apps:
rules:
- <<: *if-protected
- <<: *if-label-build
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ The registered components in ESP-IoT-Solution are listed below:
| [openai](https://components.espressif.com/components/espressif/openai) | [![Component Registry](https://components.espressif.com/components/espressif/openai/badge.svg)](https://components.espressif.com/components/espressif/openai) |
| [power_measure](https://components.espressif.com/components/espressif/power_measure) | [![Component Registry](https://components.espressif.com/components/espressif/power_measure/badge.svg)](https://components.espressif.com/components/espressif/power_measure) |
| [pwm_audio](https://components.espressif.com/components/espressif/pwm_audio) | [![Component Registry](https://components.espressif.com/components/espressif/pwm_audio/badge.svg)](https://components.espressif.com/components/espressif/pwm_audio) |
| [sensor_hub](https://components.espressif.com/components/espressif/sensor_hub) | [![Component Registry](https://components.espressif.com/components/espressif/sensor_hub/badge.svg)](https://components.espressif.com/components/espressif/sensor_hub) |
| [servo](https://components.espressif.com/components/espressif/servo) | [![Component Registry](https://components.espressif.com/components/espressif/servo/badge.svg)](https://components.espressif.com/components/espressif/servo) |
| [sht3x](https://components.espressif.com/components/espressif/sht3x) | [![Component Registry](https://components.espressif.com/components/espressif/sht3x/badge.svg)](https://components.espressif.com/components/espressif/sht3x) |
| [spi_bus](https://components.espressif.com/components/espressif/spi_bus) | [![Component Registry](https://components.espressif.com/components/espressif/spi_bus/badge.svg)](https://components.espressif.com/components/espressif/spi_bus) |
Expand Down
1 change: 1 addition & 0 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ ESP-IoT-Solution 中注册的组件如下:
| [openai](https://components.espressif.com/components/espressif/openai) | [![Component Registry](https://components.espressif.com/components/espressif/openai/badge.svg)](https://components.espressif.com/components/espressif/openai) |
| [power_measure](https://components.espressif.com/components/espressif/power_measure) | [![Component Registry](https://components.espressif.com/components/espressif/power_measure/badge.svg)](https://components.espressif.com/components/espressif/power_measure) |
| [pwm_audio](https://components.espressif.com/components/espressif/pwm_audio) | [![Component Registry](https://components.espressif.com/components/espressif/pwm_audio/badge.svg)](https://components.espressif.com/components/espressif/pwm_audio) |
| [sensor_hub](https://components.espressif.com/components/espressif/sensor_hub) | [![Component Registry](https://components.espressif.com/components/espressif/sensor_hub/badge.svg)](https://components.espressif.com/components/espressif/sensor_hub) |
| [servo](https://components.espressif.com/components/espressif/servo) | [![Component Registry](https://components.espressif.com/components/espressif/servo/badge.svg)](https://components.espressif.com/components/espressif/servo) |
| [sht3x](https://components.espressif.com/components/espressif/sht3x) | [![Component Registry](https://components.espressif.com/components/espressif/sht3x/badge.svg)](https://components.espressif.com/components/espressif/sht3x) |
| [spi_bus](https://components.espressif.com/components/espressif/spi_bus) | [![Component Registry](https://components.espressif.com/components/espressif/spi_bus/badge.svg)](https://components.espressif.com/components/espressif/spi_bus) |
Expand Down
6 changes: 6 additions & 0 deletions components/sensors/humiture/hdc2010/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# ChangeLog

## v0.2.0 - 2024-12-19

### Enhancements:

* Update the method of driver registration to the `sensor_hub`

## v0.1.1 - 2024-12-11

### Bug Fixes:
Expand Down
4 changes: 4 additions & 0 deletions components/sensors/humiture/hdc2010/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
idf_component_register(SRCS "hdc2010.c"
INCLUDE_DIRS include)

if(CONFIG_SENSOR_INCLUDED_HUMITURE)
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u humiture_hdc2010_init")
endif()

include(package_manager)
cu_pkg_define_version(${CMAKE_CURRENT_LIST_DIR})
81 changes: 80 additions & 1 deletion components/sensors/humiture/hdc2010/hdc2010.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand All @@ -8,6 +8,7 @@
#include "i2c_bus.h"
#include "esp_log.h"
#include "hdc2010.h"
#include "iot_sensor_hub.h"

#define WRITE_BIT I2C_MASTER_WRITE /*!< I2C master write */
#define READ_BIT I2C_MASTER_READ /*!< I2C master read */
Expand Down Expand Up @@ -289,3 +290,81 @@ esp_err_t hdc2010_default_init(hdc2010_handle_t sensor)

return ESP_OK;
}

#ifdef CONFIG_SENSOR_INCLUDED_HUMITURE

static hdc2010_handle_t hdc2010 = NULL;
static bool is_init = false;

esp_err_t humiture_hdc2010_init(i2c_bus_handle_t i2c_bus, uint8_t addr)
{
if (is_init || !i2c_bus) {
return ESP_FAIL;
}

hdc2010 = hdc2010_create(i2c_bus, addr);

if (!hdc2010) {
return ESP_FAIL;
}

is_init = true;
return ESP_OK;
}

esp_err_t humiture_hdc2010_deinit(void)
{
if (!is_init) {
return ESP_FAIL;
}

esp_err_t ret = hdc2010_delete(&hdc2010);

if (ret != ESP_OK) {
return ESP_FAIL;
}

is_init = false;
return ESP_OK;
}

esp_err_t humiture_hdc2010_test(void)
{
if (!is_init) {
return ESP_FAIL;
}

return ESP_OK;
}

esp_err_t humiture_hdc2010_acquire_humidity(float *h)
{
if (!is_init) {
return ESP_FAIL;
}

*h = hdc2010_get_humidity(hdc2010);
return ESP_OK;
}

esp_err_t humiture_hdc2010_acquire_temperature(float *t)
{
if (!is_init) {
return ESP_FAIL;
}

*t = hdc2010_get_temperature(hdc2010);
return ESP_OK;
}

static humiture_impl_t hdc2010_impl = {
.init = humiture_hdc2010_init,
.deinit = humiture_hdc2010_deinit,
.test = humiture_hdc2010_test,
.acquire_humidity = humiture_hdc2010_acquire_humidity,
.acquire_temperature = humiture_hdc2010_acquire_temperature,
};

SENSOR_HUB_DETECT_FN(HUMITURE_ID, hdc2010, &hdc2010_impl);

#endif
5 changes: 4 additions & 1 deletion components/sensors/humiture/hdc2010/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "0.1.1"
version: "0.2.0"
description: I2C driver for HDC2010 humiture sensor
url: https://github.com/espressif/esp-iot-solution/tree/master/components/sensors/humiture/hdc2010
repository: https://github.com/espressif/esp-iot-solution.git
Expand All @@ -8,5 +8,8 @@ dependencies:
i2c_bus:
public: true
override_path: "../../../i2c_bus"
sensor_hub:
public: true
override_path: "../../../sensors/sensor_hub"
idf: '>=4.4'
cmake_utilities: "0.*"
6 changes: 6 additions & 0 deletions components/sensors/humiture/mvh3004d/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# ChangeLog

## v0.2.0 - 2024-12-19

### Enhancements:

* Update the method of driver registration to the `sensor_hub`

## v0.1.0 - 2024-11-5

### Enhancements:
Expand Down
4 changes: 4 additions & 0 deletions components/sensors/humiture/mvh3004d/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
idf_component_register(SRCS "mvh3004d.c"
INCLUDE_DIRS include)

if(CONFIG_SENSOR_INCLUDED_HUMITURE)
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u humiture_mvh3004d_init")
endif()

include(package_manager)
cu_pkg_define_version(${CMAKE_CURRENT_LIST_DIR})
5 changes: 4 additions & 1 deletion components/sensors/humiture/mvh3004d/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "0.1.0"
version: "0.2.0"
description: I2C driver for MVH3004D humiture sensor
url: https://github.com/espressif/esp-iot-solution/tree/master/components/sensors/humiture/mvh3004d
repository: https://github.com/espressif/esp-iot-solution.git
Expand All @@ -8,5 +8,8 @@ dependencies:
i2c_bus:
public: true
override_path: "../../../i2c_bus"
sensor_hub:
public: true
override_path: "../../../sensors/sensor_hub"
idf: '>=4.4'
cmake_utilities: "0.*"
97 changes: 96 additions & 1 deletion components/sensors/humiture/mvh3004d/mvh3004d.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <stdio.h>
#include "esp_log.h"
#include "mvh3004d.h"
#include "iot_sensor_hub.h"

static const char *TAG = "mvh3004d";
typedef struct {
Expand Down Expand Up @@ -69,3 +70,97 @@ esp_err_t mvh3004d_get_temperature(mvh3004d_handle_t sensor, float *tp)
{
return mvh3004d_get_data(sensor, tp, NULL);
}

#ifdef CONFIG_SENSOR_INCLUDED_HUMITURE

static mvh3004d_handle_t mvh3004d = NULL;
static bool is_init = false;

esp_err_t humiture_mvh3004d_init(i2c_bus_handle_t i2c_bus, uint8_t addr)
{
if (is_init || !i2c_bus) {
return ESP_FAIL;
}

mvh3004d = mvh3004d_create(i2c_bus, addr);

if (!mvh3004d) {
return ESP_FAIL;
}

is_init = true;
return ESP_OK;
}

esp_err_t humiture_mvh3004d_deinit(void)
{
if (!is_init) {
return ESP_FAIL;
}

esp_err_t ret = mvh3004d_delete(&mvh3004d);

if (ret != ESP_OK) {
return ESP_FAIL;
}

is_init = false;
return ESP_OK;
}

esp_err_t humiture_mvh3004d_test(void)
{
if (!is_init) {
return ESP_FAIL;
}

return ESP_OK;
}

esp_err_t humiture_mvh3004d_acquire_humidity(float *h)
{
if (!is_init) {
return ESP_FAIL;
}

float humidity = 0;
esp_err_t ret = mvh3004d_get_huminity(mvh3004d, &humidity);

if (ret == ESP_OK) {
*h = humidity;
return ESP_OK;
}

*h = 0;
return ESP_FAIL;
}

esp_err_t humiture_mvh3004d_acquire_temperature(float *t)
{
if (!is_init) {
return ESP_FAIL;
}

float temperature = 0;
esp_err_t ret = mvh3004d_get_temperature(mvh3004d, &temperature);

if (ret == ESP_OK) {
*t = temperature;
return ESP_OK;
}

*t = 0;
return ESP_FAIL;
}

static humiture_impl_t mvh3004d_impl = {
.init = humiture_mvh3004d_init,
.deinit = humiture_mvh3004d_deinit,
.test = humiture_mvh3004d_test,
.acquire_humidity = humiture_mvh3004d_acquire_humidity,
.acquire_temperature = humiture_mvh3004d_acquire_temperature,
};

SENSOR_HUB_DETECT_FN(HUMITURE_ID, mvh3004d, &mvh3004d_impl);

#endif
6 changes: 6 additions & 0 deletions components/sensors/humiture/sht3x/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# ChangeLog

## v0.2.0 - 2024-12-9

### Enhancements:

* Update the method of driver registration to the `sensor hub`

## v0.1.0 - 2024-11-5

### Enhancements:
Expand Down
4 changes: 4 additions & 0 deletions components/sensors/humiture/sht3x/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@ idf_component_register(SRCS "sht3x.c"
INCLUDE_DIRS include
REQUIRES esp_timer)

if(CONFIG_SENSOR_INCLUDED_HUMITURE)
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u humiture_sht3x_init")
endif()

include(package_manager)
cu_pkg_define_version(${CMAKE_CURRENT_LIST_DIR})
5 changes: 4 additions & 1 deletion components/sensors/humiture/sht3x/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "0.1.0"
version: "0.2.0"
description: I2C driver for SHT3X humiture sensor
url: https://github.com/espressif/esp-iot-solution/tree/master/components/sensors/humiture/sht3x
repository: https://github.com/espressif/esp-iot-solution.git
Expand All @@ -8,5 +8,8 @@ dependencies:
i2c_bus:
public: true
override_path: "../../../i2c_bus"
sensor_hub:
public: true
override_path: "../../sensor_hub"
idf: '>=4.4'
cmake_utilities: "0.*"
Loading

0 comments on commit 350117f

Please sign in to comment.