def main(): device_uuid = uuid.uuid4() local_ip_address = get_ip_address() web_server_port = 8088 http_server = UPNPHTTPServer(web_server_port, friendly_name="Xeleum Xi-Fi Gateway", manufacturer="Xeleum Lighting", manufacturer_url='http://www.xeleum.com/', model_description='Xi-Fi Gateway', model_name="Xi-F Gateway", model_number="XRF001", model_url="http://www.xeleum.com", serial_number="XRF1234", uuid=device_uuid, presentation_url="index.html") http_server.start() ssdp_server = SSDPServer() ssdp_server.register( 'local', 'uuid:{}::upnp:rootdevice'.format(device_uuid), 'upnp:rootdevice', 'http://{}:{}/description.xml'.format(local_ip_address, web_server_port)) ssdp_server.start() XrfAPI.getInstance().start() app.run(debug=True, host='0.0.0.0', port=port, use_reloader=False)
def _start_ssdp(): ssdp = SSDPServer() thread_ssdp = threading.Thread(target=ssdp.run, args=()) thread_ssdp.daemon = True # Daemonize thread thread_ssdp.start() ssdp.register( 'local', 'uuid:{}::upnp:rootdevice'.format(discoverData['DeviceID']), 'upnp:rootdevice', 'http://{}:{}/device.xml'.format(config['tvhProxyHost'], config['tvhProxyPort']), 'SSDP Server for tvhProxy')
class SSDPGenerator: def __init__(self, connection_type, mqtt_port): self.network_interface = connection_type self.device_uuid = uuid.uuid4() self.local_ip_address = self.__get_network_interface_ip_address( self.network_interface) self.http_server = UPNPHTTPServer( 8088, friendly_name="Camera Test", manufacturer="L-IoT-ning", manufacturer_url='http://liotningshop.azurewebsites.net/', model_description='Pi Camera Test', model_name="PiCamera", model_number="3000", model_url="", serial_number="JBN425133", uuid=self.device_uuid, presentation_url=("tcp://{}:" + mqtt_port).format( self.local_ip_address)) self.ssdp = SSDPServer() self.ssdp.register( 'local', 'uuid:{}::upnp:rootdevice'.format(self.device_uuid), 'upnp:rootdevice', 'http://{}:8088/jambon-3000.xml'.format(self.local_ip_address)) def __get_network_interface_ip_address(self, interface='eth0'): """ Get the first IP address of a network interface. :param interface: The name of the interface. :return: The IP address. """ while True: if interface not in ni.interfaces(): print('Could not find interface %s.' % (interface, )) exit(1) interface = ni.ifaddresses(interface) if (2 not in interface) or (len(interface[2]) == 0): print('Could not find IP of interface %s. Sleeping.' % (interface, )) sleep(60) continue return interface[2][0]['addr'] def server_start(self): thread.start_new_thread(self.http_server.start, ()) thread.start_new_thread(self.ssdp.run, ()) def server_close(self): self.http_server.shutdown() self.ssdp.shutdown() self.ssdp.unregister('uuid:{}::upnp:rootdevice'.format( self.device_uuid))
def startssdp(dvbtype): discover = getdeviceinfo.discoverdata(dvbtype) device_uuid = discover['DeviceUUID'] if config.hrtunerproxy.debug.value: logger.info('Starting SSDP for %s, device_uuid: %s' % (dvbtype,device_uuid)) local_ip_address = getIP() ssdp = SSDPServer() ssdp.register('local', 'uuid:{}::upnp:rootdevice'.format(device_uuid), 'upnp:rootdevice', 'http://{}:{}/device.xml'.format(local_ip_address,tunerports[dvbtype])) thread_ssdp = threading.Thread(target=ssdp.run, args=()) thread_ssdp.daemon = True # Daemonize thread thread_ssdp.start()
def startssdp(dvbtype): discover = getdeviceinfo.deviceinfo(dvbtype) device_uuid = discover[dvbtype]['DeviceUUID'] print '[Plex DVR API] Starting SSDP for %s, device_uuid: %s' % ( dvbtype, device_uuid) local_ip_address = getIP() ssdp = SSDPServer() ssdp.register( 'local', 'uuid:{}::upnp:rootdevice'.format(device_uuid), 'upnp:rootdevice', 'http://{}:{}/device.xml'.format(local_ip_address, tunerports[dvbtype])) thread_ssdp = threading.Thread(target=ssdp.run, args=()) thread_ssdp.daemon = True # Daemonize thread thread_ssdp.start()
from ssdp import SSDPServer from upnp_http_server import UPNPHTTPServer import uuid import logging logger = logging.getLogger() logger.setLevel(logging.DEBUG) device_uuid = uuid.uuid4() http_server = UPNPHTTPServer( 8088, friendly_name="Bigfoot device", manufacturer="Yeti SL", manufacturer_url='https://getyeti.co/', model_description='Yeti Python appliance V1', model_name="Python", model_number="1", model_url="https://github.com/netbeast/bigfoot/python", serial_number="v1", uuid=device_uuid, presentation_url="http://localhost:5000/") http_server.start() ssdp = SSDPServer() ssdp.register('local', 'uuid:{}::upnp:rootdevice'.format(device_uuid), 'bigfoot:all', 'http://localhost:8088/python-v1.xml') ssdp.run()
model_number="HPA250B", model_url="https://www.honeywellpluggedin.com/air-purifiers/shop/honeywell-air-purifier-bluetooth-smart-controls", serial_number="N/A", uuid=device_uuid, presentation_url="http://{}:5000/".format(local_ip_address)) http_server.start() print "Server started" ssdp = SSDPServer() print "SSDP started" ssdp.register('local', 'uuid:{}::urn:schemas-upnp-org:device:hpa250b:1'.format(device_uuid), 'urn:schemas-upnp-org:device:hpa250b:1', 'http://{}:8090/hpa250b.xml'.format(local_ip_address)) print "SSDP registered" ssdp.run()
http_server = UPNPHTTPServer( 8090, friendly_name="Air Mentor Pro 2", manufacturer="Air Mentor", manufacturer_url='https://www.air-mentor.com/web2017/?lang=en', model_description='Air Mentor Pro 2', model_name="Air Mentor", model_number="Air Mentor Pro 2", model_url="https://www.air-mentor.com/web2017/product/air_mentor_8096ap", serial_number="N/A", uuid=device_uuid, presentation_url="http://{}:5000/".format(local_ip_address)) http_server.start() print "Server started" ssdp = SSDPServer() print "SSDP started" ssdp.register( 'local', 'uuid:{}::urn:schemas-upnp-org:device:AirMentorPro2:1'.format(device_uuid), 'urn:schemas-upnp-org:device:AirMentorPro2:1', 'http://{}:8090/airmentorpro2.xml'.format(local_ip_address)) print "SSDP registered" ssdp.run()