|
| static void | mupnp_device_initchildnodes (mUpnpDevice *dev) |
| |
| static void | mupnp_device_initdevicelist (mUpnpDevice *dev) |
| |
| static void | mupnp_device_initservicelist (mUpnpDevice *dev) |
| |
| static void | mupnp_device_initiconlist (mUpnpDevice *dev) |
| |
| static void | mupnp_device_notifywait (mUpnpDevice *dev) |
| |
| mUpnpDevice * | mupnp_device_new (void) |
| | Create a new UPnP device instance.
|
| |
| void | mupnp_device_delete (mUpnpDevice *dev) |
| | Delete a UPnP device and free all associated resources.
|
| |
| void | mupnp_device_clear (mUpnpDevice *dev) |
| |
| void | mupnp_device_setdevicenode (mUpnpDevice *dev, mUpnpXmlNode *node) |
| |
| mUpnpDevice * | mupnp_device_getrootdevice (mUpnpDevice *dev) |
| |
| bool | mupnp_device_parsedescription (mUpnpDevice *dev, const char *desciption, size_t descriptionLen) |
| |
| bool | mupnp_device_parsedescriptionurl (mUpnpDevice *dev, mUpnpNetURL *url) |
| |
| bool | mupnp_device_updatefromssdppacket (mUpnpDevice *dev, mUpnpSSDPPacket *ssdpPkt) |
| |
| char * | mupnp_devicetype_getidentifier (const char *deviceType) |
| |
| char * | mupnp_devicetype_geturn (const char *deviceType) |
| |
| char * | mupnp_devicetype_getdevice (const char *deviceType) |
| |
| char * | mupnp_devicetype_gettype (const char *deviceType) |
| |
| char * | mupnp_devicetype_getschematype (const char *deviceType) |
| |
| char * | mupnp_devicetype_getversion (const char *deviceType) |
| |
| mUpnpDevice * | mupnp_device_getdevicebytype (mUpnpDevice *dev, const char *type) |
| |
| mUpnpDevice * | mupnp_device_getdevicebyexacttype (mUpnpDevice *dev, const char *exacttype) |
| |
| mUpnpDevice * | mupnp_device_getdevicebyudn (mUpnpDevice *dev, const char *udn) |
| |
| mUpnpDevice * | mupnp_device_getdevicebydescriptionuri (mUpnpDevice *dev, const char *url) |
| |
| const char * | mupnp_device_getlocationurl (mUpnpDevice *dev, const char *host, char *buf, int bufSize) |
| |
| char * | mupnp_device_getnotifydevicent (mUpnpDevice *dev, char *buf, int bufSize) |
| |
| char * | mupnp_device_getnotifydeviceusn (mUpnpDevice *dev, char *buf, int bufSize) |
| |
| char * | mupnp_device_getnotifydevicetypent (mUpnpDevice *dev, char *buf, int bufSize) |
| |
| char * | mupnp_device_getnotifydevicetypeusn (mUpnpDevice *dev, char *buf, int bufSize) |
| |
| bool | mupnp_device_announcefrom (mUpnpDevice *dev, char *bindAddr) |
| |
| void | mupnp_device_announce (mUpnpDevice *dev) |
| |
| bool | mupnp_device_byebyefrom (mUpnpDevice *dev, char *bindAddr) |
| |
| void | mupnp_device_byebye (mUpnpDevice *dev) |
| |
| bool | mupnp_device_postsearchresponse (mUpnpDevice *dev, mUpnpSSDPPacket *ssdpPkt, const char *st, const char *usn) |
| |
| bool | mupnp_device_start (mUpnpDevice *dev) |
| | Start a UPnP device and begin advertising on the network.
|
| |
| bool | mupnp_device_ipchanged (mUpnpDevice *dev) |
| |
| bool | mupnp_device_stop (mUpnpDevice *dev) |
| | Stop a UPnP device and cease network advertising.
|
| |
| bool | mupnp_device_isrunning (mUpnpDevice *dev) |
| |
| mUpnpService * | mupnp_device_getservicebyserviceid (mUpnpDevice *dev, const char *serviceId) |
| |
| mUpnpService * | mupnp_device_getservicebyexacttype (mUpnpDevice *dev, const char *type) |
| |
| mUpnpService * | mupnp_device_getservicebytype (mUpnpDevice *dev, const char *type) |
| |
| mUpnpService * | mupnp_device_getservicebyscpdurl (mUpnpDevice *dev, const char *url) |
| |
| mUpnpService * | mupnp_device_getservicebycontrolurl (mUpnpDevice *dev, const char *url) |
| |
| mUpnpService * | mupnp_device_getservicebysid (mUpnpDevice *dev, const char *sid) |
| |
| void | mupnp_device_setactionlistener (mUpnpDevice *dev, MUPNP_ACTION_LISTNER actionListner) |
| |
| void | mupnp_device_setquerylistener (mUpnpDevice *dev, MUPNP_STATEVARIABLE_LISTNER queryListner) |
| |
| mUpnpService * | mupnp_device_getservicebyeventsuburl (mUpnpDevice *dev, const char *url) |
| |
| mUpnpIcon * | mupnp_device_getsmallesticonbymimetype (mUpnpDevice *dev, const char *mimeType) |
| |
| mUpnpIcon * | mupnp_device_getsmallesticon (mUpnpDevice *dev) |
| |
| bool | mupnp_device_getabsoluteiconurl (mUpnpDevice *dev, mUpnpIcon *icon, mUpnpString *buf) |
| |
| mUpnpAction * | mupnp_device_getactionbyname (mUpnpDevice *dev, const char *name) |
| |
| mUpnpStateVariable * | mupnp_device_getstatevariablebyname (mUpnpDevice *dev, const char *name) |
| |
| bool | mupnp_device_addicon (mUpnpDevice *dev, mUpnpIcon *icon) |
| |
| void | mupnp_device_updateudn (mUpnpDevice *dev) |
| |
| void | mupnp_device_setpresentationlistener (mUpnpDevice *dev, MUPNP_PRESENTATION_LISTNER func) |
| |
Start a UPnP device and begin advertising on the network.
Activates the device and starts all required network services:
- HTTP server for device description, SOAP control, and eventing (default port: 38400, or as set by mupnp_device_sethttpport())
- SSDP multicast listener for M-SEARCH discovery requests
- SSDP advertisement broadcaster (sends periodic ssdp:alive messages)
- Sends initial ssdp:alive notifications for the device and all its services
After successful startup, the device will:
- Respond to M-SEARCH discovery requests from control points
- Periodically advertise its presence via ssdp:alive (based on lease time)
- Accept action invocations via SOAP
- Accept event subscriptions and send notifications
The device description must be properly configured before calling this function (friendly name, UDN, services, etc.).
- Parameters
-
| dev | The device to start. Must not be NULL and must have a valid description with at least a UDN and device type. |
- Return values
-
| true | Successfully started all services |
| false | Failed to start due to:
- NULL parameter
- HTTP port already in use
- Network error (e.g., cannot bind to multicast address)
- Invalid or incomplete device description
- Insufficient permissions
|
- Note
- This function may fail if the HTTP port is already in use. Configure an alternative port with mupnp_device_sethttpport() if needed.
-
Thread-safe: Can be called from any thread, but must not be called concurrently on the same device.
-
Calling this function on an already-running device has no effect and returns true.
-
Side effect: Sends SSDP advertisements to the network immediately and starts the advertisement thread.
- Warning
- On some platforms, binding to multicast addresses may require elevated privileges.
-
Ensure proper firewall configuration to allow:
- Incoming TCP on HTTP port
- Outgoing UDP to SSDP multicast address (239.255.255.250:1900)
- Incoming UDP on SSDP port (1900)
- See also
- mupnp_device_stop()
-
mupnp_device_isrunning()
-
mupnp_device_sethttpport()
-
mupnp_device_setleasetime()
printf("Device started and advertising\n");
} else {
fprintf(stderr, "Failed to start device\n");
}
mUpnpDevice * mupnp_device_new(void)
Create a new UPnP device instance.
Definition device.c:41
void mupnp_device_delete(mUpnpDevice *dev)
Delete a UPnP device and free all associated resources.
Definition device.c:95
bool mupnp_device_start(mUpnpDevice *dev)
Start a UPnP device and begin advertising on the network.
Definition device.c:1373
void mupnp_device_updateudn(mUpnpDevice *dev)
Definition device.c:2082
void mupnp_device_setquerylistener(mUpnpDevice *dev, MUPNP_STATEVARIABLE_LISTNER queryListner)
Definition device.c:1804
void mupnp_device_setactionlistener(mUpnpDevice *dev, MUPNP_ACTION_LISTNER actionListner)
Definition device.c:1784
#define mupnp_device_setmodelname(dev, value)
Definition device.h:565
#define mupnp_device_setdevicetype(dev, value)
Definition device.h:384
#define mupnp_device_setfriendlyname(dev, value)
Definition device.h:477
#define mupnp_device_setmanufacturer(dev, value)
Definition device.h:499
The generic UPnP device structure.
Definition device.h:122
Stop a UPnP device and cease network advertising.
Gracefully shuts down all network services:
- Sends ssdp:byebye notifications for the device and all its services, informing control points that the device is leaving the network
- Stops the HTTP server (no longer accepts connections)
- Closes SSDP multicast listener
- Terminates the advertisement broadcaster thread
After stopping, the device will no longer:
- Respond to M-SEARCH discovery requests
- Accept action invocations
- Send periodic advertisements
- Accept event subscriptions or send notifications
The device description and configuration are retained. The device can be restarted with mupnp_device_start().
- Parameters
-
| dev | The device to stop. Must not be NULL. |
- Return values
-
| true | Successfully stopped all services and sent byebye notifications |
| false | Failed to stop (unlikely), or dev is NULL |
- Note
- This function blocks until:
- ssdp:byebye messages are sent (a few hundred milliseconds)
- All listener threads have terminated (may take a few seconds)
-
Calling this function on an already-stopped device has no effect and returns true.
-
Thread-safe: Can be called from any thread, but must not be called concurrently on the same device.
-
Side effect: Sends SSDP byebye messages to the network, which should prompt control points to remove the device from their lists.
-
Active event subscriptions are not explicitly cancelled. Subscribed control points will detect the device is unavailable when subscriptions expire or when they attempt to renew.
- See also
- mupnp_device_start()
-
mupnp_device_isrunning()
-
mupnp_device_delete()