This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC3200AUDBOOST: Detect two separate streaming devices on the network

Part Number: CC3200AUDBOOST
Other Parts Discussed in Thread: CC3200

Hi Vincent,

I have been exploring the wifi_audio_app source code. The following code snippet looks like what detects the hosts (2 x streaming devices) in the network. In my case I will have two streaming devices. Would sl_NetAppDnsGetHostByService function return two IP addresses if there are two devices configured with audio service? This function is in network.c

void mDNS_Task()
{
    int lRetValmDNS;
    unsigned int pAddr;
    unsigned long usPort;
    unsigned short     ulTextLen = 200;
    char cText[201]; 

 
    //UnRegister mDNS Service if done Previously
    lRetValmDNS = sl_NetAppMDNSUnRegisterService((signed char *)CC3200_MDNS_NAME,
                              strlen(CC3200_MDNS_NAME));

    while(1)
    {  
        lRetValmDNS = 1;
        
        //Read mDNS service.
        while(lRetValmDNS)
        {
            ulTextLen = 200;
            lRetValmDNS = sl_NetAppDnsGetHostByService((signed char *) \
                                    CC3200_MDNS_NAME,
                                    strlen((const char *)CC3200_MDNS_NAME),
                                    SL_AF_INET,(unsigned long *)&pAddr,&usPort,
                                    &ulTextLen,(signed char *)&cText[0]);
        }
        if(lRetValmDNS == 0 && (pAddr!=INVALID_CLIENT_ADDRESS) && \
                                                 (pAddr!=g_uiIpAddress))
        {               
             //Speaker Detected - Add Client
             g_UdpSock.Client.sin_family = AF_INET;
             g_UdpSock.Client.sin_addr.s_addr = htonl(pAddr);
             g_UdpSock.Client.sin_port = htons(usPort);
             g_UdpSock.iClientLength = sizeof(g_UdpSock.Client);

             g_loopback = 0;

        }
         
             MAP_UtilsDelay(80*1000*100);
    }    
}

Thanks 

Shavinda

  • Shavinda,

    No, this will only return one IP address with that host name for MDNS. You would need to create a list and loop through GetServiceList() function to get more than one IP Address.

    BR,
    Vince
  • Hi Vincent,

    Thanks for the prompt reply. Is my understanding correct here?

    In the wifi_audio_app mDNS advertiser is the speaker device which advertises with the service "CC3200._audio._udp.local." Then the MIC side uses sl_NetAppDnsGetHostByService to detect the speaker device. Is there a reason for mDNS advertising to be done on the speaker side? I think that this can be done on either side. Based on this observation I decided to do the following. 

    The streaming device 1 will advertise with the service "CC3200._audio_stream1._udp.local." at PORT 5050" The streaming device 2 will advertise with the service "CC3200._audio_stream2._udp.local." at PORT 5051. 

    #ifndef MULTICAST          
                        lRetVal = sendto(g_UdpSock.iSockDesc, \
                                           (char*)(pRecordBuffer->pucReadPtr),PACKET_SIZE,\
                                           0,(struct sockaddr*)&(g_UdpSock.Client),\
                                           sizeof(g_UdpSock.Client));
                        if(lRetVal < 0)
                        {
                            UART_PRINT("Unable to send data\n\r");
                            LOOP_FOREVER();
                        }
    
    #else	//MULTICAST

    I think I can use sendto function from each streaming device to send the data out. The information about the service port is also passed to this function via g_UdpSock.Client right?

    On the receiver side I'll use GetServiceList() function and identify IP address of these specific device and the port of service. I can use recvfrom twice to receive each stream from their respective port. I can use receive function twice to read audio data from respective ports. 

                        g_iRetVal = recvfrom(g_UdpSock.iSockDesc, (char*)(speaker_data),\
                                              PACKET_SIZE*16, 0,\
                                              (struct sockaddr *)&(g_UdpSock.Client),\
                                              (SlSocklen_t*)&(g_UdpSock.iClientLength));

    Does this understanding make sense to you?

    Thanks

    Shavinda 

  • Shavinda,

    Your thoughts are valid. The reason we do mdns service on both devices is because the demo allows for bidirectional audio streaming.

    BR,

    Vince