[Library Bluetooth in Windows.] [Libreria para conectar Bluetooth en Windows] lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- martinartaza · 2011-06-19 11:21 En español. Estoy creando una unidad para permitir que lazarus trabaje con dispositivos Bluetooth, básicamente estoy traduciendo una DLL creada en C++ llamada btfunc.dll, estoy usando 2 archivos para lograr traducir la librería, la dirección de los documentos se la puede encontrar en: http://perseo.cs.buap.mx/bellatrix/tesis/TES965.pdf http://read.pudn.com/downloads161/ebook/728784/%E8%93%9D%E7%89%99%E6%A 8%A1%E5%9D%97%E8%B5%84%E6%96%99/API_0.83_for_BlueSoleil.2.0.0.0_Releas e_051103_web_public/Doc/IVT%20BlueSoleil%20Bluetooth%20API.doc Por el momento, eh logrado hacer funcionar 3 funciones de la librería, la cual posee 30 funciones. Eh pasado las estructuras de las librerias, pero eh cometido error en pasar algunos char[tamaño] a char en vez de pasarlo a string. También debo encontrar equivalente para uchar y otros tipos. Por el momento eh creado lo siguiente: Code: [Select]unit UBluetooth; {$mode objfpc}{$H+} interface uses   Classes, SysUtils; type     T_BLUETOOTH_DEVICE_INFO = Record        dwSize :DWORD ;        address : BYTE;        classOfDevice : Byte;        szName : char;        bPaired: boolean;     end;     T_BLUETOOTH_DEVICE_INFO_EX = Record     dwSize : DWORD;     address: BYTE ;     classOfDevice : BYTE ;     szName :CHAR ;     bPaired: Boolean; //    ucLmpVersion: UCHAR ;     wManuName: WORD ;     wLmpSubversion: WORD ; //    reserved[16] : BYTE ;     wClockOffset: WORD ;     bConnected :Boolean ;     dwDataRecvBytes: DWORD ;     dwDataSentBytes: DWORD ;     cSignalStrength : CHAR ;     end;     T_SPP_CLIENT_PARAM = Record     dwSize: DWORD ; //    ucComIndex: UCHAR ;     end;     T_DUN_CLIENT_PARAM = Record     dwSize: DWORD;     wShortcutFlags: Boolean;     bAutoDial: Boolean ;     szUserName: CHAR;     password: CHAR;     dialNumber: CHAR;     end;     T_OPP_CLIENT_PARAM =Record     dwSize: DWORD ;     wCmdFlags: WORD ;     szObjectPath: CHAR;     end;     T_SYNC_CLIENT_PARAM = Record     dwSize: DWORD ;     bShowSyncDlg: Boolean ; //    ucSyncType: UCHAR ;     end;     T_GENERAL_SERVICE_INFO = Record     dwSize: DWORD ;     dwServiceHandle: DWORD ;     wServiceClassUuid16: WORD ;     szServiceName: CHAR;     end;     T_SPPEX_SERVICE_INFO = Record     dwSize: DWORD ;     dwSDAPRecordHanlde: DWORD ; //    serviceClassUuid128: UUID ;     szServiceName: CHAR; //    ucServiceChannel: UCHAR ; //    ucComIndex: UCHAR ;       end;     T_GENERAL_CONNECT_INFO = Record     dwHandle: DWORD ;     bIsOutgoing: Boolean ;     wServiceClasss: WORD ;     remoteBdAddr: BYTE;     end;   TBluetooth = class(TComponent)   private     { private declarations }   public     function BT_InitializeLibrary() : Boolean; stdcall;     procedure BT_UninitializeLibrary() ; cdecl;     function BT_IsBlueSoleilStarted (dwSeconds :DWord) :Boolean; stdcall;   end; implementation //external 'btfunc.dll' name 'BT_InitializeLibrary'; function TBluetooth.BT_InitializeLibrary() : Boolean; stdcall;          external 'btfunc.dll' name 'BT_InitializeLibrary'; procedure TBluetooth.BT_UninitializeLibrary(); cdecl;          external 'btfunc.dll' name 'BT_UninitializeLibrary'; function TBluetooth.BT_IsBlueSoleilStarted (dwSeconds :DWord) :Boolean; stdcall;          external 'btfunc.dll' name 'BT_InitializeLibrary'; end. Para probar tiro un formulario con unos cuantos botones y llamo a las funciones de la dll. Code: [Select]unit Unit1; {$mode objfpc}{$H+} interface uses   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,   UBluetooth; type   { TForm1 }   TForm1 = class(TForm)     BTN_BT_InitializeLibrary: TButton;     btn_BT_UninitializeLibrary: TButton;     BTN_BT_IsBlueSoleilStarted: TButton;     CB_BT_InitializeLibrary: TCheckBox;     CB_BT_IsBlueSoleilStarted: TCheckBox;     E_BT_IsBlueSoleilStarted: TEdit;     Label1: TLabel;     procedure BTN_BT_InitializeLibraryClick(Sender: TObject);     procedure BTN_BT_IsBlueSoleilStartedClick(Sender: TObject);     procedure btn_BT_UninitializeLibraryClick(Sender: TObject);   private     { private declarations }   public     bl : TBluetooth;   end; var   Form1: TForm1; implementation { TForm1 } procedure TForm1.BTN_BT_InitializeLibraryClick(Sender: TObject); begin   CB_BT_InitializeLibrary.Checked:= bl.BT_InitializeLibrary(); end; procedure TForm1.BTN_BT_IsBlueSoleilStartedClick(Sender: TObject);  var    secons: DWord; begin   // Como paso de str a Dword o de Float a Dword o de lo que sea a DWord // secons:= strtoDWORD (E_BT_IsBlueSoleilStarted.text) //  CB_BT_IsBlueSoleilStarted.Checked:= BT_IsBlueSoleilStarted(secons); end; procedure TForm1.btn_BT_UninitializeLibraryClick(Sender: TObject); begin      bl.BT_UninitializeLibrary(); end; {$R *.lfm} end. ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// ////////////////////////////// In English. I am creating a unit to allow Bluetooth devices to work with lazarus, basically I'm translating a DLL created in C + + called btfunc.dll, I'm using 2 files to get the library to translate the address of the documents can be found at: http://perseo.cs.buap.mx/bellatrix/tesis/TES965.pdf http://read.pudn.com/downloads161/ebook/728784/% E8% 93% 9D% E7% 89% 99% E6% A8% A1% E5% 9D% 97% E8% B5% 84% E6% 96 20BlueSoleil 99/API_0.8 3_for_BlueSoleil.2.0.0.0_Release_051103_web_public/Doc/IVT%%%% 20Bluetooth 20API.doc At the moment, eh managed to run 3 library functions, which has 30 functions. Eh past structures of libraries, but hey erred in passing a few char [size] to char instead of passing a string. I also find equivalent uchar and other types. At the moment eh created the following: Code: [Select]unit UBluetooth; {$mode objfpc}{$H+} interface uses   Classes, SysUtils; type     T_BLUETOOTH_DEVICE_INFO = Record        dwSize :DWORD ;        address : BYTE;        classOfDevice : Byte;        szName : char;        bPaired: boolean;     end;     T_BLUETOOTH_DEVICE_INFO_EX = Record     dwSize : DWORD;     address: BYTE ;     classOfDevice : BYTE ;     szName :CHAR ;     bPaired: Boolean; //    ucLmpVersion: UCHAR ;     wManuName: WORD ;     wLmpSubversion: WORD ; //    reserved[16] : BYTE ;     wClockOffset: WORD ;     bConnected :Boolean ;     dwDataRecvBytes: DWORD ;     dwDataSentBytes: DWORD ;     cSignalStrength : CHAR ;     end;     T_SPP_CLIENT_PARAM = Record     dwSize: DWORD ; //    ucComIndex: UCHAR ;     end;     T_DUN_CLIENT_PARAM = Record     dwSize: DWORD;     wShortcutFlags: Boolean;     bAutoDial: Boolean ;     szUserName: CHAR;     password: CHAR;     dialNumber: CHAR;     end;     T_OPP_CLIENT_PARAM =Record     dwSize: DWORD ;     wCmdFlags: WORD ;     szObjectPath: CHAR;     end;     T_SYNC_CLIENT_PARAM = Record     dwSize: DWORD ;     bShowSyncDlg: Boolean ; //    ucSyncType: UCHAR ;     end;     T_GENERAL_SERVICE_INFO = Record     dwSize: DWORD ;     dwServiceHandle: DWORD ;     wServiceClassUuid16: WORD ;     szServiceName: CHAR;     end;     T_SPPEX_SERVICE_INFO = Record     dwSize: DWORD ;     dwSDAPRecordHanlde: DWORD ; //    serviceClassUuid128: UUID ;     szServiceName: CHAR; //    ucServiceChannel: UCHAR ; //    ucComIndex: UCHAR ;       end;     T_GENERAL_CONNECT_INFO = Record     dwHandle: DWORD ;     bIsOutgoing: Boolean ;     wServiceClasss: WORD ;     remoteBdAddr: BYTE;     end;   TBluetooth = class(TComponent)   private     { private declarations }   public     function BT_InitializeLibrary() : Boolean; stdcall;     procedure BT_UninitializeLibrary() ; cdecl;     function BT_IsBlueSoleilStarted (dwSeconds :DWord) :Boolean; stdcall;   end; implementation //external 'btfunc.dll' name 'BT_InitializeLibrary'; function TBluetooth.BT_InitializeLibrary() : Boolean; stdcall;          external 'btfunc.dll' name 'BT_InitializeLibrary'; procedure TBluetooth.BT_UninitializeLibrary(); cdecl;          external 'btfunc.dll' name 'BT_UninitializeLibrary'; function TBluetooth.BT_IsBlueSoleilStarted (dwSeconds :DWord) :Boolean; stdcall;          external 'btfunc.dll' name 'BT_InitializeLibrary'; end. To test firing a form with few buttons and call the functions of the dll. Code: [Select]unit Unit1; {$mode objfpc}{$H+} interface uses   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,   UBluetooth; type   { TForm1 }   TForm1 = class(TForm)     BTN_BT_InitializeLibrary: TButton;     btn_BT_UninitializeLibrary: TButton;     BTN_BT_IsBlueSoleilStarted: TButton;     CB_BT_InitializeLibrary: TCheckBox;     CB_BT_IsBlueSoleilStarted: TCheckBox;     E_BT_IsBlueSoleilStarted: TEdit;     Label1: TLabel;     procedure BTN_BT_InitializeLibraryClick(Sender: TObject);     procedure BTN_BT_IsBlueSoleilStartedClick(Sender: TObject);     procedure btn_BT_UninitializeLibraryClick(Sender: TObject);   private     { private declarations }   public     bl : TBluetooth;   end; var   Form1: TForm1; implementation { TForm1 } procedure TForm1.BTN_BT_InitializeLibraryClick(Sender: TObject); begin   CB_BT_InitializeLibrary.Checked:= bl.BT_InitializeLibrary(); end; procedure TForm1.BTN_BT_IsBlueSoleilStartedClick(Sender: TObject);  var    secons: DWord; begin   // Como paso de str a Dword o de Float a Dword o de lo que sea a DWord // secons:= strtoDWORD (E_BT_IsBlueSoleilStarted.text) //  CB_BT_IsBlueSoleilStarted.Checked:= BT_IsBlueSoleilStarted(secons); end; procedure TForm1.btn_BT_UninitializeLibraryClick(Sender: TObject); begin      bl.BT_UninitializeLibrary(); end; {$R *.lfm} end. ---------------------------------------------------------------------- martinartaza · 2011-06-19 11:26 Disculpen, no termine el mensaje anterior. Lo que necesito saber es si ya se está trabajando en esto. Además si alguien tiene algo que comentar sobre el código, por ejemplo use la T para nombrar los registro (ese es el estandar). Además si tienen algo que corregidme o guiarme o si pueden ayudarme en algo, todo tipo de comentario sera bienvenido. Desde ya muchas gracias por su tiempo. ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// ////////////////////////////// in English Sorry, do not complete the previous message. I need to know is if it is already working on this. Also if anyone has anything to say about the code, for example, use the T to name record (that's the standard). Also, if they have something to guide me or if corregidme or I help you, all kinds of comments will be welcome. Also need help, the library is very long. Already thank you very much for your time. ---------------------------------------------------------------------- Profepaco · 2013-05-29 16:33 Hola: ¿hay alguna noticia de esto? Estoy buscando como utilizar el bluettoth en Lazarus