The socket module of the previous PyS60 releases has been renamed as btsocket. For information on the usage of this module refer to Ensymble README. The following related constants and functions are defined:
bt_rfcomm_get_available_server_channelincorrectly expected to be given the internal
e32socket.socketobject as the socket parameter instead of the proper
socketobject. Now the functions work correctly. The old calling convention is still supported but it is deprecated and may be removed in a future release.
Represents the Bluetooth address family.
This constant represents the Bluetooth protocol RFCOMM.
Bluetooth service classes supported by
Bluetooth security mode flags.
|name, socket, flag, class)|
Sets a service advertising the service name (Unicode) on local channel
that is bound to socket. If flag is
True, the advertising is
turned on, otherwise it is turned off. The service class to be advertised is
Performs the Bluetooth device discovery (if the optional BT device address is not given) and the discovery of RFCOMM class services on the chosen device. Returns a pair: BT device address, dictionary of services, where Unicode service name is the key and the corresponding port is the value.
discover, but for discovery of OBEX class services on the
|address, channel, filename)|
Sends file filename (Unicode) wrapped into an OBEX object to remote address, channel.
Receives a file as an OBEX object, unwraps and stores it into filename
(Unicode). socket is a bound
Returns an available RFCOMM server channel for socket.
Sets the security level of the given bound socket. The
mode is an integer flag that is formed using a binary
or operation of one or more of:
AUTHOR (authorization). Example:
set_security(s, AUTH | AUTHOR).
For examples on the usage of these functions, see Programming with Python for S60 Platform .
Setting default Access Point (AP) has been added to the standard
module. The following related constants and functions are defined:
"None"will clear default access point.
import btsocket #access point is selected from the list apid = btsocket.select_access_point() apo = btsocket.access_point(apid) btsocket.set_default_access_point(apo) s = btsocket.socket(btsocket.AF_INET, btsocket.SOCK_STREAM) print apo.ip() s.connect(('www.sourceforge.net',80)) s.send('GET /\r\n\r\n') s.recv(100) s.close() apo.stop()
import btsocket #Access point id is already known apo = btsocket.access_point(1) btsocket.set_default_access_point(apo) s = btsocket.socket(btsocket.AF_INET, btsocket.SOCK_STREAM) s.connect(('www.sourceforge.net',80)) s.send('GET /\r\n\r\n') s.recv(100) s.close() apo.stop()
import btsocket #display interface ip. #access point is selected from the list apid = btsocket.select_access_point() apo = btsocket.access_point(apid) apo.start() #Note that ip-address is given by operator, if static ip-address is not defined, #when connection is started print apo.ip() #When connection is closed dynamic ip-address is released apo.stop()
See About this document... for information on suggesting changes.