none
Miracast over Infrastructure Sink RTSP RRS feed

  • Question

  • Hi,

    i would like to implement a Miracast over Infrastructure Sink with UWP on IoT. I just need RTSP stream, so I can´t use the implementation of MS.

    I recorded a working implementation with Wireshark, see below:

    I have tried to rebuild this with UWP

    private void StartWifi()
            {
                string serviceName = Dns.GetHostName();
                var msg = GetMessage(serviceName, "192.168.1.115");
                var ie = new Windows.Devices.WiFiDirect.WiFiDirectInformationElement()
                {
                    Oui = (new byte[] { 0x00, 0x01, 0x37 }).AsBuffer(),
                    OuiType = 0x01,
                    Value = msg
                };
    
                var publisher = new Windows.Devices.WiFiDirect.WiFiDirectAdvertisementPublisher();
    
                publisher.Advertisement.LegacySettings.IsEnabled = true;
                publisher.Advertisement.LegacySettings.Ssid = serviceName;
                publisher.Advertisement.InformationElements.Add(ie);
                publisher.Advertisement.IsAutonomousGroupOwnerEnabled = true;
                publisher.Advertisement.ListenStateDiscoverability = Windows.Devices.WiFiDirect.WiFiDirectAdvertisementListenStateDiscoverability.Intensive;
    
                var wifiListner = new Windows.Devices.WiFiDirect.WiFiDirectConnectionListener();
    
                publisher.Start();
            }
    
            IBuffer GetMessage(string host, string ip)
            {
                DataWriter dataWriter = new DataWriter
                {
                    UnicodeEncoding = Windows.Storage.Streams.UnicodeEncoding.Utf8,
                    ByteOrder = ByteOrder.BigEndian
                };
    
                var venMsg = new byte[] { 0x10, 0x49 };
                var capMsg = new byte[] { 0x00, 0x01, 0x37, 0x20, 0x01, 0x00, 0x01, 0x05 };
    
                //Host
                var hostMsg = new byte[] { 0x20, 0x02 };
                var hostLen = dataWriter.MeasureString(host);
    
                //IP
                var ipMsg = new byte[] { 0x20, 0x05 };
                var ipLength = dataWriter.MeasureString(ip);
    
                var dataLength = capMsg.Length + hostMsg.Length + (hostLen + 2) + (ipMsg.Length + ipLength);
                dataWriter.WriteBytes(venMsg);
                dataWriter.WriteUInt16((ushort)dataLength);
                dataWriter.WriteBytes(capMsg);
    
                dataWriter.WriteBytes(hostMsg);
                dataWriter.WriteUInt16((ushort)hostLen);
                dataWriter.WriteString(host);
    
                dataWriter.WriteBytes(ipMsg);
                dataWriter.WriteUInt16((ushort)ipLength);
                dataWriter.WriteString(ip);
    
                return dataWriter.DetachBuffer();
            }

    Result:


    If I try as OUI: 0x00, 0x50, 0xF2 (MS WPS), the publisher won´t start.

    Another solution for publisher would be right for me (PowerShell, Registry, C++, whatever).

    I just would like to take over from projection.


    Gruß Thomas
    13 Millionen Schweine landen jährlich im Müll
    Dev Apps von mir: UWP Segoe MDL2 Assets, UI Strings

    Thursday, July 11, 2019 10:44 PM

All replies

  • Hello Thomas Wycichowski,

    May I confirm with you about following questions:

    1. Could the publisher start on desktop?

    2. Did you refer to this sample(https://github.com/microsoft/Windows-universal-samples/tree/master/Samples/WiFiDirect)? 

    3. From this document, the value of OUI is 0x000137 for messages defined by specification. Did you try to catch any exception when the publisher starts?

    Best Regards,

    Michael


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, July 12, 2019 4:30 AM
  • Hi Michael,

    on desktop the service starts, but it won´t if I enter OUI MS WPS.

    In this case a wrong vendor starts. 

    With the value of OUI 0x000137 a wrong vendor is taken.

    My service should be found in projection (win+p / wireless device).

    I know the sample, but it´s not helpful for my problem.

    Thanks 


    Gruß Thomas
    13 Millionen Schweine landen jährlich im Müll
    Dev Apps von mir: UWP Segoe MDL2 Assets, UI Strings

    Friday, July 12, 2019 9:57 PM
  • Hello Thomas,

    Which WiFi module did you use? And are you sure the WiFi direct is supported or enabled on you device?

    Best Regards,

    Michael


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Monday, July 15, 2019 9:03 AM
  • Hello Michael,

    i am use a Laptop and Raspberry PI 3B. Wifi Direct ist supported and enable. That is not the problem.

    Wi-Fi Simple Configuration must this structure 

    DD<Length>0050F204<Data> (1049<Length>000137...)


    Gruß Thomas
    13 Millionen Schweine landen jährlich im Müll
    Dev Apps von mir: UWP Segoe MDL2 Assets, UI Strings

    Wednesday, July 17, 2019 3:30 AM
  • Hello Thomas,

    So the problem is the app works fine on PC, but it does not work in Windows IoT Core?

    Best Regards,

    Michael


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, July 18, 2019 8:55 AM
  • Hello Michael,

    her a simple code demo

    public MainPage()
    {
        this.InitializeComponent();
    
        //TestWifiNotWork();
        //TestWifiWorkFine();
    }
    
    void TestWifiNotWork()
    {
        var ie = new Windows.Devices.WiFiDirect.WiFiDirectInformationElement()
        {
            Oui = (new byte[] { 0x00, 0x50, 0xf2 }).AsBuffer(),
            OuiType = 0x04,
            Value = (new byte[] { 0x00, 0x37, 0x2a, 0x00, 0x01, 0x20 }).AsBuffer()
        };
    
        var publisher = new Windows.Devices.WiFiDirect.WiFiDirectAdvertisementPublisher();
    
        publisher.Advertisement.LegacySettings.IsEnabled = true;
        publisher.Advertisement.LegacySettings.Ssid = "Uwp Wifi Test";
        publisher.Advertisement.InformationElements.Add(ie);
        publisher.Advertisement.IsAutonomousGroupOwnerEnabled = true;
        publisher.Advertisement.ListenStateDiscoverability = Windows.Devices.WiFiDirect.WiFiDirectAdvertisementListenStateDiscoverability.Intensive;
    
        publisher.Start();
    }
    
    void TestWifiWorkFine()
    {
        //This is work but OUI is wrong
        var ie = new Windows.Devices.WiFiDirect.WiFiDirectInformationElement()
        {
            Oui = (new byte[] { 0x00, 0x50, 0xf3 }).AsBuffer(), //Oui from 0x0050f2 > 0x0050f3
            OuiType = 0x04,
            Value = (new byte[] { 0x00, 0x37, 0x2a, 0x00, 0x01, 0x20 }).AsBuffer()
        };
    
        var publisher = new Windows.Devices.WiFiDirect.WiFiDirectAdvertisementPublisher();
    
        publisher.Advertisement.LegacySettings.IsEnabled = true;
        publisher.Advertisement.LegacySettings.Ssid = "Uwp Wifi Test";
        publisher.Advertisement.InformationElements.Add(ie);
        publisher.Advertisement.IsAutonomousGroupOwnerEnabled = true;
        publisher.Advertisement.ListenStateDiscoverability = Windows.Devices.WiFiDirect.WiFiDirectAdvertisementListenStateDiscoverability.Intensive;
    
        publisher.Start();
    }


    Gruß Thomas
    13 Millionen Schweine landen jährlich im Müll
    Dev Apps von mir: UWP Segoe MDL2 Assets, UI Strings

    Thursday, July 18, 2019 9:53 AM