15 class DLNAControlPointMgr;
53 const char* searchTarget =
"ssdp:all", uint32_t processingTime = 0,
54 bool stopWhenFound =
true) {
75 uint64_t
end = millis() + processingTime;
76 while (millis() <
end) {
77 if (stopWhenFound &&
devices.size() > 0)
break;
89 for (
auto& device :
devices) device.clear();
124 char url_buffer[200] = {0};
125 char seconds_txt[80] = {0};
126 Url url{
getUrl(device, service.event_sub_url, url_buffer, 200)};
127 snprintf(seconds_txt, 80,
"Second-%d", seconds);
156 if (schedule !=
nullptr) {
179 if (result)
return result;
190 for (
auto& srv : dev.getServices()) {
191 if (srv == srv)
return dev;
200 if (dev.getDeviceURL() == location) {
212 for (
auto& existing_device :
devices) {
213 if (dev.
getUDN() == existing_device.getUDN()) {
234 int rc = req.
get(url,
"text/xml");
245 int len = req.
read(buffer, 512);
247 xml.write(buffer, len);
283 if (nts.
equals(
"ssdp:byebye")) {
287 if (nts.
equals(
"ssdp:alive")) {
290 select ?
"added" :
"filtered");
308 for (
auto& srv : dev.getServices()) {
309 srv.is_active =
false;
310 if (usn.
endsWith(srv.service_type)) {
313 srv.is_active =
false;
342 "xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" "
343 "s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"",
348 StrView namespace_str(ns, 200);
349 namespace_str =
"xmlns:u=\"%1\"";
368 if (action.getServiceType() !=
nullptr) result.
add(
postAction(action));
388 action_str.add(action.
action);
389 action_str.add(
"\"");
394 char url_buffer[200] = {0};
417 str_print.
write(buffer, len);
429 StrView url_str{(
char*)buffer, len};
431 if (url_str ==
nullptr) {
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:185
size_t createXML(ActionRequest &action)
Definition: DLNAControlPointMgr.h:337
bool matches(const char *usn)
checks if the usn contains the search target
Definition: DLNAControlPointMgr.h:299
bool isActive()
Checks if the scheduler is active.
Definition: DLNAControlPointMgr.h:264
DLNADevice & getDevice(Url location)
Get a device for a Url.
Definition: DLNAControlPointMgr.h:198
DLNADevice & getDevice(DLNAServiceInfo &service)
Provides the device for a service.
Definition: DLNAControlPointMgr.h:188
bool loop()
Definition: DLNAControlPointMgr.h:148
const char * search_target
Definition: DLNAControlPointMgr.h:276
bool addDevice(Url url)
Adds the device from the device xml url if it does not already exist.
Definition: DLNAControlPointMgr.h:224
const char * getUrl(DLNADevice &device, const char *suffix, const char *buffer, int len)
Definition: DLNAControlPointMgr.h:427
DLNADevice NO_DEVICE
Definition: DLNAControlPointMgr.h:275
ActionReply postAllActions()
Definition: DLNAControlPointMgr.h:365
ActionRequest & addAction(ActionRequest act)
Registers a method that will be called.
Definition: DLNAControlPointMgr.h:94
bool addDevice(DLNADevice dev)
Adds a new device.
Definition: DLNAControlPointMgr.h:210
Vector< DLNADevice > devices
Definition: DLNAControlPointMgr.h:270
ActionReply postAction(ActionRequest &action)
Definition: DLNAControlPointMgr.h:373
static bool processDevice(NotifyReplyCP &data)
Processes a NotifyReplyCP message.
Definition: DLNAControlPointMgr.h:281
DLNAHttpRequest * p_http
Definition: DLNAControlPointMgr.h:268
StringRegistry strings
Definition: DLNAControlPointMgr.h:277
DLNAControlPointMgr()
Definition: DLNAControlPointMgr.h:34
bool is_parse_device
Definition: DLNAControlPointMgr.h:274
Scheduler scheduler
Definition: DLNAControlPointMgr.h:267
IUDPService * p_udp
Definition: DLNAControlPointMgr.h:269
bool subscribe(const char *serviceName, int seconds)
Subscribe to changes.
Definition: DLNAControlPointMgr.h:107
bool begin(DLNAHttpRequest &http, IUDPService &udp, const char *searchTarget="ssdp:all", uint32_t processingTime=0, bool stopWhenFound=true)
Definition: DLNAControlPointMgr.h:52
XMLPrinter xml
Definition: DLNAControlPointMgr.h:272
Url local_url
Definition: DLNAControlPointMgr.h:278
Vector< ActionRequest > actions
Definition: DLNAControlPointMgr.h:271
void setActive(bool flag)
We can activate/deactivate the scheduler.
Definition: DLNAControlPointMgr.h:261
bool processBye(Str &usn)
processes a bye-bye message
Definition: DLNAControlPointMgr.h:305
Vector< DLNADevice > & getDevices()
Definition: DLNAControlPointMgr.h:207
bool is_active
Definition: DLNAControlPointMgr.h:273
void setLocalURL(Url url)
Defines the lacal url (needed for subscriptions)
Definition: DLNAControlPointMgr.h:38
void end()
Stops the processing and releases the resources.
Definition: DLNAControlPointMgr.h:87
ActionReply executeActions()
Executes all registered methods.
Definition: DLNAControlPointMgr.h:100
DLNAServiceInfo & getService(const char *id)
Provide addess to the service information.
Definition: DLNAControlPointMgr.h:175
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:158
Url & getDeviceURL()
This method returns base url/device.xml.
Definition: DLNADevice.h:67
Url device_url
Definition: DLNADevice.h:170
const char * getBaseURL()
Provides the base url.
Definition: DLNADevice.h:58
const char * getUDN()
Provide the udn uuid.
Definition: DLNADevice.h:52
void updateTimestamp()
Update the timestamp.
Definition: DLNADevice.h:153
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:116
virtual int subscribe(Url &url)
Definition: HttpRequest.h:89
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:128
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:95
Abstract Interface for UDP API.
Definition: IUDPService.h:34
virtual RequestData receive()=0
virtual bool begin(int port)=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:19
virtual void add(int value)
adds a int value
Definition: StrView.h:124
virtual bool isEmpty()
checks if the string is empty
Definition: StrView.h:376
virtual bool startsWith(const char *str)
checks if the string starts with the indicated substring
Definition: StrView.h:179
virtual const char * c_str()
provides the string value as const char*
Definition: StrView.h:369
virtual bool endsWith(const char *str)
checks if the string ends with the indicated substring
Definition: StrView.h:187
virtual bool replace(const char *toReplace, const int replaced)
Replaces the first instance of toReplace with replaced.
Definition: StrView.h:388
virtual bool equals(const char *str)
checks if the string equals indicated parameter string
Definition: StrView.h:173
virtual bool contains(const char *str)
checks if the string contains a substring
Definition: StrView.h:279
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
Definition: StringRegistry.h:9
URL parser which breaks a full url string up into its individual parts.
Definition: Url.h:18
int port()
Definition: Url.h:51
const char * protocol()
Definition: Url.h:49
const char * url()
Definition: Url.h:46
const char * host()
Definition: Url.h:48
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, StringRegistry &strings, const char *xmlStr)
Definition: XMLDeviceParser.h:19
Definition: Allocator.h:6
@ DlnaDebug
Definition: Logger.h:16
@ 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