static int RegisterSocketServices(void) { int retval; char servicename[MDNS_SERVICE_NAME_MAXLEN]; LOG(LOG_IMPORTANT, "%sRegistering services on mDNS...",wifi_log_prefix); //retreive the device mac address char macstring[20]; unsigned char mac[SL_MAC_ADDR_LEN]; unsigned char maclen = SL_MAC_ADDR_LEN; retval = sl_NetCfgGet(SL_MAC_ADDRESS_GET, NULL, &maclen, mac); if(retval < 0) { RETURN_ERROR(retval, "Sock: Unable to get MAC address."); } sprintf(macstring, "[%02X:%02X:%02X:%02X:%02X:%02X]", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); for(int i=0; i<NUM_SOCKETS; i++){ sprintf(servicename, "%s - %s", macstring, socket_mdns_names_fixedpart[i]); retval = sl_NetAppMDNSRegisterService((signed char*)servicename, (unsigned char)strlen(servicename), (signed char*)socket_mdns_descriptions[i], (unsigned char)strlen(socket_mdns_descriptions[i]), socket_ports[i],MDNS_SERVICE_TTL,1); if(retval < 0) { RETURN_ERROR(retval, "Sock: Unable to register mDNS."); } } LOG(LOG_IMPORTANT, "%sServices registered.",wifi_log_prefix); return RET_SUCCESS; }
//***************************************************************************** //! registerMdnsService //! //! Registers the mDNS Service. //! //! Service settings for type and port are set in simplelinklibrary.h //! //! Returns: On success returns 0 //! //**************************************************************************** int registerMdnsService() { int iretVal; unsigned int i; // Create mDNS Service Name for (i = 0; i < 40; i++) mdnsServiceName[i] = 0x00; // Obtain the device name char * deviceName = getDeviceName(); strcat(mdnsServiceName, (const char *)deviceName); strcat(mdnsServiceName, MDNS_SERVICE); // Create mDNS Text for (i = 0; i < 50; i++) mdnsText[i] = 0x00; // Obtain the MAC Address char * macAddress = getMacAddress(); strcat(mdnsText, "mac="); strcat(mdnsText, macAddress); strcat(mdnsText, ";ver="); strcat(mdnsText, DEVICE_VERSION); strcat(mdnsText, ";man="); strcat(mdnsText, DEVICE_MANUFACTURE); strcat(mdnsText, ";mod="); strcat(mdnsText, DEVICE_MODEL); strcat(mdnsText, "\0"); int strSvrLength = strlen(mdnsServiceName); int strTxtLength = strlen(mdnsText); //Unregisters the mDNS service. unregisterMdnsService(); //Registering for the mDNS service. iretVal = sl_NetAppMDNSRegisterService((const signed char *)mdnsServiceName,strlen(mdnsServiceName), (const signed char *)mdnsText,strlen(mdnsText)+1, UDPPORT, TTL, UNIQUE_SERVICE); return iretVal; }
//***************************************************************************** //! registermDNSService //! //! Registers the mDNS Service //! //! //**************************************************************************** int registermDNSService() { uint8_t iretvalmDNS; uint8_t i; // Obtain the device name sl_NetAppGet(SL_NET_APP_DEVICE_CONFIG_ID, NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN, (unsigned char *)strlen((const char *)lightConfig.deviceName), lightConfig.deviceName); //sl_NetAppGet(SL_NET_APP_DEVICE_CONFIG_ID, NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN, strlen((const char *)lightConfig.deviceName), lightConfig.deviceName); // Convert to ASCII char lightCountChar[4]; sprintf(lightCountChar, "%d", lightConfig.lightCount); char icTypeChar[1]; sprintf(icTypeChar, "%d", lightConfig.icType); char protocolTypeChar[1]; sprintf(protocolTypeChar, "%d", lightConfig.protocolType); char colorTypeChar[1]; sprintf(colorTypeChar, "%d", lightConfig.colorOrder); char bitCountChar[2]; sprintf(bitCountChar, "%d", lightConfig.bitCount); // Create mDNS Service Name for (i = 0; i < 40; i++) mdnsServiceName[i] = 0x00; strcat(mdnsServiceName, (const char *)lightConfig.deviceName); strcat(mdnsServiceName, MDNS_SERVICE); // Create mDNS Text for (i = 0; i < 70; i++) mdnsText[i] = 0x00; char * macAddress = getMacAddress(); strcat(mdnsText, "mac="); strcat(mdnsText, macAddress); strcat(mdnsText, ";ver="); strcat(mdnsText, DEVICE_VERSION); strcat(mdnsText, ";man="); strcat(mdnsText, DEVICE_MANUFACTURE); strcat(mdnsText, ";mod="); strcat(mdnsText, DEVICE_MODEL); strcat(mdnsText, ";l="); strcat(mdnsText, (const char *)lightCountChar); strcat(mdnsText, ";it="); strcat(mdnsText, (const char *)icTypeChar); strcat(mdnsText, ";pt="); strcat(mdnsText, (const char *)protocolTypeChar); strcat(mdnsText, ";ct="); strcat(mdnsText, (const char *)colorTypeChar); strcat(mdnsText, ";bc="); strcat(mdnsText, (const char *)bitCountChar); strcat(mdnsText, "\0"); int strSvrLength = strlen(mdnsServiceName); int strTxtLength = strlen(mdnsText); //Registering for the mDNS service. iretvalmDNS = sl_NetAppMDNSUnRegisterService((const signed char *)mdnsServiceName,strlen(mdnsServiceName)); iretvalmDNS = sl_NetAppMDNSRegisterService((const signed char *)mdnsServiceName,strlen(mdnsServiceName), (const signed char *)mdnsText,strlen(mdnsText)+1, UDPPORT, TTL, UNIQUE_SERVICE); if(iretvalmDNS == 0) { System_printf("MDNS Registration successful\n"); } else { System_printf("MDNS Registered failed\n"); } System_flush(); return iretvalmDNS; }
void SpeakerControl(void* pValue) { int iCount=0; unsigned long ulPin6Val = 1; long lRetVal = -1; //Check whether GPIO Level is Stable As No Debouncing Circuit in LP for(iCount=0;iCount<3;iCount++) { osi_Sleep(200); ulPin6Val = MAP_GPIOPinRead(GPIOA2_BASE,GPIO_PIN_6); if(ulPin6Val) { //False Alarm return; } } if (g_ucSpkrStartFlag == 0) { #ifndef MULTICAST //Un Register mDNS Service. lRetVal = sl_NetAppMDNSUnRegisterService((signed char *)CC3200_MDNS_NAME,\ (unsigned char)strlen((const char *)CC3200_MDNS_NAME)); if(lRetVal < 0) { UART_PRINT("Unable to unregister MDNS service\n\r"); } //Registering for the mDNS service. lRetVal = sl_NetAppMDNSRegisterService((signed char *)CC3200_MDNS_NAME, \ (unsigned char)strlen((const char *)CC3200_MDNS_NAME),\ (signed char *)"multicast",\ (unsigned char)strlen((const char *)"multicast"),\ AUDIO_PORT,1000,0); if(lRetVal < 0) { UART_PRINT("Unable to register MDNS service\n\r"); LOOP_FOREVER(); } #endif //Blink LED 3 times to Indicate ON for(iCount = 0; iCount<3; iCount++) { GPIO_IF_LedOff(MCU_ORANGE_LED_GPIO); osi_Sleep(50); GPIO_IF_LedOn(MCU_ORANGE_LED_GPIO); osi_Sleep(50); } g_ucSpkrStartFlag = 1; } else { //Un Register mDNS Service. lRetVal = sl_NetAppMDNSUnRegisterService((signed char *)CC3200_MDNS_NAME,\ (unsigned char)strlen((const char *)CC3200_MDNS_NAME)); if(lRetVal < 0) { UART_PRINT("Unable to unregister MDNS service\n\r"); } //Blink LED 3 times to Indicate OFF for(iCount = 0; iCount<3; iCount++) { GPIO_IF_LedOn(MCU_ORANGE_LED_GPIO); osi_Sleep(50); GPIO_IF_LedOff(MCU_ORANGE_LED_GPIO); osi_Sleep(50); } g_ucSpkrStartFlag = 0; } //Enable GPIO Interrupt MAP_GPIOIntClear(GPIOA2_BASE,GPIO_PIN_6); MAP_IntPendClear(INT_GPIOA2); MAP_IntEnable(INT_GPIOA2); MAP_GPIOIntEnable(GPIOA2_BASE,GPIO_PIN_6); }