Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
giroudon committed Feb 15, 2023
2 parents e73005a + 15ef01e commit a17e317
Show file tree
Hide file tree
Showing 9 changed files with 130 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@ build_esp8266_demo:
- chmod 600 ~/.ssh/id_rsa
- echo -e "Host gitlab.espressif.cn\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
- git --version
- git clone --recursive --depth 1 $GITLAB_SSH_SERVER/sdk/ESP8266_RTOS_SDK.git
- git clone -b v3.3 --recursive --depth 1 $GITLAB_SSH_SERVER/sdk/ESP8266_RTOS_SDK.git
- cd ESP8266_RTOS_SDK
- source tools/ci/configure_ci_environment.sh
- cd ..
- git submodule update --init --recursive
- export IDF_PATH=$CI_PROJECT_DIR/ESP8266_RTOS_SDK
- cd examples/iothub_client_sample_mqtt
- make defconfig
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@
- [Monitoring Results](#monitoring)
- [Troubleshooting](#troubleshooting)

## 2021 Update

<a name="2021 update"></a>

Since this library has been published, Microsoft has created newer versions of the Azure SDK for usage with the Espressif ESP32. This new library is better suited for microcontrollers, great for composition with your own network stack and officially supported by Microsoft.

The first one, [Azure IoT middleware for FreeRTOS](https://github.com/Azure/azure-iot-middleware-freertos), is based on ESP-IDF and FreeRTOS and it has [samples](https://github.com/Azure-Samples/iot-middleware-freertos-samples) for IoT Hub and IoT Central using the device provisioning service (DPS).

The second one is based on [Azure IoT for C library for Arduino](https://github.com/Azure/azure-sdk-for-c-arduino) and also has samples for IoT Hub.

If you can, **avoid using this library for any new projects**.

## Introduction

<a name="introduction"></a>
Expand Down
2 changes: 1 addition & 1 deletion azure-iot-sdk-c
Submodule azure-iot-sdk-c updated 817 files
2 changes: 1 addition & 1 deletion component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ COMPONENT_SRCDIRS += azure-iot-sdk-c/certs
endif

CFLAGS += -Wno-unused-function -Wno-missing-braces -Wno-missing-field-initializers -DHSM_TYPE_X509 -DHSM_TYPE_SAS_TOKEN -DHSM_TYPE_SYMM_KEY
CFLAGS += -Wno-error=maybe-uninitialized -Wno-error=char-subscripts
CFLAGS += -Wno-error=maybe-uninitialized -Wno-error=char-subscripts -Wno-unknown-pragmas

ifdef CONFIG_DEVICE_COMMON_NAME
CFLAGS += -DUSE_PROV_MODULE
Expand Down
37 changes: 37 additions & 0 deletions examples/iothub_client_sample_mqtt/main/azure_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
#include "esp_system.h"
#include "esp_system.h"
#include "esp_wifi.h"
#ifdef CONFIG_IDF_TARGET_ESP8266 || (ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(4, 0, 0))
#include "esp_event_loop.h"
#else
#include "esp_event.h"
#endif
#include "esp_log.h"

#include "nvs_flash.h"
Expand All @@ -35,6 +39,7 @@ const int CONNECTED_BIT = BIT0;

static const char *TAG = "azure";

#ifdef CONFIG_IDF_TARGET_ESP8266 || (ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(4, 0, 0))
static esp_err_t event_handler(void *ctx, system_event_t *event)
{
switch(event->event_id) {
Expand All @@ -55,12 +60,37 @@ static esp_err_t event_handler(void *ctx, system_event_t *event)
}
return ESP_OK;
}
#else
static void event_handler(void* arg, esp_event_base_t event_base,
int32_t event_id, void* event_data)
{
if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) {
esp_wifi_connect();
} else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) {
xEventGroupSetBits(wifi_event_group, CONNECTED_BIT);
} else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) {
/* This is a workaround as ESP platform WiFi libs don't currently
auto-reassociate. */
esp_wifi_connect();
xEventGroupClearBits(wifi_event_group, CONNECTED_BIT);
}
}
#endif

static void initialise_wifi(void)
{
#ifdef CONFIG_IDF_TARGET_ESP8266 || (ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(4, 0, 0))
tcpip_adapter_init();
wifi_event_group = xEventGroupCreate();
ESP_ERROR_CHECK( esp_event_loop_init(event_handler, NULL) );
#else
ESP_ERROR_CHECK( esp_netif_init() );
wifi_event_group = xEventGroupCreate();
ESP_ERROR_CHECK( esp_event_loop_create_default() );
esp_netif_t *sta_netif = esp_netif_create_default_wifi_sta();
assert(sta_netif);
#endif

wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK( esp_wifi_init(&cfg) );
ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) );
Expand All @@ -71,6 +101,13 @@ static void initialise_wifi(void)
},
};
ESP_LOGI(TAG, "Setting WiFi configuration SSID %s...", wifi_config.sta.ssid);

#ifdef CONFIG_IDF_TARGET_ESP8266 || (ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(4, 0, 0))
#else
ESP_ERROR_CHECK( esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL) );
ESP_ERROR_CHECK( esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &event_handler, NULL) );
#endif

ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) );
ESP_ERROR_CHECK( esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config) );
ESP_ERROR_CHECK( esp_wifi_start() );
Expand Down
37 changes: 37 additions & 0 deletions examples/iothub_devicetwin_samples_and_methods/main/azure_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
#include "esp_system.h"
#include "esp_system.h"
#include "esp_wifi.h"
#ifdef CONFIG_IDF_TARGET_ESP8266 || (ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(4, 0, 0))
#include "esp_event_loop.h"
#else
#include "esp_event.h"
#endif
#include "esp_log.h"

#include "nvs_flash.h"
Expand All @@ -37,6 +41,7 @@ static const char *TAG = "azure";

extern int iothhub_devicetwin_init(void);

#ifdef CONFIG_IDF_TARGET_ESP8266 || (ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(4, 0, 0))
static esp_err_t event_handler(void *ctx, system_event_t *event)
{
switch(event->event_id) {
Expand All @@ -57,12 +62,37 @@ static esp_err_t event_handler(void *ctx, system_event_t *event)
}
return ESP_OK;
}
#else
static void event_handler(void* arg, esp_event_base_t event_base,
int32_t event_id, void* event_data)
{
if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) {
esp_wifi_connect();
} else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) {
xEventGroupSetBits(wifi_event_group, CONNECTED_BIT);
} else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) {
/* This is a workaround as ESP platform WiFi libs don't currently
auto-reassociate. */
esp_wifi_connect();
xEventGroupClearBits(wifi_event_group, CONNECTED_BIT);
}
}
#endif

static void initialise_wifi(void)
{
#ifdef CONFIG_IDF_TARGET_ESP8266 || (ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(4, 0, 0))
tcpip_adapter_init();
wifi_event_group = xEventGroupCreate();
ESP_ERROR_CHECK( esp_event_loop_init(event_handler, NULL) );
#else
ESP_ERROR_CHECK( esp_netif_init() );
wifi_event_group = xEventGroupCreate();
ESP_ERROR_CHECK( esp_event_loop_create_default() );
esp_netif_t *sta_netif = esp_netif_create_default_wifi_sta();
assert(sta_netif);
#endif

wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK( esp_wifi_init(&cfg) );
ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) );
Expand All @@ -73,6 +103,13 @@ static void initialise_wifi(void)
},
};
ESP_LOGI(TAG, "Setting WiFi configuration SSID %s...", wifi_config.sta.ssid);

#ifdef CONFIG_IDF_TARGET_ESP8266 || (ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(4, 0, 0))
#else
ESP_ERROR_CHECK( esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL) );
ESP_ERROR_CHECK( esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &event_handler, NULL) );
#endif

ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) );
ESP_ERROR_CHECK( esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config) );
ESP_ERROR_CHECK( esp_wifi_start() );
Expand Down
37 changes: 37 additions & 0 deletions examples/prov_dev_client_ll_sample/main/azure_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
#include "esp_system.h"
#include "esp_system.h"
#include "esp_wifi.h"
#ifdef CONFIG_IDF_TARGET_ESP8266 || (ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(4, 0, 0))
#include "esp_event_loop.h"
#else
#include "esp_event.h"
#endif
#include "esp_log.h"

#include "nvs_flash.h"
Expand All @@ -35,6 +39,7 @@ const int CONNECTED_BIT = BIT0;

static const char *TAG = "azure";

#ifdef CONFIG_IDF_TARGET_ESP8266 || (ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(4, 0, 0))
static esp_err_t event_handler(void *ctx, system_event_t *event)
{
switch(event->event_id) {
Expand All @@ -55,12 +60,37 @@ static esp_err_t event_handler(void *ctx, system_event_t *event)
}
return ESP_OK;
}
#else
static void event_handler(void* arg, esp_event_base_t event_base,
int32_t event_id, void* event_data)
{
if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) {
esp_wifi_connect();
} else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) {
xEventGroupSetBits(wifi_event_group, CONNECTED_BIT);
} else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) {
/* This is a workaround as ESP platform WiFi libs don't currently
auto-reassociate. */
esp_wifi_connect();
xEventGroupClearBits(wifi_event_group, CONNECTED_BIT);
}
}
#endif

static void initialise_wifi(void)
{
#ifdef CONFIG_IDF_TARGET_ESP8266 || (ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(4, 0, 0))
tcpip_adapter_init();
wifi_event_group = xEventGroupCreate();
ESP_ERROR_CHECK( esp_event_loop_init(event_handler, NULL) );
#else
ESP_ERROR_CHECK( esp_netif_init() );
wifi_event_group = xEventGroupCreate();
ESP_ERROR_CHECK( esp_event_loop_create_default() );
esp_netif_t *sta_netif = esp_netif_create_default_wifi_sta();
assert(sta_netif);
#endif

wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK( esp_wifi_init(&cfg) );
ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) );
Expand All @@ -71,6 +101,13 @@ static void initialise_wifi(void)
},
};
ESP_LOGI(TAG, "Setting WiFi configuration SSID %s...", wifi_config.sta.ssid);

#ifdef CONFIG_IDF_TARGET_ESP8266 || (ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(4, 0, 0))
#else
ESP_ERROR_CHECK( esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL) );
ESP_ERROR_CHECK( esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &event_handler, NULL) );
#endif

ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) );
ESP_ERROR_CHECK( esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config) );
ESP_ERROR_CHECK( esp_wifi_start() );
Expand Down
1 change: 1 addition & 0 deletions port/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ component_compile_options (
-Wno-unused-function
-Wno-missing-braces
-Wno-missing-field-initializers
-Wno-unknown-pragmas
)

component_compile_definitions (
Expand Down
12 changes: 2 additions & 10 deletions port/src/agenttime_esp.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,11 @@
#include <sys/time.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/event_groups.h"
#include "esp_system.h"
#include "esp_wifi.h"
#include "esp_event_loop.h"
#include "esp_log.h"
#include "esp_attr.h"
#include "lwip/apps/sntp.h"

#include "lwip/err.h"
#include "azure_c_shared_utility/agenttime.h"
#include "azure_c_shared_utility/xlogging.h"

#include "lwip/apps/sntp.h"

void initialize_sntp(void)
{
if (!sntp_enabled()) {
Expand Down Expand Up @@ -67,7 +59,7 @@ time_t get_time(time_t* currentTime)
}

double get_difftime(time_t stopTime, time_t startTime)
{
{
return (double)stopTime - (double)startTime;
}

Expand Down

0 comments on commit a17e317

Please sign in to comment.