Module btpycom :: Class BTServer
[hide private]
[frames] | no frames]

Class BTServer

source code

        object --+        
                 |        
threading._Verbose --+    
                     |    
      threading.Thread --+
                         |
                        BTServer

Class that represents a Bluetooth server.

Instance Methods [hide private]
 
__init__(self, serviceName, stateChanged, isVerbose=False)
Creates a Bluetooth server that listens for a connecting client.
source code
 
run(self)
Method representing the thread's activity.
source code
 
disconnect(self)
Closes the connection with the client and enters the LISTENING state
source code
 
sendMessage(self, msg)
Sends the information msg to the client (as String, the character (ASCII 0) serves as end of string indicator, it is transparently added and removed)
source code
 
terminate(self)
Terminates the server (finishs the listening state).
source code
 
isConnected(self)
Returns True, if a client is connected to the server.
source code
 
isTerminated(self)
Returns True, if the server is in TERMINATED state.
source code

Inherited from threading.Thread: __repr__, getName, isAlive, isDaemon, is_alive, join, setDaemon, setName, start

Inherited from threading.Thread (private): _reset_internal_locks, _set_daemon, _set_ident

Inherited from threading._Verbose (private): _note

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

Static Methods [hide private]
 
debug(msg) source code
 
getVersion()
Returns the library version.
source code
Class Variables [hide private]
  isVerbose = False
  CONNECTED = "CONNECTED"
  LISTENING = "LISTENING"
  TERMINATED = "TERMINATED"
  MESSAGE = "MESSAGE"
Properties [hide private]

Inherited from threading.Thread: daemon, ident, name

Inherited from threading.Thread (private): _block

Inherited from object: __class__

Method Details [hide private]

__init__(self, serviceName, stateChanged, isVerbose=False)
(Constructor)

source code 

Creates a Bluetooth server that listens for a connecting client. The server runs in its own thread, so the constructor returns immediately. State changes invoke the callback onStateChanged(state, msg) where state is one of the following strings: "LISTENING", "CONNECTED", "MESSAGE", "TERMINATED". msg is a string with further information: LISTENING: empty, CONNECTED: connection url, MESSAGE: message received, TERMINATED: empty. The server uses an internal handler thread to detect incoming messages.

Parameters:
  • serviceName - the service name the server is exposing
  • stateChanged - the callback function to register
  • isVerbose - if true, debug messages are written to System.out, default: False
Overrides: object.__init__

run(self)

source code 

Method representing the thread's activity.

You may override this method in a subclass. The standard run() method invokes the callable object passed to the object's constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.

Overrides: threading.Thread.run
(inherited documentation)

sendMessage(self, msg)

source code 

Sends the information msg to the client (as String, the character (ASCII 0) serves as end of string indicator, it is transparently added and removed)

Parameters:
  • msg - the message to send

isConnected(self)

source code 

Returns True, if a client is connected to the server.

Returns:
True, if the communication link is established

isTerminated(self)

source code 

Returns True, if the server is in TERMINATED state.

Returns:
True, if the server thread is terminated

getVersion()
Static Method

source code 

Returns the library version.

Returns:
the current version of the library