[PythonCE] Bluetooth

Ruben Miguelez Garcia xrubenx.es at gmail.com
Tue Feb 13 17:30:13 CET 2007


> I have extracted the libraries and files that I think contain the core of
> the Bluetooth stack for Windows CE.

	They are:

winsock2.h
ws2bth.h
bthapi.h
bthutil.h

	They can not contain absolutely everything, but the core for BT.

	I obtain this list joining all the files used by the BT library 
http://msdn2.microsoft.com/en-us/library/ms863414.aspx
	And the ones used by wmconsole
http://www.xmailserver.org/wmconsole.html

-----------

> [1] Use SWIG and compile files for PocketPC in order to use them from
> Python.

	I tried to use SWIG and compile without success. No way to eliminate too many 
errors on SWIG parser output.


	Now I am thinking on compile them as a .dll and use it with ctypes. Any 
comment, hint, suggestion, help would be welcome.


	
	------------

	By the way, I could receive Bluetooth information on the PocketPC/PDA without 
use bluetooth.
	One BT device connect to the PDA using the Serial Port Profile, so the 
connection is mapped on a COM: port. Then using the module provided by 
Benjamin McBride  -- ceserial.py --, you open the port and read. That's all.

	Here I'll let a small code, because on my way I found a lot of help just 
reading a few lines that got me out of where I was stuck.


----------
# Program to read and print the info received on COM6:  
# by Ruben  }:o)

import ceserial
MAX=1024


try:
   port=ceserial.Serial(port='COM6:')
   port.open()

   while port.isOpen(): # Need to modify this, because the port can be opened 
but the BT connection closed.
      comming=port.inWaiting()
      take= comming * (comming >= MAX) or MAX * (MAX > comming)
      data=port.read(take)
      print data
      
except KeyboardInterrupt:  # If you press Ctrl+C
      port.close()
      print "Ending program..."

except ceserial.SerialException:
      port.close()
      print "Problem with COM6. Closing and ending"

	


-- 

 Kind regards / Cumprimentos / Atentamente, Ruben.

Começar já é metade de toda ação. 

Provérbio grego


More information about the PythonCE mailing list