15 class DLNAControlPointMgr;
51 const char* searchTarget =
"ssdp:all", uint32_t processingTime = 0,
52 bool stopWhenFound =
true) {
73 uint64_t
end = millis() + processingTime;
74 while (millis() <
end) {
75 if (stopWhenFound &&
devices.size() > 0)
break;
87 for (
auto& device :
devices) device.clear();
124 if (schedule !=
nullptr) {
147 if (result)
return result;
158 for (
auto& srv : dev.getServices()) {
159 if (srv == srv)
return dev;
168 if (dev.getDeviceURL() == location) {
182 for (
auto& existing_device :
devices) {
183 if (dev.
getUDN() == existing_device.getUDN()) {
204 int rc = req.
get(url,
"text/xml");
214 int len = req.
read(buffer, 512);
216 xml.write(buffer, len);
223 parser.
parse(new_device,
xml.c_str());
251 if (nts.
equals(
"ssdp:byebye")) {
255 if (nts.
equals(
"ssdp:alive")) {
258 select ?
"added" :
"filtered");
276 for (
auto& srv : dev.getServices()) {
277 srv.is_active =
false;
278 if (usn.
endsWith(srv.service_type)) {
281 srv.is_active =
false;
310 "xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" "
311 "s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"",
316 StrView namespace_str(ns, 200);
317 namespace_str =
"xmlns:u=\"%1\"";
336 if (action.getServiceType()!=
nullptr)
359 action_str.add(action.
action);
360 action_str.add(
"\"");
365 char url_buffer[200];
366 StrView url_str{url_buffer, 200};
369 Url post_url{url_str.c_str()};
381 str_print.
write(buffer, len);
void add(ActionReply alt)
Definition: Action.h:44
Vector< Argument > arguments
Definition: Action.h:72
const char * getServiceType()
Definition: Action.h:75
DLNAServiceInfo * p_service
Definition: Action.h:70
const char * action
Definition: Action.h:71
Setup of a Basic DLNA Control Point. The control point.
Definition: DLNAControlPointMgr.h:32
void setParseDevice(bool flag)
Requests the parsing of the device information.
Definition: DLNAControlPointMgr.h:36
DLNADevice & getDevice(int deviceIdx=0)
Provides the device information by index.
Definition: DLNAControlPointMgr.h:153
size_t createXML(ActionRequest &action)
Definition: DLNAControlPointMgr.h:305
bool matches(const char *usn)
checks if the usn contains the search target
Definition: DLNAControlPointMgr.h:267
bool isActive()
Checks if the scheduler is active.
Definition: DLNAControlPointMgr.h:233
DLNADevice & getDevice(Url location)
Get a device for a Url.
Definition: DLNAControlPointMgr.h:166
DLNADevice & getDevice(DLNAServiceInfo &service)
Provides the device for a service.
Definition: DLNAControlPointMgr.h:156
bool loop()
Definition: DLNAControlPointMgr.h:116
const char * search_target
Definition: DLNAControlPointMgr.h:246
bool addDevice(Url url)
Adds the device from the device xml url if it does not already exist.
Definition: DLNAControlPointMgr.h:194
DLNADevice NO_DEVICE
Definition: DLNAControlPointMgr.h:245
ActionReply postAllActions()
Definition: DLNAControlPointMgr.h:333
ActionRequest & addAction(ActionRequest act)
Registers a method that will be called.
Definition: DLNAControlPointMgr.h:92
bool addDevice(DLNADevice dev)
Adds a new device.
Definition: DLNAControlPointMgr.h:180
Vector< DLNADevice > devices
Definition: DLNAControlPointMgr.h:239
ActionReply postAction(ActionRequest &action)
Definition: DLNAControlPointMgr.h:342
static bool processDevice(NotifyReplyCP &data)
Processes a NotifyReplyCP message.
Definition: DLNAControlPointMgr.h:249
DLNAControlPointMgr()
Definition: DLNAControlPointMgr.h:34
bool is_parse_device
Definition: DLNAControlPointMgr.h:244
Scheduler scheduler
Definition: DLNAControlPointMgr.h:236
IUDPService * p_udp
Definition: DLNAControlPointMgr.h:237
XMLPrinter xml
Definition: DLNAControlPointMgr.h:242
HttpRequest * p_http
Definition: DLNAControlPointMgr.h:238
Vector< ActionRequest > actions
Definition: DLNAControlPointMgr.h:241
void setActive(bool flag)
We can activate/deactivate the scheduler.
Definition: DLNAControlPointMgr.h:230
bool processBye(Str &usn)
processes a bye-bye message
Definition: DLNAControlPointMgr.h:273
bool begin(HttpRequest &http, IUDPService &udp, const char *searchTarget="ssdp:all", uint32_t processingTime=0, bool stopWhenFound=true)
Definition: DLNAControlPointMgr.h:50
Vector< DLNADevice > & getDevices()
Definition: DLNAControlPointMgr.h:175
bool is_active
Definition: DLNAControlPointMgr.h:243
void end()
Stops the processing and releases the resources.
Definition: DLNAControlPointMgr.h:85
ActionReply executeActions()
Executes all registered methods.
Definition: DLNAControlPointMgr.h:98
DLNAServiceInfo & getService(const char *id)
Provide addess to the service information.
Definition: DLNAControlPointMgr.h:143
Translates DLNA UDP Requests to Schedule so that we can schedule a reply.
Definition: DLNAControlPointRequestParser.h:15
Schedule * parse(RequestData &req)
Definition: DLNAControlPointRequestParser.h:17
Device Attributes and generation of XML using urn:schemas-upnp-org:device-1-0. We could just return a...
Definition: DLNADevice.h:27
void setActive(bool flag)
Definition: DLNADevice.h:159
Url device_url
Definition: DLNADevice.h:168
Url & getBaseURL()
Provides the base url.
Definition: DLNADevice.h:56
const char * getUDN()
Provide the udn uuid.
Definition: DLNADevice.h:50
void updateTimestamp()
Update the timestamp.
Definition: DLNADevice.h:154
Attributes needed for the DLNA Service Definition.
Definition: DLNAServiceInfo.h:16
const char * control_url
Definition: DLNAServiceInfo.h:36
Simple API to process get, put, post, del http requests I tried to use Arduino HttpClient,...
Definition: HttpRequest.h:21
virtual HttpRequestHeader & request()
Definition: HttpRequest.h:111
virtual int get(Url &url, const char *acceptMime=nullptr, const char *data=nullptr, int len=-1)
Definition: HttpRequest.h:75
Client * client()
Definition: HttpRequest.h:123
virtual int post(Url &url, const char *mime, const char *data, int len=-1)
Definition: HttpRequest.h:59
virtual void stop()
Definition: HttpRequest.h:54
virtual int read(uint8_t *str, int len)
Definition: HttpRequest.h:90
Abstract Interface for UDP API.
Definition: IUDPService.h:34
virtual RequestData receive()=0
virtual bool begin(IPAddressAndPort addr)=0
void log(DlnaLogLevel current_level, const char *fmt...)
Print log message.
Definition: Logger.h:40
Str usn
Definition: Schedule.h:125
Str location
Definition: Schedule.h:124
Send MSearch request.
Definition: Schedule.h:39
Definition: Schedule.h:135
std::function< bool(NotifyReplyCP &ref)> callback
Definition: Schedule.h:146
Str nts
Definition: Schedule.h:138
Scheduler which processes all due Schedules (to send out UDP replies)
Definition: Scheduler.h:15
void execute(IUDPService &udp)
Execute all due schedules.
Definition: Scheduler.h:25
void add(Schedule *schedule)
Add a schedule to the scheduler.
Definition: Scheduler.h:18
Definition: StrPrint.h:11
size_t length()
Definition: StrPrint.h:32
size_t write(uint8_t ch) override
Definition: StrPrint.h:14
void reset()
Definition: StrPrint.h:34
const char * c_str()
Definition: StrPrint.h:30
A simple wrapper to provide string functions on char*. If the underlying char* is a const we do not a...
Definition: StrView.h:25
virtual void add(int value)
adds a int value
Definition: StrView.h:130
virtual bool startsWith(const char *str)
checks if the string starts with the indicated substring
Definition: StrView.h:177
virtual const char * c_str()
provides the string value as const char*
Definition: StrView.h:366
virtual bool endsWith(const char *str)
checks if the string ends with the indicated substring
Definition: StrView.h:185
virtual bool replace(const char *toReplace, const int replaced)
Replaces the first instance of toReplace with replaced.
Definition: StrView.h:385
virtual bool equals(const char *str)
checks if the string equals indicated parameter string
Definition: StrView.h:171
virtual bool contains(const char *str)
checks if the string contains a substring
Definition: StrView.h:277
String implementation which keeps the data on the heap. We grow the allocated memory only if the copy...
Definition: Str.h:22
const char * c_str()
provides the string value as const char*
Definition: Str.h:188
URL parser which breaks a full url string up into its individual parts.
Definition: Url.h:18
const char * url()
Definition: Url.h:46
Vector implementation which provides the most important methods as defined by std::vector....
Definition: Vector.h:21
Parses an DLNA device xml string to fill the DLNADevice data structure.
Definition: XMLDeviceParser.h:17
void parse(DLNADevice &result, const char *xmlStr)
Definition: XMLDeviceParser.h:19
Definition: Allocator.h:6
@ DlnaInfo
Definition: Logger.h:16
@ DlnaError
Definition: Logger.h:16
DLNAControlPointMgr * selfDLNAControlPoint
Definition: DLNAControlPointMgr.h:16
LoggerClass DlnaLogger
Definition: Logger.cpp:5
Provides information of the received UDP which consists of the (xml) data and the peer address and po...
Definition: IUDPService.h:23
An individual Schedule (to send out UDP messages)
Definition: Schedule.h:17
uint64_t end_time
Definition: Schedule.h:24
virtual const char * name()
Definition: Schedule.h:30
uint32_t repeat_ms
Definition: Schedule.h:22
Functions to efficiently output XML. XML data contains a lot of redundancy so it is more memory effic...
Definition: XMLPrinter.h:31
size_t printNodeBegin(const char *node, const char *attributes=nullptr, const char *ns=nullptr)
Definition: XMLPrinter.h:97
size_t printNode(XMLNode node)
Definition: XMLPrinter.h:43
size_t printNodeEnd(const char *node, const char *ns=nullptr)
Definition: XMLPrinter.h:122
void setOutput(Print &output)
Defines the output.
Definition: XMLPrinter.h:36
size_t printXMLHeader()
Definition: XMLPrinter.h:38