Skip to content

Commit a7f700e

Browse files
committed
Optimize hostname variable size
1 parent 66e289d commit a7f700e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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)