|
Arduino DLNA Server
|
Lightweight DLNA control point manager. More...
#include <DLNAControlPoint.h>

Public Member Functions | |
| DLNAControlPoint () | |
| Default constructor w/o Notifications. | |
| DLNAControlPoint (IHttpRequest &http, IUDPService &udp) | |
| Constructor wiring HTTP and UDP dependencies; notifications disabled. | |
| DLNAControlPoint (IHttpRequest &http, IUDPService &udp, IHttpServer &server) | |
| Constructor wiring HTTP and UDP dependencies; notifications disabled. | |
| DLNAControlPoint (IHttpServer &server) | |
| Constructor supporting Notifications. | |
| ~DLNAControlPoint () override=default | |
| void | setParseDevice (bool flag) override |
| Requests the parsing of the device information. | |
| void | setLocalURL (Url url) override |
| Defines the local url (needed for subscriptions) | |
| void | setLocalURL (IPAddress url, int port=9001, const char *path="") override |
| Set the local callback URL for event subscriptions. | |
| void | setSearchRepeatMs (int repeatMs) override |
| Sets the repeat interval for M-SEARCH requests (define before begin) | |
| void | setReference (void *ref) override |
| Attach an opaque reference pointer (optional, for caller context) | |
| void | setDeviceIndex (int idx) override |
| Selects the default device by index. | |
| void | setEventSubscriptionCallback (std::function< void(const char *sid, const char *varName, const char *newValue, void *reference)> cb, void *ref=nullptr) override |
| Register a callback that will be invoked for incoming event notification. | |
| void | setHttpServer (IHttpServer &server) override |
| Set HttpServer instance and register the notify handler. | |
| void | onResultNode (std::function< void(const char *nodeName, const char *text, const char *attributes)> cb) override |
| bool | begin (const char *searchTarget="ssdp:all", uint32_t minWaitMs=3000, uint32_t maxWaitMs=60000) override |
| Start discovery with default HTTP/UDP services. | |
| bool | begin (IHttpRequest &http, IUDPService &udp, const char *searchTarget="ssdp:all", uint32_t minWaitMs=3000, uint32_t maxWaitMs=60000) override |
| Start discovery by sending M-SEARCH requests and process replies. | |
| void | setTransports (IHttpRequest &http, IUDPService &udp) |
| void | end () override |
| Stops the processing and releases the resources. | |
| ActionRequest & | addAction (ActionRequest act) override |
| Registers a method that will be called. | |
| ActionReply & | executeActions (XMLCallback xmlProcessor=nullptr) override |
| Executes action and parses the reply xml to collect the reply entries. If an XML processor is provided it will be used to process the reply XML instead of the standard processing: This can be useful for large replies where we do not want to store the big data chunks. | |
| bool | loop () override |
| DLNAServiceInfo & | getService (const char *id) override |
| Provide addess to the service information. | |
| DLNADeviceInfo & | getDevice () override |
| Provides the device information of the actually selected device. | |
| DLNADeviceInfo & | getDevice (int idx) override |
| Provides the device information by index. | |
| DLNADeviceInfo & | getDevice (DLNAServiceInfo &service) override |
| Provides the device for a service. | |
| DLNADeviceInfo & | getDevice (Url location) override |
| Get a device for a Url. | |
| Vector< DLNADeviceInfo > & | getDevices () override |
| Get list of all discovered devices. | |
| const char * | getUrl (DLNADeviceInfo &device, const char *suffix, char *buffer, int len) override |
| bool | addDevice (DLNADeviceInfo dev) override |
| Adds a new device. | |
| bool | addDevice (Url url) override |
| Adds the device from the device xml url if it does not already exist. | |
| void | setActive (bool flag) override |
| We can activate/deactivate the scheduler. | |
| bool | isActive () override |
| Checks if the scheduler is active. | |
| void | setAllowLocalhost (bool flag) override |
| Defines if localhost devices should be allowed. | |
| ActionReply & | getLastReply () override |
| Provides the last reply. | |
| SubscriptionMgrControlPoint * | getSubscriptionMgr () override |
| Provides the subscription manager. | |
| void | setSubscribeNotificationsActive (bool flag) override |
| Activate/deactivate subscription notifications. | |
| const char * | registerString (const char *s) override |
| Register a string in the shared registry and return the stored pointer. | |
Protected Member Functions | |
| bool | isDiscoveryAllowed (Url &url) |
| bool | matches (const char *usn) |
| checks if the usn contains the search target | |
| bool | processBye (Str &usn) |
| processes a bye-bye message | |
| size_t | createXML (ActionRequest &action) |
| ActionReply & | postAllActions (XMLCallback xmlProcessor=nullptr) |
| ActionReply & | postAction (ActionRequest &action, XMLCallback xmlProcessor=nullptr) |
| size_t | createSoapXML (ActionRequest &action, Print &out) |
Build the SOAP XML request body for the action into out | |
| ActionReply & | processActionHttpPost (ActionRequest &action, Url &post_url, const char *soapAction, XMLCallback xmlProcessor=nullptr) |
| Processes an HTTP POST request for the given action and URL. | |
| void | parseResult () |
| Parses the XML response from the HTTP client and populates reply arguments. | |
| void | unEscapeStr (Str &str) |
| const char * | getUrlImpl (DLNADeviceInfo &device, const char *suffix, const char *buffer, int len) |
Static Protected Member Functions | |
| static bool | handleNotifyByebye (Str &usn) |
| static bool | isUdnKnown (const char *usn_c, DLNADeviceInfo *&outDev) |
| static bool | handleNotifyAlive (NotifyReplyCP &data) |
| static bool | processDevice (NotifyReplyCP &data) |
| static bool | processMSearchReply (MSearchReplyCP &data) |
| Processes an M-SEARCH HTTP 200 reply and attempts to add the device. | |
Protected Attributes | |
| DLNADeviceInfo | NO_DEVICE {false} |
| Scheduler | scheduler |
| IHttpRequest * | p_http = nullptr |
| IUDPService * | p_udp = nullptr |
| SubscriptionMgrControlPoint | subscription_mgr |
| Vector< DLNADeviceInfo > | devices |
| Vector< ActionRequest > | actions |
| ActionReply | reply |
| XMLPrinter | xml_printer |
| int | default_device_idx = 0 |
| int | msearch_repeat_ms = 10000 |
| bool | is_active = false |
| bool | is_parse_device = false |
| const char * | search_target |
| Url | local_url |
| bool | allow_localhost = false |
| IHttpServer * | p_http_server = nullptr |
| void * | reference = nullptr |
| std::function< void(const char *nodeName, const char *text, const char *attributes)> | result_callback |
Lightweight DLNA control point manager.
This class implements a compact, embeddable DLNA/UPnP control point suitable for small devices and emulators. It provides the core responsibilities a control point needs in order to discover devices, subscribe to service events, and invoke actions on services:
DLNADevice objects and their DLNAServiceInfo entries.HttpServer.onNotification).Notes and usage:
HttpServer with setHttpServer() (or construct with a server). The server's request handler will forward NOTIFY bodies to this manager.onNotification() to receive parsed property updates. An opaque reference pointer may be stored with setReference() and will be passed back with the callback.begin() to start discovery and loop() frequently (e.g. from the device main loop) to process incoming network events and scheduled tasks.The class is intentionally small and avoids dynamic STL-heavy constructs so it can run in constrained environments. It is not a full-featured UPnP stack but provides the common features required by many DLNA control point use cases.
|
inline |
Default constructor w/o Notifications.
|
inline |
Constructor wiring HTTP and UDP dependencies; notifications disabled.
|
inline |
Constructor wiring HTTP and UDP dependencies; notifications disabled.
|
inline |
Constructor supporting Notifications.
|
overridedefault |
|
inlineoverridevirtual |
Registers a method that will be called.
Implements tiny_dlna::IControlPoint.
|
inlineoverridevirtual |
Adds a new device.
Implements tiny_dlna::IControlPoint.
|
inlineoverridevirtual |
Adds the device from the device xml url if it does not already exist.
Implements tiny_dlna::IControlPoint.
|
inlineoverridevirtual |
Start discovery with default HTTP/UDP services.
Implements tiny_dlna::IControlPoint.
|
inlineoverridevirtual |
Start discovery by sending M-SEARCH requests and process replies.
searchTarget: the SSDP search target (e.g. "ssdp:all", device/service urn) minWaitMs: minimum time in milliseconds to wait before returning a result (default: 3000 ms) maxWaitMs: maximum time in milliseconds to wait for replies (M-SEARCH window) (default: 60000 ms) Behavior: the function will wait at least minWaitMs and at most maxWaitMs. If a device is discovered after minWaitMs elapsed the function will return early; otherwise it will block until maxWaitMs.
Implements tiny_dlna::IControlPoint.
|
inlineprotected |
Build the SOAP XML request body for the action into out
|
inlineprotected |
Creates the Action Soap XML request. E.g "<?xml version=\"1.0\"?>\r\n" "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"\r\n" "s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\r\n" "<s:Body>\r\n" "<u:SetTarget " "xmlns:u=\"urn:schemas-upnp-org:service:SwitchPower:1\">\r\n" "<newTargetValue>1</newTargetValue>\r\n" "</u:SetTarget>\r\n" "</s:Body>\r\n" "</s:Envelope>\r\n";
|
inlineoverridevirtual |
Stops the processing and releases the resources.
Implements tiny_dlna::IControlPoint.
|
inlineoverridevirtual |
Executes action and parses the reply xml to collect the reply entries. If an XML processor is provided it will be used to process the reply XML instead of the standard processing: This can be useful for large replies where we do not want to store the big data chunks.
| xmlProcessor | Optional XML processor callback |
Implements tiny_dlna::IControlPoint.
|
inlineoverridevirtual |
Provides the device information of the actually selected device.
Implements tiny_dlna::IControlPoint.
|
inlineoverridevirtual |
Provides the device for a service.
Implements tiny_dlna::IControlPoint.
|
inlineoverridevirtual |
Provides the device information by index.
Implements tiny_dlna::IControlPoint.
|
inlineoverridevirtual |
Get a device for a Url.
Implements tiny_dlna::IControlPoint.
|
inlineoverridevirtual |
Get list of all discovered devices.
Implements tiny_dlna::IControlPoint.
|
inlineoverridevirtual |
Provides the last reply.
Implements tiny_dlna::IControlPoint.
|
inlineoverridevirtual |
Provide addess to the service information.
Implements tiny_dlna::IControlPoint.
|
inlineoverridevirtual |
Provides the subscription manager.
Implements tiny_dlna::IControlPoint.
|
inlineoverridevirtual |
Public wrapper to build a fully-qualified URL for a device + suffix. This calls the protected getUrl() helper so external helpers can reuse the control point's URL normalization logic without exposing the internal protected method directly.
Implements tiny_dlna::IControlPoint.
|
inlineprotected |
|
inlinestaticprotected |
|
inlinestaticprotected |
Processes a NotifyReplyCP message Note: split into smaller helpers for clarity and testability.
|
inlineoverridevirtual |
Checks if the scheduler is active.
Implements tiny_dlna::IControlPoint.
|
inlineprotected |
|
inlinestaticprotected |
Returns true and sets outDev if a device with the UDN part of usn_c is already present in the device list.
|
inlineoverridevirtual |
call this method in the Arduino loop as often as possible: the processes all replys
Implements tiny_dlna::IControlPoint.
|
inlineprotected |
checks if the usn contains the search target
|
inlineoverridevirtual |
Register a callback that will be invoked when parsing SOAP/Action results Signature: void(const char* nodeName, const char* text, const char* attributes)
Implements tiny_dlna::IControlPoint.
|
inlineprotected |
Parses the XML response from the HTTP client and populates reply arguments.
| xml_parser | XMLParserPrint instance for parsing |
| buffer | Temporary buffer for reading client data |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
Processes an HTTP POST request for the given action and URL.
|
inlineprotected |
processes a bye-bye message
|
inlinestaticprotected |
|
inlinestaticprotected |
Processes an M-SEARCH HTTP 200 reply and attempts to add the device.
|
inlineoverridevirtual |
Register a string in the shared registry and return the stored pointer.
Implements tiny_dlna::IControlPoint.
|
inlineoverridevirtual |
We can activate/deactivate the scheduler.
Implements tiny_dlna::IControlPoint.
|
inlineoverridevirtual |
Defines if localhost devices should be allowed.
Implements tiny_dlna::IControlPoint.
|
inlineoverridevirtual |
Selects the default device by index.
Implements tiny_dlna::IControlPoint.
|
inlineoverridevirtual |
Register a callback that will be invoked for incoming event notification.
Implements tiny_dlna::IControlPoint.
|
inlineoverridevirtual |
Set HttpServer instance and register the notify handler.
Implements tiny_dlna::IControlPoint.
|
inlineoverridevirtual |
Set the local callback URL for event subscriptions.
Implements tiny_dlna::IControlPoint.
|
inlineoverridevirtual |
Defines the local url (needed for subscriptions)
Implements tiny_dlna::IControlPoint.
|
inlineoverridevirtual |
Requests the parsing of the device information.
Implements tiny_dlna::IControlPoint.
|
inlineoverridevirtual |
Attach an opaque reference pointer (optional, for caller context)
Implements tiny_dlna::IControlPoint.
|
inlineoverridevirtual |
Sets the repeat interval for M-SEARCH requests (define before begin)
Implements tiny_dlna::IControlPoint.
|
inlineoverridevirtual |
Activate/deactivate subscription notifications.
Implements tiny_dlna::IControlPoint.
|
inline |
|
inlineprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |