Skip to content

Commit

Permalink
further c2 optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
NonPIayerCharacter committed Sep 14, 2024
1 parent 88666bb commit 79fd139
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 18 deletions.
5 changes: 4 additions & 1 deletion idf/sdkconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ CONFIG_ESP_MAIN_TASK_STACK_SIZE=4096
CONFIG_VFS_SUPPORT_IO=n
CONFIG_MBEDTLS_SHA512_C=n
CONFIG_MBEDTLS_TLS_CLIENT_ONLY=y
CONFIG_HAL_LOG_LEVEL_ERROR=y
CONFIG_HAL_LOG_LEVEL_ERROR=y

CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_1=n
CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_2=n
31 changes: 25 additions & 6 deletions idf/sdkconfig.defaults.esp32c2
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,43 @@ CONFIG_PM_DFS_INIT_AUTO=y
CONFIG_XTAL_FREQ_26=y
CONFIG_XTAL_FREQ=26

CONFIG_RTC_CLK_SRC_INT_RC=y

CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y
CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION=y

CONFIG_RTC_CLK_SRC_EXT_OSC=y

CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-2mb.csv"

CONFIG_LWIP_MAX_SOCKETS=6
CONFIG_LWIP_MAX_SOCKETS=5
CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=16
CONFIG_LWIP_MAX_ACTIVE_TCP=5
CONFIG_LWIP_MAX_LISTENING_TCP=5
CONFIG_LWIP_TCP_HIGH_SPEED_RETRANSMISSION=n
CONFIG_LWIP_TCP_SYNMAXRTX=12
CONFIG_LWIP_TCP_MSL=40000
CONFIG_LWIP_TCP_FIN_WAIT_TIMEOUT=16000
CONFIG_LWIP_TCP_SND_BUF_DEFAULT=4096
CONFIG_LWIP_TCP_WND_DEFAULT=2440
CONFIG_LWIP_TCP_OVERSIZE_QUARTER_MSS=y
CONFIG_LWIP_TCP_RTO_TIME=1500
CONFIG_LWIP_MAX_UDP_PCBS=8
CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=2560

CONFIG_MBEDTLS_DYNAMIC_BUFFER=y
CONFIG_MBEDTLS_DYNAMIC_FREE_CONFIG_DATA=y
CONFIG_MBEDTLS_DYNAMIC_FREE_CA_CERT=y
CONFIG_MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH=y
CONFIG_MBEDTLS_SSL_KEEP_PEER_CERTIFICATE=n

CONFIG_HEAP_PLACE_FUNCTION_INTO_FLASH=y

CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=3
CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM=6
CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER_NUM=6
CONFIG_ESP_WIFI_RX_BA_WIN=6
CONFIG_LWIP_TCP_SND_BUF_DEFAULT=6
CONFIG_LWIP_TCP_WND_DEFAULT=6
CONFIG_LWIP_IRAM_OPTIMIZATION=0

CONFIG_SPI_MASTER_ISR_IN_IRAM=n
CONFIG_SPI_SLAVE_ISR_IN_IRAM=n
CONFIG_SPI_FLASH_ROM_DRIVER_PATCH=n
CONFIG_SPI_FLASH_ROM_IMPL=y
22 changes: 11 additions & 11 deletions src/hal/espidf/hal_wifi_espidf.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ void HAL_PrintNetworkInfo()
{
uint8_t mac[6];
esp_read_mac(mac, ESP_MAC_BASE);
ADDLOG_DEBUG(LOG_FEATURE_GENERAL, "+--------------- net device info ------------+\r\n");
ADDLOG_DEBUG(LOG_FEATURE_GENERAL, "|netif type : %-16s |\r\n", g_bOpenAccessPointMode == 0 ? "STA" : "AP");
ADDLOG_DEBUG(LOG_FEATURE_GENERAL, "|netif ip = %-16s |\r\n", HAL_GetMyIPString());
ADDLOG_DEBUG(LOG_FEATURE_GENERAL, "|netif mask = %-16s |\r\n", HAL_GetMyMaskString());
ADDLOG_DEBUG(LOG_FEATURE_GENERAL, "|netif gateway = %-16s |\r\n", HAL_GetMyGatewayString());
ADDLOG_DEBUG(LOG_FEATURE_GENERAL, "|netif mac : [%02X:%02X:%02X:%02X:%02X:%02X] %-7s |\r\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], "");
ADDLOG_DEBUG(LOG_FEATURE_GENERAL, "+--------------------------------------------+\r\n");
bk_printf("+--------------- net device info ------------+\r\n");
bk_printf("|netif type : %-16s |\r\n", g_bOpenAccessPointMode == 0 ? "STA" : "AP");
bk_printf("|netif ip = %-16s |\r\n", HAL_GetMyIPString());
bk_printf("|netif mask = %-16s |\r\n", HAL_GetMyMaskString());
bk_printf("|netif gateway = %-16s |\r\n", HAL_GetMyGatewayString());
bk_printf("|netif mac : [%02X:%02X:%02X:%02X:%02X:%02X] %-7s |\r\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], "");
bk_printf("+--------------------------------------------+\r\n");
}

int HAL_GetWifiStrength()
Expand Down Expand Up @@ -109,11 +109,11 @@ void event_handler(void* arg, esp_event_base_t event_base,
}
else if(event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED)
{
esp_wifi_restore();
if(g_wifiStatusCallback != NULL)
{
g_wifiStatusCallback(WIFI_STA_DISCONNECTED);
}
esp_wifi_restore();
ADDLOG_INFO(LOG_FEATURE_MAIN, "WiFi Disconnected");
}
else if(event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP)
Expand Down Expand Up @@ -157,10 +157,10 @@ void HAL_ConnectToWiFi(const char* oob_ssid, const char* connect_key, obkStaticI

wifi_config_t wifi_config;
esp_wifi_get_config(WIFI_IF_STA, &wifi_config);
if(strlen(&wifi_config.sta.ssid) == 0 || strlen(&wifi_config.sta.password) == 0)
if(strcmp((char*)wifi_config.sta.ssid, oob_ssid) != 0 || strcmp((char*)wifi_config.sta.password, connect_key) != 0)
{
esp_wifi_restore();
esp_wifi_get_config(WIFI_IF_STA, &wifi_config);
ADDLOG_ERROR(LOG_FEATURE_MAIN, "WiFi saved ssid/pass != current, resetting");
memset(&wifi_config.sta, 0, sizeof(wifi_sta_config_t));
wifi_config.sta.threshold.authmode = WIFI_AUTH_WPA2_PSK;
strncpy((char*)wifi_config.sta.ssid, (char*)oob_ssid, 32);
strncpy((char*)wifi_config.sta.password, (char*)connect_key, 64);
Expand Down

0 comments on commit 79fd139

Please sign in to comment.