Skip to content

Commit a9e50e2

Browse files
authored
Merge pull request #9677 from RetiredWizard/lmhostname
Optimize hostname variable size
2 parents 29f64c7 + 156d7a8 commit a9e50e2

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

ports/espressif/boards/sunton_esp32_8048S050/sdkconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#
88
# LWIP
99
#
10-
CONFIG_LWIP_LOCAL_HOSTNAME="sunton-esp32-8048S050"
1110
# end of LWIP
1211

1312
# end of Component config

ports/espressif/common-hal/wifi/__init__.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
#include "py/gc.h"
1717
#include "py/mpstate.h"
1818
#include "py/runtime.h"
19-
#include "py/objstr.h"
20-
#include "py/objint.h"
2119

2220
#include "components/esp_wifi/include/esp_wifi.h"
2321

@@ -42,6 +40,8 @@ wifi_radio_obj_t common_hal_wifi_radio_obj;
4240
#include "nvs_flash.h"
4341
#endif
4442

43+
#define MAC_ADDRESS_LENGTH 6
44+
4545
static const char *TAG = "CP wifi";
4646

4747
static void schedule_background_on_cp_core(void *arg) {
@@ -200,8 +200,8 @@ void common_hal_wifi_init(bool user_initiated) {
200200
return;
201201
}
202202
// set the default lwip_local_hostname
203-
char cpy_default_hostname[80];
204-
uint8_t mac[6];
203+
char cpy_default_hostname[strlen(CIRCUITPY_BOARD_ID) + (MAC_ADDRESS_LENGTH * 2) + 6];
204+
uint8_t mac[MAC_ADDRESS_LENGTH];
205205
esp_wifi_get_mac(ESP_IF_WIFI_STA, mac);
206206
sprintf(cpy_default_hostname, "cpy_%s_%x", CIRCUITPY_BOARD_ID, (unsigned int)mac);
207207
const char *default_lwip_local_hostname = cpy_default_hostname;

0 commit comments

Comments
 (0)