全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:10905
推到 Plurk!
推到 Facebook!

Bluetooth 有程式可以測試嗎

答題得分者是:axsoft
kraen
一般會員


發表:5
回覆:1
積分:1
註冊:2003-12-01

發送簡訊給我
#1 引用回覆 回覆 發表時間:2006-07-27 15:23:52 IP:61.222.xxx.xxx 未訂閱

請問大大

Bluetooth有簡單又不會很複雜可以測device的嗎?因為在Builder沒有

適用的元件可以寫

axsoft
版主


發表:681
回覆:1056
積分:969
註冊:2002-03-13

發送簡訊給我
#2 引用回覆 回覆 發表時間:2006-07-28 10:41:18 IP:61.219.xxx.xxx 未訂閱

http://windowssdk.msdn.microsoft.com/en-us/library/ms678239.aspx

Bluetooth
Bluetooth Functions

<!--Content type: PSDK_1. Transform: psdk2mtps.xslt.-->

<!---->
The functions in this section are used for managing Bluetooth devices and services.
Bluetooth is also supported by using the Windows Sockets programming interface. For more information about programming Bluetooth by using the Windows Sockets interface, see BluetoothAuthenticateDevice
Sends an authentication request to a remote Bluetooth device.
BluetoothDisplayDeviceProperties Invokes the Control Panel device information property sheet.
BluetoothEnableIncomingConnections Modifies whether a local Bluetooth radio accepts incoming connections.
BluetoothFindDeviceClose Closes an enumeration handle that is associated with a device query.
BluetoothFindFirstRadio Begins the enumeration of local Bluetooth radios.
BluetoothFindNextRadio Finds the next Bluetooth radio.
BluetoothGetDeviceInfo Retrieves information about a remote Bluetooth device. The Bluetooth device must have been previously identified through a successful device inquiry function call.
BluetoothIsConnectable Determines whether a Bluetooth radio or radios is connectable.
BluetoothRegisterForAuthentication Registers a callback function that is called when a particular Bluetooth device requests authentication.
BluetoothSdpEnumAttributes Enumerates through the SDP record stream and calls the callback function for each attribute in the record.
BluetoothSdpGetContainerElementData Iterates over a container stream and returns each element that is contained within the container element.
BluetoothSdpGetString Converts a raw string that is embedded in the SDP record into a Unicode string.
BluetoothSelectDevicesFree Frees resources associated with a previous call to the BluetoothSelectDevices function.
BluetoothSetServiceState Enables or disables services for a Bluetooth device.
BluetoothUpdateDeviceRecord Updates the local computer cache about a Bluetooth device.

Send comments about this topic to Microsoft
axsoft
版主


發表:681
回覆:1056
積分:969
註冊:2002-03-13

發送簡訊給我
#3 引用回覆 回覆 發表時間:2006-07-28 10:49:13 IP:61.219.xxx.xxx 未訂閱
Bluetooth
Bluetooth Structures
http://windowssdk.msdn.microsoft.com/en-us/library/ms678257.aspx
<!--Content type: PSDK_1. Transform: psdk2mtps.xslt.-->
<!---->
This section provides definitions for structures used for managing Bluetooth devices and services.
    <!---->
Bluetooth is also supported by using the Windows Sockets programming interface. For more information about programming Bluetooth by using the Windows Sockets interface, see BLUETOOTH_ADDRESS Provides the address of a Bluetooth device. BLUETOOTH_DEVICE_INFO Provides information about a Bluetooth device. BLUETOOTH_FIND_RADIO_PARAMS Facilitates the enumeration of installed Bluetooth radios. BLUETOOTH_SELECT_DEVICE_PARAMS Facilitates and manages the visibility, authentication, and selection of Bluetooth devices and services. BTH_HCI_EVENT_INFO Used in connection with obtaining WM_DEVICECHANGE messages for Bluetooth. BTH_QUERY_DEVICE Used when querying for the presence of a Bluetooth device. BTH_RADIO_IN_RANGE Stores data about the Bluetooth devices that are within communication range. SDP_ELEMENT_DATA Stores SDP element data. SdpAttributeRange Used in a Bluetooth query to constrain the set of attributes to return in the query. SdpQueryUuidUnion Contains the UUID on which to perform an SDP query. Used in conjunction with the SdpQueryUuid structure. SOCKADDR_BTH Used in conjunction with Bluetooth socket operations as defined by the AF_BTH address family.
axsoft
版主


發表:681
回覆:1056
積分:969
註冊:2002-03-13

發送簡訊給我
#4 引用回覆 回覆 發表時間:2006-07-28 10:52:39 IP:61.219.xxx.xxx 未訂閱
Bluetooth
Bluetooth Callbacks
<!--Content type: PSDK_1. Transform: psdk2mtps.xslt.-->
<!---->
The Bluetooth callback functions in this section are used in combination with functions that make it possible to manage Bluetooth devices and services.
    <!---->
Bluetooth is also supported by using the Windows Sockets programming interface. For more information about programming Bluetooth by using the Windows Sockets interface, see PFN_AUTHENTICATION_CALLBACK Used in conjunction with the PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK Called once for each attribute found in the pSDPStream parameter that is passed to the PFN_DEVICE_CALLBACK Used in association with selecting Bluetooth devices.
axsoft
版主


發表:681
回覆:1056
積分:969
註冊:2002-03-13

發送簡訊給我
#5 引用回覆 回覆 發表時間:2006-07-28 11:02:53 IP:61.219.xxx.xxx 未訂閱

Bluetooth Programming with Windows Sockets
http://windowssdk.msdn.microsoft.com/en-us/library/ms678241.aspx

<!--Content type: PSDK_1. Transform: psdk2mtps.xslt.--><!---->
This section describes how to use Windows Sockets functions and structures to program a Bluetooth application. Complete reference information for the Windows Sockets API elements can be found in the Windows Sockets section of the Platform SDK; this section provides only Bluetooth-specific information for each Windows Sockets programming element.
As with all Windows Sockets application programming, the WSAStartup function must be called to initiate Windows Sockets functionality and enable Bluetooth.
Windows Sockets 2
WSAStartup
<!--Content type: PSDK_1. Transform: psdk2mtps.xslt.-->
<!---->
The WSAStartup function initiates use of WS2_32.DLL by a process.
int WSAStartup(
  WORD wVersionRequested,
  LPWSADATA lpWSAData
);
Parameters
wVersionRequested
[in] Highest version of Windows Sockets support that the caller can use. The high-order byte specifies the minor version (revision) number; the low-order byte specifies the major version number.
lpWSAData
[out] Pointer to the WSADATA data structure that is to receive details of the Windows Sockets implementation.
Return Values
The WSAStartup function returns zero if successful. Otherwise, it returns one of the error codes listed in the following.
An application cannot call WSAGetLastError to determine the error code as is normally done in Windows Sockets if WSAStartup fails. The WS2_32.DLL will not have been loaded in the case of a failure so the client data area where the last error information is stored could not be established.
Error code Meaning
WSASYSNOTREADY Indicates that the underlying network subsystem is not ready for network communication.
WSAVERNOTSUPPORTED The version of Windows Sockets support requested is not provided by this particular Windows Sockets implementation.
WSAEINPROGRESS A blocking Windows Sockets 1.1 operation is in progress.
WSAEPROCLIM Limit on the number of tasks supported by the Windows Sockets implementation has been reached.
WSAEFAULT The lpWSAData is not a valid pointer.

Remarks
The WSAStartup function must be the first Windows Sockets function called by an application or DLL. It allows an application or DLL to specify the version of Windows Sockets required and retrieve details of the specific Windows Sockets implementation. The application or DLL can only issue further Windows Sockets functions after successfully calling WSAStartup.
In order to support future Windows Sockets implementations and applications that can have functionality differences from the current version of Windows Sockets, a negotiation takes place in WSAStartup. The caller of WSAStartup and the WS2_32.DLL indicate to each other the highest version that they can support, and each confirms that the other's highest version is acceptable. Upon entry to WSAStartup, the WS2_32.DLL examines the version requested by the application. If this version is equal to or higher than the lowest version supported by the DLL, the call succeeds and the DLL returns in wHighVersion the highest version it supports and in wVersion the minimum of its high version and wVersionRequested. The WS2_32.DLL then assumes that the application will use wVersion If the wVersion parameter of the WSADATA structure is unacceptable to the caller, it should call WSACleanup and either search for another WS2_32.DLL or fail to initialize.
It is legal and possible for an application written to this version of the specification to successfully negotiate a higher version number version. In that case, the application is only guaranteed access to higher-version functionality that fits within the syntax defined in this version, such as new Ioctl codes and new behavior of existing functions. New functions may be inaccessible. To get full access to the new syntax of a future version, the application must fully conform to that future version, such as compiling against a new header file, linking to a new library, or other special cases.
This negotiation allows both a WS2_32.DLL and a Windows Sockets application to support a range of Windows Sockets versions. An application can use WS2_32.DLL if there is any overlap in the version ranges. The following table shows how WSAStartup works with different applications and WS2_32.DLL versions.
App versions DLL versions wVersion
requested
wVersion wHigh
version
End result
1.1 1.1 1.1 1.1 1.1 use 1.1
1.0 1.1 1.0 1.1 1.0 1.0 use 1.0
1.0 1.0 1.1 1.0 1.0 1.1 use 1.0
1.1 1.0 1.1 1.1 1.1 1.1 use 1.1
1.1 1.0 1.1 1.0 1.0 Application fails
1.0 1.1 1.0 --- --- WSAVERNOTSUPPORTED
1.0 1.1 1.0 1.1 1.1 1.1 1.1 use 1.1
1.1 2.0 1.1 2.0 1.1 1.1 use 1.1
2.0 2.0 2.0 2.0 2.0 use 2.0

Example Code
The following code fragment demonstrates how an application that supports only version 2.2 of Windows Sockets makes a WSAStartup call:
WORD wVersionRequested;
WSADATA wsaData;
int err;
 
wVersionRequested = MAKEWORD( 2, 2 );
 
err = WSAStartup( wVersionRequested, &wsaData );
if ( err != 0 ) {
    /* Tell the user that we could not find a usable */
    /* WinSock DLL.                                  */
    return;
}
 
/* Confirm that the WinSock DLL supports 2.2.*/
/* Note that if the DLL supports versions greater    */
/* than 2.2 in addition to 2.2, it will still return */
/* 2.2 in wVersion since that is the version we      */
/* requested.                                        */
 
if ( LOBYTE( wsaData.wVersion ) != 2 ||
        HIBYTE( wsaData.wVersion ) != 2 ) {
    /* Tell the user that we could not find a usable */
    /* WinSock DLL.                                  */
    WSACleanup( );
    return; 
}
 
/* The WinSock DLL is acceptable. Proceed. */
Example Code
Once an application or DLL has made a successful WSAStartup call, it can proceed to make other Windows Sockets calls as needed. When it has finished using the services of the WS2_32.DLL, the application or DLL must call WSACleanup to allow the WS2_32.DLL to free any resources for the application.
Details of the actual Windows Sockets implementation are described in the WSADATA structure.
An application or DLL can call WSAStartup more than once if it needs to obtain the WSADATA structure information more than once. On each such call the application can specify any version number supported by the DLL.
An application must call one WSACleanup call for every successful WSAStartup call to allow third-party DLLs to make use of a WS2_32.DLL on behalf of an application. This means, for example, that if an application calls WSAStartup three times, it must call WSACleanup three times. The first two calls to WSACleanup do nothing except decrement an internal counter; the final WSACleanup call for the task does all necessary resource deallocation for the task.
Requirements
Client Requires Windows Vista, Windows XP, Windows 2000 Professional, Windows NT Workstation, Windows Me, Windows 98, or Windows 95.
Server Requires Windows Server "Longhorn", Windows Server 2003, Windows 2000 Server, or Windows NT Server.
Header
Declared in Winsock2.h.
Library
Use Ws2_32.lib.
DLL Requires Ws2_32.dll.
See Also

kraen
一般會員


發表:5
回覆:1
積分:1
註冊:2003-12-01

發送簡訊給我
#6 引用回覆 回覆 發表時間:2006-08-02 15:25:11 IP:61.222.xxx.xxx 未訂閱

請問大大你有用api寫過相關的測試程式嗎

因為上面太多看了有點沒看沒懂小弟功力不夠

可以指點一下用那幾個api就可以單純測試連線

taishyang
站務副站長


發表:377
回覆:5490
積分:4563
註冊:2002-10-08

發送簡訊給我
#7 引用回覆 回覆 發表時間:2008-10-29 10:34:17 IP:118.169.xxx.xxx 訂閱
小弟最近也在接觸bluetooth的案子,有些心得可以分享一下
最早小弟已經可以透過USB dongle來控制WII搖桿
但是藍芽連線的部份得手動連線[控制台]->[藍芽]... 這過程繁瑣又麻煩
所以小弟在網路上找到下面範例
http://www.codeproject.com/KB/winsdk/BluetoothAPI__Device_Enum.aspx
可以用程式自己控制連線,但連線的部分還是得手動(程式會呼叫出連線的畫面)

繼續google的結果可以找到VCL元件
http://www.btframework.com/
Bluetooth Framework VCL
雖然BCB可以使用,但他的範例全部都是Delphi,且出現錯誤訊息看不出問題在哪(小弟功力太差)

於是繼續google的結果終於找到可以用的範例
http://discussion.forum.nokia.com/forum/showthread.php?t=78477
他是利用MS本身所提供的Bluetooth API

但過程中遇到一個問題,add Irprops.lib到專案中
會出格式錯誤的訊息
這時只要利用BCB附的小程式coff2omf.exe,就可以轉成BCB可以用的格式

連線的步驟大約如下
1. search radio
2. search BT device
3. set service
(實驗的結果 網路上的文章提到:必須要在set service前先呼叫BluetoothRemoveDevice才能確保每次都能呼叫成功)
4. register

大致是這樣 ^_^




系統時間:2024-03-29 10:14:14
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!