Package brisa :: Package upnp :: Package control_point :: Module control_point :: Class ControlPoint
[hide private]
[frames] | no frames]

Class ControlPoint

source code

object --+
         |
        ControlPoint

This class implements UPnP Control Point functionalities.

The simplest way of using it is by subscribing for the device events, starting it with start() and search for devices with start_search(). Note that after start() the control point will be already listening for notifications. It will be listening for search responses only after start_search().

Available events for subscription:

You may stop the control point anytime with stop() and it can be reused by calling start() again. If you want to stop it definitely, you may use destroy().

Instance Methods [hide private]
 
__init__(self, receive_notify=True)
ControlPoint class constructor.
source code
 
get_devices(self)
Returns a dict of devices found.
source code
 
is_running(self) source code
 
start(self)
Starts the control point.
source code
 
stop(self)
Stops the control point.
source code
 
destroy(self)
Destroys and quits the control point definitely.
source code
 
_cleanup(self)
Cleanup references.
source code
 
subscribe(self, name, callback)
Subscribes the callback for an event.
source code
 
unsubscribe(self, name, callback)
Unsubscribes the callback for an event.
source code
 
start_search(self, interval, search_type="ssdp:all", reset=False)
Sends a multicast M-SEARCH message to discover UPnP devices.
source code
 
stop_search(self)
Stops the device search.
source code
 
force_discovery(self, search_type="ssdp:all")
Forces a multicast MSearch bypassing the time interval.
source code
boolean
is_msearch_running(self)
Returns whether MSEARCH is running or not.
source code
boolean
_get_recv_notify(self)
GET function for the receive_notify property.
source code
 
_set_recv_notify(self, n)
SET function for the receive_notify property.
source code
 
_new_device_event(self, st, device_info)
Receives a new device event.
source code
 
_new_device_event_impl(self, device_info, device)
Real implementation of the new device event handler.
source code
 
_removed_device_event(self, device_info)
Receives a removed device event.
source code
 
_on_event(self, sid, changed_vars)
Receives an event.
source code
 
_callback(self, name, *args)
Callback for any event.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  msg_already_started = 'tried to start() ControlPoint when alre...
  msg_already_stopped = 'tried to stop() ControlPoint when alrea...
  receive_notify = property(_get_recv_notify, _set_recv_notify, ...
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, receive_notify=True)
(Constructor)

source code 

ControlPoint class constructor.

Parameters:
  • receive_notify (boolean) - if False, ignores notify messages from devices. Default value is True and it can be set during runtime
Overrides: object.__init__

subscribe(self, name, callback)

source code 

Subscribes the callback for an event.

Parameters:
  • name (string) - event name
  • callback (callable) - callback which will listen on the event

unsubscribe(self, name, callback)

source code 

Unsubscribes the callback for an event.

Parameters:
  • name (string) - event name
  • callback (callable) - callback which listens for the event

start_search(self, interval, search_type="ssdp:all", reset=False)

source code 

Sends a multicast M-SEARCH message to discover UPnP devices.

Parameters:
  • interval (float) - interval to wait between sending search messages
  • search_type (string) - UPnP type search. Default value is "ssdp:all"
  • reset (boolean) - clears the device list from any previous search

force_discovery(self, search_type="ssdp:all")

source code 

Forces a multicast MSearch bypassing the time interval. This method force msearch to send discovery message, bypassing the initial time interval passed to start_search function. Note this method doesn't cause any effect if the start_search call was never called.

Parameters:
  • search_type (string) - UPnP type search

is_msearch_running(self)

source code 

Returns whether MSEARCH is running or not.

Returns: boolean
Status of the MSearch

_get_recv_notify(self)

source code 

GET function for the receive_notify property. Use self.receive_notify instead.

Returns: boolean
The receive_notify status

_set_recv_notify(self, n)

source code 

SET function for the receive_notify property. Use self.receive_notify instead.

Parameters:
  • n (boolean) - The value to be set.

_new_device_event(self, st, device_info)

source code 

Receives a new device event.

Parameters:
  • st (string) - defines the device type
  • device_info (dict) - informations about the device

_new_device_event_impl(self, device_info, device)

source code 

Real implementation of the new device event handler.

Parameters:
  • device_info (dict) - informations about the device
  • device (Device) - the device object itself

_removed_device_event(self, device_info)

source code 

Receives a removed device event.

Parameters:
  • device_info (dict) - information about the device

_on_event(self, sid, changed_vars)

source code 

Receives an event.

Parameters:
  • sid (str) - Service id
  • changed_vars (dict) - Variables that have changed

_callback(self, name, *args)

source code 

Callback for any event. Forwards the event to the subscribed callbacks.

Parameters:
  • name (string) - event name
  • args (tuple) - arguments for the callbacks

Class Variable Details [hide private]

msg_already_started

Value:
'tried to start() ControlPoint when already started'

msg_already_stopped

Value:
'tried to stop() ControlPoint when already stopped'

receive_notify

Value:
property(_get_recv_notify, _set_recv_notify, doc= 'If False, the contr\
ol point ignores NOTIFY\
                              messages from devices.')