From 6ca2934843d4e0d07d45e481d663d56e34b54716 Mon Sep 17 00:00:00 2001 From: Wu Jian Gang Date: Fri, 6 Jan 2017 18:36:11 +0800 Subject: [PATCH 1/4] example: fix CI error of coap client demo --- .../23_coap_client/main/Kconfig.projbuild | 13 -- examples/23_coap_client/main/coap_client.c | 183 ++++++++++-------- examples/23_coap_client/main/coap_client.h | 43 ---- 3 files changed, 106 insertions(+), 133 deletions(-) delete mode 100644 examples/23_coap_client/main/coap_client.h diff --git a/examples/23_coap_client/main/Kconfig.projbuild b/examples/23_coap_client/main/Kconfig.projbuild index ba3e0d458b..045137a0e9 100644 --- a/examples/23_coap_client/main/Kconfig.projbuild +++ b/examples/23_coap_client/main/Kconfig.projbuild @@ -1,24 +1,11 @@ menu "Example Configuration" -config TARGET_DOMAIN - string "Target Domain" - default "californium.eclipse.org" - help - Target domain for the example to connect to. - config TARGET_DOMAIN_URI string "Target Uri" default "coap://californium.eclipse.org" help Target uri for the example to use. -config TARGET_PORT_NUMBER - int "Target port number" - range 0 65535 - default 5683 - help - Target port number for the example to connect to. - config WIFI_SSID string "WiFi SSID" default "myssid" diff --git a/examples/23_coap_client/main/coap_client.c b/examples/23_coap_client/main/coap_client.c index cef24f4c6e..7c0df1afec 100644 --- a/examples/23_coap_client/main/coap_client.c +++ b/examples/23_coap_client/main/coap_client.c @@ -6,9 +6,10 @@ software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ -#include "coap_client.h" #include +#include +#include #include "freertos/FreeRTOS.h" #include "freertos/task.h" @@ -19,12 +20,28 @@ #include "esp_event_loop.h" #include "nvs_flash.h" -#include -#include "coap_config.h" -#include "resource.h" #include "coap.h" +/* The examples use simple WiFi configuration that you can set via + 'make menuconfig'. + + If you'd rather not, just change the below entries to strings with + the config you want - ie #define EXAMPLE_WIFI_SSID "mywifissid" +*/ +#define EXAMPLE_WIFI_SSID CONFIG_WIFI_SSID +#define EXAMPLE_WIFI_PASS CONFIG_WIFI_PASSWORD + +#define COAP_DEFAULT_TIME_SEC 5 +#define COAP_DEFAULT_TIME_USEC 0 + +/* The examples use uri "coap://californium.eclipse.org" that + you can set via 'make menuconfig'. + + If you'd rather not, just change the below entries to strings with + the config you want - ie #define COAP_DEFAULT_DEMO_URI "coap://californium.eclipse.org" +*/ +#define COAP_DEFAULT_DEMO_URI CONFIG_TARGET_DOMAIN_URI static EventGroupHandle_t wifi_event_group; @@ -33,98 +50,111 @@ static EventGroupHandle_t wifi_event_group; to the AP with an IP? */ const static int CONNECTED_BIT = BIT0; -const static char *TAG = "CoAP_demo"; +const static char *TAG = "CoAP_client"; static void message_handler(struct coap_context_t *ctx, const coap_endpoint_t *local_interface, const coap_address_t *remote, coap_pdu_t *sent, coap_pdu_t *received, const coap_tid_t id) { - unsigned char* data = NULL; - size_t data_len; - if (COAP_RESPONSE_CLASS(received->hdr->code) == 2) { - if (coap_get_data(received, &data_len, &data)) { - printf("Received: %s\n", data); - } - } + unsigned char* data = NULL; + size_t data_len; + if (COAP_RESPONSE_CLASS(received->hdr->code) == 2) { + if (coap_get_data(received, &data_len, &data)) { + printf("Received: %s\n", data); + } + } } static void coap_demo_thread(void *p) { - coap_context_t* ctx = NULL; - coap_address_t dst_addr, src_addr; - static coap_uri_t uri; - fd_set readfds; - struct timeval tv; - int flags, result; - coap_pdu_t* request = NULL; - const char* server_uri = COAP_DEFAULT_DEMO_URI; - uint8_t get_method = 1; + struct hostent *hp; + struct ip4_addr *ip4_addr; - coap_address_init(&src_addr); - src_addr.addr.sin.sin_family = AF_INET; - src_addr.addr.sin.sin_port = htons(0); - src_addr.addr.sin.sin_addr.s_addr = INADDR_ANY; + coap_context_t* ctx = NULL; + coap_address_t dst_addr, src_addr; + static coap_uri_t uri; + fd_set readfds; + struct timeval tv; + int flags, result; + coap_pdu_t* request = NULL; + const char* server_uri = COAP_DEFAULT_DEMO_URI; + uint8_t get_method = 1; - ctx = coap_new_context(&src_addr); - if (ctx) { - coap_address_init(&dst_addr); - dst_addr.addr.sin.sin_family = AF_INET; - dst_addr.addr.sin.sin_port = htons(COAP_DEFAULT_PORT); - dst_addr.addr.sin.sin_addr.s_addr = inet_addr(COAP_DEFAULT_DEMO_ADDR); + while (1) { + /* Wait for the callback to set the CONNECTED_BIT in the + event group. + */ + xEventGroupWaitBits(wifi_event_group, CONNECTED_BIT, + false, true, portMAX_DELAY); + ESP_LOGI(TAG, "Connected to AP"); - coap_split_uri((const uint8_t *)server_uri, strlen(server_uri), &uri); - request = coap_new_pdu(); - if (request){ - request->hdr->type = COAP_MESSAGE_CON; - request->hdr->id = coap_new_message_id(ctx); - request->hdr->code = get_method; - coap_add_option(request, COAP_OPTION_URI_PATH, uri.path.length, uri.path.s); + if (coap_split_uri((const uint8_t *)server_uri, strlen(server_uri), &uri) == -1) { + ESP_LOGE(TAG, "CoAP server uri error"); + break; + } - coap_register_response_handler(ctx, message_handler); - coap_send_confirmed(ctx, ctx->endpoint, &dst_addr, request); + hp = gethostbyname((const char *)uri.host.s); - flags = fcntl(ctx->sockfd, F_GETFL, 0); - fcntl(ctx->sockfd, F_SETFL, flags|O_NONBLOCK); + if (hp == NULL) { + ESP_LOGE(TAG, "DNS lookup failed"); + vTaskDelay(1000 / portTICK_PERIOD_MS); + continue; + } - tv.tv_usec = COAP_DEFAULT_TIME_USEC; - tv.tv_sec = COAP_DEFAULT_TIME_SEC; + /* Code to print the resolved IP. - for(;;) { - FD_ZERO(&readfds); - FD_CLR( ctx->sockfd, &readfds ); - FD_SET( ctx->sockfd, &readfds ); - result = select( FD_SETSIZE, &readfds, 0, 0, &tv ); - if (result > 0) { - if (FD_ISSET( ctx->sockfd, &readfds )) - coap_read(ctx); - } else if (result < 0) { - break; - } else { - printf("select timeout\n"); - } - } - } - coap_free_context(ctx); - } + Note: inet_ntoa is non-reentrant, look at ipaddr_ntoa_r for "real" code */ + ip4_addr = (struct ip4_addr *)hp->h_addr; + ESP_LOGI(TAG, "DNS lookup succeeded. IP=%s", inet_ntoa(*ip4_addr)); - vTaskDelete(NULL); -} + coap_address_init(&src_addr); + src_addr.addr.sin.sin_family = AF_INET; + src_addr.addr.sin.sin_port = htons(0); + src_addr.addr.sin.sin_addr.s_addr = INADDR_ANY; -static void coap_server_init(void) -{ - int ret = pdPASS; - xTaskHandle coap_handle = NULL; + ctx = coap_new_context(&src_addr); + if (ctx) { + coap_address_init(&dst_addr); + dst_addr.addr.sin.sin_family = AF_INET; + dst_addr.addr.sin.sin_port = htons(COAP_DEFAULT_PORT); + dst_addr.addr.sin.sin_addr.s_addr = ip4_addr->addr; - ret = xTaskCreate(coap_demo_thread, - COAP_DEMO_THREAD_NAME, - COAP_DEMO_THREAD_STACK_WORDS, - NULL, - COAP_DEMO_THREAD_PRORIOTY, - &coap_handle); + request = coap_new_pdu(); + if (request){ + request->hdr->type = COAP_MESSAGE_CON; + request->hdr->id = coap_new_message_id(ctx); + request->hdr->code = get_method; + coap_add_option(request, COAP_OPTION_URI_PATH, uri.path.length, uri.path.s); - if (ret != pdPASS) { - ESP_LOGI(TAG, "create thread %s failed", COAP_DEMO_THREAD_NAME); + coap_register_response_handler(ctx, message_handler); + coap_send_confirmed(ctx, ctx->endpoint, &dst_addr, request); + + flags = fcntl(ctx->sockfd, F_GETFL, 0); + fcntl(ctx->sockfd, F_SETFL, flags|O_NONBLOCK); + + tv.tv_usec = COAP_DEFAULT_TIME_USEC; + tv.tv_sec = COAP_DEFAULT_TIME_SEC; + + for(;;) { + FD_ZERO(&readfds); + FD_CLR( ctx->sockfd, &readfds ); + FD_SET( ctx->sockfd, &readfds ); + result = select( FD_SETSIZE, &readfds, 0, 0, &tv ); + if (result > 0) { + if (FD_ISSET( ctx->sockfd, &readfds )) + coap_read(ctx); + } else if (result < 0) { + break; + } else { + ESP_LOGE(TAG, "select timeout"); + } + } + } + coap_free_context(ctx); + } } + + vTaskDelete(NULL); } static esp_err_t wifi_event_handler(void *ctx, system_event_t *event) @@ -135,7 +165,6 @@ static esp_err_t wifi_event_handler(void *ctx, system_event_t *event) break; case SYSTEM_EVENT_STA_GOT_IP: xEventGroupSetBits(wifi_event_group, CONNECTED_BIT); - coap_server_init(); break; case SYSTEM_EVENT_STA_DISCONNECTED: /* This is a workaround as ESP32 WiFi libs don't currently @@ -165,7 +194,6 @@ static void wifi_conn_init(void) }; ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) ); ESP_ERROR_CHECK( esp_wifi_set_config(WIFI_IF_STA, &wifi_config) ); - ESP_ERROR_CHECK( esp_wifi_start() ); } @@ -173,4 +201,5 @@ void app_main(void) { nvs_flash_init(); wifi_conn_init(); + xTaskCreate(coap_demo_thread, "coap", 2048, NULL, 5, NULL); } diff --git a/examples/23_coap_client/main/coap_client.h b/examples/23_coap_client/main/coap_client.h deleted file mode 100644 index 50f4ccd16f..0000000000 --- a/examples/23_coap_client/main/coap_client.h +++ /dev/null @@ -1,43 +0,0 @@ -/* CoAP client Example - - This example code is in the Public Domain (or CC0 licensed, at your option.) - - Unless required by applicable law or agreed to in writing, this - software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR - CONDITIONS OF ANY KIND, either express or implied. -*/ - -#ifndef _COAP_CLIENT_H_ -#define _COAP_CLIENT_H_ - -#include - -/* The examples use simple WiFi configuration that you can set via - 'make menuconfig'. - - If you'd rather not, just change the below entries to strings with - the config you want - ie #define EXAMPLE_WIFI_SSID "mywifissid" -*/ -#define EXAMPLE_WIFI_SSID CONFIG_WIFI_SSID -#define EXAMPLE_WIFI_PASS CONFIG_WIFI_PASSWORD - -#define COAP_DEMO_THREAD_NAME "CoAP_demo" -#define COAP_DEMO_THREAD_STACK_WORDS 10240 -#define COAP_DEMO_THREAD_PRORIOTY 8 - -#define COAP_DEFAULT_TIME_SEC 5 -#define COAP_DEFAULT_TIME_USEC 0 - -/* The examples use domain of "californium.eclipse.org",uri "coap://californium.eclipse.org" and port number of 5683 that - you can set via 'make menuconfig'. - - If you'd rather not, just change the below entries to strings with - the config you want - ie #define COAP_DEFAULT_DEMO_ADDR "californium.eclipse.org" - , ie #define COAP_DEFAULT_DEMO_URI "coap://californium.eclipse.org" and ie #define COAP_DEFAULT_PORT 5683 -*/ -#define COAP_DEFAULT_PORT CONFIG_TARGET_PORT_NUMBER -#define COAP_DEFAULT_DEMO_ADDR CONFIG_TARGET_DOMAIN -#define COAP_DEFAULT_DEMO_URI CONFIG_TARGET_DOMAIN_URI - -#endif - From 4491dd0e2a2024e5c3fcc3e877aa459079179d87 Mon Sep 17 00:00:00 2001 From: Wu Jian Gang Date: Fri, 6 Jan 2017 18:42:46 +0800 Subject: [PATCH 2/4] example: fix CI error of coap server demo --- .../24_coap_server/main/Kconfig.projbuild | 7 - examples/24_coap_server/main/coap_server.c | 168 +++++++++--------- examples/24_coap_server/main/coap_server.h | 38 ---- 3 files changed, 85 insertions(+), 128 deletions(-) delete mode 100644 examples/24_coap_server/main/coap_server.h diff --git a/examples/24_coap_server/main/Kconfig.projbuild b/examples/24_coap_server/main/Kconfig.projbuild index 4926bfb200..7a9cb97a0e 100644 --- a/examples/24_coap_server/main/Kconfig.projbuild +++ b/examples/24_coap_server/main/Kconfig.projbuild @@ -1,12 +1,5 @@ menu "Example Configuration" -config LOCAL_PORT_NUMBER - int "Local port number" - range 0 65535 - default 5683 - help - Local port number for the example to use. - config WIFI_SSID string "WiFi SSID" default "myssid" diff --git a/examples/24_coap_server/main/coap_server.c b/examples/24_coap_server/main/coap_server.c index 4e066689bb..75e3296f79 100644 --- a/examples/24_coap_server/main/coap_server.c +++ b/examples/24_coap_server/main/coap_server.c @@ -6,9 +6,9 @@ software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ -#include "coap_server.h" #include +#include #include "freertos/FreeRTOS.h" #include "freertos/task.h" @@ -19,12 +19,20 @@ #include "esp_event_loop.h" #include "nvs_flash.h" -#include -#include "coap_config.h" -#include "resource.h" #include "coap.h" +/* The examples use simple WiFi configuration that you can set via + 'make menuconfig'. + + If you'd rather not, just change the below entries to strings with + the config you want - ie #define EXAMPLE_WIFI_SSID "mywifissid" +*/ +#define EXAMPLE_WIFI_SSID CONFIG_WIFI_SSID +#define EXAMPLE_WIFI_PASS CONFIG_WIFI_PASSWORD + +#define COAP_DEFAULT_TIME_SEC 5 +#define COAP_DEFAULT_TIME_USEC 0 static EventGroupHandle_t wifi_event_group; @@ -33,32 +41,32 @@ static EventGroupHandle_t wifi_event_group; to the AP with an IP? */ const static int CONNECTED_BIT = BIT0; -const static char *TAG = "CoAP_demo"; +const static char *TAG = "CoAP_server"; static coap_async_state_t *async = NULL; static void send_async_response(coap_context_t *ctx, const coap_endpoint_t *local_if) { - coap_pdu_t *response; - unsigned char buf[3]; - const char* response_data = "Hello World!"; - size_t size = sizeof(coap_hdr_t) + 20; - response = coap_pdu_init(async->flags & COAP_MESSAGE_CON, COAP_RESPONSE_CODE(205), 0, size); - response->hdr->id = coap_new_message_id(ctx); - if (async->tokenlen) - coap_add_token(response, async->tokenlen, async->token); - coap_add_option(response, COAP_OPTION_CONTENT_TYPE, coap_encode_var_bytes(buf, COAP_MEDIATYPE_TEXT_PLAIN), buf); - coap_add_data (response, strlen(response_data), (unsigned char *)response_data); + coap_pdu_t *response; + unsigned char buf[3]; + const char* response_data = "Hello World!"; + size_t size = sizeof(coap_hdr_t) + 20; + response = coap_pdu_init(async->flags & COAP_MESSAGE_CON, COAP_RESPONSE_CODE(205), 0, size); + response->hdr->id = coap_new_message_id(ctx); + if (async->tokenlen) + coap_add_token(response, async->tokenlen, async->token); + coap_add_option(response, COAP_OPTION_CONTENT_TYPE, coap_encode_var_bytes(buf, COAP_MEDIATYPE_TEXT_PLAIN), buf); + coap_add_data (response, strlen(response_data), (unsigned char *)response_data); - if (coap_send(ctx, local_if, &async->peer, response) == COAP_INVALID_TID) { + if (coap_send(ctx, local_if, &async->peer, response) == COAP_INVALID_TID) { - } - coap_delete_pdu(response); - coap_async_state_t *tmp; - coap_remove_async(ctx, async->id, &tmp); - coap_free_async(async); - async = NULL; + } + coap_delete_pdu(response); + coap_async_state_t *tmp; + coap_remove_async(ctx, async->id, &tmp); + coap_free_async(async); + async = NULL; } /* @@ -69,76 +77,70 @@ async_handler(coap_context_t *ctx, struct coap_resource_t *resource, const coap_endpoint_t *local_interface, coap_address_t *peer, coap_pdu_t *request, str *token, coap_pdu_t *response) { - async = coap_register_async(ctx, peer, request, COAP_ASYNC_SEPARATE | COAP_ASYNC_CONFIRM, (void*)"no data"); + async = coap_register_async(ctx, peer, request, COAP_ASYNC_SEPARATE | COAP_ASYNC_CONFIRM, (void*)"no data"); } static void coap_demo_thread(void *p) { - coap_context_t* ctx = NULL; - coap_address_t serv_addr; - coap_resource_t* resource = NULL; - fd_set readfds; - struct timeval tv; - int flags = 0; - /* Prepare the CoAP server socket */ - coap_address_init(&serv_addr); - serv_addr.addr.sin.sin_family = AF_INET; - serv_addr.addr.sin.sin_addr.s_addr = INADDR_ANY; - serv_addr.addr.sin.sin_port = htons(COAP_DEFAULT_PORT); - ctx = coap_new_context(&serv_addr); - if (ctx) { - flags = fcntl(ctx->sockfd, F_GETFL, 0); - fcntl(ctx->sockfd, F_SETFL, flags|O_NONBLOCK); + coap_context_t* ctx = NULL; + coap_address_t serv_addr; + coap_resource_t* resource = NULL; + fd_set readfds; + struct timeval tv; + int flags = 0; - tv.tv_usec = COAP_DEFAULT_TIME_USEC; - tv.tv_sec = COAP_DEFAULT_TIME_SEC; - /* Initialize the resource */ - resource = coap_resource_init((unsigned char *)"Espressif", 9, 0); - if (resource){ - coap_register_handler(resource, COAP_REQUEST_GET, async_handler); - coap_add_resource(ctx, resource); - /*For incoming connections*/ - for (;;) { - FD_ZERO(&readfds); - FD_CLR( ctx->sockfd, &readfds); - FD_SET( ctx->sockfd, &readfds); + while (1) { + /* Wait for the callback to set the CONNECTED_BIT in the + event group. + */ + xEventGroupWaitBits(wifi_event_group, CONNECTED_BIT, + false, true, portMAX_DELAY); + ESP_LOGI(TAG, "Connected to AP"); - int result = select( FD_SETSIZE, &readfds, 0, 0, &tv ); - if (result > 0){ - if (FD_ISSET( ctx->sockfd, &readfds )) - coap_read(ctx); - } else if (result < 0){ - break; - } else { - printf("select timeout\n"); - } + /* Prepare the CoAP server socket */ + coap_address_init(&serv_addr); + serv_addr.addr.sin.sin_family = AF_INET; + serv_addr.addr.sin.sin_addr.s_addr = INADDR_ANY; + serv_addr.addr.sin.sin_port = htons(COAP_DEFAULT_PORT); + ctx = coap_new_context(&serv_addr); + if (ctx) { + flags = fcntl(ctx->sockfd, F_GETFL, 0); + fcntl(ctx->sockfd, F_SETFL, flags|O_NONBLOCK); - if (async) - send_async_response(ctx, ctx->endpoint); - } - } + tv.tv_usec = COAP_DEFAULT_TIME_USEC; + tv.tv_sec = COAP_DEFAULT_TIME_SEC; + /* Initialize the resource */ + resource = coap_resource_init((unsigned char *)"Espressif", 9, 0); + if (resource){ + coap_register_handler(resource, COAP_REQUEST_GET, async_handler); + coap_add_resource(ctx, resource); + /*For incoming connections*/ + for (;;) { + FD_ZERO(&readfds); + FD_CLR( ctx->sockfd, &readfds); + FD_SET( ctx->sockfd, &readfds); - coap_free_context(ctx); - } + int result = select( FD_SETSIZE, &readfds, 0, 0, &tv ); + if (result > 0){ + if (FD_ISSET( ctx->sockfd, &readfds )) + coap_read(ctx); + } else if (result < 0){ + break; + } else { + ESP_LOGE(TAG, "select timeout"); + } - vTaskDelete(NULL); -} + if (async) { + send_async_response(ctx, ctx->endpoint); + } + } + } -static void coap_server_init(void) -{ - int ret = pdPASS; - xTaskHandle coap_handle = NULL; - - ret = xTaskCreate(coap_demo_thread, - COAP_DEMO_THREAD_NAME, - COAP_DEMO_THREAD_STACK_WORDS, - NULL, - COAP_DEMO_THREAD_PRORIOTY, - &coap_handle); - - if (ret != pdPASS) { - ESP_LOGI(TAG, "create thread %s failed", COAP_DEMO_THREAD_NAME); + coap_free_context(ctx); + } } + + vTaskDelete(NULL); } static esp_err_t wifi_event_handler(void *ctx, system_event_t *event) @@ -149,7 +151,6 @@ static esp_err_t wifi_event_handler(void *ctx, system_event_t *event) break; case SYSTEM_EVENT_STA_GOT_IP: xEventGroupSetBits(wifi_event_group, CONNECTED_BIT); - coap_server_init(); break; case SYSTEM_EVENT_STA_DISCONNECTED: /* This is a workaround as ESP32 WiFi libs don't currently @@ -179,7 +180,6 @@ static void wifi_conn_init(void) }; ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) ); ESP_ERROR_CHECK( esp_wifi_set_config(WIFI_IF_STA, &wifi_config) ); - ESP_ERROR_CHECK( esp_wifi_start() ); } @@ -187,4 +187,6 @@ void app_main(void) { nvs_flash_init(); wifi_conn_init(); + + xTaskCreate(coap_demo_thread, "coap", 2048, NULL, 5, NULL); } diff --git a/examples/24_coap_server/main/coap_server.h b/examples/24_coap_server/main/coap_server.h deleted file mode 100644 index e9e8728fc3..0000000000 --- a/examples/24_coap_server/main/coap_server.h +++ /dev/null @@ -1,38 +0,0 @@ -/* CoAP server Example - - This example code is in the Public Domain (or CC0 licensed, at your option.) - - Unless required by applicable law or agreed to in writing, this - software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR - CONDITIONS OF ANY KIND, either express or implied. -*/ - -#ifndef _COAP_SERVER_H_ -#define _COAP_SERVER_H_ - -#include - -/* The examples use simple WiFi configuration that you can set via - 'make menuconfig'. - - If you'd rather not, just change the below entries to strings with - the config you want - ie #define EXAMPLE_WIFI_SSID "mywifissid" -*/ -#define EXAMPLE_WIFI_SSID CONFIG_WIFI_SSID -#define EXAMPLE_WIFI_PASS CONFIG_WIFI_PASSWORD - -#define COAP_DEMO_THREAD_NAME "CoAP_demo" -#define COAP_DEMO_THREAD_STACK_WORDS 10240 -#define COAP_DEMO_THREAD_PRORIOTY 8 - -/* The examples use local port number of 5683 that you can set via 'make menuconfig'. - - If you'd rather not, just change the below entries to strings with - the config you want - ie #define OPENSSL_DEMO_TARGET_TCP_PORT 5683 -*/ -#define COAP_DEFAULT_PORT CONFIG_LOCAL_PORT_NUMBER -#define COAP_DEFAULT_TIME_SEC 5 -#define COAP_DEFAULT_TIME_USEC 0 - -#endif - From ed01eb2df16c871ba8e67746953d5602867bc1a0 Mon Sep 17 00:00:00 2001 From: Wu Jian Gang Date: Fri, 6 Jan 2017 18:52:58 +0800 Subject: [PATCH 3/4] example: fix CI error of ota demo --- examples/26_ota/main/ota.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/26_ota/main/ota.c b/examples/26_ota/main/ota.c index 8c8caf2d37..4956129e5d 100644 --- a/examples/26_ota/main/ota.c +++ b/examples/26_ota/main/ota.c @@ -7,6 +7,9 @@ CONDITIONS OF ANY KIND, either express or implied. */ #include +#include +#include + #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "freertos/event_groups.h" @@ -19,11 +22,6 @@ #include "esp_partition.h" #include "nvs_flash.h" -#include "lwip/err.h" -#include "lwip/sockets.h" -#include "lwip/sys.h" -#include "lwip/netdb.h" -#include "lwip/dns.h" #define EXAMPLE_WIFI_SSID CONFIG_WIFI_SSID #define EXAMPLE_WIFI_PASS CONFIG_WIFI_PASSWORD @@ -226,6 +224,10 @@ void __attribute__((noreturn)) task_fatal_error() ESP_LOGE(TAG, "Exiting task due to fatal error..."); close(socket_id); (void)vTaskDelete(NULL); + + while (1) { + ; + } } void main_task(void *pvParameter) From 1b9f477b152c843fe1e6215d5aac3a5966c33674 Mon Sep 17 00:00:00 2001 From: Wu Jian Gang Date: Fri, 6 Jan 2017 21:39:32 +0800 Subject: [PATCH 4/4] example: Reindex ota demo --- examples/{26_ota => 25_ota}/Makefile | 0 examples/{26_ota => 25_ota}/OTA_workflow.png | Bin examples/{26_ota => 25_ota}/README.md | 0 examples/{26_ota => 25_ota}/main/Kconfig.projbuild | 0 examples/{26_ota => 25_ota}/main/component.mk | 0 examples/{26_ota => 25_ota}/main/ota.c | 0 examples/{26_ota => 25_ota}/sdkconfig.defaults | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename examples/{26_ota => 25_ota}/Makefile (100%) rename examples/{26_ota => 25_ota}/OTA_workflow.png (100%) rename examples/{26_ota => 25_ota}/README.md (100%) rename examples/{26_ota => 25_ota}/main/Kconfig.projbuild (100%) rename examples/{26_ota => 25_ota}/main/component.mk (100%) rename examples/{26_ota => 25_ota}/main/ota.c (100%) rename examples/{26_ota => 25_ota}/sdkconfig.defaults (100%) diff --git a/examples/26_ota/Makefile b/examples/25_ota/Makefile similarity index 100% rename from examples/26_ota/Makefile rename to examples/25_ota/Makefile diff --git a/examples/26_ota/OTA_workflow.png b/examples/25_ota/OTA_workflow.png similarity index 100% rename from examples/26_ota/OTA_workflow.png rename to examples/25_ota/OTA_workflow.png diff --git a/examples/26_ota/README.md b/examples/25_ota/README.md similarity index 100% rename from examples/26_ota/README.md rename to examples/25_ota/README.md diff --git a/examples/26_ota/main/Kconfig.projbuild b/examples/25_ota/main/Kconfig.projbuild similarity index 100% rename from examples/26_ota/main/Kconfig.projbuild rename to examples/25_ota/main/Kconfig.projbuild diff --git a/examples/26_ota/main/component.mk b/examples/25_ota/main/component.mk similarity index 100% rename from examples/26_ota/main/component.mk rename to examples/25_ota/main/component.mk diff --git a/examples/26_ota/main/ota.c b/examples/25_ota/main/ota.c similarity index 100% rename from examples/26_ota/main/ota.c rename to examples/25_ota/main/ota.c diff --git a/examples/26_ota/sdkconfig.defaults b/examples/25_ota/sdkconfig.defaults similarity index 100% rename from examples/26_ota/sdkconfig.defaults rename to examples/25_ota/sdkconfig.defaults