void OpenHome::TestFramework::Runner::Main(TInt aArgc, TChar* aArgv[], InitialisationParams* aInitParams) { OptionParser parser; Brn emptyString(""); OptionString config("-c", "--config", emptyString, "[full dir path] to folder containing web UI"); parser.AddOption(&config); OptionBool loopback("-l", "--loopback", "Use the loopback adapter only"); parser.AddOption(&loopback); if (!parser.Parse(aArgc, aArgv) || parser.HelpDisplayed()) { return; } if (config.Value().Bytes() == 0) { parser.DisplayHelp(); return; } if (loopback.Value()) { aInitParams->SetUseLoopbackNetworkAdapter(); } aInitParams->SetDvNumWebSocketThreads(5); aInitParams->SetDvWebSocketPort(54320); aInitParams->SetDvUpnpServerPort(0); UpnpLibrary::Initialise(aInitParams); Debug::SetLevel(Debug::kDvWebSocket | Debug::kError | Debug::kDvInvocation | Debug::kDvEvent | Debug::kDvDevice); UpnpLibrary::StartDv(); Print("TestDvTestBasic - starting ('q' to quit)\n"); DeviceBasic* device = new DeviceBasic(config.Value()); while (getchar() != 'q') { ; } delete device; Print("TestDvTestBasic - exiting\n"); UpnpLibrary::Close(); }
void TestDeviceList(const std::vector<Brn>& aArgs) { OptionParser parser; OptionUint mx("-mx", "--mx", 1, "[1..5] number of second to spread response over"); parser.AddOption(&mx); OptionBool all("-a", "--all", "Search for all devices and services"); parser.AddOption(&all); OptionBool root("-r", "--root", "Search for root devices only"); parser.AddOption(&root); Brn emptyString(""); OptionString uuid("-u", "--uuid", emptyString, "[uuid string] search for a particular device"); parser.AddOption(&uuid); OptionString urn("-t", "--urn", emptyString, "Search for a device or service of the form [domain:[device|service]:type:ver]"); parser.AddOption(&urn); OptionBool refresh("-f", "--refresh", "Wait mx secs then refresh list"); parser.AddOption(&refresh); if (!parser.Parse(aArgs) || parser.HelpDisplayed()) { return; } // Debug::SetLevel(Debug::kDevice); DeviceListLogger logger; CpDeviceList* deviceList = NULL; FunctorCpDevice added = MakeFunctorCpDevice(logger, &DeviceListLogger::Added); FunctorCpDevice removed = MakeFunctorCpDevice(logger, &DeviceListLogger::Removed); if (all.Value()) { deviceList = new CpDeviceListUpnpAll(added, removed); } else if (root.Value()) { Print("Search root...\n"); deviceList = new CpDeviceListUpnpRoot(added, removed); } else if (uuid.Value().Bytes() > 0) { Print("Search uuid...\n"); deviceList = new CpDeviceListUpnpUuid(uuid.Value(), added, removed); } else if (urn.Value().Bytes() > 0) { Print("Search device/service...\n"); Brn domainName; Brn type; TUint ver; if (OpenHome::Net::Ssdp::ParseUrnDevice(urn.Value(), domainName, type, ver)) { deviceList = new CpDeviceListUpnpDeviceType(domainName, type, ver, added, removed); } else if (OpenHome::Net::Ssdp::ParseUrnService(urn.Value(), domainName, type, ver)) { deviceList = new CpDeviceListUpnpServiceType(domainName, type, ver, added, removed); } else { parser.DisplayHelp(); } } else { parser.DisplayHelp(); } Blocker* blocker = new Blocker; if (deviceList != NULL) { blocker->Wait(Stack::InitParams().MsearchTimeSecs()); } if (refresh.Value()) { Print("\nRefreshing...\n\n"); deviceList->Refresh(); blocker->Wait(Stack::InitParams().MsearchTimeSecs()); } delete blocker; delete deviceList; }
void TestSsdpUListen(Environment& aEnv, const std::vector<Brn>& aArgs) { OptionParser parser; OptionUint mx("-mx", "--mx", 0, "[1..5] number of second to spread response over"); parser.AddOption(&mx); OptionUint adapter("-i", "--interface", 0, "index of network adapter to use"); parser.AddOption(&adapter); OptionBool all("-a", "--all", "Search for all devices and services"); parser.AddOption(&all); OptionBool root("-r", "--root", "Search for root devices only"); parser.AddOption(&root); Brn emptyString(""); OptionString uuid("-u", "--uuid", emptyString, "[uuid string] search for a particular device"); parser.AddOption(&uuid); OptionString urn("-t", "--urn", emptyString, "Search for a device or service of the form [domain:[device|service]:type:ver]"); parser.AddOption(&urn); if (!parser.Parse(aArgs) || parser.HelpDisplayed()) { return; } //Debug::SetLevel(Debug::kSsdpMulticast); TBool block = true; SsdpNotifyLoggerU logger; SsdpListenerUnicast* uListener = new SsdpListenerUnicast(aEnv, logger, NetworkIf(aEnv, adapter.Value())); uListener->Start(); if (all.Value()) { Print("Search all...\n"); uListener->MsearchAll(); } else if (root.Value()) { Print("Search root...\n"); uListener->MsearchRoot(); } else if (uuid.Value().Bytes() > 0) { Print("Search uuid...\n"); uListener->MsearchUuid(uuid.Value()); } else if (urn.Value().Bytes() > 0) { Print("Search device/service...\n"); Brn domainName; Brn deviceType; TUint ver; if (OpenHome::Net::Ssdp::ParseUrnDevice(urn.Value(), domainName, deviceType, ver)) { uListener->MsearchDeviceType(domainName, deviceType, ver); } else if (OpenHome::Net::Ssdp::ParseUrnService(urn.Value(), domainName, deviceType, ver)) { uListener->MsearchServiceType(domainName, deviceType, ver); } else { parser.DisplayHelp(); block = false; } } else { parser.DisplayHelp(); block = false; } if (block) { Blocker* blocker = new Blocker(aEnv); blocker->Wait(aEnv.InitParams()->MsearchTimeSecs()); delete blocker; } delete uListener; }