Query
168
SWRU455A – February 2017 – Revised March 2017
Copyright © 2017, Texas Instruments Incorporated
mDNS
10.4 Query
The SimpleLink Wi-Fi device can discover remote services on the local network. The discovery is
performed by sending one-shot or continuous queries. The queries are transmitted on IPv4 or IPv6
interfaces, according to the host request and configuration.
10.4.1 One Shot Query
The SimpleLink Wi-Fi device can issue one-shot queries in which the device triggers only a single mDNS
query to the network by calling the API sl_NetAppDnsGetHostByService. The query can be set as IPv4 or
IPv6 (If enabled) format, or both. A discovery result returns the first response received with information
regarding the remote service: IP address, port, and service text description.
Example:
_i16 Status;
_i8 query[] = "_http._tcp.local";
_u32 addr;
_u32 Port
= 0;
_u16 TextLen = 800;
_i8
pText[800];
Status =
sl_NetAppDnsGetHostByService(query, (
unsigned char
)strlen(&query[0]), SL_AF_INET,
&addr, &Port, &TextLen,pText);
if
( Status )
{
/* Error */
}
10.4.2 Continuous Query
In a continuous mDNS query mode, the device keeps sending queries to the network according to a
specific service name. The queries are sent in IPv4 and IPv6 (if enabled) formats or both. To see the
complete list of responding services, sl_NetAppGetServiceList must be called. To stop the continuous
query, call the same API with length 0.
Continuous query configuration is persistent by default, and can be set according to a system-persistent
configuration.
Example:
_i16 Status;
_i8 query[] = "_http._tcp.local";
/* Start continues query */
Status = sl_NetAppSet(SL_NETAPP_MDNS_ID, SL_NETAPP_MDNS_CONT_QUERY_OPT, (
unsigned
char
)strlen(&query[0]), query);
if( Status )
{
/* Error */
}
/* Stop continues query */
Status = sl_NetAppSet(SL_NETAPP_MDNS_ID, SL_NETAPP_MDNS_CONT_QUERY_OPT,0
, 0); /* Set length to
zero to stop continuous query */
if
( Status )
{
/* Error */
}
10.4.3 Mask Services
The SimpleLink Wi-Fi device offers the ability to predefine specific services types to monitor. If the host
application decides not to get responses from certain types of services (not stored in the cache), the adapt
bit can be set in the event mask related to according to the following list: