Skip to content

Commit

Permalink
ESP32: software update using hawkbit over HTTPS
Browse files Browse the repository at this point in the history
  • Loading branch information
Danielius1922 authored and Daniel Adam committed Jan 11, 2024
1 parent 8f16eca commit f74b116
Show file tree
Hide file tree
Showing 32 changed files with 769 additions and 477 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,11 @@ jobs:
run: |
sudo apt install -y git wget flex bison gperf python3 python3-pip python3-setuptools python3-serial python3-click python3-cryptography python3-future python3-pyparsing python3-pyelftools cmake ninja-build ccache libffi-dev libssl-dev libusb-1.0-0
cd ./port/esp32
# git clone --recursive -b release/v5.0 https://github.com/espressif/esp-idf.git
git clone -b release/v5.0 https://github.com/espressif/esp-idf.git
( cd esp-idf && git checkout 335ca8a687d4f507b8ffe8a4ec3132ba4a4a4be3 )
( cd esp-idf && git submodule update --init --recursive )
git clone --recursive -b release/v5.1 https://github.com/espressif/esp-idf.git
./esp-idf/install.sh
. ./esp-idf/export.sh
idf.py ${{ matrix.args }} set-target esp32
( cd esp-idf/components/mbedtls/mbedtls && patch -p1 < ../../../../../../patches/mbedtls/3.1/01-ocf-x509san-anon-psk.patch)
( cd esp-idf/components/mbedtls/mbedtls && patch -p1 < ../../../../patches/mbedtls/3.1/02-ocf-mbedtls-config.patch)
( cd esp-idf/components/mbedtls/mbedtls && patch -p1 < ../../../../../../patches/mbedtls/3.5/01-ocf-anon-psk.patch )
( cd esp-idf/components/mbedtls/mbedtls && patch -p1 < ../../../../patches/mbedtls/3.5/02-ocf-mbedtls-config.patch )
( cd esp-idf/components/lwip/lwip && find ../../../../patches/lwip/ -type f -name '*.patch' -exec patch -p1 -i {} \; )
idf.py build
1 change: 1 addition & 0 deletions port/esp32/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ for mbedTLS v3.1.0:
# apply iotivity-lite patches for mbedTLS v3.1.0
( cd esp-idf/components/mbedtls/mbedtls && patch -p1 < ../../../../../../patches/mbedtls/3.1/01-ocf-x509san-anon-psk.patch )
( cd esp-idf/components/mbedtls/mbedtls && patch -p1 < ../../../../patches/mbedtls/3.1/02-ocf-mbedtls-config.patch )
( cd esp-idf/components/lwip/lwip && find ../../../../patches/lwip/ -type f -name '*.patch' -exec patch -p1 -i {} \; )
-->

```bash
Expand Down
24 changes: 3 additions & 21 deletions port/esp32/adapter/include/debug_print.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
extern "C" {
#endif

#define APP_PRINT(...) printf(__VA_ARGS__)

/**
* @brief print current all macro information
*
Expand All @@ -38,23 +36,7 @@ void print_macro_info();
* @param[in] message: the struct oc_message_t to print
*
*/
void print_message_info(oc_message_t *message);

/**
* @brief print the data detail information
*
* print input data, print from data[0] to data[len-1], addtionally add notes
* string
*
* @param[in] data: input data pointer to print
* @param[in] len: data length
* @param[in] note: notes for read easily
* @param[in] mode: 0x00, 0x01, 0x10, 0x11 to decide the BINARY_SHOW &&
* BYTES_SHOW
*
*/
void print_debug(const char *data, const unsigned int len, const char *note,
int mode);
void print_message_info(const oc_message_t *message);

/**
* @brief print the fatal error information and cycle it
Expand All @@ -73,8 +55,8 @@ void print_debug(const char *data, const unsigned int len, const char *note,

#define APP_LOG(level, ...) \
do { \
APP_PRINT("%s: %s <%s:%d>: ", level, __FILE__, __FUNCTION__, __LINE__); \
APP_PRINT(__VA_ARGS__); \
printf("%s: %s <%s:%d>: ", level, __FILE__, __FUNCTION__, __LINE__); \
printf(__VA_ARGS__); \
printf("\n"); \
} while (0)
#define APP_DBG(...) APP_LOG("DEBUG", __VA_ARGS__)
Expand Down
80 changes: 28 additions & 52 deletions port/esp32/adapter/src/debug_print.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/
#include "debug_print.h"
#include "port/oc_connectivity.h"
#include "port/oc_log_internal.h"
#include <stdint.h>
#include <stdio.h>

Expand All @@ -15,11 +16,7 @@ print_macro_info()
{
printf("\n****************************************\n");

#ifdef OC_DEBUG
printf("OC_DEBUG defined!\n");
#else
printf("OC_DEBUG not defined!\n");
#endif
printf("OC_LOG_MAXIMUM_LEVEL=%d\n", OC_LOG_MAXIMUM_LEVEL);

#ifdef APP_DEBUG
printf("APP_DEBUG defined!\n");
Expand All @@ -45,6 +42,12 @@ print_macro_info()
printf("OC_IPV4 not defined!\n");
#endif

#ifdef OC_CLOUD
printf("OC_CLOUD defined!\n");
#else
printf("OC_CLOUD not defined!\n");
#endif

#ifdef ENABLE_LIGHT
printf("ENABLE_LIGHT defined!\n");
#else
Expand All @@ -57,6 +60,12 @@ print_macro_info()
printf("OC_SECURITY not defined!\n");
#endif

#ifdef OC_PKI
printf("OC_PKI defined!\n");
#else
printf("OC_PKI not defined!\n");
#endif

#ifdef OC_DYNAMIC_ALLOCATION
printf("OC_DYNAMIC_ALLOCATION defined!\n");
#else
Expand All @@ -69,13 +78,25 @@ print_macro_info()
printf("OC_BLOCK_WISE not defined!\n");
#endif

#ifdef OC_SOFTWARE_UPDATE
printf("OC_SOFTWARE_UPDATE defined!\n");
#else
printf("OC_SOFTWARE_UPDATE not defined!\n");
#endif

#ifdef PLGD_DEV_HAWKBIT
printf("PLGD_DEV_HAWKBIT defined!\n");
#else
printf("PLGD_DEV_HAWKBIT not defined!\n");
#endif

printf("\n****************************************\n");
}

void
print_message_info(oc_message_t *message)
print_message_info(const oc_message_t *message)
{
#ifdef OC_DEBUG
#ifdef APP_DEBUG
printf("\n****************************************\n");

#ifdef OC_IPV4
Expand Down Expand Up @@ -106,48 +127,3 @@ print_message_info(oc_message_t *message)
printf("\n****************************************\n");
#endif
}

/**
* @brief print the data detail information
*
* print input data, print from data[0] to data[len-1], addtionally add notes
* string
*
* @param[in] data: input data pointer to print
* @param[in] len: data length
* @param[in] note: notes for read easily
* @param[in] mode: 0x00, 0x01, 0x10, 0x11 to decide the BINARY_SHOW &&
* BYTES_SHOW
*
* @return noreturn
*
*/
void
print_debug(const char *data, const unsigned int len, const char *note,
int mode)
{
#define BINARY_SHOW 0x10
#define BYTES_SHOW 0x01
printf("\n********** %s [len:%u] start addr:%p **********\n", note, len,
data);
int i = 0;
for (i = 0; i < len; ++i) {
if (BINARY_SHOW & mode) {
printf("%02x ", data[i]);
} else {
if (data[i] < 32 || data[i] > 126) { // control || invisible charset
if (i > 0 && (data[i - 1] >= 33 && data[i - 1] <= 126))
printf(" ");
printf("%02x ", data[i]);
} else {
printf("%c", data[i]);
}
}

if ((BYTES_SHOW & mode) && ((i + 1) % 32 == 0)) {
printf(" | %d Bytes\n", i + 1);
}
} // end for

printf("\n---------- %s End ----------\n", note);
}
7 changes: 1 addition & 6 deletions port/esp32/adapter/src/ipadapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1722,12 +1722,7 @@ oc_dns_lookup(const char *domain, oc_string_t *addr, transport_flags flags)
#endif /* OC_DNS_CACHE */
freeaddrinfo(result);
} else {
#ifdef OC_DEBUG
OC_ERR("failed to resolve address(%s) with error(%d): %s", domain, ret,
gai_strerror(ret));
#else /* OC_DEBUG */
OC_ERR("failed to resolve address(%s) with error(%d)", domain, ret);
#endif /* !OC_DEBUG */
OC_ERR("failed to resolve address(%s) with error(%d)", domain, ret);
}
#ifdef OC_DNS_CACHE
} else {
Expand Down
2 changes: 2 additions & 0 deletions port/esp32/adapter/src/tcpadapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
*
****************************************************************************/

#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif

#include "api/oc_message_internal.h"
#include "api/oc_session_events_internal.h"
Expand Down
Loading

0 comments on commit f74b116

Please sign in to comment.