After I flash it into esp32-c3 develop board, it can connect wifi and got ip successfully
But it stopped here, mqtt app didn't start
I put a esp_log in mqtt_app_start() function, it didn't print in terminal
How to start mqtt?
I (264) boot: Loaded app from partition at offset 0x10000
I (264) boot: Disabling RNG early entropy source...
I (276) cpu_start: Unicore app
I (285) cpu_start: Pro cpu start user code
I (285) cpu_start: cpu freq: 160000000 Hz
I (285) app_init: Application information:
I (288) app_init: Project name: mqtt_tcp
I (293) app_init: App version: 1
I (297) app_init: Compile time: Apr 23 2025 10:53:34
I (303) app_init: ELF file SHA256: e7f7e6213...
I (308) app_init: ESP-IDF: v5.3.1
I (313) efuse_init: Min chip rev: v0.3
I (318) efuse_init: Max chip rev: v1.99
I (323) efuse_init: Chip rev: v1.1
I (328) heap_init: Initializing. RAM available for dynamic allocation:
I (335) heap_init: At 3FC9A650 len 000259B0 (150 KiB): RAM
I (341) heap_init: At 3FCC0000 len 0001C710 (113 KiB): Retention RAM
I (348) heap_init: At 3FCDC710 len 0000294C (10 KiB): Retention RAM
I (355) heap_init: At 50000200 len 00001DE8 (7 KiB): RTCRAM
I (362) spi_flash: detected chip: generic
I (366) spi_flash: flash io: dio
W (370) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (383) sleep: Configure to isolate all GPIO pins in sleep state
I (390) sleep: Enable automatic switching of GPIO sleep configuration
I (397) main_task: Started on CPU0
I (407) main_task: Calling app_main()
I (407) mqtt_example: [APP] Startup..
I (407) mqtt_example: [APP] Free memory: 272468 bytes
I (407) mqtt_example: [APP] IDF version: v5.3.1
I (417) example_connect: Start example_connect.
I (417) pp: pp rom version: 74f9620
I (427) net80211: net80211 rom version: 74f9620
I (437) wifi:wifi driver task: 3fca2e78, prio:23, stack:6656, core=0
I (437) wifi:wifi firmware version: ccaebfa
I (437) wifi:wifi certification version: v7.0
I (447) wifi:config NVS flash: enabled
I (447) wifi:config nano formating: disabled
I (447) wifi:Init data frame dynamic rx buffer num: 32
I (457) wifi:Init static rx mgmt buffer num: 5
I (457) wifi:Init management short buffer num: 32
I (467) wifi:Init dynamic tx buffer num: 32
I (467) wifi:Init static tx FG buffer num: 2
I (477) wifi:Init static rx buffer size: 1600
I (477) wifi:Init static rx buffer num: 10
I (477) wifi:Init dynamic rx buffer num: 32
I (487) wifi_init: rx ba win: 6
I (487) wifi_init: accept mbox: 6
I (497) wifi_init: tcpip mbox: 32
I (497) wifi_init: udp mbox: 6
I (497) wifi_init: tcp mbox: 6
I (507) wifi_init: tcp tx win: 5760
I (507) wifi_init: tcp rx win: 5760
I (517) wifi_init: tcp mss: 1440
I (517) wifi_init: WiFi IRAM OP enabled
I (517) wifi_init: WiFi RX IRAM OP enabled
I (527) phy_init: phy_version 1180,01f2a49,Jun 4 2024,16:34:25
I (567) wifi:mode : sta (18:8b:0e:88:81:cc)
I (567) wifi:enable tsf
I (567) example_connect: Connecting to ZTE_E0D5B6...
W (567) wifi:Password length matches WPA2 standards, authmode threshold changes from OPEN to WPA2
I (577) example_connect: Waiting for IP(s)
I (3267) wifi<1,0>, old:<1,0>, ap:<255,255>, sta:<1,0>, prof:1, snd_ch_cfg:0x0
I (3267) wifi:state: init -> auth (0xb0)
I (3267) wifi:state: auth -> assoc (0x0)
I (3287) wifi:state: assoc -> run (0x10)
I (3307) wifi:connected with ZTE_E0D5B6, aid = 8, channel 1, BW20, bssid = 10:3c:59:e0:d5:b6
I (3307) wifi:security: WPA2-PSK, phy: bgn, rssi: -32
I (3307) wifi:pm start, type: 1
I (3307) wifi:dp: 1, bi: 102400, li: 3, scale listen interval from 307200 us to 307200 us
I (3317) wifi:set rx beacon pti, rx_bcn_pti: 0, bcn_timeout: 25000, mt_pti: 0, mt_time: 10000
I (3327) wifi:AP's beacon interval = 102400 us, DTIM period = 3
I (4337) esp_netif_handlers: example_netif_sta ip: 192.168.0.134, mask: 255.255.255.0, gw: 192.168.0.1
I (4337) example_connect: Got IPv4 event: Interface "example_netif_sta" address: 192.168.0.134
Code: Select all
static void mqtt_app_start(void)
{
esp_mqtt_client_config_t mqtt_cfg = {
.broker.address.uri = CONFIG_BROKER_URL,
};
ESP_LOGI(TAG, "mqtt_app_start..."); //This is the esp_log which i insert
#if CONFIG_BROKER_URL_FROM_STDIN
char line[128];
if (strcmp(mqtt_cfg.broker.address.uri, "FROM_STDIN") == 0) {
int count = 0;
printf("Please enter url of mqtt broker\n");
while (count < 128) {
int c = fgetc(stdin);
if (c == '\n') {
line[count] = '\0';
break;
} else if (c > 0 && c < 127) {
line[count] = c;
++count;
}
vTaskDelay(10 / portTICK_PERIOD_MS);
}
mqtt_cfg.broker.address.uri = line;
printf("Broker url: %s\n", line);
} else {
ESP_LOGE(TAG, "Configuration mismatch: wrong broker url");
abort();
}
#endif /* CONFIG_BROKER_URL_FROM_STDIN */
esp_mqtt_client_handle_t client = esp_mqtt_client_init(&mqtt_cfg);
/* The last argument may be used to pass data to the event handler, in this example mqtt_event_handler */
esp_mqtt_client_register_event(client, ESP_EVENT_ANY_ID, mqtt_event_handler, NULL);
esp_mqtt_client_start(client);
}