0

I am trying to make an application that discovers my Yeelight devices via SSDP multicasting. According to their specification, I need to send the message to 239.255.255.250 on port 1982. The code you see here works perfect on both of my MacOS machines, but on Windows, it does nothing anymore. It worked before, but now when I came back to it after 2 days of not touching it, it stopped working.

I suspect this has something to do with Windows blocking something, but I can't figure it out.

import socket
import threading

from pprint import pprint
from time import sleep
from colorama import Fore, Style

discoveryAddress = ("239.255.255.250", 1982)
discoveryMessage = "M-SEARCH * HTTP/1.1\r\n" + "HOST: 239.255.255.250:1982\r\n" + \
    "MAN: \"ssdp:discover\"\r\n" + "ST: wifi_bulb\r\n"


def doSearch():
    ssdpSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
    ssdpSocket.sendto(str.encode(discoveryMessage), discoveryAddress)

    while True:
        response = ssdpSocket.recvfrom(1024)
        msg = format(response[0])
        formattedResponse = formatResponse(msg.split('\\r\\n'))

        print("hi")

        print(Fore.GREEN, "Received response")
        print(Fore.WHITE, formattedResponse, '\n')


def formatResponse(response: list) -> list:
    result = []
    filteredAttr = ['HTTP', 'Location:', 'power:']

    for s in response:
        for attr in filteredAttr:
            if attr in s:
                result.append(s)

    return result


doSearch()

I have tried making exceptions in my Firewall, turning off my anti virus, tested the application on two mac machines.

  • Please post the error. – Christoph Fischer Nov 07 '22 at 10:51
  • @ChristophFischer there is no error, nothing happens. In wireshark, I can see that the packets are being sent, but nothing ever arrives back from the device. It seems to me like Windows blocks it. I read something about that unicast responses to multicast messages are forbidden, and the device sends a unicast response. Is there a workaround there? – Daanooo Nov 08 '22 at 11:07

0 Answers0