Building Bluetooth Applications On The Windows CE 5.0 And Windows Mobile Platforms .


96 views
Uploaded on:
Description
Building Bluetooth Applications On The Windows CE 5.0 And Windows Mobile Platforms. Gaurav Khanna gkhanna@microsoft.com Developer Evangelist Microsoft India. . . . . Administration Tools. Correspondences
Transcripts
Slide 1



Slide 2

Building Bluetooth Applications On The Windows CE 5.0 And Windows Mobile Platforms Gaurav Khanna gkhanna@microsoft.com Developer Evangelist Microsoft India

Slide 3

OEM/IHV Supplied BSP (ARM, SH4, MIPS) OEM Hardware and Standard Drivers Standard PC Hardware and Drivers H ardware/D waterways Windows XP DDK D evice B uilding T ools Windows Embedded Studio Platform Builder D ata L ightweight R elational EDB SQL Server 2005 Express Edition SQL Server 2005 Mobile Edition SQL Server 2005 Win32 N ative M anaged S erver S ide P rogramming M odel MFC 8.0, ATL 8.0 .NET Compact Framework .NET Framework ASP.NET Mobile Controls ASP.NET Windows Media M ultimedia DirectX L ocation S ervices MapPoint D evelopment T ools Visual Studio 2005 Internet Security and Acceleration Server C ommunications & M essaging Exchange Server Live Communications Server Speech Server Device Update Agent M anagement T ools Software Update Services Image Update Systems Management Server Microsoft Operations Manager

Slide 4

Agenda Technology Overview Bluetooth Application Concepts Windows CE Development Windows Mobile Development Demo Q&A

Slide 5

Technology Overview A short range remote correspondence innovation 10-100 meter go Operates in 2.4 GHz band utilizing recurrence bouncing Ad-Hoc organize topology Supports voice and information through isolated stations Support for gadget disclosure Devices can be questioned for abilities Standardized administrations

Slide 6

Typical Usage Scenarios Audio Services Hands Free gadgets Wireless Stereo Headsets Wireless Data administrations Share Internet Connections Ad-Hoc Data Exchange Business card exchange File trade Printing Cable Replacement Keyboard, Mouse, Printer

Slide 7

Agenda Technology Overview Bluetooth Application Concepts Windows CE Development Windows Mobile Development Demo Q&A

Slide 8

Bluetooth Devices Identified by interesting location Advertise to others in discoverable mode Class of gadget field Devices keep up rundown of upheld administrations Use Service Discovery for questioning rundown on different gadgets

Slide 9

Bluetooth Services Describe information trade conventions Identified by a one of a kind GUID Standardized administrations called "profiles" for regular utilize cases File Transfer (FTP) Dial-Up systems administration (DUN) Stereo Audio (A2DP)

Slide 10

General Tips Keep clients educated Use OS UI for gadget revelation, blending Application ought to deal with inactivity Don\'t square UI strings Handle blunders nimbly Conserve the juice Limit time in discoverable mode Keep Bluetooth Off when not being used 5 stage prepare for application advancement

Slide 11

The 5 Step Process Find gadgets in range Choose a gadget to interface with Establish a protected association (matching) Choose an administration Transfer Data

Slide 12

Step 1: Find Devices In Range Target gadgets must be in discoverable mode Client gadget tunes in to communicates from discoverable gadgets

Slide 13

Step 2: Choose A Device To Connect With OS as a rule furnishes GUI to interface with another gadget Each gadget recognized by a remarkable address

Slide 14

Step 3: Establish A Secure Connection Process called "blending" Requires both end focuses to utilize a similar stick scratch Usually some portion of associating UI

Slide 15

Step 4: Choose A Service Each administration distinguished by novel GUID Set of "standard" administrations for surely understood profiles New applications can distribute claim GUID Services more often than not picked through gadget UI

Slide 16

Step 5: Transfer Data Point to point style 2-way correspondence Applications utilize benefit/profile conventions to convey adequately

Slide 17

Agenda Technology Overview Bluetooth Application Concepts Windows CE Development Windows Mobile Development Demo Q&A

Slide 18

Bluetooth Application Programming Winsock API is reached out to bolster Bluetooth New Protocol Family for Bluetooth AF_BTH New Protocol Option BTPROTO_RFCOMM New attachment choices for Bluetooth Enable/incapacitate encryption Control send/get cradle estimate Set power level

Slide 19

Bluetooth Creating an attachment SOCKET s = attachment (AF_BT, SOCK_STREAM, BTHPROTO_RFCOMM);

Slide 20

Windows CE: Native Approach Windows Sockets APIs Device and Service Discovery: WSALookupServiceBegin(), WSALookupServiceNext(), WSALookupServiceEnd() Use standard attachment association APIs tie(), tune in(), acknowledge(), associate() Data Transfer APIs send(), recv()

Slide 21

Bluetooth Connecting an attachment SOCKADDR_BTH sa; memset (&sa, 0, sizeof(sa)); sa.addressFamily = AF_BT; sa.btAddr = b; sa.port = station; interface (s, (SOCKADDR*)&sa, sizeof(sa));

Slide 22

Bluetooth Listening on an attachment SOCKADDR_BTH sa; memset (&sa, 0, sizeof(sa)); sa.addressFamily = AF_BT; sa.port = BT_PORT_ANY; tie (server, (SOCKADDR *)&sa, sizeof(sa); getsockname(server, (SOCKADDR *)&sa, &namelen); tune in (server, 5); SOCKET s2 = acknowledge (server, (SOCKADDR *)&sa2, &size);

Slide 23

Bluetooth getsockname Use getsockname to recover server station dispensed to attachment by a call to tie and Bluetooth address of nearby gadget. SOCKADDR_BTH sab; int len = sizeof(sab); if (0 == getsockname (s, &sab, &len)) { wprintf (L"Local Bluetooth gadget is %04x%08x, server channel = %d\n", GET_NAP(sab.btAddr), GET_SAP(sab.btAddr), sab.port); }

Slide 24

Bluetooth getpeername Use getpeername on associated attachment to recover Bluetooth address of companion Bluetooth gadget. SOCKADDR_BTH sab; int len = sizeof(sab); if (0 == getpeername (s, &sab, &len)) { wprintf (L"Remote Bluetooth gadget is %04x%08x, associated with %d\n", GET_NAP(sab.btAddr), GET_SAP(sab.btAddr), sab.port); }

Slide 25

Bluetooth getsockopt Queries different parameters related with server channel or association. The parameters are as per the following: s must be Bluetooth attachment level must be SOL_RFCOMM SO_BTH_GET_MTU_MAX,…

Slide 26

Bluetooth setsockopt Configures different parameters related with server channel or association. The parameters are as per the following: s must be Bluetooth attachment level must be SOL_RFCOMM SO_BTH_AUTHENTICATE, SO_BTH_ENCRYPT, …

Slide 27

Bluetooth Discovering Devices WSAQUERYSET wsaq; wsaq.dwNameSpace = NS_BTH; WSALookupServiceBegin (&wsaq, LUP_CONTAINERS, &hLookup); WSALookupServiceNext (hLookup, LUP_RETURN_ADDR, &dwSize, pwsaResults); pNew->b = ((SOCKADDR_BTH *)pwsaResults->lpcsaBuffer->RemoteAddr.lpSockaddr)- >btAddr

Slide 28

Bluetooth Querying for names Change WSALookupServiceNext to WSALookupServiceNext (hLookup, LUP_RETURN_NAME | LUP_RETURN_ADDR, &dwSize, pwsaResults) … wcscpy (pRes->szName, pwsaResults->lpszServiceInstanceName);

Slide 29

Bluetooth Enabling Legacy Applications: Registering COM ports PORTEMUPortParams pp; memset( &pp, 0, sizeof( pp ) );/associate with serial port profile on gadget recognized by/remoteDeviceAddr pp.device = remoteDeviceAddr; pp.uuidService = SerialPortServiceClass_UUID; pp.uiportflags = RFCOMM_PORT_FLAGS_REMOTE_DCB; HANDLE h = RegisterDevice (L"COM", record, L"btd.dll", (DWORD)&pp);

Slide 30

Bluetooth Enabling Legacy Applications: Serial Data Transfer WCHAR szComPort[30];/open beforehand enlisted COM port for perusing and composing wsprintf( szComPort, L"COM%d:", file ); HANDLE hCommPort = CreateFile ( szComPort, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL ); WriteFile ( hCommPort, … ); ReadFile ( hCommPort, … );/cleanup CloseHandle ( hCommPort ); DeregisterDevice ( h );

Slide 31

Agenda Technology Overview Bluetooth Application Concepts Windows CE Development Windows Mobile Development Demo Q&A

Slide 32

Bluetooth Application Development On Windows Mobile Native Can use WinCE Winsock APIs Windows Mobile particular utility techniques BthGetMode()/BthSetMode() Managed Code Bluetooth Class Library

Slide 33

Windows Mobile: Managed Approach Use UI for matching Publish Service new BluetoothService( GUID ) List of Paired Devices BluetoothRadio.PairedDevices Connect to an administration BluetoothDevice.Connect( GUID ) Use NetworkStream objects for information exchange

Slide 34

Windows Mobile Managed Approach Benefits Simplicity Intuitive class interface for all levels of oversaw designers Focus on the application, not on the innovation Easy to manufacture custom administrations Leverage NETCF APIs for protest serialization Flexible, abnormal state organizing APIs Powerful NetworkStream class Rich threading bolster Shared Source Add and change in the engine

Slide 35

Agenda Technology Overview Bluetooth Application Concepts Windows CE Development Windows Mobile Development Demo Q&A

Slide 36

Inside the Managed Bluetooth Library

Slide 37

Enumerating Paired Devices

Slide 38

Windows Mobile Managed Library Download http://msdn.microsoft.com/installed/usewinemb/ce/sharedsrccode/west/default.aspx

Slide 39

Conclusion Bluetooth is a universal, effective specially appointed systems administration innovation Rich support on Windows CE and Windows Mobile Windows Sockets API Managed Class Library for Windows Mobile Leverage Visual Studio 2005 for local and oversaw advancement

Slide 40

Tools & Resources Build Develop Websites msdn.microsoft.com/implanted msdn.microsoft.com/versatility Newsgroups microsoft.public. pocketpc.developer smartphone.developer dotnet.framework.compactframework microsoft.public. windowsxp.embedded windowsce.platbuilder windowsce.embedded.vc Blogs blogs.msdn.com/windowsmobile vsdteam netcfteam blogs.msdn.com/mikehall Tools Windows CE 5.0 Eval Kit Windows XP Embedded Eval Kit Windows Mobile 5.0 Eval Kit

Slide 41

Your Feedback is Important! It would be ideal if you Fill Out the criticism shape Questions? gkhanna@microsoft.com

Slide 42

© 2005 Microsoft Corporation. All rights saved. This introduction is for enlightening purposes as it were. Microsoft makes no guarantees, express or inferred, in this rundown.

Recommended
View more...