How to use the umqtt.simple in other socket
I am use the esp32 and w5500 eth module. But I am using a third-party driver().
The socket of third-party drivers does not include the read and write method
How can I make umqtt.simple support this socket
MQTT on LAN using ESP32
Can I use the umqtt.simple library on ESP32 DevkitC with LAN as my network?
I tried using this library and it generated an error for connect():
`
from machine import Pin
import micropython,network,time
led = Pin(32, Pin.OUT, value=1)
l = network.LAN(mdc = Pin(23), mdio = Pin(18), power = Pin(17), phy_type = network.PHY_LAN8720, phy_addr=1)
I (17267) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
l.active(1)
I (18487) emac: emac reset done
True
I (18487) ethernet: start
I (22487) ethernet: LAN cable connected
I (23237) event: eth ip: 192.168.29.37, mask: 255.255.255.0, gw: 192.168.29.1
I (23237) ethernet: Got IP
from umqtt.simple import MQTTClient
I (49577) modsocket: Initializing
SERVER = "broker.mqttdashboard.com"
CLIENT_ID = "6pPjrbwL6h"
TOPIC = "testtopic/1"
c = MQTTClient(CLIENT_ID, SERVER)
c.connect()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "umqtt/simple.py", line 105, in connect
IndexError: bytes index out of range
`
On checking the library i found out that the error is generated on line :
resp = self.sock.read(4)
Have you checked this discussion https://github.com/orgs/micropython/discussions/11474? Since MicroPython version 1.20.0 the W5500 is supported by MicroPython (from Espressif ESP-IDF implementation). So I think that if you use that, everything else (like as mqtt client and any other protocol, including ssl) will be transparent because that espressif W5500 implementation (and micropython support) is using a raw ethernet implementation.
Can anyone confirm if what I did write is correct?
I have reviewed the discussion, but I have only succeeded with the code in the discussion once. Even if the same code is used after the second attempt, it cannot connect to the network and can cause SPI blocking. I do not understand why this is the case. Even if SPI is available after a power outage and restart, ETH still cannot obtain the IP, so I can only try using a third-party driver
Under the same code, there will always be an OSError prompt: Ethernet enable failed. I guess it's a problem with SPI blocking. How can I avoid this problem.
When I am in the shell, I can obtain the IP address, but when I use thorny to actually execute it, it cannot work