SWRU368C May 2018 – January 2021 CC3100 , CC3100MOD , CC3200 , CC3200MOD
Besides the default HTTP, users can register up to five mDNS to broadcast. Registration is persistent regardless of NWP being active of not because registration information is permanently stored inside the serial flash. Use sl_NetAppMDNSRegisterService() and sl_NetAppMDNSUnRegisterService() to register and unregister an mDNS service, respectively.
The following example shows the register process:
#define SERVICE_NAME "AAA._uart._tcp.local"
#define SERVICE_NAME2 "BBB._http._tcp.local"
void mDNS_Broadcast()
{
int retVal = 0;
// Start mDNS – not required since it’s started by default.
// However, it’s a good practice just to ensure the mDNS is started. In this
// case, -6 is returned. 0 will be returned if it was stopped previously.
retVal = sl_NetAppStart(SL_NET_APP_MDNS_ID);
// Unregister first, then register to clean up previous registration
// with the same service name.
sl_NetAppMDNSUnRegisterService(SERVICE_NAME, (unsigned char) strlen(SERVICE_NAME));
retVal = sl_NetAppMDNSRegisterService(SERVICE_NAME,
(unsigned char)strlen(SERVICE_NAME),
"Apple",
(unsigned char)strlen("Apple"),
200,
2000,
0x00000001);
Report("MDNS 1 Registered with NAME: %s & ERROR code: %d\n\r",
SERVICE_NAME,
retVal);
//Second registration with a different name
sl_NetAppMDNSUnRegisterService(SERVICE_NAME2,(unsigned char) strlen(SERVICE_NAME2));
retVal = sl_NetAppMDNSRegisterService(SERVICE_NAME2,
(unsigned char)strlen(SERVICE_NAME2),
"Banana",
(unsigned char)strlen("Banana"),
201,
2000,
0x00000001);
Report("MDNS 2 Registered with NAME: %s & ERROR code: %d\n\r", SERVICE_NAME2, retVal);
}
To unregister all mDNS services at once, use the following call:
sl_NetAppMDNSUnRegisterService(0, 0);
Register, just once, a specific service. The service is saved and advertised after each reset (if mDNS is started and STA with IP or P2P/AP up).