Skip to content

Commit 3ad0ece

Browse files
committed
Improved performance
By adding functions using IRAM and cache
1 parent 02cfda3 commit 3ad0ece

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

components/utils/include/utils.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ extern "C"
1717
#include <stdlib.h>
1818
#include <esp_err.h>
1919

20+
#ifdef ICACHE_FLASH
21+
#define ICACHE_FLASH_ATTR __attribute__((section(".irom0.text")))
22+
#define ICACHE_RODATA_ATTR __attribute__((section(".irom.text")))
23+
#else
24+
#define ICACHE_FLASH_ATTR
25+
#define ICACHE_RODATA_ATTR
26+
#endif /* ICACHE_FLASH */
27+
2028
float system_uptime_s(void);
2129
void restart(void);
2230

components/utils/initialization.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ char *ssid, *ent_username, *ent_identity,
2626
char currentMAC[18];
2727

2828
//-----------------------------------------------------------------------------
29-
esp_err_t parms_init()
29+
esp_err_t IRAM_ATTR parms_init()
3030
{
3131
int webServer = 1, ledEnable = 1, customDnsEnable = 0,
3232
darkModeEnable = 0, randomizeMac = 0;

components/web_server/response_handler.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ url_handler_t handlers[] = {
6363

6464

6565
//-----------------------------------------------------------------------------
66-
esp_err_t common_page_response_handler(httpd_req_t *req, int req_id)
66+
esp_err_t ICACHE_FLASH_ATTR common_page_response_handler(httpd_req_t *req, int req_id)
6767
{
6868
for (int i = 0; i < sizeof(handlers) / sizeof(handlers[0]); i++)
6969
{
@@ -108,7 +108,7 @@ const size_t num_js_files = sizeof(js_files) / sizeof(js_files[0]);
108108

109109

110110
//-----------------------------------------------------------------------------
111-
esp_err_t common_js_response(httpd_req_t *req)
111+
esp_err_t ICACHE_FLASH_ATTR common_js_response(httpd_req_t *req)
112112
{
113113
for (int i = 0; i < num_js_files; i++)
114114
{

components/wifi_handler/wifi_handler.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
//-----------------------------------------------------------------------------
2121
// Handles wifi scan and return AP records in json string format
22-
char *wifi_scan_handler(void)
22+
char* IRAM_ATTR wifi_scan_handler(void)
2323
{
2424
// Disconnect from the current access point if not already connected
2525
if (!ap_connect)
@@ -84,7 +84,7 @@ char *wifi_scan_handler(void)
8484

8585
//-----------------------------------------------------------------------------
8686
// Handles wifi information and return in json format
87-
char *wifi_info_handler(void)
87+
char* IRAM_ATTR wifi_info_handler(void)
8888
{
8989
wifi_ap_record_t ap_info;
9090
wifi_sta_list_t wifi_sta_list;

components/wifi_handler/wifi_init.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ bool has_static_ip = false;
3434
// initiating wifi setup
3535
void wifi_init()
3636
{
37-
37+
esp_log_level_set("wifi", ESP_LOG_NONE);
3838
wifi_event_group = xEventGroupCreate();
3939
esp_netif_init();
4040
ESP_ERROR_CHECK(esp_event_loop_create_default());
@@ -127,7 +127,7 @@ void wifi_init()
127127
// Enable DNS (offer) for dhcp server
128128
dhcps_offer_t dhcps_dns_value = OFFER_DNS;
129129
dhcps_set_option_info(6, &dhcps_dns_value, sizeof(dhcps_dns_value));
130-
130+
131131
ESP_ERROR_CHECK(esp_wifi_start());
132132

133133
if (strlen(ssid) > 0)

0 commit comments

Comments
 (0)