From d7b8b36082cd051985b5a05b52c61fe19763f5f6 Mon Sep 17 00:00:00 2001 From: Bogdan Kolendovskyy Date: Thu, 15 Dec 2022 16:15:39 +0100 Subject: [PATCH 1/3] examples: fix format errors, remove -Wno-format Logging in series of examples has misuse of "%d" instead of type-appropriate format specifiers. Fix by changing "%d" to PRIxx macros corresponding to type. Remove -Wno-format compile flag in those examples that are affected. --- .../common_components/iperf/CMakeLists.txt | 2 -- examples/common_components/iperf/iperf.c | 18 ++++++++++++------ examples/ethernet/iperf/main/CMakeLists.txt | 1 - examples/ethernet/iperf/main/cmd_ethernet.c | 10 +++++++--- .../network/simple_sniffer/main/CMakeLists.txt | 1 - .../network/simple_sniffer/main/cmd_sniffer.c | 2 +- .../protocols/icmp_echo/main/CMakeLists.txt | 1 - .../icmp_echo/main/echo_example_main.c | 4 ++-- .../protocols/mqtt/ssl/main/CMakeLists.txt | 1 - examples/protocols/mqtt/ssl/main/app_main.c | 6 +++--- .../protocols/mqtt/ssl_ds/main/CMakeLists.txt | 4 ++-- examples/protocols/mqtt/ssl_ds/main/app_main.c | 6 +++--- .../mqtt/ssl_mutual_auth/main/CMakeLists.txt | 1 - .../mqtt/ssl_mutual_auth/main/app_main.c | 6 +++--- .../protocols/mqtt/ssl_psk/main/CMakeLists.txt | 1 - .../protocols/mqtt/ssl_psk/main/app_main.c | 6 +++--- .../protocols/mqtt/tcp/main/CMakeLists.txt | 1 - examples/protocols/mqtt/tcp/main/app_main.c | 4 ++-- examples/protocols/mqtt/ws/main/CMakeLists.txt | 1 - examples/protocols/mqtt/ws/main/app_main.c | 4 ++-- .../protocols/mqtt/wss/main/CMakeLists.txt | 1 - examples/protocols/mqtt/wss/main/app_main.c | 6 +++--- examples/protocols/mqtt5/main/CMakeLists.txt | 1 - examples/protocols/mqtt5/main/app_main.c | 9 +++++---- 24 files changed, 48 insertions(+), 49 deletions(-) diff --git a/examples/common_components/iperf/CMakeLists.txt b/examples/common_components/iperf/CMakeLists.txt index 3662ec032a..85a30c1257 100644 --- a/examples/common_components/iperf/CMakeLists.txt +++ b/examples/common_components/iperf/CMakeLists.txt @@ -6,8 +6,6 @@ idf_component_register(SRCS "iperf.c" REQUIRES lwip PRIV_REQUIRES esp_timer) -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") - if(CONFIG_SOC_WIFI_HE_SUPPORT) idf_component_optional_requires(PRIVATE esp_wifi console) endif() diff --git a/examples/common_components/iperf/iperf.c b/examples/common_components/iperf/iperf.c index d2adf83276..ced73a1f02 100644 --- a/examples/common_components/iperf/iperf.c +++ b/examples/common_components/iperf/iperf.c @@ -1,7 +1,7 @@ /* Iperf Example - iperf implementation 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. @@ -11,6 +11,7 @@ #include #include #include +#include #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "esp_check.h" @@ -86,14 +87,14 @@ static void iperf_report_task(void *arg) while (!s_iperf_ctrl.finish) { vTaskDelay(delay_interval); actual_bandwidth = (s_iperf_ctrl.actual_len / coefficient[format] * 8) / interval; - printf("%4d-%4d sec %.2f %cbits/sec\n", cur, cur + interval, + printf("%4" PRIi32 "-%4" PRIi32 " sec %.2f %cbits/sec\n", cur, cur + interval, actual_bandwidth, unit[format]); cur += interval; average = ((average * (k - 1) / k) + (actual_bandwidth / k)); k++; s_iperf_ctrl.actual_len = 0; if (cur >= time) { - printf("%4d-%4d sec %.2f %cbits/sec\n", 0, time, + printf("%4d-%4" PRIu32 " sec %.2f %cbits/sec\n", 0, time, average, unit[format]); break; } @@ -395,7 +396,7 @@ static esp_err_t IRAM_ATTR iperf_run_udp_server(void) err = bind(listen_socket, (struct sockaddr *)&listen_addr6, sizeof(struct sockaddr_in6)); ESP_GOTO_ON_FALSE((err == 0), ESP_FAIL, exit, TAG, "Socket unable to bind: errno %d", errno); - ESP_LOGI(TAG, "Socket bound, port %d", listen_addr6.sin6_port); + ESP_LOGI(TAG, "Socket bound, port %" PRIu16, listen_addr6.sin6_port); memcpy(&listen_addr, &listen_addr6, sizeof(listen_addr6)); } else if (s_iperf_ctrl.cfg.type == IPERF_IP_TYPE_IPV4) { @@ -452,7 +453,7 @@ static esp_err_t iperf_run_udp_client(void) client_socket = socket(AF_INET6, SOCK_DGRAM, IPPROTO_IPV6); ESP_GOTO_ON_FALSE((client_socket >= 0), ESP_FAIL, exit, TAG, "Unable to create socket: errno %d", errno); - ESP_LOGI(TAG, "Socket created, sending to %s:%d", s_iperf_ctrl.cfg.destination_ip6, s_iperf_ctrl.cfg.dport); + ESP_LOGI(TAG, "Socket created, sending to %s:%" PRIu16, s_iperf_ctrl.cfg.destination_ip6, s_iperf_ctrl.cfg.dport); setsockopt(client_socket, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)); memcpy(&dest_addr, &dest_addr6, sizeof(dest_addr6)); @@ -463,7 +464,12 @@ static esp_err_t iperf_run_udp_client(void) client_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); ESP_GOTO_ON_FALSE((client_socket >= 0), ESP_FAIL, exit, TAG, "Unable to create socket: errno %d", errno); - ESP_LOGI(TAG, "Socket created, sending to %d:%d", s_iperf_ctrl.cfg.destination_ip4, s_iperf_ctrl.cfg.dport); + ESP_LOGI(TAG, "Socket created, sending to %d.%d.%d.%d:%" PRIu16, + (uint16_t) s_iperf_ctrl.cfg.destination_ip4 & 0xFF, + (uint16_t) (s_iperf_ctrl.cfg.destination_ip4 >> 8) & 0xFF, + (uint16_t) (s_iperf_ctrl.cfg.destination_ip4 >> 16) & 0xFF, + (uint16_t) (s_iperf_ctrl.cfg.destination_ip4 >> 24) & 0xFF, + s_iperf_ctrl.cfg.dport); setsockopt(client_socket, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)); memcpy(&dest_addr, &dest_addr4, sizeof(dest_addr4)); diff --git a/examples/ethernet/iperf/main/CMakeLists.txt b/examples/ethernet/iperf/main/CMakeLists.txt index 0efe55ab10..fc8e5dd8bb 100644 --- a/examples/ethernet/iperf/main/CMakeLists.txt +++ b/examples/ethernet/iperf/main/CMakeLists.txt @@ -1,4 +1,3 @@ idf_component_register(SRCS "cmd_ethernet.c" "ethernet_example_main.c" INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/examples/ethernet/iperf/main/cmd_ethernet.c b/examples/ethernet/iperf/main/cmd_ethernet.c index 0a7754feea..cb4158af02 100644 --- a/examples/ethernet/iperf/main/cmd_ethernet.c +++ b/examples/ethernet/iperf/main/cmd_ethernet.c @@ -8,6 +8,7 @@ */ #include #include +#include #include "freertos/FreeRTOS.h" #include "freertos/event_groups.h" #include "sys/socket.h" // for INADDR_ANY @@ -175,11 +176,14 @@ static int eth_cmd_iperf(int argc, char **argv) } } - printf("mode=%s-%s sip=%d.%d.%d.%d:%d, dip=%d.%d.%d.%d:%d, interval=%d, time=%d\r\n", + printf("mode=%s-%s sip=" IPSTR ":%" PRIu16 ", dip=%" PRIu32 ".%" PRIu32 ".%" PRIu32 ".%" PRIu32 ":%" PRIu16 ", interval=%" PRIu32 ", time=%" PRIu32 "\r\n", cfg.flag & IPERF_FLAG_TCP ? "tcp" : "udp", cfg.flag & IPERF_FLAG_SERVER ? "server" : "client", - cfg.source_ip4 & 0xFF, (cfg.source_ip4 >> 8) & 0xFF, (cfg.source_ip4 >> 16) & 0xFF, - (cfg.source_ip4 >> 24) & 0xFF, cfg.sport, + (uint16_t) cfg.source_ip4 & 0xFF, + (uint16_t) (cfg.source_ip4 >> 8) & 0xFF, + (uint16_t) (cfg.source_ip4 >> 16) & 0xFF, + (uint16_t) (cfg.source_ip4 >> 24) & 0xFF, + cfg.sport, cfg.destination_ip4 & 0xFF, (cfg.destination_ip4 >> 8) & 0xFF, (cfg.destination_ip4 >> 16) & 0xFF, (cfg.destination_ip4 >> 24) & 0xFF, cfg.dport, cfg.interval, cfg.time); diff --git a/examples/network/simple_sniffer/main/CMakeLists.txt b/examples/network/simple_sniffer/main/CMakeLists.txt index 485037a752..5d4205471d 100644 --- a/examples/network/simple_sniffer/main/CMakeLists.txt +++ b/examples/network/simple_sniffer/main/CMakeLists.txt @@ -2,4 +2,3 @@ idf_component_register(SRCS "simple_sniffer_example_main.c" "cmd_sniffer.c" "cmd_pcap.c" INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/examples/network/simple_sniffer/main/cmd_sniffer.c b/examples/network/simple_sniffer/main/cmd_sniffer.c index 31b1aad800..aae307df62 100644 --- a/examples/network/simple_sniffer/main/cmd_sniffer.c +++ b/examples/network/simple_sniffer/main/cmd_sniffer.c @@ -430,7 +430,7 @@ static int do_sniffer_cmd(int argc, char **argv) snf_rt.packets_to_sniff = -1; if (sniffer_args.number->count) { snf_rt.packets_to_sniff = sniffer_args.number->ival[0]; - ESP_LOGI(SNIFFER_TAG, "%d packages will be captured", snf_rt.packets_to_sniff); + ESP_LOGI(SNIFFER_TAG, "%" PRIi32 " packages will be captured", snf_rt.packets_to_sniff); } /* start sniffer */ diff --git a/examples/protocols/icmp_echo/main/CMakeLists.txt b/examples/protocols/icmp_echo/main/CMakeLists.txt index 7797d714dd..30b73c7688 100644 --- a/examples/protocols/icmp_echo/main/CMakeLists.txt +++ b/examples/protocols/icmp_echo/main/CMakeLists.txt @@ -1,3 +1,2 @@ idf_component_register(SRCS "echo_example_main.c" INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/examples/protocols/icmp_echo/main/echo_example_main.c b/examples/protocols/icmp_echo/main/echo_example_main.c index ce7955b7fd..18a3b148b8 100644 --- a/examples/protocols/icmp_echo/main/echo_example_main.c +++ b/examples/protocols/icmp_echo/main/echo_example_main.c @@ -31,7 +31,7 @@ static void cmd_ping_on_ping_success(esp_ping_handle_t hdl, void *args) esp_ping_get_profile(hdl, ESP_PING_PROF_IPADDR, &target_addr, sizeof(target_addr)); esp_ping_get_profile(hdl, ESP_PING_PROF_SIZE, &recv_len, sizeof(recv_len)); esp_ping_get_profile(hdl, ESP_PING_PROF_TIMEGAP, &elapsed_time, sizeof(elapsed_time)); - printf("%d bytes from %s icmp_seq=%d ttl=%d time=%d ms\n", + printf("%" PRIu32 " bytes from %s icmp_seq=%" PRIu16 " ttl=%" PRIu16 " time=%" PRIu32 " ms\n", recv_len, ipaddr_ntoa((ip_addr_t*)&target_addr), seqno, ttl, elapsed_time); } @@ -60,7 +60,7 @@ static void cmd_ping_on_ping_end(esp_ping_handle_t hdl, void *args) } else { printf("\n--- %s ping statistics ---\n", inet6_ntoa(*ip_2_ip6(&target_addr))); } - printf("%d packets transmitted, %d received, %d%% packet loss, time %dms\n", + printf("%" PRIu32 " packets transmitted, %" PRIu32 " received, %" PRIu32 "%% packet loss, time %" PRIu32 "ms\n", transmitted, received, loss, total_time_ms); // delete the ping sessions, so that we clean up all resources and can create a new ping session // we don't have to call delete function in the callback, instead we can call delete function from other tasks diff --git a/examples/protocols/mqtt/ssl/main/CMakeLists.txt b/examples/protocols/mqtt/ssl/main/CMakeLists.txt index c31750a8f7..61fac40e63 100644 --- a/examples/protocols/mqtt/ssl/main/CMakeLists.txt +++ b/examples/protocols/mqtt/ssl/main/CMakeLists.txt @@ -1,3 +1,2 @@ idf_component_register(SRCS "app_main.c" INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/examples/protocols/mqtt/ssl/main/app_main.c b/examples/protocols/mqtt/ssl/main/app_main.c index acfcb3f745..570bdd3fec 100644 --- a/examples/protocols/mqtt/ssl/main/app_main.c +++ b/examples/protocols/mqtt/ssl/main/app_main.c @@ -62,7 +62,7 @@ static void send_binary(esp_mqtt_client_handle_t client) */ static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data) { - ESP_LOGD(TAG, "Event dispatched from event loop base=%s, event_id=%d", base, event_id); + ESP_LOGD(TAG, "Event dispatched from event loop base=%s, event_id=%" PRIi32, base, event_id); esp_mqtt_event_handle_t event = event_data; esp_mqtt_client_handle_t client = event->client; int msg_id; @@ -130,7 +130,7 @@ static void mqtt_app_start(void) }, }; - ESP_LOGI(TAG, "[APP] Free memory: %d bytes", esp_get_free_heap_size()); + ESP_LOGI(TAG, "[APP] Free memory: %" PRIu32 " bytes", esp_get_free_heap_size()); esp_mqtt_client_handle_t client = esp_mqtt_client_init(&mqtt_cfg); /* The last argument may be used to pass data to the event handler, in this example mqtt_event_handler */ esp_mqtt_client_register_event(client, ESP_EVENT_ANY_ID, mqtt_event_handler, NULL); @@ -140,7 +140,7 @@ static void mqtt_app_start(void) void app_main(void) { ESP_LOGI(TAG, "[APP] Startup.."); - ESP_LOGI(TAG, "[APP] Free memory: %d bytes", esp_get_free_heap_size()); + ESP_LOGI(TAG, "[APP] Free memory: %" PRIu32 " bytes", esp_get_free_heap_size()); ESP_LOGI(TAG, "[APP] IDF version: %s", esp_get_idf_version()); esp_log_level_set("*", ESP_LOG_INFO); diff --git a/examples/protocols/mqtt/ssl_ds/main/CMakeLists.txt b/examples/protocols/mqtt/ssl_ds/main/CMakeLists.txt index c31750a8f7..b8ef6eadbd 100644 --- a/examples/protocols/mqtt/ssl_ds/main/CMakeLists.txt +++ b/examples/protocols/mqtt/ssl_ds/main/CMakeLists.txt @@ -1,3 +1,3 @@ idf_component_register(SRCS "app_main.c" - INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") + INCLUDE_DIRS "." + REQUIRED_IDF_TARGETS esp32s2 esp32c3 esp32s3) diff --git a/examples/protocols/mqtt/ssl_ds/main/app_main.c b/examples/protocols/mqtt/ssl_ds/main/app_main.c index 709143c6c3..160392a4e4 100644 --- a/examples/protocols/mqtt/ssl_ds/main/app_main.c +++ b/examples/protocols/mqtt/ssl_ds/main/app_main.c @@ -47,7 +47,7 @@ extern const uint8_t server_cert_pem_end[] asm("_binary_mosquitto_org_crt_end"); */ static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data) { - ESP_LOGD(TAG, "Event dispatched from event loop base=%s, event_id=%d", base, event_id); + ESP_LOGD(TAG, "Event dispatched from event loop base=%s, event_id=%" PRIi32, base, event_id); esp_mqtt_event_handle_t event = event_data; esp_mqtt_client_handle_t client = event->client; int msg_id; @@ -124,7 +124,7 @@ static void mqtt_app_start(void) }, }; - ESP_LOGI(TAG, "[APP] Free memory: %d bytes", esp_get_free_heap_size()); + ESP_LOGI(TAG, "[APP] Free memory: %" PRIu32 " bytes", esp_get_free_heap_size()); esp_mqtt_client_handle_t client = esp_mqtt_client_init(&mqtt_cfg); esp_mqtt_client_register_event(client, ESP_EVENT_ANY_ID, mqtt_event_handler, NULL); esp_mqtt_client_start(client); @@ -133,7 +133,7 @@ static void mqtt_app_start(void) void app_main(void) { ESP_LOGI(TAG, "[APP] Startup.."); - ESP_LOGI(TAG, "[APP] Free memory: %d bytes", esp_get_free_heap_size()); + ESP_LOGI(TAG, "[APP] Free memory: %" PRIu32 " bytes", esp_get_free_heap_size()); ESP_LOGI(TAG, "[APP] IDF version: %s", esp_get_idf_version()); esp_log_level_set("*", ESP_LOG_INFO); diff --git a/examples/protocols/mqtt/ssl_mutual_auth/main/CMakeLists.txt b/examples/protocols/mqtt/ssl_mutual_auth/main/CMakeLists.txt index c31750a8f7..61fac40e63 100644 --- a/examples/protocols/mqtt/ssl_mutual_auth/main/CMakeLists.txt +++ b/examples/protocols/mqtt/ssl_mutual_auth/main/CMakeLists.txt @@ -1,3 +1,2 @@ idf_component_register(SRCS "app_main.c" INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/examples/protocols/mqtt/ssl_mutual_auth/main/app_main.c b/examples/protocols/mqtt/ssl_mutual_auth/main/app_main.c index 76cc45563a..9798cb9b49 100644 --- a/examples/protocols/mqtt/ssl_mutual_auth/main/app_main.c +++ b/examples/protocols/mqtt/ssl_mutual_auth/main/app_main.c @@ -57,7 +57,7 @@ static void log_error_if_nonzero(const char *message, int error_code) */ static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data) { - ESP_LOGD(TAG, "Event dispatched from event loop base=%s, event_id=%d", base, event_id); + ESP_LOGD(TAG, "Event dispatched from event loop base=%s, event_id=%" PRIi32, base, event_id); esp_mqtt_event_handle_t event = event_data; esp_mqtt_client_handle_t client = event->client; int msg_id; @@ -122,7 +122,7 @@ static void mqtt_app_start(void) } }; - ESP_LOGI(TAG, "[APP] Free memory: %d bytes", esp_get_free_heap_size()); + ESP_LOGI(TAG, "[APP] Free memory: %" PRIu32 " bytes", esp_get_free_heap_size()); esp_mqtt_client_handle_t client = esp_mqtt_client_init(&mqtt_cfg); /* The last argument may be used to pass data to the event handler, in this example mqtt_event_handler */ esp_mqtt_client_register_event(client, ESP_EVENT_ANY_ID, mqtt_event_handler, NULL); @@ -132,7 +132,7 @@ static void mqtt_app_start(void) void app_main(void) { ESP_LOGI(TAG, "[APP] Startup.."); - ESP_LOGI(TAG, "[APP] Free memory: %d bytes", esp_get_free_heap_size()); + ESP_LOGI(TAG, "[APP] Free memory: %" PRIu32 " bytes", esp_get_free_heap_size()); ESP_LOGI(TAG, "[APP] IDF version: %s", esp_get_idf_version()); esp_log_level_set("*", ESP_LOG_INFO); diff --git a/examples/protocols/mqtt/ssl_psk/main/CMakeLists.txt b/examples/protocols/mqtt/ssl_psk/main/CMakeLists.txt index c31750a8f7..61fac40e63 100644 --- a/examples/protocols/mqtt/ssl_psk/main/CMakeLists.txt +++ b/examples/protocols/mqtt/ssl_psk/main/CMakeLists.txt @@ -1,3 +1,2 @@ idf_component_register(SRCS "app_main.c" INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/examples/protocols/mqtt/ssl_psk/main/app_main.c b/examples/protocols/mqtt/ssl_psk/main/app_main.c index f024e1382a..67df8639b2 100644 --- a/examples/protocols/mqtt/ssl_psk/main/app_main.c +++ b/examples/protocols/mqtt/ssl_psk/main/app_main.c @@ -64,7 +64,7 @@ static const psk_hint_key_t psk_hint_key = { */ static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data) { - ESP_LOGD(TAG, "Event dispatched from event loop base=%s, event_id=%d", base, event_id); + ESP_LOGD(TAG, "Event dispatched from event loop base=%s, event_id=%" PRIi32 "", base, event_id); esp_mqtt_event_handle_t event = event_data; esp_mqtt_client_handle_t client = event->client; int msg_id; @@ -117,7 +117,7 @@ static void mqtt_app_start(void) .broker.verification.psk_hint_key = &psk_hint_key, }; - ESP_LOGI(TAG, "[APP] Free memory: %d bytes", esp_get_free_heap_size()); + ESP_LOGI(TAG, "[APP] Free memory: %" PRIu32 " bytes", esp_get_free_heap_size()); esp_mqtt_client_handle_t client = esp_mqtt_client_init(&mqtt_cfg); /* The last argument may be used to pass data to the event handler, in this example mqtt_event_handler */ esp_mqtt_client_register_event(client, ESP_EVENT_ANY_ID, mqtt_event_handler, NULL); @@ -127,7 +127,7 @@ static void mqtt_app_start(void) void app_main(void) { ESP_LOGI(TAG, "[APP] Startup.."); - ESP_LOGI(TAG, "[APP] Free memory: %d bytes", esp_get_free_heap_size()); + ESP_LOGI(TAG, "[APP] Free memory: %" PRIu32 " bytes", esp_get_free_heap_size()); ESP_LOGI(TAG, "[APP] IDF version: %s", esp_get_idf_version()); esp_log_level_set("*", ESP_LOG_INFO); diff --git a/examples/protocols/mqtt/tcp/main/CMakeLists.txt b/examples/protocols/mqtt/tcp/main/CMakeLists.txt index c31750a8f7..61fac40e63 100644 --- a/examples/protocols/mqtt/tcp/main/CMakeLists.txt +++ b/examples/protocols/mqtt/tcp/main/CMakeLists.txt @@ -1,3 +1,2 @@ idf_component_register(SRCS "app_main.c" INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/examples/protocols/mqtt/tcp/main/app_main.c b/examples/protocols/mqtt/tcp/main/app_main.c index f40581296b..06ff1ad43e 100644 --- a/examples/protocols/mqtt/tcp/main/app_main.c +++ b/examples/protocols/mqtt/tcp/main/app_main.c @@ -52,7 +52,7 @@ static void log_error_if_nonzero(const char *message, int error_code) */ static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data) { - ESP_LOGD(TAG, "Event dispatched from event loop base=%s, event_id=%d", base, event_id); + ESP_LOGD(TAG, "Event dispatched from event loop base=%s, event_id=%" PRIi32 "", base, event_id); esp_mqtt_event_handle_t event = event_data; esp_mqtt_client_handle_t client = event->client; int msg_id; @@ -146,7 +146,7 @@ static void mqtt_app_start(void) void app_main(void) { ESP_LOGI(TAG, "[APP] Startup.."); - ESP_LOGI(TAG, "[APP] Free memory: %d bytes", esp_get_free_heap_size()); + ESP_LOGI(TAG, "[APP] Free memory: %" PRIu32 " bytes", esp_get_free_heap_size()); ESP_LOGI(TAG, "[APP] IDF version: %s", esp_get_idf_version()); esp_log_level_set("*", ESP_LOG_INFO); diff --git a/examples/protocols/mqtt/ws/main/CMakeLists.txt b/examples/protocols/mqtt/ws/main/CMakeLists.txt index c31750a8f7..61fac40e63 100644 --- a/examples/protocols/mqtt/ws/main/CMakeLists.txt +++ b/examples/protocols/mqtt/ws/main/CMakeLists.txt @@ -1,3 +1,2 @@ idf_component_register(SRCS "app_main.c" INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/examples/protocols/mqtt/ws/main/app_main.c b/examples/protocols/mqtt/ws/main/app_main.c index 247f305184..59f09cf4e0 100644 --- a/examples/protocols/mqtt/ws/main/app_main.c +++ b/examples/protocols/mqtt/ws/main/app_main.c @@ -50,7 +50,7 @@ static void log_error_if_nonzero(const char *message, int error_code) */ static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data) { - ESP_LOGD(TAG, "Event dispatched from event loop base=%s, event_id=%d", base, event_id); + ESP_LOGD(TAG, "Event dispatched from event loop base=%s, event_id=%" PRIi32, base, event_id); esp_mqtt_event_handle_t event = event_data; esp_mqtt_client_handle_t client = event->client; int msg_id; @@ -119,7 +119,7 @@ static void mqtt_app_start(void) void app_main(void) { ESP_LOGI(TAG, "[APP] Startup.."); - ESP_LOGI(TAG, "[APP] Free memory: %d bytes", esp_get_free_heap_size()); + ESP_LOGI(TAG, "[APP] Free memory: %" PRIu32 " bytes", esp_get_free_heap_size()); ESP_LOGI(TAG, "[APP] IDF version: %s", esp_get_idf_version()); esp_log_level_set("*", ESP_LOG_INFO); diff --git a/examples/protocols/mqtt/wss/main/CMakeLists.txt b/examples/protocols/mqtt/wss/main/CMakeLists.txt index c31750a8f7..61fac40e63 100644 --- a/examples/protocols/mqtt/wss/main/CMakeLists.txt +++ b/examples/protocols/mqtt/wss/main/CMakeLists.txt @@ -1,3 +1,2 @@ idf_component_register(SRCS "app_main.c" INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/examples/protocols/mqtt/wss/main/app_main.c b/examples/protocols/mqtt/wss/main/app_main.c index 0e570b11be..f91305180e 100644 --- a/examples/protocols/mqtt/wss/main/app_main.c +++ b/examples/protocols/mqtt/wss/main/app_main.c @@ -89,7 +89,7 @@ static esp_err_t mqtt_event_handler_cb(esp_mqtt_event_handle_t event) static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data) { /* The argument passed to esp_mqtt_client_register_event can de accessed as handler_args*/ - ESP_LOGD(TAG, "Event dispatched from event loop base=%s, event_id=%d", base, event_id); + ESP_LOGD(TAG, "Event dispatched from event loop base=%s, event_id=%" PRIi32, base, event_id); mqtt_event_handler_cb(event_data); } @@ -100,7 +100,7 @@ static void mqtt_app_start(void) .broker.verification.certificate = (const char *)mqtt_eclipseprojects_io_pem_start, }; - ESP_LOGI(TAG, "[APP] Free memory: %d bytes", esp_get_free_heap_size()); + ESP_LOGI(TAG, "[APP] Free memory: %" PRIu32 " bytes", esp_get_free_heap_size()); esp_mqtt_client_handle_t client = esp_mqtt_client_init(&mqtt_cfg); /* The last argument may be used to pass data to the event handler, in this example mqtt_event_handler */ esp_mqtt_client_register_event(client, ESP_EVENT_ANY_ID, mqtt_event_handler, NULL); @@ -111,7 +111,7 @@ static void mqtt_app_start(void) void app_main(void) { ESP_LOGI(TAG, "[APP] Startup.."); - ESP_LOGI(TAG, "[APP] Free memory: %d bytes", esp_get_free_heap_size()); + ESP_LOGI(TAG, "[APP] Free memory: %" PRIu32 " bytes", esp_get_free_heap_size()); ESP_LOGI(TAG, "[APP] IDF version: %s", esp_get_idf_version()); esp_log_level_set("*", ESP_LOG_INFO); diff --git a/examples/protocols/mqtt5/main/CMakeLists.txt b/examples/protocols/mqtt5/main/CMakeLists.txt index c31750a8f7..61fac40e63 100644 --- a/examples/protocols/mqtt5/main/CMakeLists.txt +++ b/examples/protocols/mqtt5/main/CMakeLists.txt @@ -1,3 +1,2 @@ idf_component_register(SRCS "app_main.c" INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/examples/protocols/mqtt5/main/app_main.c b/examples/protocols/mqtt5/main/app_main.c index a0f7ee8a0b..461ca4c2d7 100644 --- a/examples/protocols/mqtt5/main/app_main.c +++ b/examples/protocols/mqtt5/main/app_main.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -99,12 +99,12 @@ static void print_user_property(mqtt5_user_property_handle_t user_property) */ static void mqtt5_event_handler(void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data) { - ESP_LOGD(TAG, "Event dispatched from event loop base=%s, event_id=%d", base, event_id); + ESP_LOGD(TAG, "Event dispatched from event loop base=%s, event_id=%" PRIi32, base, event_id); esp_mqtt_event_handle_t event = event_data; esp_mqtt_client_handle_t client = event->client; int msg_id; - ESP_LOGD(TAG, "free heap size is %d, maxminu %d", esp_get_free_heap_size(), esp_get_minimum_free_heap_size()); + ESP_LOGD(TAG, "free heap size is %" PRIu32 ", minimum %" PRIu32, esp_get_free_heap_size(), esp_get_minimum_free_heap_size()); switch ((esp_mqtt_event_id_t)event_id) { case MQTT_EVENT_CONNECTED: ESP_LOGI(TAG, "MQTT_EVENT_CONNECTED"); @@ -263,8 +263,9 @@ static void mqtt5_app_start(void) void app_main(void) { + ESP_LOGI(TAG, "[APP] Startup.."); - ESP_LOGI(TAG, "[APP] Free memory: %d bytes", esp_get_free_heap_size()); + ESP_LOGI(TAG, "[APP] Free memory: %" PRIu32 " bytes", esp_get_free_heap_size()); ESP_LOGI(TAG, "[APP] IDF version: %s", esp_get_idf_version()); esp_log_level_set("*", ESP_LOG_INFO); From 133d0ea784d77ec30953db6f969ba0432fd24b8a Mon Sep 17 00:00:00 2001 From: Bogdan Kolendovskyy Date: Fri, 10 Mar 2023 14:28:26 +0100 Subject: [PATCH 2/3] examples: common_components/iperf esp32c6 wifi code formatting fix --- examples/common_components/iperf/wifi_cmd.c | 50 +++++------ examples/common_components/iperf/wifi_stats.c | 84 +++++++++---------- 2 files changed, 64 insertions(+), 70 deletions(-) diff --git a/examples/common_components/iperf/wifi_cmd.c b/examples/common_components/iperf/wifi_cmd.c index 1f1466c336..ecaff9000a 100644 --- a/examples/common_components/iperf/wifi_cmd.c +++ b/examples/common_components/iperf/wifi_cmd.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -35,6 +35,11 @@ * (1) esp_wifi_enable_rx_statistics(true, true); * (2) esp_wifi_enable_tx_statistics(ESP_WIFI_ACI_BE, true); */ +#define VAR2IPSTR(var) (uint16_t) var & 0xFF, \ + (uint16_t) (var >> 8) & 0xFF, \ + (uint16_t) (var >> 16) & 0xFF, \ + (uint16_t) (var >> 24) & 0xFF + /******************************************************* * Constants @@ -258,12 +263,12 @@ static int wifi_cmd_reg_rw(int argc, char **argv) } if (reg_rw_args.read->count) { addr = (uint32_t) reg_rw_args.read->dval[0]; - ESP_LOGW(TAG, "reg read 0x%08x : 0x%08x\n", addr, REG_READ(addr)); + ESP_LOGW(TAG, "reg read 0x%08lx : 0x%08lx\n", addr, REG_READ(addr)); } else if (reg_rw_args.write->count && (uint32_t) reg_rw_args.value->count) { addr = (uint32_t) reg_rw_args.write->dval[0]; - ESP_LOGW(TAG, "reg write 0x%8x : 0x%8x\n", addr, (uint32_t) reg_rw_args.value->dval[0]); + ESP_LOGW(TAG, "reg write 0x%8lx : 0x%8lx\n", addr, (uint32_t) reg_rw_args.value->dval[0]); REG_WRITE(addr, (uint32_t ) reg_rw_args.value->dval[0]); - ESP_LOGW(TAG, "reg read 0x%08x : 0x%08x\n", addr, REG_READ(addr)); + ESP_LOGW(TAG, "reg read 0x%08lx : 0x%08lx\n", addr, REG_READ(addr)); } else { printf("Input Error\n"); } @@ -360,7 +365,7 @@ static void cmd_ping_on_ping_success(esp_ping_handle_t hdl, void *args) esp_ping_get_profile(hdl, ESP_PING_PROF_IPADDR, &target_addr, sizeof(target_addr)); esp_ping_get_profile(hdl, ESP_PING_PROF_SIZE, &recv_len, sizeof(recv_len)); esp_ping_get_profile(hdl, ESP_PING_PROF_TIMEGAP, &elapsed_time, sizeof(elapsed_time)); - printf("%d bytes from %s icmp_seq=%d ttl=%d time=%d ms\n", + printf("%" PRIu32 " bytes from %s icmp_seq=%d ttl=%d time=%" PRIu32 " ms\n", recv_len, inet_ntoa(target_addr.u_addr.ip4), seqno, ttl, elapsed_time); } @@ -389,7 +394,7 @@ static void cmd_ping_on_ping_end(esp_ping_handle_t hdl, void *args) } else { printf("\n--- %s ping statistics ---\n", inet6_ntoa(*ip_2_ip6(&target_addr))); } - printf("%d packets transmitted, %d received, %d%% packet loss, time %dms\n", + printf("%" PRIu32 " packets transmitted, %" PRIu32 " received, %" PRIu32 "%% packet loss, time %" PRIu32 "ms\n", transmitted, received, loss, total_time_ms); // delete the ping sessions, so that we clean up all resources and can create a new ping session // we don't have to call delete function in the callback, instead we can call delete function from other tasks @@ -512,10 +517,8 @@ static int wifi_cmd_set_ip(int argc, char **argv) /* set static IP settings */ esp_netif_set_static_ip(netif_sta, ip, gw, netmask); - ESP_LOGD(TAG, "ip:%d.%d.%d.%d, gateway:%d.%d.%d.%d, netmask:%d.%d.%d.%d,", ip & 0xFF, - (ip >> 8) & 0xFF, (ip >> 16) & 0xFF, (ip >> 24) & 0xFF, gw & 0xFF, (gw >> 8) & 0xFF, - (gw >> 16) & 0xFF, (gw >> 24) & 0xFF, netmask & 0xFF, (netmask >> 8) & 0xFF, - (netmask >> 16) & 0xFF, (netmask >> 24) & 0xFF); + ESP_LOGD(TAG, "ip:%d.%d.%d.%d, gateway:%d.%d.%d.%d, netmask:%d.%d.%d.%d,", + VAR2IPSTR(ip), VAR2IPSTR(gw), VAR2IPSTR(netmask)); return 0; } @@ -570,13 +573,9 @@ static int wifi_cmd_query(int argc, char **argv) printf("\tap mac: "MACSTR, MAC2STR(mac)); printf("\n"); } - printf("\tip: %d.%d.%d.%d\n", ip_info.ip.addr & 0xFF, (ip_info.ip.addr >> 8) & 0xFF, - (ip_info.ip.addr >> 16) & 0xFF, (ip_info.ip.addr >> 24) & 0xFF); - printf("\tnetmask: %d.%d.%d.%d\n", ip_info.netmask.addr & 0xFF, - (ip_info.netmask.addr >> 8) & 0xFF, (ip_info.netmask.addr >> 16) & 0xFF, - (ip_info.netmask.addr >> 24) & 0xFF); - printf("\tgateway: %d.%d.%d.%d\n", ip_info.gw.addr & 0xFF, (ip_info.gw.addr >> 8) & 0xFF, - (ip_info.gw.addr >> 16) & 0xFF, (ip_info.gw.addr >> 24) & 0xFF); + printf("\tip: %d.%d.%d.%d\n", VAR2IPSTR(ip_info.ip.addr)); + printf("\tnetmask: %d.%d.%d.%d\n", VAR2IPSTR(ip_info.netmask.addr)); + printf("\tgateway: %d.%d.%d.%d\n", VAR2IPSTR(ip_info.gw.addr)); printf("\n"); } else if (WIFI_MODE_STA == mode) { int bits = xEventGroupWaitBits(wifi_event_group, CONNECTED_BIT, 0, 1, 0); @@ -612,14 +611,9 @@ static int wifi_cmd_query(int argc, char **argv) printf("\tsta mac: "MACSTR, MAC2STR(mac)); printf("\n"); } - printf("\tip: %d.%d.%d.%d\n", ip_info.ip.addr & 0xFF, (ip_info.ip.addr >> 8) & 0xFF, - (ip_info.ip.addr >> 16) & 0xFF, (ip_info.ip.addr >> 24) & 0xFF); - printf("\tnetmask: %d.%d.%d.%d\n", ip_info.netmask.addr & 0xFF, - (ip_info.netmask.addr >> 8) & 0xFF, (ip_info.netmask.addr >> 16) & 0xFF, - (ip_info.netmask.addr >> 24) & 0xFF); - printf("\tgateway: %d.%d.%d.%d\n", ip_info.gw.addr & 0xFF, - (ip_info.gw.addr >> 8) & 0xFF, (ip_info.gw.addr >> 16) & 0xFF, - (ip_info.gw.addr >> 24) & 0xFF); + printf("\tip: %d.%d.%d.%d\n", VAR2IPSTR(ip_info.ip.addr)); + printf("\tnetmask: %d.%d.%d.%d\n", VAR2IPSTR(ip_info.netmask.addr)); + printf("\tgateway: %d.%d.%d.%d\n", VAR2IPSTR(ip_info.gw.addr)); printf("\n"); } else { @@ -719,7 +713,7 @@ static int wifi_cmd_inactive_time(int argc, char **argv) if (err != ESP_OK) { ESP_LOGW(TAG, "set softAP inactive time to %d seconds, err:0x%x\n", inactive_time_args.val->ival[0], err); } else { - ESP_LOGI(TAG, "set softAP inactive time to %d seconds, err:0x%x\n", inactive_time_args.val->ival[0]); + ESP_LOGI(TAG, "set softAP inactive time to %d seconds\n", inactive_time_args.val->ival[0]); } } //WIFI_MODE_STA or WIFI_MODE_APSTA @@ -728,7 +722,7 @@ static int wifi_cmd_inactive_time(int argc, char **argv) if (err != ESP_OK) { ESP_LOGW(TAG, "set STA inactive time to %d seconds, err:0x%x\n", inactive_time_args.val->ival[0], err); } else { - ESP_LOGI(TAG, "set STA inactive time to %d seconds, err:0x%x\n", inactive_time_args.val->ival[0]); + ESP_LOGI(TAG, "set STA inactive time to %d seconds\n", inactive_time_args.val->ival[0]); } } uint16_t secs = 0; @@ -814,7 +808,7 @@ static int wifi_cmd_set_tx_pwr(int argc, char **argv) ESP_LOGW(TAG, "set MCS%d TX PWR to %d", tx_pwr_args.mcs->ival[0], tx_pwr_args.power->ival[0]); } else if (tx_pwr_args.power->ival[0] == 0xff) { esp_test_set_tx_mcs_pwr(tx_pwr_args.mcs->ival[0] + WIFI_PHY_RATE_MCS0_LGI, tx_pwr_args.power->ival[0]); - ESP_LOGW(TAG, "set MCS%d TX PWR to default value", tx_pwr_args.mcs->ival[0], tx_pwr_args.power->ival[0]); + ESP_LOGW(TAG, "set MCS%d TX PWR to default value", tx_pwr_args.mcs->ival[0]); } } else { ESP_LOGW(TAG, "Set TX power fail, MCS should in range [0,9], power should in range [-13, 30] or set 0xFF for default"); diff --git a/examples/common_components/iperf/wifi_stats.c b/examples/common_components/iperf/wifi_stats.c index cbb1652a07..f10cc3b71c 100644 --- a/examples/common_components/iperf/wifi_stats.c +++ b/examples/common_components/iperf/wifi_stats.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -158,8 +158,8 @@ int wifi_cmd_get_tx_statistics(int argc, char **argv) for (i = 2; i < 3; i++) { esp_wifi_get_tx_tb_statistics(i, &tb_stats); /* TB */ - printf("(test)aci:%d, tb(suc:%d, ack:%d, err:%d), " - "count(suc:%d, ack:%d, err:%d, tot:%d, max_sent:%d)\n", + printf("(test)aci:%" PRIu8 ", tb(suc:%" PRIu32 ", ack:%" PRIu32 ", err:%" PRIu32 "), " + "count(suc:%" PRIu32 ", ack:%" PRIu32 ", err:%" PRIu32 ", tot:%" PRIu32 ", max_sent:%" PRIu32 ")\n", i, tb_stats.complete_suc_tb, tb_stats.complete_ack_tb, @@ -173,9 +173,9 @@ int wifi_cmd_get_tx_statistics(int argc, char **argv) esp_wifi_get_tx_statistics(i, &tx_stats, (esp_test_tx_fail_statistics_t *) &tx_fail); int tot_tx_times = tx_stats.tb_times + (tx_stats.tx_enable - tx_stats.tb_last); //TB + EDCA int tot_fail = tx_fail[1].count + tx_fail[2].count + tx_fail[3].count + tx_fail[4].count + tx_fail[5].count; - printf("(test)aci:%d, enable:%d, complete:%d, tb_times:%d, tb_last:%d, edca:%d, " - "succ:%d, fail(%d,%d,%d, cts:%d/%2.2f%%, ack:%d/%2.2f%%, tot:%d, %.2f%%), " - "edca(ack:%d, ba:%d), tb(hw-ba:%d, sw-ba:%d)\n", + printf("(test)aci:%" PRIu8 ", enable:%" PRIu32 ", complete:%" PRIu32 ", tb_times:%" PRIu32 ", tb_last:%" PRIu32 ", edca:%" PRIu32 ", " + "succ:%" PRIu32 ", fail(%" PRIu32 ",%" PRIu32 ",%" PRIu32 ", cts:%" PRIu32 "/%2.2f%%, ack:%" PRIu32 "/%2.2f%%, tot:%d, %.2f%%), " + "edca(ack:%" PRIu32 ", ba:%" PRIu32 "), tb(hw-ba:%" PRIu32 ", sw-ba:%" PRIu32 ")\n", i, tx_stats.tx_enable, tx_stats.tx_complete, tx_stats.tb_times, @@ -195,9 +195,9 @@ int wifi_cmd_get_tx_statistics(int argc, char **argv) tx_stats.tb_rx_ba, //including ACKs tx_stats.rx_dump_ba); - printf("(test)aci:%d, txFrames:%d, s-mpdu:%d(%.2f%%), " - "bitmap(max:%d, min:%d, tot:%d, avg:%.2f), " - "retry(edca:%d, tb:%d, %.2f%%), collision:%d, timeout:%d\n", + printf("(test)aci:%" PRIu8 ", txFrames:%" PRIu32 ", s-mpdu:%" PRIu32 "(%.2f%%), " + "bitmap(max:%d, min:%d, tot:%" PRIu32 ", avg:%.2f), " + "retry(edca:%" PRIu32 ", tb:%" PRIu32 ", %.2f%%), collision:%" PRIu32 ", timeout:%" PRIu32 "\n", i, tx_stats.tx_succ, tx_stats.rx_ack, @@ -210,7 +210,7 @@ int wifi_cmd_get_tx_statistics(int argc, char **argv) tx_stats.collision, tx_stats.timeout); float tot_rtt_ms = (float) tx_stats.tx_tot_rtt / (float) 1000; - printf("(test)aci:%d, seqno_rtt[%d,%d], hw_rtt[%d, %d], muedca[enable:%d, times:%d, %.2f, %.2f, tot:%.2f], avg:%.3f ms, tot:%.3f secs\n", + printf("(test)aci:%" PRIu8 ", seqno_rtt[%" PRIu32 ",%" PRIu32 "], hw_rtt[%" PRIu32 ", %" PRIu32 "], muedca[enable:%" PRIu32 ", times:%" PRIi64 ", %.2f, %.2f, tot:%.2f], avg:%.3f ms, tot:%.3f secs\n", i, tx_stats.tx_seq_min_rtt, tx_stats.tx_seq_max_rtt, @@ -228,7 +228,7 @@ int wifi_cmd_get_tx_statistics(int argc, char **argv) for (j = 0; j < TEST_TX_WAIT_MAX; j++) { //match for (k = 0; k < TEST_TX_FAIL_ERROR_MAX; k++) { //error if (tx_fail[h].match[j][k]) { - printf("(test)[%d][%d][%d](%16s + %16s + %16s)%3d/%3d(%.2f%%)\n", h, j, k, tx_fail_state2str(h), + printf("(test)[%d][%d][%d](%16s + %16s + %16s)%3" PRIu32 "/%3" PRIu32 "(%.2f%%)\n", h, j, k, tx_fail_state2str(h), tx_fail_match2str(j), tx_fail_error2str(k), tx_fail[h].match[j][k], tx_fail[h].count, ((float) tx_fail[h].match[j][k] / (float) tx_fail[h].count) * 100); @@ -250,16 +250,16 @@ void print_rx_statistics_nonmimo(const esp_test_rx_mu_statistics_t *mu_stats) int i, j; int tot_rx_nonmimo = 0; - ESP_LOGW(TAG, "(nonmimo)dut rx:%d", mu_stats->nonmimo_rx); - ESP_LOGW(TAG, "(nonmimo)ru_alloc_96_num_2046:%d, ru_alloc_112_num_2046:%d", mu_stats->ru_alloc_96_num_2046, mu_stats->ru_alloc_112_num_2046); - ESP_LOGW(TAG, "(nonmimo)sigb, mcs0:%d(%2.2f%%), mcs1:%d(%2.2f%%), mcs2:%d(%2.2f%%), mcs3:%d(%2.2f%%), mcs4:%d(%2.2f%%), mcs5:%d(%2.2f%%)", + ESP_LOGW(TAG, "(nonmimo)dut rx:%" PRIu32, mu_stats->nonmimo_rx); + ESP_LOGW(TAG, "(nonmimo)ru_alloc_96_num_2046:%" PRIu32 ", ru_alloc_112_num_2046:%" PRIu32, mu_stats->ru_alloc_96_num_2046, mu_stats->ru_alloc_112_num_2046); + ESP_LOGW(TAG, "(nonmimo)sigb, mcs0:%" PRIu32 "(%2.2f%%), mcs1:%" PRIu32 "(%2.2f%%), mcs2:%" PRIu32 "(%2.2f%%), mcs3:%" PRIu32 "(%2.2f%%), mcs4:%" PRIu32 "(%2.2f%%), mcs5:%" PRIu32 "(%2.2f%%)", mu_stats->nonmimo_sigb_mcs[0], ((float) mu_stats->nonmimo_sigb_mcs[0] / (float) mu_stats->nonmimo_rx) * 100, mu_stats->nonmimo_sigb_mcs[1], ((float) mu_stats->nonmimo_sigb_mcs[1] / (float) mu_stats->nonmimo_rx) * 100, mu_stats->nonmimo_sigb_mcs[2], ((float) mu_stats->nonmimo_sigb_mcs[2] / (float) mu_stats->nonmimo_rx) * 100, mu_stats->nonmimo_sigb_mcs[3], ((float) mu_stats->nonmimo_sigb_mcs[3] / (float) mu_stats->nonmimo_rx) * 100, mu_stats->nonmimo_sigb_mcs[4], ((float) mu_stats->nonmimo_sigb_mcs[4] / (float) mu_stats->nonmimo_rx) * 100, mu_stats->nonmimo_sigb_mcs[5], ((float) mu_stats->nonmimo_sigb_mcs[5] / (float) mu_stats->nonmimo_rx) * 100); - ESP_LOGW(TAG, "(nonmimo)users, num1:%d(%2.2f%%), num2:%d(%2.2f%%), num3:%d(%2.2f%%), num4:%d(%2.2f%%), num5:%d(%2.2f%%), num6:%d(%2.2f%%), num7:%d(%2.2f%%), num8:%d(%2.2f%%), num9:%d(%2.2f%%)", + ESP_LOGW(TAG, "(nonmimo)users, num1:%" PRIu32 "(%2.2f%%), num2:%" PRIu32 "(%2.2f%%), num3:%" PRIu32 "(%2.2f%%), num4:%" PRIu32 "(%2.2f%%), num5:%" PRIu32 "(%2.2f%%), num6:%" PRIu32 "(%2.2f%%), num7:%" PRIu32 "(%2.2f%%), num8:%" PRIu32 "(%2.2f%%), num9:%" PRIu32 "(%2.2f%%)", mu_stats->nonmimo_user_num_occu[0], ((float) mu_stats->nonmimo_user_num_occu[0] / (float) mu_stats->nonmimo_rx) * 100, mu_stats->nonmimo_user_num_occu[1], ((float) mu_stats->nonmimo_user_num_occu[1] / (float) mu_stats->nonmimo_rx) * 100, mu_stats->nonmimo_user_num_occu[2], ((float) mu_stats->nonmimo_user_num_occu[2] / (float) mu_stats->nonmimo_rx) * 100, @@ -274,7 +274,7 @@ void print_rx_statistics_nonmimo(const esp_test_rx_mu_statistics_t *mu_stats) if (!mu_stats->nonmimo_ru_alloc[i][j]) { continue; } - ESP_LOGI(TAG, "(nonmimo)ru_allocation:0x%2x(%3d), position:%d, %5d(%2.2f%%)", i, i, j + 1, mu_stats->nonmimo_ru_alloc[i][j], + ESP_LOGI(TAG, "(nonmimo)ru_allocation:0x%2x(%3" PRIu8 "), position:%" PRIu8 ", %5" PRIu32 "(%2.2f%%)", i, i, j + 1, mu_stats->nonmimo_ru_alloc[i][j], ((float) mu_stats->nonmimo_ru_alloc[i][j] / (float) mu_stats->nonmimo_rx) * 100); } } @@ -286,12 +286,12 @@ void print_rx_statistics_nonmimo(const esp_test_rx_mu_statistics_t *mu_stats) continue; } tot_rx_nonmimo = mu_stats->nonmimo[i].occu_nsts[0] + mu_stats->nonmimo[i].occu_nsts[1] + mu_stats->nonmimo[i].occu_nsts[2] + mu_stats->nonmimo[i].occu_nsts[3]; - printf("[%d]%said:0x%x, txbf:%d, dcm:%d\n", i, (mu_stats->aid == mu_stats->nonmimo[i].aid) ? "#" : " ", mu_stats->nonmimo[i].aid, + printf("[%" PRIu8 "]%said:0x%x, txbf:%" PRIu32 ", dcm:%" PRIu32 "\n", i, (mu_stats->aid == mu_stats->nonmimo[i].aid) ? "#" : " ", mu_stats->nonmimo[i].aid, mu_stats->nonmimo[i].txbf, mu_stats->nonmimo[i].dcm); printf("[%d]%said:0x%x, " - "mcs0:%d(%2.2f%%), mcs1:%d(%2.2f%%), mcs2:%d(%2.2f%%), mcs3:%d(%2.2f%%), mcs4:%d(%2.2f%%), " - "mcs5:%d(%2.2f%%), mcs6:%d(%2.2f%%), mcs7:%d(%2.2f%%), mcs8:%d(%2.2f%%), mcs9:%d(%2.2f%%), " - "mcs10:%d(%2.2f%%), mcs11:%d(%2.2f%%)\n", + "mcs0:%" PRIu32 "(%2.2f%%), mcs1:%" PRIu32 "(%2.2f%%), mcs2:%" PRIu32 "(%2.2f%%), mcs3:%" PRIu32 "(%2.2f%%), mcs4:%" PRIu32 "(%2.2f%%), " + "mcs5:%" PRIu32 "(%2.2f%%), mcs6:%" PRIu32 "(%2.2f%%), mcs7:%" PRIu32 "(%2.2f%%), mcs8:%" PRIu32 "(%2.2f%%), mcs9:%" PRIu32 "(%2.2f%%), " + "mcs10:%" PRIu32 "(%2.2f%%), mcs11:%" PRIu32 "(%2.2f%%)\n", i, (mu_stats->aid == mu_stats->nonmimo[i].aid) ? "#" : " ", mu_stats->nonmimo[i].aid, mu_stats->nonmimo[i].occu_mcs[0], ((float) mu_stats->nonmimo[i].occu_mcs[0] / (float) tot_rx_nonmimo) * 100, mu_stats->nonmimo[i].occu_mcs[1], ((float) mu_stats->nonmimo[i].occu_mcs[1] / (float) tot_rx_nonmimo) * 100, @@ -305,14 +305,14 @@ void print_rx_statistics_nonmimo(const esp_test_rx_mu_statistics_t *mu_stats) mu_stats->nonmimo[i].occu_mcs[9], ((float) mu_stats->nonmimo[i].occu_mcs[9] / (float) tot_rx_nonmimo) * 100, mu_stats->nonmimo[i].occu_mcs[10], ((float) mu_stats->nonmimo[i].occu_mcs[10] / (float) tot_rx_nonmimo) * 100, mu_stats->nonmimo[i].occu_mcs[11], ((float) mu_stats->nonmimo[i].occu_mcs[11] / (float) tot_rx_nonmimo) * 100); - printf("[%d]%said:0x%x, " - "nsts0:%d(%2.2f%%), nsts1:%d(%2.2f%%), nsts2:%d(%2.2f%%), nsts3:%d(%2.2f%%)\n", + printf("[%" PRIu8 "]%said:0x%x, " + "nsts0:%" PRIu32 "(%2.2f%%), nsts1:%" PRIu32 "(%2.2f%%), nsts2:%" PRIu32 "(%2.2f%%), nsts3:%" PRIu32 "(%2.2f%%)\n", i, (mu_stats->aid == mu_stats->nonmimo[i].aid) ? "#" : " ", mu_stats->nonmimo[i].aid, mu_stats->nonmimo[i].occu_nsts[0], ((float) mu_stats->nonmimo[i].occu_nsts[0] / (float) tot_rx_nonmimo) * 100, mu_stats->nonmimo[i].occu_nsts[1], ((float) mu_stats->nonmimo[i].occu_nsts[1] / (float) tot_rx_nonmimo) * 100, mu_stats->nonmimo[i].occu_nsts[2], ((float) mu_stats->nonmimo[i].occu_nsts[2] / (float) tot_rx_nonmimo) * 100, mu_stats->nonmimo[i].occu_nsts[3], ((float) mu_stats->nonmimo[i].occu_nsts[3] / (float) tot_rx_nonmimo) * 100); - printf("[%d]%said:0x%x, " + printf("[%" PRIu8 "]%said:0x%x, " "tot_rx_nonmimo:%8d, sta/dut:%2.2f%%\n", i, (mu_stats->aid == mu_stats->nonmimo[i].aid) ? "#" : " ", mu_stats->nonmimo[i].aid, tot_rx_nonmimo, ((float) tot_rx_nonmimo / (float) mu_stats->nonmimo_rx) * 100); @@ -327,15 +327,15 @@ void print_rx_statistics_mimo(const esp_test_rx_mu_statistics_t *mu_stats) int i; int tot_rx_mimo = 0; - ESP_LOGW(TAG, "(mimo)dut rx:%d", mu_stats->mimo_rx); - ESP_LOGW(TAG, "(mimo)sigb, mcs0:%d(%2.2f%%), mcs1:%d(%2.2f%%), mcs2:%d(%2.2f%%), mcs3:%d(%2.2f%%), mcs4:%d(%2.2f%%), mcs5:%d(%2.2f%%)", + ESP_LOGW(TAG, "(mimo)dut rx:%" PRIu32 "", mu_stats->mimo_rx); + ESP_LOGW(TAG, "(mimo)sigb, mcs0:%" PRIu32 "(%2.2f%%), mcs1:%" PRIu32 "(%2.2f%%), mcs2:%" PRIu32 "(%2.2f%%), mcs3:%" PRIu32 "(%2.2f%%), mcs4:%" PRIu32 "(%2.2f%%), mcs5:%" PRIu32 "(%2.2f%%)", mu_stats->mimo_sigb_mcs[0], ((float) mu_stats->mimo_sigb_mcs[0] / (float) mu_stats->mimo_rx) * 100, mu_stats->mimo_sigb_mcs[1], ((float) mu_stats->mimo_sigb_mcs[1] / (float) mu_stats->mimo_rx) * 100, mu_stats->mimo_sigb_mcs[2], ((float) mu_stats->mimo_sigb_mcs[2] / (float) mu_stats->mimo_rx) * 100, mu_stats->mimo_sigb_mcs[3], ((float) mu_stats->mimo_sigb_mcs[3] / (float) mu_stats->mimo_rx) * 100, mu_stats->mimo_sigb_mcs[4], ((float) mu_stats->mimo_sigb_mcs[4] / (float) mu_stats->mimo_rx) * 100, mu_stats->mimo_sigb_mcs[5], ((float) mu_stats->mimo_sigb_mcs[5] / (float) mu_stats->mimo_rx) * 100); - ESP_LOGW(TAG, "(mimo)users num2:%d(%2.2f%%), num3:%d(%2.2f%%), num4:%d(%2.2f%%), num5:%d(%2.2f%%), num6:%d(%2.2f%%), num7:%d(%2.2f%%), num8:%d(%2.2f%%)", + ESP_LOGW(TAG, "(mimo)users num2:%" PRIu32 "(%2.2f%%), num3:%" PRIu32 "(%2.2f%%), num4:%" PRIu32 "(%2.2f%%), num5:%" PRIu32 "(%2.2f%%), num6:%" PRIu32 "(%2.2f%%), num7:%" PRIu32 "(%2.2f%%), num8:%" PRIu32 "(%2.2f%%)", mu_stats->mimo_user_num_occu[0], ((float) mu_stats->mimo_user_num_occu[0] / (float) mu_stats->mimo_rx) * 100, mu_stats->mimo_user_num_occu[1], ((float) mu_stats->mimo_user_num_occu[1] / (float) mu_stats->mimo_rx) * 100, mu_stats->mimo_user_num_occu[2], ((float) mu_stats->mimo_user_num_occu[2] / (float) mu_stats->mimo_rx) * 100, @@ -348,10 +348,10 @@ void print_rx_statistics_mimo(const esp_test_rx_mu_statistics_t *mu_stats) continue; } tot_rx_mimo = mu_stats->mimo[i].occu_ss[0] + mu_stats->mimo[i].occu_ss[1] + mu_stats->mimo[i].occu_ss[2] + mu_stats->mimo[i].occu_ss[3]; - printf("[%d]%said:0x%x, " - "mcs0:%d(%2.2f%%), mcs1:%d(%2.2f%%), mcs2:%d(%2.2f%%), mcs3:%d(%2.2f%%), mcs4:%d(%2.2f%%), " - "mcs5:%d(%2.2f%%), mcs6:%d(%2.2f%%), mcs7:%d(%2.2f%%), mcs8:%d(%2.2f%%), mcs9:%d(%2.2f%%), " - "mcs10:%d(%2.2f%%), mcs11:%d(%2.2f%%)\n", + printf("[%" PRIu8 "]%said:0x%x, " + "mcs0:%" PRIu32 "(%2.2f%%), mcs1:%" PRIu32 "(%2.2f%%), mcs2:%" PRIu32 "(%2.2f%%), mcs3:%" PRIu32 "(%2.2f%%), mcs4:%" PRIu32 "(%2.2f%%), " + "mcs5:%" PRIu32 "(%2.2f%%), mcs6:%" PRIu32 "(%2.2f%%), mcs7:%" PRIu32 "(%2.2f%%), mcs8:%" PRIu32 "(%2.2f%%), mcs9:%" PRIu32 "(%2.2f%%), " + "mcs10:%" PRIu32 "(%2.2f%%), mcs11:%" PRIu32 "(%2.2f%%)\n", i, (mu_stats->aid == mu_stats->mimo[i].aid) ? "#" : " ", mu_stats->mimo[i].aid, mu_stats->mimo[i].occu_mcs[0], ((float) mu_stats->mimo[i].occu_mcs[0] / (float) tot_rx_mimo) * 100, mu_stats->mimo[i].occu_mcs[1], ((float) mu_stats->mimo[i].occu_mcs[1] / (float) tot_rx_mimo) * 100, @@ -365,14 +365,14 @@ void print_rx_statistics_mimo(const esp_test_rx_mu_statistics_t *mu_stats) mu_stats->mimo[i].occu_mcs[9], ((float) mu_stats->mimo[i].occu_mcs[9] / (float) tot_rx_mimo) * 100, mu_stats->mimo[i].occu_mcs[10], ((float) mu_stats->mimo[i].occu_mcs[10] / (float) tot_rx_mimo) * 100, mu_stats->mimo[i].occu_mcs[11], ((float) mu_stats->mimo[i].occu_mcs[11] / (float) tot_rx_mimo) * 100); - printf("[%d]%said:0x%x, " - "ss0:%d(%2.2f%%), ss1:%d(%2.2f%%), ss2:%d(%2.2f%%), ss3:%d(%2.2f%%)\n", + printf("[%" PRIu8 "]%said:0x%x, " + "ss0:%" PRIu32 "(%2.2f%%), ss1:%" PRIu32 "(%2.2f%%), ss2:%" PRIu32 "(%2.2f%%), ss3:%" PRIu32 "(%2.2f%%)\n", i, (mu_stats->aid == mu_stats->mimo[i].aid) ? "#" : " ", mu_stats->mimo[i].aid, mu_stats->mimo[i].occu_ss[0], ((float) mu_stats->mimo[i].occu_ss[0] / (float) tot_rx_mimo) * 100, mu_stats->mimo[i].occu_ss[1], ((float) mu_stats->mimo[i].occu_ss[1] / (float) tot_rx_mimo) * 100, mu_stats->mimo[i].occu_ss[2], ((float) mu_stats->mimo[i].occu_ss[2] / (float) tot_rx_mimo) * 100, mu_stats->mimo[i].occu_ss[3], ((float) mu_stats->mimo[i].occu_ss[3] / (float) tot_rx_mimo) * 100); - printf("[%d]%said:0x%x, " + printf("[%" PRIu8 "]%said:0x%x, " "tot_rx_mimo:%8d, sta/dut:%2.2f%%\n", i, (mu_stats->aid == mu_stats->mimo[i].aid) ? "#" : " ", mu_stats->mimo[i].aid, tot_rx_mimo, ((float) tot_rx_mimo / (float) mu_stats->mimo_rx) * 100); @@ -396,7 +396,7 @@ void print_hw_rx_statistics(void) "WDEVRX_LASTUNMATCH_ERR :%d\n" "RXHUNG_STATIS :%d\n" "TXHUNG_STATIS :%d\n" - "RXTXHUNG :%d\n" + "RXTXHUNG :%" PRIu32 "\n" "WDEVRX_CFO :%d\n" "WDEVRX_SF :%d\n" "WDEVRX_OTHER_UCAST :%d\n" @@ -493,12 +493,12 @@ int wifi_cmd_get_rx_statistics(int argc, char **argv) esp_wifi_get_rx_statistics(0, &rx_stats); //tid=0 print_hw_tb_statistics(); - ESP_LOGW(TAG, "(0)legacy:%d, ht(ht:%d, ht_retry:%d/%2.2f%%, ht_noeb:%d/%2.2f%%)", + ESP_LOGW(TAG, "(0)legacy:%" PRIu32 ", ht(ht:%" PRIu32 ", ht_retry:%" PRIu32 "/%2.2f%%, ht_noeb:%" PRIu32 "/%2.2f%%)", rx_stats.legacy, rx_stats.ht, rx_stats.ht_retry, rx_stats.ht_retry ? ((float) ((float) rx_stats.ht_retry / (float) rx_stats.ht) * 100) : 0, rx_stats.ht_noeb, rx_stats.ht_noeb ? ((float) ((float) rx_stats.ht_noeb / (float) rx_stats.ht) * 100) : 0); - ESP_LOGW(TAG, "(0)su(su:%d, su_txbf:%d, su_stbc:%d, su_retry:%d/%2.2f%%, ersu:%d, ersu_dcm:%d, su_noeb:%d/%2.2f%%)", + ESP_LOGW(TAG, "(0)su(su:%" PRIu32 ", su_txbf:%" PRIu32 ", su_stbc:%" PRIu32 ", su_retry:%" PRIu32 "/%2.2f%%, ersu:%" PRIu32 ", ersu_dcm:%" PRIu32 ", su_noeb:%" PRIu32 "/%2.2f%%)", rx_stats.su, rx_stats.su_txbf, rx_stats.su_stbc, rx_stats.su_retry, @@ -506,7 +506,7 @@ int wifi_cmd_get_rx_statistics(int argc, char **argv) rx_stats.ersu, rx_stats.ersu_dcm, rx_stats.su_noeb, rx_stats.su_noeb ? ((float) ((float) rx_stats.su_noeb / (float) rx_stats.su) * 100) : 0); - ESP_LOGW(TAG, "(0)mu(mu:%d, mimo:%d, non-mimo:%d, txbf:%d, stbc:%d, mu_retry:%d/%2.2f%%, mu_noeb:%d/%2.2f%%)", + ESP_LOGW(TAG, "(0)mu(mu:%" PRIu32 ", mimo:%" PRIu32 ", non-mimo:%" PRIu32 ", txbf:%" PRIu32 ", stbc:%" PRIu32 ", mu_retry:%" PRIu32 "/%2.2f%%, mu_noeb:%" PRIu32 "/%2.2f%%)", rx_stats.mu, rx_stats.mu_mimo, rx_stats.mu_ofdma, rx_stats.mu_txbf, rx_stats.mu_stbc, @@ -516,26 +516,26 @@ int wifi_cmd_get_rx_statistics(int argc, char **argv) memset(&rx_stats, 0, sizeof(rx_stats)); esp_wifi_get_rx_statistics(7, &rx_stats); //tid=7 - ESP_LOGW(TAG, "(7)legacy:%d, ht:%d, su:%d, su_txbf:%d, ersu:%d, mu:%d", rx_stats.legacy, + ESP_LOGW(TAG, "(7)legacy:%" PRIu32 ", ht:%" PRIu32 ", su:%" PRIu32 ", su_txbf:%" PRIu32 ", ersu:%" PRIu32 ", mu:%" PRIu32, rx_stats.legacy, rx_stats.ht, rx_stats.su, rx_stats.su_txbf, rx_stats.ersu, rx_stats.mu); - ESP_LOGW(TAG, "(hw)isr:%d, nblks:%d", rx_stats.rx_isr, rx_stats.rx_nblks); + ESP_LOGW(TAG, "(hw)isr:%" PRIu32 ", nblks:%" PRIu32, rx_stats.rx_isr, rx_stats.rx_nblks); /* hw rx statistics */ print_hw_rx_statistics(); #if CONFIG_ESP_WIFI_ENABLE_WIFI_RX_MU_STATS print_rx_mu_statistics(); #endif esp_test_get_rx_error_occurs(&rx_error_occurs); - ESP_LOGW(TAG, "(rx)tot_errors:%d", rx_error_occurs.tot); + ESP_LOGW(TAG, "(rx)tot_errors:%" PRIu32, rx_error_occurs.tot); int known_errors = 0; //rx error: 0x40-0xff int i; for (i = 0; i < 2; i++) { if (rx_error_occurs.occurs[i]) { known_errors += rx_error_occurs.occurs[i]; - printf("[%3d] 0x%x, %8d, %2.2f%%\n", i, (i ? 0xf5 : 0xc6), rx_error_occurs.occurs[i], ((float) rx_error_occurs.occurs[i] / (float) rx_error_occurs.tot) * 100); + printf("[%3d] 0x%x, %8" PRIu32 ", %2.2f%%\n", i, (i ? 0xf5 : 0xc6), rx_error_occurs.occurs[i], ((float) rx_error_occurs.occurs[i] / (float) rx_error_occurs.tot) * 100); } } if (rx_error_occurs.tot - known_errors) { - printf("[%3d]others, %8d, %2.2f%%\n\n", i, rx_error_occurs.tot - known_errors, ((float) known_errors / (float) rx_error_occurs.tot) * 100); + printf("[%3d]others, %8" PRIu32 ", %2.2f%%\n\n", i, rx_error_occurs.tot - known_errors, ((float) known_errors / (float) rx_error_occurs.tot) * 100); } wifi_cmd_clr_rx_statistics(0, 0); return 0; From 9a05cc77338ece52aef70b4cae3a359714ca0163 Mon Sep 17 00:00:00 2001 From: Bogdan Kolendovskyy Date: Fri, 17 Mar 2023 16:03:52 +0100 Subject: [PATCH 3/3] Updated CMakeList.txt for main component of mqtt/ssl_ds. --- examples/protocols/mqtt/ssl_ds/main/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/protocols/mqtt/ssl_ds/main/CMakeLists.txt b/examples/protocols/mqtt/ssl_ds/main/CMakeLists.txt index b8ef6eadbd..61fac40e63 100644 --- a/examples/protocols/mqtt/ssl_ds/main/CMakeLists.txt +++ b/examples/protocols/mqtt/ssl_ds/main/CMakeLists.txt @@ -1,3 +1,2 @@ idf_component_register(SRCS "app_main.c" - INCLUDE_DIRS "." - REQUIRED_IDF_TARGETS esp32s2 esp32c3 esp32s3) + INCLUDE_DIRS ".")