Merge branch 'bugfix/fix_format_error' into 'master'

examples: fix format errors, remove -Wno-format

Closes IDF-6433

See merge request espressif/esp-idf!21637
This commit is contained in:
Jiang Jiang Jian
2023-03-21 19:19:47 +08:00
26 changed files with 109 additions and 117 deletions

View File

@@ -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);
@@ -614,14 +613,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 {
@@ -721,7 +715,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
@@ -730,7 +724,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;
@@ -816,7 +810,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");