From 8429361cf8fe5c958d095ca152431f8425a77be1 Mon Sep 17 00:00:00 2001 From: windowsair Date: Tue, 9 Mar 2021 15:51:36 +0800 Subject: [PATCH] feat: Add static IP feature --- README.md | 10 ++++++---- components/DAP/config/DAP_config.h | 2 +- main/DAP_handle.c | 5 ++++- main/main.c | 16 ++++++++++++++++ main/wifi_configuration.h | 15 +++++++++++---- 5 files changed, 38 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index d05c649..c88bc8a 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,8 @@ The default connected WIFI SSID is `DAP` , password `12345678` You can change `WIFI_SSID` and ` WIFI_PASS` in [wifi_configuration.h](main/wifi_configuration.h) +You can also specify your IP in the above file (We recommend using the static address binding feature of the router). + ### Debugger @@ -184,7 +186,7 @@ When you select max clock, we will take the following actions: 1. Use WinUSB Mode(enabled by default): - change `USE_WINUSB` macor in [USBd_config.h](components/USBIP/USBd_config.h) + change `USE_WINUSB` macor in [dap_configuration.h](main/dap_configuration.h) @@ -234,9 +236,9 @@ Credits to the following project, people and organizations: > - https://github.com/cezanne/usbip-win for usbip windows -- @HeavenSpree -- @Zy19930907 -- @caiguang1997 +- [@HeavenSpree](https://www.github.com/HeavenSpree) +- [@Zy19930907](https://www.github.com/Zy19930907) +- [@caiguang1997](https://www.github.com/caiguang1997) ## License diff --git a/components/DAP/config/DAP_config.h b/components/DAP/config/DAP_config.h index 11bf230..44b3012 100644 --- a/components/DAP/config/DAP_config.h +++ b/components/DAP/config/DAP_config.h @@ -120,7 +120,7 @@ This information includes: #define DAP_PACKET_COUNT 255 ///< Specifies number of packets buffered. /// Indicates that the SWO function(UART SWO & Streaming Trace) is available -#define SWO_FUNCTION_ENABLE 1 ///< SWO function: 1 = available, 0 = not available. +#define SWO_FUNCTION_ENABLE 0 ///< SWO function: 1 = available, 0 = not available. /// Indicate that UART Serial Wire Output (SWO) trace is available. diff --git a/main/DAP_handle.c b/main/DAP_handle.c index 042b464..e7bd5ab 100644 --- a/main/DAP_handle.c +++ b/main/DAP_handle.c @@ -115,7 +115,7 @@ void handle_dap_data_response(usbip_stage2_header *header) void handle_swo_trace_response(usbip_stage2_header *header) { - +#if (SWO_FUNCTION_ENABLE == 1) if (kSwoTransferBusy) { // busy indicates that there is data to be send @@ -128,6 +128,9 @@ void handle_swo_trace_response(usbip_stage2_header *header) // nothing to send. send_stage2_submit(header, 0, 0); } +#else + send_stage2_submit(header, 0, 0); +#endif } // SWO Data Queue Transfer diff --git a/main/main.c b/main/main.c index 4e2dad5..de1b1fa 100644 --- a/main/main.c +++ b/main/main.c @@ -97,6 +97,22 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) static void initialise_wifi(void) { tcpip_adapter_init(); + +#if (USE_STATIC_IP == 1) + tcpip_adapter_dhcps_stop(TCPIP_ADAPTER_IF_STA); + + tcpip_adapter_ip_info_t ip_info; + +#define MY_IP4_ADDR(...) IP4_ADDR(__VA_ARGS__) + MY_IP4_ADDR(&ip_info.ip, DAP_IP_ADDRESS); + MY_IP4_ADDR(&ip_info.gw, DAP_IP_GATEWAY); + MY_IP4_ADDR(&ip_info.netmask, DAP_IP_NETMASK); +#undef MY_IP4_ADDR + + tcpip_adapter_set_ip_info(TCPIP_ADAPTER_IF_STA, &ip_info); +#endif // (USE_STATIC_IP == 1) + + wifi_event_group = xEventGroupCreate(); ESP_ERROR_CHECK(esp_event_loop_init(event_handler, NULL)); diff --git a/main/wifi_configuration.h b/main/wifi_configuration.h index 5f84b6d..6c40f2c 100644 --- a/main/wifi_configuration.h +++ b/main/wifi_configuration.h @@ -3,9 +3,9 @@ * @brief Fill in your wifi configuration information here. * @version 0.1 * @date 2020-01-22 - * + * * @copyright Copyright (c) 2020 - * + * */ #ifndef __WIFI_CONFIGURATION__ #define __WIFI_CONFIGURATION__ @@ -13,8 +13,15 @@ #define WIFI_SSID "DAP" #define WIFI_PASS "12345678" -#define PORT 3240 +#define USE_STATIC_IP 1 +// If you don't want to specify the ip configuration, then ignore the following items. +#define DAP_IP_ADDRESS 192, 168, 137, 123 +#define DAP_IP_GATEWAY 192, 168, 137, 1 +#define DAP_IP_NETMASK 255, 255, 255, 0 + +// DO NOT CHANGE +#define PORT 3240 #define CONFIG_EXAMPLE_IPV4 1 -#endif \ No newline at end of file +#endif \ No newline at end of file