Sony's Developer World forum

    • Home
    • Forum guidelines

    HT-ZF9 API and discovery process

    Audio Control API
    3
    25
    50238
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    This topic has been deleted. Only users with topic management privileges can see it.
    • G
      grolschie @TheFC Company last edited by grolschie

      @TheFC-Company great find! I will have a more thorough look later. I'm no expert on datagrams, but I'm wondering if it has something to do with joining a multicast group vs merely sending a datagram to a multicast address - the latter is what I am doing and numerous other devices do respond.

      Edit: the project also uses a DatagramChannel, which is something I'm unfamiliar with.

      T 1 Reply Last reply Reply Quote
      • T
        TheFC Company @grolschie last edited by

        @grolschie
        I have sent an email to the UPnP Tool guy, he confirm for the github code, here is it's full reply:

        M-SEARCH packet sent from UPnP Tool is like this and you can also check it or more packet logs by clicking "LOG…” Button on the main screen
        https://i.ibb.co/m59w5S3/upnp-tool.jpg
        If you need a java code sending M-SEARCH via datagram socket, please check this code
        https://github.com/bjtj/upnp-java/blob/master/src/main/java/com/tjapp/upnp/SSDPMsearchSender.java
        Above code is mine and very similar to UPnP Tool’s code

        🙂
        So the code that he use is:

        String customQuery = "M-SEARCH * HTTP/1.1\r\n" 
            + "HOST: 239.255.255.250:1900\r\n" 
            + "MAN: \"ssdp:discover\"\r\n"
            + "MX: 3\r\n"
            + "ST: upnp:rootdevice\r\n" 
            + "USER-AGENT: Android/27 UPnP/1.1 UPnPTool/1.5.1"
            + "\r\n";
        

        Unfortunately, that didn't help me to find the device. So we need to dig more in the datagram thing, but I'm not familiar too 😞

        G 1 Reply Last reply Reply Quote
        • G
          grolschie @TheFC Company last edited by

          @TheFC-Company Thanks for the update. I also see that he uses an HttpHeader object rather than just construct a String. Then puts that into a byte array. I wonder why? 🤔

          G 1 Reply Last reply Reply Quote
          • G
            grolschie @grolschie last edited by

            @TheFC-Company any joy? I have had a further look. So the format of that project's SSDP packet is pretty much the same. The HttpHeader object is just a class in the same project that stores key-value pairs.

            Functionally, the only major difference I can see is that he is using a DatagramChannel instead of a DatagramSocket. Hmmm.....

            1 Reply Last reply Reply Quote
            • G
              grolschie last edited by

              I found and fixed a bug in my detection code. I managed to finally get a response from the receiver using the Android emulator, but not from my actual phone. So for now "ssdp:all" shall remain my ST field value.

              1 Reply Last reply Reply Quote
              • G
                grolschie last edited by

                Hi @david. The weirdest thing. Using "ST: urn:schemas-sony.com:service:ScalarWebAPI:1" is now strangely working for me!!!??? I have no idea why! My original search string works (posted back on StackOverflow)!

                I'm wondering if the most recent firmware update for the STR-DN1080 changed something. I'm reluctant to roll out the corrected code in case it actually did and some users haven't updated their firmware. The release notes didn't mention anything.

                Failing that, a library update at my end or something...

                1 Reply Last reply Reply Quote
                • D
                  david DeveloperWorld last edited by

                  @grolschie glad to hear that it is working for you now. Don't know if anything has changed in the last firmware and have limited access to devices right now, but tested on SRS-ZR5 and HT-ZF9 and "urn:schemas-sony-com:service:ScalarWebAPI:1" works for me too (had to resend the query a few times to be sure to get a response). Feels like I get a better response rate now than before, think I only got it to work reliably with "ssdp:all" before, but that is just a feeling...

                  1 Reply Last reply Reply Quote
                  • G
                    grolschie last edited by

                    @david thanks. Sometimes with UDP you may need to send 2 packets in quick succession, because delivery is not guaranteed. That's what I'm doing (I wasn't previously). Also I'm now sending on a different thread to listening for the reply. In doing so, now the socket starts listening for a reply before the first packet gets sent. So no replies should be missed.

                    1 Reply Last reply Reply Quote
                    • G
                      grolschie last edited by grolschie

                      @david You'll never believe this. But today it's not working again! I give up. Back to ssdp:all.
                      ...or maybe not.

                      Discovery:
                      Interestingly, if you replace "ssdp" with any word you get even better results than ssdp:all (i.e. less devices responding), e.g. "ST: blah:all\r\n". And the Sony STR-DN1080's DIAL service does respond to this. LOL! This makes processing the results a lot quicker, especially if you have a lot of devices responding to ssdp:all and you are querying every device's device-desc.xml file for the model name. This might help someone.

                      Edit: actually ST: urn:dial-multiscreen-org:device:dial:1 might be safer.

                      1 Reply Last reply Reply Quote
                      • G
                        grolschie last edited by grolschie

                        Arrgghh!!! The latest firmware update for the STR-DN1080 has removed the DIAL function from the receiver so my detection routine no longer works! The firmware updates the built-in Chromecast Audio device. Doing some UPnP searches, no DIAL device is detected. And the following file is no longer served by the receiver:
                        http://ipaddress:8008/ssdp/device-desc.xml

                        1 Reply Last reply Reply Quote
                        • First post
                          Last post
                        Developer World
                        Copyright © 2021 Sony Group Corporation. All rights reserved.
                        • Contact us
                        • Legal