[Python] Connect paho-mqtt using an existing python socket object

Discussão em 'Python' iniciado por Stack, Abril 26, 2025.

  1. Stack

    Stack Membro Participativo

    I am using a LuckFox Pico Mino board.

    https://wiki.luckfox.com/Luckfox-Pico/Luckfox-Pico-GPIO/

    This board runs Ubuntu but does not have a network.

    This board can obtain a python low level socket object using the W5500 SPI Ethernet module.

    So, can I use the python low level socket object obtained in this way with mqtt-paho or other mqtt library?

    import board
    import busio
    import digitalio
    import adafruit_connection_manager
    from adafruit_wiznet5k.adafruit_wiznet5k import WIZNET5K

    # Initialize module
    cs_pin = digitalio.DigitalInOut(board.G54)
    reset_pin = digitalio.DigitalInOut(board.G55)
    spi_bus = busio.SPI(board.SCLK, MOSI=board.MOSI, MISO=board.MISO)

    # Initialize ethernet interface with DHCP
    #eth = WIZNET5K(spi_bus, cs)
    eth = WIZNET5K(spi_bus, cs=cs_pin, reset=reset_pin, mac='DE:AD:BE:EF:FE:ED')

    # Initialize socket
    socket = adafruit_connection_manager.get_radio_socketpool(eth)
    # I want to use this python low level socket object with paho or other mqtt library

    Continue reading...

Compartilhe esta Página