# # PyAffix - Affix socket interface for python - Bluetooth Protocol Stack for Linux # Copyright (C) 2004 Nokia Corporation # # Written by Carlos Chinea. # 1. Introduction The socket interface support for affix is given by affixsocket in python. This socket interface is based in the source code from socketmodule.c from python-2.2.3. Actually, you just can create a patch from affixsocketmodule.c and apply it to socketmodule.c in Python 2.2.3, if you don't want to have a separate socket module. This socket module supports also all the protocols supported in socket module for python-2.2.3. 2. Quick Guide to use the python affix socket interface. To use the affix socket interface in python, you just need to compile and install the affixsocketmodule. After that you just can import the module: >import affixsocket or >from affixsocket import * Once you have imported the module you can use all the socket interface functions. Non-blocking sockets are supported. To create a socket you just need to call socket() funtion: example: affix_sock=socket(PF_AFFIX,SOCK_STREAM,BTPROTO_L2CAP) The family name and protocols are: Family: PF_AFFIX Protocols: BTPROTO_HCISCO, type SOCK_SEQPACKET BTPROTO_HCIACL, type SOCK_SEQPACKET BTPROTO_L2CAP, type SOCK_SEQPACKET and SOCK_STREAM BTPROTO_RFCOMM, type SOCK_STREAM BTPROTO_L2CAP_RET, type SOCK_STREAM BTPROTO_L2CAP_FC, type SOCK_STREAM Note: L2CAP retransmission mode (BTPROTO_L2CAP_RET) L2CAP flow control mode (BTPROTO_L2CAP_FC) The following socket level and options are also supported: Socket level: SOL_AFFIX Socket option: BTSO_MTU, BTSO_SECURITY, BTSO_EVENT_MASK, BTSO_PKT_MASK, BTSO_PROMISC, BTSO_TYPE The socket address information is represented by a tuple in python: (devnum,BTaddress, port) where devnum is a positive integer representing the device. BTaddress is a string representing the Bluetooth address. port is a positive integer representing the channel/psm/etc to connect to. as an example: (0,"01:02:03:A0:B0:C0",1) Device 0, BT Address: 01:02:03:A0:B0:C0, Channel: 1 3. Notes You can get more information from the Affix documentation (specially Chapter 3): http://affix.sourceforge.net/affix-doc/ You can also find helpful the two given examples: aff_demo_server.py and aff_demo_client.py