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

Public Member Functions | |
| DLNAControlPointMgr () | |
| Default constructor w/o Notifications. | |
| DLNAControlPointMgr (HttpServer &server, int port=80) | |
| Constructor supporting Notifications. | |
| void | setParseDevice (bool flag) |
| Requests the parsing of the device information. | |
| void | setLocalURL (Url url) |
| Defines the local url (needed for subscriptions) | |
| void | setSearchRepeatMs (int repeatMs) |
| Sets the repeat interval for M-SEARCH requests (define before begin) | |
| bool | begin (DLNAHttpRequest &http, IUDPService &udp, const char *searchTarget="ssdp:all", uint32_t minWaitMs=3000, uint32_t maxWaitMs=60000) |
| Start discovery by sending M-SEARCH requests and process replies. | |
| void | end () |
| Stops the processing and releases the resources. | |
| ActionRequest & | addAction (ActionRequest act) |
| Registers a method that will be called. | |
| ActionReply & | executeActions () |
| Executes all registered methods. | |
| bool | subscribeNotifications (DLNADeviceInfo &device, int timeoutSeconds=60) |
| Subscribe to changes for all device services. | |
| bool | subscribeNotifications (DLNAServiceInfo &service, int timoutSeconds=60) |
| Subscribe to changes for defined device service. | |
| void | onNotification (std::function< void(void *reference, const char *sid, const char *varName, const char *newValue)> cb) |
| Register a callback that will be invoked for incoming event notification. | |
| void | setReference (void *ref) |
| Attach an opaque reference pointer (optional, for caller context) | |
| void | setHttpServer (HttpServer &server, int port=80) |
| Set HttpServer instance and register the notify handler. | |
| bool | loop () |
| DLNAServiceInfo & | getService (const char *id) |
| Provide addess to the service information. | |
| DLNADeviceInfo & | getDevice (int deviceIdx=0) |
| Provides the device information by index. | |
| DLNADeviceInfo & | getDevice (DLNAServiceInfo &service) |
| Provides the device for a service. | |
| DLNADeviceInfo & | getDevice (Url location) |
| Get a device for a Url. | |
| Vector< DLNADeviceInfo > & | getDevices () |
| bool | addDevice (DLNADeviceInfo dev) |
| Adds a new device. | |
| bool | addDevice (Url url) |
| Adds the device from the device xml url if it does not already exist. | |
| void | setActive (bool flag) |
| We can activate/deactivate the scheduler. | |
| bool | isActive () |
| Checks if the scheduler is active. | |
Protected Member Functions | |
| void | attachHttpServer (HttpServer &server) |
| void | parseAndDispatchEvent (NotifyReplyCP &data) |
| Parse the xml content of a NotifyReplyCP and dispatch each property. | |
| 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 & | getLastReply () |
| ActionReply & | postAllActions () |
| ActionReply & | postAction (ActionRequest &action) |
| void | buildActionBody (ActionRequest &action, StrPrint &out) |
Build the SOAP XML request body for the action into out | |
| ActionReply & | processActionHttpPost (Url &post_url, StrPrint &requestBody, const char *soapAction) |
| const char * | getUrl (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 | |
| Scheduler | scheduler |
| DLNAHttpRequest * | p_http = nullptr |
| IUDPService * | p_udp = nullptr |
| Vector< DLNADeviceInfo > | devices |
| Vector< ActionRequest > | actions |
| ActionReply | reply |
| XMLPrinter | xml |
| int | msearch_repeat_ms = 10000 |
| bool | is_active = false |
| bool | is_parse_device = false |
| DLNADeviceInfo | NO_DEVICE {false} |
| const char * | search_target |
| StringRegistry | strings |
| Url | local_url |
| HttpServer * | p_http_server = nullptr |
| int | http_server_port = 0 |
| void * | reference = nullptr |
| std::function< void(void *reference, const char *sid, const char *varName, const char *newValue)> | eventCallback |
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 supporting Notifications.
|
inline |
Registers a method that will be called.
|
inline |
Adds a new device.
|
inline |
Adds the device from the device xml url if it does not already exist.
|
inlineprotected |
Attach an HttpServer so the control point can receive HTTP NOTIFY event messages. This registers a handler at the configured local URL path (see local_url) which will extract the SID header and body and call parseAndDispatchEvent() to dispatch property changes.
|
inline |
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.
|
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";
|
inline |
Stops the processing and releases the resources.
|
inline |
Executes all registered methods.
|
inline |
Provides the device for a service.
|
inline |
Provides the device information by index.
|
inline |
Get a device for a Url.
|
inline |
|
inlineprotected |
|
inline |
Provide addess to the service information.
|
inlineprotected |
|
inlinestaticprotected |
|
inlinestaticprotected |
Processes a NotifyReplyCP message Note: split into smaller helpers for clarity and testability.
|
inline |
Checks if the scheduler is active.
|
inlinestaticprotected |
Returns true and sets outDev if a device with the UDN part of usn_c is already present in the device list.
|
inline |
call this method in the Arduino loop as often as possible: the processes all replys
|
inlineprotected |
checks if the usn contains the search target
|
inline |
Register a callback that will be invoked for incoming event notification.
|
inlineprotected |
Parse the xml content of a NotifyReplyCP and dispatch each property.
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
response body is written into responseOut (an XMLParserPrint). Returns the HTTP rc.
|
inlineprotected |
processes a bye-bye message
|
inlinestaticprotected |
|
inlinestaticprotected |
Processes an M-SEARCH HTTP 200 reply and attempts to add the device.
|
inline |
We can activate/deactivate the scheduler.
|
inline |
Set HttpServer instance and register the notify handler.
|
inline |
Defines the local url (needed for subscriptions)
|
inline |
Requests the parsing of the device information.
|
inline |
Attach an opaque reference pointer (optional, for caller context)
|
inline |
Sets the repeat interval for M-SEARCH requests (define before begin)
|
inline |
Subscribe to changes for all device services.
|
inline |
Subscribe to changes for defined device service.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |