Availability: S60.
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_advertise_service
,
bt_obex_receive
, and
bt_rfcomm_get_available_server_channel
incorrectly
expected to be given the internal e32socket.socket
object as the
socket parameter instead of the proper socket
object. 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 bt_advertise_service
.
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
either RFCOMM
or OBEX
.
[address]) |
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.
[address]) |
Same as discover
, but for discovery of OBEX class services on the
chosen device.
address, channel, filename) |
Sends file filename (Unicode) wrapped into an OBEX object to remote address, channel.
socket, filename) |
Receives a file as an OBEX object, unwraps and stores it into filename
(Unicode). socket is a bound OBEX
socket.
socket) |
Returns an available RFCOMM server channel for socket.
socket, mode) |
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: AUTH
(authentication),
ENCRYPT
, 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 socket
module. The following related constants and functions are defined:
) |
apid) |
apo) |
"None"
will clear default access point.
) |
Example 1:
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()
Example 2:
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()
Example 3:
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.