Creating an MQTT and HTTP component in 'esp-thread-br' cannot connect (TZ-1173)
Closed this issue · 2 comments
Checklist
- Checked the issue tracker for similar issues to ensure this is not a duplicate.
- Provided a clear description of your suggestion.
- Included any relevant context or examples.
Issue or Suggestion Description
The border router has been set up and thread devices can be seen on the web. However, I want to add my own components, HTTP and MQTT components, based on the SDK, but the connection has failed. The problem I am looking for seems to be related to DNS. Is there a way to develop my own HTTP and MQTT functions on the border router?
IDF VER :V5.3.1
error: esp-tls: [sock=57] connect() error: Host is unreachable
log:
(27) boot: compile time Sep 25 2024 11:53:23
I (27) boot: Multicore bootloader
I (27) boot: chip revision: v0.1
I (27) boot.esp32s3: Boot SPI Speed : 80MHz
I (28) boot.esp32s3: SPI Mode : DIO
I (28) boot.esp32s3: SPI Flash Size : 4MB
I (28) boot: Enabling RNG early entropy source...
I (28) boot: Partition Table:
I (28) boot: ## Label Usage Type ST Offset Length
I (29) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (29) boot: 1 otadata OTA data 01 00 0000f000 00002000
I (30) boot: 2 phy_init RF data 01 01 00011000 00001000
I (30) boot: 3 ota_0 OTA app 00 10 00020000 00190000
I (30) boot: 4 ota_1 OTA app 00 11 001b0000 00190000
I (31) boot: 5 web_storage Unknown data 01 82 00340000 00019000
I (31) boot: 6 rcp_fw Unknown data 01 82 00359000 000a0000
I (32) boot: End of partition table
I (32) boot: No factory image, trying OTA 0
I (32) esp_image: segment 0: paddr=00020020 vaddr=3c110020 size=5a5c4h (370116) map
I (99) esp_image: segment 1: paddr=0007a5ec vaddr=3fc99c00 size=054e4h ( 21732) load
I (104) esp_image: segment 2: paddr=0007fad8 vaddr=40374000 size=00540h ( 1344) load
I (105) esp_image: segment 3: paddr=00080020 vaddr=42000020 size=108bb8h (1084344) map
I (300) esp_image: segment 4: paddr=00188be0 vaddr=40374540 size=1567ch ( 87676) load
I (328) boot: Loaded app from partition at offset 0x20000
I (390) boot: Set actual ota_seq=1 in otadata[0]
I (390) boot: Disabling RNG early entropy source...
I (392) cpu_start: Multicore app
I (400) cpu_start: Pro cpu start user code
I (401) cpu_start: cpu freq: 160000000 Hz
I (401) app_init: Application information:
I (401) app_init: Project name: esp_ot_br
I (401) app_init: App version: v1.1-dirty
I (401) app_init: Compile time: Sep 25 2024 15:43:49
I (402) app_init: ELF file SHA256: eb7e26859...
I (402) app_init: ESP-IDF: v5.3.1
I (402) efuse_init: Min chip rev: v0.0
I (402) efuse_init: Max chip rev: v0.99
I (402) efuse_init: Chip rev: v0.1
I (402) heap_init: Initializing. RAM available for dynamic allocation:
I (403) heap_init: At 3FCAF788 len 00039F88 (231 KiB): RAM
I (403) heap_init: At 3FCE9710 len 00005724 (21 KiB): RAM
I (403) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
I (404) heap_init: At 600FE100 len 00001EE8 (7 KiB): RTCRAM
I (405) spi_flash: detected chip: generic
I (405) spi_flash: flash io: dio
I (406) sleep: Configure to isolate all GPIO pins in sleep state
I (406) sleep: Enable automatic switching of GPIO sleep configuration
I (407) main_task: Started on CPU0
I (417) main_task: Calling app_main()
I (477) RCP_UPDATE: RCP: using update sequence 0
I (477) uart: ESP_INTR_FLAG_IRAM flag not set while CONFIG_UART_ISR_IN_IRAM is enabled, flag updated
I (477) OPENTHREAD: spinel UART interface initialization completed
I (477) user_task_handler: User Task Handler Initialize ..
I (477) user_task_handler: wait wifi connecting ..
I (477) main_task: Returned from app_main()
I(477) OPENTHREAD:[I] P-SpinelDrive-: co-processor reset: RESET_POWER_ON
E(487) OPENTHREAD:[C] P-SpinelDrive-: Software reset co-processor successfully
I(527) OPENTHREAD:[I] ChildSupervsn-: Timeout: 0 -> 190
I(547) OPENTHREAD:[I] Settings------: Read NetworkInfo {rloc:0x3c00, extaddr:9ad950a49c2e7195, role:leader, mode:0x0f, version:5, keyseq:0x0, ...
I(547) OPENTHREAD:[I] Settings------: ... pid:0x581dbf09, mlecntr:0x231f6, maccntr:0x22050, mliid:7767fa2492b839ea}
I(557) OPENTHREAD:[I] Settings------: Read ChildInfo {rloc:0x3c01, extaddr:d2f7668e06a72b43, timeout:240, mode:0x0f, version:5}
I (567) esp_ot_br: Internal RCP Version: openthread-esp32/c8fc5f643b-f32c18bc0; esp32h2; 2024-09-25 03:49:56 UTC
I (567) esp_ot_br: Running RCP Version: openthread-esp32/c8fc5f643b-f32c18bc0; esp32h2; 2024-09-25 03:49:56 UTC
I (577) OPENTHREAD: OpenThread attached to netif
I (577) esp_ot_br: use the Wi-Fi config from NVS
I (577) pp: pp rom version: e7ae62f
I (597) net80211: net80211 rom version: e7ae62f
I (607) wifi:wifi driver task: 3fcc4754, prio:23, stack:6144, core=0
I (607) wifi:wifi firmware version: ccaebfa
I (607) wifi:wifi certification version: v7.0
I (607) wifi:config NVS flash: enabled
I (607) wifi:config nano formating: enabled
I (607) wifi:Init data frame dynamic rx buffer num: 32
I (607) wifi:Init static rx mgmt buffer num: 5
I (607) wifi:Init management short buffer num: 32
I (607) wifi:Init dynamic tx buffer num: 32
I (617) wifi:Init static tx FG buffer num: 2
I (617) wifi:Init static rx buffer size: 1600
I (617) wifi:Init static rx buffer num: 10
I (617) wifi:Init dynamic rx buffer num: 32
I (617) wifi_init: rx ba win: 6
I (617) wifi_init: accept mbox: 6
I (617) wifi_init: tcpip mbox: 32
I (627) wifi_init: udp mbox: 6
I (637) wifi_init: tcp mbox: 6
I (637) wifi_init: tcp tx win: 5760
I (637) wifi_init: tcp rx win: 5760
I (637) wifi_init: tcp mss: 1440
I (637) wifi_init: WiFi IRAM OP enabled
I (637) wifi_init: WiFi RX IRAM OP enabled
I (637) phy_init: phy_version 680,a6008b2,Jun 4 2024,16:41:10
I (687) wifi:mode : sta (34:85:18:7e:7c:ec)
I (687) wifi:enable tsf
I (687) wifi:Set ps type: 2, coexist: 0
I (687) ot_ext_cli: wifi handler registered
I (697) ot_ext_cli: Start example_connect
I (697) example_connect: Connecting to Gerlsair_XizhenElec...
W (697) wifi:Password length matches WPA2 standards, authmode threshold changes from OPEN to WPA2
I (717) example_connect: Waiting for IP(s)
I (3577) wifi:new:<7,0>, old:<1,0>, ap:<255,255>, sta:<7,0>, prof:1, snd_ch_cfg:0x0
I (3577) wifi:state: init -> auth (0xb0)
I (3587) wifi:state: auth -> assoc (0x0)
I (3587) wifi:state: assoc -> run (0x10)
I (3597) wifi:connected with Gerlsair_XizhenElec, aid = 16, channel 7, BW20, bssid = 08:bf:b8:65:4b:b8
I (3597) wifi:security: WPA2-PSK, phy: bgn, rssi: -34
I (3597) wifi:pm start, type: 2
I (3597) wifi:dp: 1, bi: 102400, li: 3, scale listen interval from 307200 us to 307200 us
I (3607) wifi:set rx beacon pti, rx_bcn_pti: 0, bcn_timeout: 25000, mt_pti: 0, mt_time: 10000
I (3607) ot_ext_cli: OT WIFI CONNECTED ..
I (3617) https_get: http url :http://cloud.rpc-test.xizhenelec.com/xz/v1/device/allocation/mqtt/address/auth?deviceId=xz.81ma1.2024301
E (3617) esp-tls: couldn't get hostname for :cloud.rpc-test.xizhenelec.com: getaddrinfo() returns 202, addrinfo=0
I (3617) wifi:idx:0 (ifx:0, 08:bf:b8:65:4b:b8), tid:6, ssn:1, winSize:64
E (3617) transport_base: Failed to open a new connection: 32769
E (3627) HTTP_CLIENT: Connection failed, sock < 0
I (3627) https_get: HTTP GET request failed: ESP_ERR_HTTP_CONNECT
I (3677) wifi:AP's beacon interval = 102400 us, DTIM period = 1
I (4607) obtr_web: <=======================server start========================>
I (4607) obtr_web: http://192.168.50.56:80/index.html
I (4607) obtr_web: <===========================================================>
I (4607) esp_netif_handlers: example_netif_sta ip: 192.168.50.56, mask: 255.255.255.0, gw: 192.168.50.1
I (4627) example_connect: Got IPv4 event: Interface "example_netif_sta" address: 192.168.50.56
I (5477) example_connect: Got IPv6 event: Interface "example_netif_sta" address: fe80:0000:0000:0000:3685:18ff:fe7e:7cec, type: ESP_IP6_ADDR_IS_LINK_LOCAL
I(5477) OPENTHREAD:[N] RoutingManager: BR ULA prefix: fd68:f704:dc7b::/48 (loaded)
I(5487) OPENTHREAD:[N] RoutingManager: Local on-link prefix: fdde:ad00:beef:cafe::/64
I (5497) OPENTHREAD: Platform UDP bound to port 49153
I(5497) OPENTHREAD:[N] Mle-----------: Role disabled -> detached
I (5517) OT_STATE: netif up
I (5517) OPENTHREAD: NAT64 ready
I (8647) https_get: http url :http://cloud.rpc-test.xizhenelec.com/xz/v1/device/allocation/mqtt/address/auth?deviceId=xz.81ma1.2024301
I (8657) wifi:idx:1 (ifx:0, 08:bf:b8:65:4b:b8), tid:0, ssn:1, winSize:64
E (8667) esp-tls: [sock=57] connect() error: Host is unreachable
E (8667) transport_base: Failed to open a new connection: 32772
E (8667) HTTP_CLIENT: Connection failed, sock < 0
@MaplestoryAlen Could you remove this line: https://github.com/espressif/esp-thread-br/blob/main/examples/common/thread_border_router/src/border_router_launch.c#L171, rebuild and rerun your test? The issue maybe caused by the default netif configuration.
@MaplestoryAlen Could you remove this line: https://github.com/espressif/esp-thread-br/blob/main/examples/common/thread_border_router/src/border_router_launch.c#L171, rebuild and rerun your test? The issue maybe caused by the default netif configuration.
Delete ESP-ERROR_CECK (esp_netif_set_default_netif (openthread_netif)); HTTP and MQTT can be used, but there is a new problem encountered, which is the flash space issue
Because my firmware is larger than 4M, I need to modify the flash space, which will result in the inability to download. I tried setting the flash size to 8M and 16M, but the same situation persisted. Even turning off rcp_update did not allow the download.
log:
alen@lee:~/esp-thread-br/examples/basic_thread_border_router$ idf.py -p /dev/ttyACM0 flash monitor
Executing action: flash
Running ninja in directory /home/alen/esp-thread-br/examples/basic_thread_border_router/build
Executing "ninja flash"...
[1/6] cd /home/alen/esp-thread-br/examples/basic_thread_border_ro...thread-br/examples/basic_thread_border_router/build/esp_ot_br.bin
esp_ot_br.bin binary size 0x1c76a0 bytes. Smallest app partition is 0x28a000 bytes. 0xc2960 bytes (30%) free.
[1/1] cd /home/alen/esp-thread-br/examples/basic_thread_border_ro...amples/basic_thread_border_router/build/bootloader/bootloader.bin
Bootloader binary size 0x51c0 bytes. 0x2e40 bytes (36%) free.
[3/4] cd /home/alen/esp-idf/components/esptool_py && /usr/bin/cma...-P /home/alen/esp-idf/components/esptool_py/run_serial_tool.cmake
esptool.py --chip esp32s3 -p /dev/ttyACM0 -b 460800 --before=default_reset --after=hard_reset --no-stub write_flash --flash_mode dio --flash_freq 80m --flash_size 8MB 0x0 bootloader/bootloader.bin 0x20000 esp_ot_br.bin 0x8000 partition_table/partition-table.bin 0xf000 ota_data_initial.bin 0x53a000 web_storage.bin
esptool.py v4.8.1
Serial port /dev/ttyACM0
Connecting...
Chip is ESP32-S3 (QFN56) (revision v0.1)
Features: WiFi, BLE, Embedded PSRAM 2MB (AP_3v3)
Crystal is 40MHz
MAC: 34:85:18:7e:7c:ec
Changing baud rate to 460800
Changed.
Enabling default SPI flash mode...
Configuring flash size...
WARNING: Set --flash_size 8MB is larger than the available flash size of 4MB.
A fatal error occurred: File web_storage.bin (length 102400) at offset 5480448 will not fit in 4194304 bytes of flash. Change the --flash_size argument, or flashing address.
CMake Error at run_serial_tool.cmake:66 (message):
/home/alen/.espressif/python_env/idf5.3_py3.10_env/bin/python;;/home/alen/esp-idf/components/esptool_py/esptool/esptool.py;--chip;esp32s3
failed.