Skip to content

Commit 13d457d

Browse files
authored
Merge pull request #79 from sorru94/support-to-idf-5.0
Support to idf 5.0
2 parents b6b43f5 + d5e9f30 commit 13d457d

File tree

12 files changed

+77
-13
lines changed

12 files changed

+77
-13
lines changed

.github/workflows/build.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ jobs:
3131
strategy:
3232
matrix:
3333
idf-version:
34-
- 4.3
34+
- "4.3"
35+
- "5.0.1"
3536
build-system:
3637
- idf
3738
runs-on: ubuntu-latest

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,6 @@ examples/edgehog_app/components/astarte-device-sdk-esp32
4747
doc/out
4848
/examples/edgehog_app/managed_components/
4949
/examples/edgehog_app/dependencies.lock
50+
51+
# VS code config
52+
.vscode/

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [0.7.0] - Unreleased
8+
### Added
9+
- Add support to ESP-IDF v5.0.
10+
711
## [0.5.2] - 2022-06-22
812

913
## [0.5.1] - 2022-06-01
@@ -15,4 +19,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1519

1620
## [0.5.0] - 2022-03-22
1721
### Added
18-
- Initial Edgehog release
22+
- Initial Edgehog release.

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ endif ()
3838
idf_component_register(SRCS "${edgehog_srcs}"
3939
INCLUDE_DIRS "include"
4040
PRIV_INCLUDE_DIRS "private"
41-
REQUIRES astarte-device-sdk-esp32 nvs_flash app_update esp_https_ota)
41+
REQUIRES astarte-device-sdk-esp32 esp_timer nvs_flash app_update esp_https_ota esp_wifi spi_flash)

examples/edgehog_app/main/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static void event_handler(
5454
ESP_LOGI(TAG, "got ip:" IPSTR, IP2STR(&event->ip_info.ip));
5555
xEventGroupSetBits(wifi_event_group, WIFI_CONNECTED_BIT);
5656
} else if (event_base == EDGEHOG_EVENTS) {
57-
ESP_LOGI(TAG, "EDGEHOG EVENT RECEIVED %d", event_id);
57+
ESP_LOGI(TAG, "EDGEHOG EVENT RECEIVED %" PRIi32 "", event_id);
5858
}
5959
}
6060

idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ dependencies:
2424
# Required IDF version
2525
idf: ">=4.1"
2626
astarte-device-sdk-esp32:
27-
version: "v1.0.2"
27+
version: "v1.1.0"
2828
git: https://github.com/astarte-platform/astarte-device-sdk-esp32.git

private/edgehog_device_private.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
extern "C" {
2626
#endif
2727

28+
#include <esp_idf_version.h>
29+
2830
#include "edgehog_device.h"
2931
#include "edgehog_telemetry.h"
3032
#if CONFIG_INDICATOR_GPIO_ENABLE
@@ -71,13 +73,19 @@ esp_err_t edgehog_device_nvs_open(
7173
* @param edgehog_device A valid Edgehog device handle.
7274
* @param namespace Namespace name.
7375
* @param type One of nvs_type_t values.
76+
* @param it Iterator used to enumerate all the entries found,or NULL if no entry satisfying
77+
* criteria was found. Iterator obtained through this function has to be released using
78+
* nvs_release_iterator when not used any more.
7479
*
75-
* @return Iterator used to enumerate all the entries found,or NULL if no entry satisfying criteria
76-
* was found. Iterator obtained through this function has to be released using nvs_release_iterator
77-
* when not used any more.
80+
* @return ESP_OK if iterator was created successfully, an esp_err_t otherwise.
7881
*/
82+
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
83+
esp_err_t edgehog_device_nvs_entry_find(edgehog_device_handle_t edgehog_device,
84+
const char *namespace, nvs_type_t type, nvs_iterator_t *it);
85+
#else
7986
nvs_iterator_t edgehog_device_nvs_entry_find(
8087
edgehog_device_handle_t edgehog_device, const char *namespace, nvs_type_t type);
88+
#endif
8189

8290
/**
8391
* @brief Telemetry periodic callback type.

src/edgehog_base_image.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ const astarte_interface_t base_image_interface = { .name = "io.edgehog.deviceman
3939

4040
void edgehog_base_image_data_publish(edgehog_device_handle_t edgehog_device)
4141
{
42+
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
43+
const esp_app_desc_t *desc = esp_app_get_description();
44+
#else
4245
const esp_app_desc_t *desc = esp_ota_get_app_description();
46+
#endif
4347
astarte_device_handle_t astarte_device = edgehog_device->astarte_device;
4448

4549
astarte_err_t ret = astarte_device_set_string_property(
@@ -64,7 +68,11 @@ void edgehog_base_image_data_publish(edgehog_device_handle_t edgehog_device)
6468
}
6569

6670
char sha256_str[65];
71+
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
72+
esp_app_get_elf_sha256(sha256_str, 65);
73+
#else
6774
esp_ota_get_app_elf_sha256(sha256_str, 65);
75+
#endif
6876
ret = astarte_device_set_string_property(
6977
astarte_device, base_image_interface.name, "/fingerprint", sha256_str);
7078
if (ret != ASTARTE_OK) {

src/edgehog_command.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ edgehog_err_t edgehog_command_event(astarte_device_data_event_t *event_request)
3737
{
3838
EDGEHOG_VALIDATE_INCOMING_DATA(TAG, event_request, "/request", BSON_TYPE_STRING);
3939

40-
size_t len;
40+
uint32_t len;
4141
const char *command = astarte_bson_value_to_string(event_request->bson_value, &len);
4242

4343
if (strcmp(command, "Reboot") == 0) {

src/edgehog_device.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
#include "edgehog_storage_usage.h"
3434
#include "esp_system.h"
3535
#include <astarte_bson_serializer.h>
36+
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
37+
#include <esp_chip_info.h>
38+
#endif
3639
#include <esp_err.h>
3740
#include <esp_heap_caps.h>
3841
#include <esp_log.h>
@@ -541,11 +544,19 @@ esp_err_t edgehog_device_nvs_open(
541544
return ESP_OK;
542545
}
543546

547+
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
548+
esp_err_t edgehog_device_nvs_entry_find(edgehog_device_handle_t edgehog_device,
549+
const char *namespace, nvs_type_t type, nvs_iterator_t *it)
550+
{
551+
return nvs_entry_find(edgehog_device->partition_name, namespace, type, it);
552+
}
553+
#else
544554
nvs_iterator_t edgehog_device_nvs_entry_find(
545555
edgehog_device_handle_t edgehog_device, const char *namespace, nvs_type_t type)
546556
{
547557
return nvs_entry_find(edgehog_device->partition_name, namespace, type);
548558
}
559+
#endif
549560

550561
telemetry_periodic edgehog_device_get_telemetry_periodic(telemetry_type_t type)
551562
{

0 commit comments

Comments
 (0)