diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 00000000..b63cfd94 --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,40 @@ +# +# This file is part of Astarte. +# +# Copyright 2024 SECO Mind Srl +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 +# + +name: ESP registry publish + +on: + push: + tags: + - 'v*' + +jobs: + publish: + name: Publish release to the ESP registry + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Upload component to the component registry + uses: espressif/upload-components-ci-action@v1 + with: + name: "astarte-device-sdk-esp32" + version: ${{ github.ref_name }} + namespace: "astarte-platform" + api_token: ${{ secrets.IDF_COMPONENT_API_TOKEN }} diff --git a/.github/workflows/reuse-lint.yaml b/.github/workflows/reuse-lint.yaml index 65516aab..8904fddb 100644 --- a/.github/workflows/reuse-lint.yaml +++ b/.github/workflows/reuse-lint.yaml @@ -12,4 +12,4 @@ jobs: steps: - uses: actions/checkout@v4 - name: REUSE Compliance Check - uses: fsfe/reuse-action@v2 + uses: fsfe/reuse-action@v4 diff --git a/.gitignore b/.gitignore index c8a13930..7df5fda8 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ dependencies.lock managed_components doc/out .vscode +dist # Files related to clang-tidy warnings.txt diff --git a/.reuse/dep5 b/.reuse/dep5 deleted file mode 100644 index 3b4110cf..00000000 --- a/.reuse/dep5 +++ /dev/null @@ -1,3 +0,0 @@ -Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: Astarte Device SDK ESP32 -Source: https://github.com/astarte-platform/astarte-device-sdk-esp32 diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c358de4..4cc112ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,23 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.1.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [1.3.3] - 2024-09-04 +### Fixed +- Correctly calling the incoming data callback. + +## [1.3.2] - 2024-09-04 [YANKED] +### Added +- Automated publishing on the +[ESP registry](https://components.espressif.com/components/astarte-platform/astarte-device-sdk-esp32). + +### Fixed +- Early exit on reception when data callback is not set. + +## [1.3.1] - 2024-01-18 +### Fixed +- Version number in `idf_component.yml`. + +## [1.3.0] - 2023-12-18 ### Added - `user_data` field is added to the `astarte_device_config_t` and `astarte_device_*_event_t` structs. This field can be used to pass user data to callback functions. diff --git a/README.md b/README.md index 344f089b..1869f0f2 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,11 @@ Astarte ESP32 SDK lets you connect your ESP32 device to The SDK simplifies all the low-level operations like credentials generation, pairing and so on, and exposes a high-level API to publish data from your device. -Have a look at the [examples](examples/README.md) for a usage example showing how to send and -receive data. +Check out the examples on the right pane of the +[astarte-device-sdk-esp32](https://components.espressif.com/components/astarte-platform/astarte-device-sdk-esp32) +component page or on the +[GitHub repository](https://github.com/astarte-platform/astarte-device-sdk-esp32/tree/master/examples/README.md) +. ## Documentation diff --git a/REUSE.toml b/REUSE.toml new file mode 100644 index 00000000..660d0398 --- /dev/null +++ b/REUSE.toml @@ -0,0 +1,8 @@ +# (C) Copyright 2024, SECO Mind Srl +# +# SPDX-License-Identifier: Apache-2.0 + +version = 1 +SPDX-PackageName = "Astarte Device SDK ESP32" +SPDX-PackageDownloadLocation = "https://github.com/astarte-platform/astarte-device-sdk-esp32" +annotations = [] diff --git a/SECURITY.md b/SECURITY.md index ba9988f7..349b18d4 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -10,9 +10,12 @@ | Version | Supported | | ------- | ------------------ | -| 0.10.x | :x: | +| 1.3.x | :white_check_mark: | +| 1.2.x | :white_check_mark: | +| 1.1.x | :white_check_mark: | +| 1.0.x | :x: | | 0.11.x | :x: | -| 1.0.x | :white_check_mark: | +| 0.10.x | :x: | ## Reporting a Vulnerability diff --git a/doc/docmain.dox b/doc/docmain.dox index 01f060e1..0924b7ec 100644 --- a/doc/docmain.dox +++ b/doc/docmain.dox @@ -1,6 +1,6 @@ /** @mainpage Astarte Device SDK ESP32 Documentation -@version 1.2.99 +@version 1.3.3 * The Astarte device SDK allows connecting an ESP32 device to Astarte. * diff --git a/examples/aggregates/CMakeLists.txt b/examples/aggregates/CMakeLists.txt index 5affcf4e..1f4d1960 100644 --- a/examples/aggregates/CMakeLists.txt +++ b/examples/aggregates/CMakeLists.txt @@ -22,6 +22,4 @@ cmake_minimum_required(VERSION 3.5) include($ENV{IDF_PATH}/tools/cmake/project.cmake) -set(EXTRA_COMPONENT_DIRS ${CMAKE_SOURCE_DIR}/../..) - project(aggregates) diff --git a/examples/aggregates/main/idf_component.yml b/examples/aggregates/main/idf_component.yml new file mode 100644 index 00000000..4c8717a0 --- /dev/null +++ b/examples/aggregates/main/idf_component.yml @@ -0,0 +1,26 @@ +# +# This file is part of Astarte. +# +# Copyright 2024 SECO Mind Srl +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 +# + +description: Example for transmission and reception of aggregated datastreams +dependencies: + idf: ">=4.4" + astarte-platform/astarte-device-sdk-esp32: + version: '1.3.3' + override_path: '../../../' # three levels up, pointing the directory with the component itself diff --git a/examples/aggregates/main/src/wifi_cfg.c b/examples/aggregates/main/src/wifi_cfg.c index 3c455fe5..a652692a 100644 --- a/examples/aggregates/main/src/wifi_cfg.c +++ b/examples/aggregates/main/src/wifi_cfg.c @@ -67,7 +67,7 @@ void wifi_init(void) ESP_ERROR_CHECK(esp_event_loop_create_default()); esp_netif_create_default_wifi_sta(); - wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); + wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); // NOLINT ESP_ERROR_CHECK(esp_wifi_init(&cfg)); esp_event_handler_instance_t instance_any_id = NULL; diff --git a/examples/datastreams/CMakeLists.txt b/examples/datastreams/CMakeLists.txt index 4d14a458..b561ecd7 100644 --- a/examples/datastreams/CMakeLists.txt +++ b/examples/datastreams/CMakeLists.txt @@ -22,6 +22,4 @@ cmake_minimum_required(VERSION 3.5) include($ENV{IDF_PATH}/tools/cmake/project.cmake) -set(EXTRA_COMPONENT_DIRS ${CMAKE_SOURCE_DIR}/../..) - project(datastreams) diff --git a/examples/datastreams/main/idf_component.yml b/examples/datastreams/main/idf_component.yml new file mode 100644 index 00000000..42ae67e5 --- /dev/null +++ b/examples/datastreams/main/idf_component.yml @@ -0,0 +1,26 @@ +# +# This file is part of Astarte. +# +# Copyright 2024 SECO Mind Srl +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 +# + +description: Example for transmission and reception of individual datastreams +dependencies: + idf: ">=4.4" + astarte-platform/astarte-device-sdk-esp32: + version: '1.3.3' + override_path: '../../../' # three levels up, pointing the directory with the component itself diff --git a/examples/datastreams/main/src/wifi_cfg.c b/examples/datastreams/main/src/wifi_cfg.c index 3c455fe5..a652692a 100644 --- a/examples/datastreams/main/src/wifi_cfg.c +++ b/examples/datastreams/main/src/wifi_cfg.c @@ -67,7 +67,7 @@ void wifi_init(void) ESP_ERROR_CHECK(esp_event_loop_create_default()); esp_netif_create_default_wifi_sta(); - wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); + wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); // NOLINT ESP_ERROR_CHECK(esp_wifi_init(&cfg)); esp_event_handler_instance_t instance_any_id = NULL; diff --git a/examples/encryption/CMakeLists.txt b/examples/encryption/CMakeLists.txt index 75b2420b..a1baaad4 100644 --- a/examples/encryption/CMakeLists.txt +++ b/examples/encryption/CMakeLists.txt @@ -22,6 +22,4 @@ cmake_minimum_required(VERSION 3.5) include($ENV{IDF_PATH}/tools/cmake/project.cmake) -set(EXTRA_COMPONENT_DIRS ${CMAKE_SOURCE_DIR}/../..) - project(encryption) diff --git a/examples/encryption/main/idf_component.yml b/examples/encryption/main/idf_component.yml new file mode 100644 index 00000000..674e82b8 --- /dev/null +++ b/examples/encryption/main/idf_component.yml @@ -0,0 +1,26 @@ +# +# This file is part of Astarte. +# +# Copyright 2024 SECO Mind Srl +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 +# + +description: Example for the use of the Astarte device SDK with encrypted flash partitions +dependencies: + idf: ">=4.4" + astarte-platform/astarte-device-sdk-esp32: + version: '1.3.3' + override_path: '../../../' # three levels up, pointing the directory with the component itself diff --git a/examples/encryption/main/src/wifi_cfg.c b/examples/encryption/main/src/wifi_cfg.c index b3083f6f..7469aeee 100644 --- a/examples/encryption/main/src/wifi_cfg.c +++ b/examples/encryption/main/src/wifi_cfg.c @@ -67,7 +67,7 @@ void wifi_init(void) ESP_ERROR_CHECK(esp_event_loop_create_default()); esp_netif_create_default_wifi_sta(); - wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); + wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); // NOLINT ESP_ERROR_CHECK(esp_wifi_init(&cfg)); esp_event_handler_instance_t instance_any_id = NULL; diff --git a/examples/non_volatile_storage/CMakeLists.txt b/examples/non_volatile_storage/CMakeLists.txt index 43c9196f..ad30fff8 100644 --- a/examples/non_volatile_storage/CMakeLists.txt +++ b/examples/non_volatile_storage/CMakeLists.txt @@ -22,6 +22,4 @@ cmake_minimum_required(VERSION 3.5) include($ENV{IDF_PATH}/tools/cmake/project.cmake) -set(EXTRA_COMPONENT_DIRS ${CMAKE_SOURCE_DIR}/../..) - project(non-volatile-storage) diff --git a/examples/non_volatile_storage/main/idf_component.yml b/examples/non_volatile_storage/main/idf_component.yml new file mode 100644 index 00000000..0ff79ea2 --- /dev/null +++ b/examples/non_volatile_storage/main/idf_component.yml @@ -0,0 +1,26 @@ +# +# This file is part of Astarte. +# +# Copyright 2024 SECO Mind Srl +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 +# + +description: Example for the use of the Astarte device SDK with non volatile storage enabled +dependencies: + idf: ">=4.4" + astarte-platform/astarte-device-sdk-esp32: + version: '1.3.3' + override_path: '../../../' # three levels up, pointing the directory with the component itself diff --git a/examples/non_volatile_storage/main/src/wifi_cfg.c b/examples/non_volatile_storage/main/src/wifi_cfg.c index b3083f6f..7469aeee 100644 --- a/examples/non_volatile_storage/main/src/wifi_cfg.c +++ b/examples/non_volatile_storage/main/src/wifi_cfg.c @@ -67,7 +67,7 @@ void wifi_init(void) ESP_ERROR_CHECK(esp_event_loop_create_default()); esp_netif_create_default_wifi_sta(); - wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); + wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); // NOLINT ESP_ERROR_CHECK(esp_wifi_init(&cfg)); esp_event_handler_instance_t instance_any_id = NULL; diff --git a/examples/properties/CMakeLists.txt b/examples/properties/CMakeLists.txt index a3cc5272..72a2b76c 100644 --- a/examples/properties/CMakeLists.txt +++ b/examples/properties/CMakeLists.txt @@ -22,6 +22,4 @@ cmake_minimum_required(VERSION 3.5) include($ENV{IDF_PATH}/tools/cmake/project.cmake) -set(EXTRA_COMPONENT_DIRS ${CMAKE_SOURCE_DIR}/../..) - project(properties) diff --git a/examples/properties/main/idf_component.yml b/examples/properties/main/idf_component.yml new file mode 100644 index 00000000..5f5cb648 --- /dev/null +++ b/examples/properties/main/idf_component.yml @@ -0,0 +1,26 @@ +# +# This file is part of Astarte. +# +# Copyright 2024 SECO Mind Srl +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 +# + +description: Example for setting and unsetting individual properties +dependencies: + idf: ">=4.4" + astarte-platform/astarte-device-sdk-esp32: + version: '1.3.3' + override_path: '../../../' # three levels up, pointing the directory with the component itself diff --git a/examples/properties/main/src/wifi_cfg.c b/examples/properties/main/src/wifi_cfg.c index 52e17cea..cbec3ea7 100644 --- a/examples/properties/main/src/wifi_cfg.c +++ b/examples/properties/main/src/wifi_cfg.c @@ -67,7 +67,7 @@ void wifi_init(void) ESP_ERROR_CHECK(esp_event_loop_create_default()); esp_netif_create_default_wifi_sta(); - wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); + wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); // NOLINT ESP_ERROR_CHECK(esp_wifi_init(&cfg)); esp_event_handler_instance_t instance_any_id = NULL; diff --git a/examples/registration/CMakeLists.txt b/examples/registration/CMakeLists.txt index 85277e93..bb0e12c4 100644 --- a/examples/registration/CMakeLists.txt +++ b/examples/registration/CMakeLists.txt @@ -22,6 +22,4 @@ cmake_minimum_required(VERSION 3.5) include($ENV{IDF_PATH}/tools/cmake/project.cmake) -set(EXTRA_COMPONENT_DIRS ${CMAKE_SOURCE_DIR}/../..) - project(registration) diff --git a/examples/registration/main/idf_component.yml b/examples/registration/main/idf_component.yml new file mode 100644 index 00000000..4ec22507 --- /dev/null +++ b/examples/registration/main/idf_component.yml @@ -0,0 +1,26 @@ +# +# This file is part of Astarte. +# +# Copyright 2024 SECO Mind Srl +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 +# + +description: Example for on board registration using a JWT +dependencies: + idf: ">=4.4" + astarte-platform/astarte-device-sdk-esp32: + version: '1.3.3' + override_path: '../../../' # three levels up, pointing the directory with the component itself diff --git a/examples/registration/main/src/wifi_cfg.c b/examples/registration/main/src/wifi_cfg.c index 154b8512..a566db3c 100644 --- a/examples/registration/main/src/wifi_cfg.c +++ b/examples/registration/main/src/wifi_cfg.c @@ -67,7 +67,7 @@ void wifi_init(void) ESP_ERROR_CHECK(esp_event_loop_create_default()); esp_netif_create_default_wifi_sta(); - wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); + wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); // NOLINT ESP_ERROR_CHECK(esp_wifi_init(&cfg)); esp_event_handler_instance_t instance_any_id = NULL; diff --git a/examples/toggle_led/CMakeLists.txt b/examples/toggle_led/CMakeLists.txt index 9a442912..b6e682d0 100644 --- a/examples/toggle_led/CMakeLists.txt +++ b/examples/toggle_led/CMakeLists.txt @@ -22,6 +22,4 @@ cmake_minimum_required(VERSION 3.5) include($ENV{IDF_PATH}/tools/cmake/project.cmake) -set(EXTRA_COMPONENT_DIRS ${CMAKE_SOURCE_DIR}/../..) - project(toggle-led) diff --git a/examples/toggle_led/main/idf_component.yml b/examples/toggle_led/main/idf_component.yml new file mode 100644 index 00000000..865affea --- /dev/null +++ b/examples/toggle_led/main/idf_component.yml @@ -0,0 +1,26 @@ +# +# This file is part of Astarte. +# +# Copyright 2024 SECO Mind Srl +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 +# + +description: Example with a led toggle for visual demonstration +dependencies: + idf: ">=4.4" + astarte-platform/astarte-device-sdk-esp32: + version: '1.3.3' + override_path: '../../../' # three levels up, pointing the directory with the component itself diff --git a/examples/toggle_led/main/src/wifi_cfg.c b/examples/toggle_led/main/src/wifi_cfg.c index 3c455fe5..a652692a 100644 --- a/examples/toggle_led/main/src/wifi_cfg.c +++ b/examples/toggle_led/main/src/wifi_cfg.c @@ -67,7 +67,7 @@ void wifi_init(void) ESP_ERROR_CHECK(esp_event_loop_create_default()); esp_netif_create_default_wifi_sta(); - wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); + wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); // NOLINT ESP_ERROR_CHECK(esp_wifi_init(&cfg)); esp_event_handler_instance_t instance_any_id = NULL; diff --git a/idf_component.yml b/idf_component.yml index 8e29de63..ff9966e7 100644 --- a/idf_component.yml +++ b/idf_component.yml @@ -18,10 +18,15 @@ # SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 # -version: "1.2.0" +version: "1.3.3" description: "A component that provides communication and pairing primitives to an Astarte cluster" -url: "https://github.com/astarte-platform/astarte-device-sdk-esp32" -documentation: "https://docs.astarte-platform.org/device-sdks/esp32/1.2/api" +repository: "https://github.com/astarte-platform/astarte-device-sdk-esp32.git" +url: "https://docs.astarte-platform.org/" +documentation: "https://docs.astarte-platform.org/device-sdks/index.html" +license: "Apache-2.0" +maintainers: + - Simone Orru + - Antonio Gisondi tags: - sdk @@ -38,8 +43,6 @@ files: exclude: - "doc/**/*" - "doc" - - "examples/**/*" - - "examples" - "python_scripts/**/*" - "python_scripts" - "tests/**/*" diff --git a/include/astarte.h b/include/astarte.h index 2b182ac1..cb13be4b 100644 --- a/include/astarte.h +++ b/include/astarte.h @@ -14,8 +14,8 @@ // Version information #define ASTARTE_DEVICE_SDK_MAJOR 1 -#define ASTARTE_DEVICE_SDK_MINOR 2 -#define ASTARTE_DEVICE_SDK_PATCH 99 +#define ASTARTE_DEVICE_SDK_MINOR 3 +#define ASTARTE_DEVICE_SDK_PATCH 3 // clang-format off diff --git a/src/astarte_device.c b/src/astarte_device.c index 891151b6..4be21ae3 100644 --- a/src/astarte_device.c +++ b/src/astarte_device.c @@ -1444,11 +1444,6 @@ static void on_incoming( return; } - if (!device->data_event_callback) { - ESP_LOGE(TAG, "data_event_callback not set"); - return; - } - if (strstr(topic, device->device_topic) != topic) { ESP_LOGE(TAG, "Incoming message topic doesn't begin with device_topic: %s", topic); return; @@ -1605,17 +1600,21 @@ static void on_incoming( return; } - astarte_device_data_event_t event = { - .device = device, - .interface_name = interface_name, - .path = path, - .bson_value = bson_value, - .bson_value_type = bson_value_type, - .bson_element = v_elem, - .user_data = device->callbacks_user_data, - }; + if (device->data_event_callback) { + astarte_device_data_event_t event = { + .device = device, + .interface_name = interface_name, + .path = path, + .bson_value = bson_value, + .bson_value_type = bson_value_type, + .bson_element = v_elem, + .user_data = device->callbacks_user_data, + }; - device->data_event_callback(&event); + device->data_event_callback(&event); + } else { + ESP_LOGE(TAG, "Data received, but data_event_callback is not defined"); + } } // NOLINTBEGIN(misc-unused-parameters)