Click here to Skip to main content
Click here to Skip to main content
Go to top

Bluetooth Connection in Windows Mobile 5.0 using InThehand - C#

, 28 Jun 2007
Rate this:
Please Sign up or sign in to vote.
Bluetooth connection in Windows Mobile 5.0

Introduction

This article discusses how Windows Mobile 5.0 devices can connect through the bluetooth using InTheHand DLL in C#.

Setting Bluetooth Discoverable in Windows Mobile

We need to set our mobile as bluetooth discoverable. In Bluetooth settings, you will check the discoverable option.

InTheHand

In Compact framework 1.0, we don't have any managed class which handles bluetooth socket connections. InTheHand is a third party component which gives the functionalities of bluetooth services for windows mobile. You can download InTheHand from here.

Using the Code

The source code is available for download from the link at the top of this article. The devices are displayed in a combobox when we click the first button name of Search devices. Then we can connect the selected device from the combobox by clicking the button named Connect.

The code is noted below which is used in the project.

//
// Directives.
//
using InTheHand.Net;
using InTheHand.Net.Bluetooth;
using InTheHand.Net.Sockets;
//
//Declaration
//
private BluetoothClient bluetoothClient;
private Guid service = BluetoothService.DialupNetworking; 
//
//Search the devices and displaying in combobox.
//
BluetoothRadio.PrimaryRadio.Mode = RadioMode.Discoverable;
bluetoothClient = new BluetoothClient();
Cursor.Current = Cursors.WaitCursor;
BluetoothDeviceInfo[] bluetoothDeviceInfo = { };
bluetoothDeviceInfo = bluetoothClient.DiscoverDevices(10);
comboBox1.DataSource = bluetoothDeviceInfo;
comboBox1.DisplayMember = "DeviceName"; 
comboBox1.ValueMember = "DeviceAddress";
comboBox1.Focus();
Cursor.Current = Cursors.Default;
//
//Connect the selected device.
//
bluetoothClient.Connect(new BluetoothEndPoint
	((BluetoothAddress)comboBox1.SelectedValue, service));

Conclusion

This will be helpful for working in Windows mobile using C#. Hereafter, we can do something via bluetooth with two Windows mobile devices.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

S.Vinothkumar
Web Developer
India India
Hi Viewers,

I wish to all. This is Vinoth. This is where I try to condense everything that you need to know about me.
 
Blog:
 
visit my blog
 
Interests:

I'm passionate about a great many things and continually learning about the things that interest me. They are wearable computers, User Interface Design, Artificial life, Industrial music.
 

 

 

Comments and Discussions

 
Questionreceiving data from a sensors PinmemberMilan126-May-13 0:19 
SuggestionWhy NullReferenceException? PinmemberWalter Luiz Rogerio30-Nov-12 12:55 
QuestionWhy NullReferenceException? Pinmemberroby58211-Sep-09 0:15 
AnswerRe: Why NullReferenceException? PinmemberGus Arik13-Sep-09 19:20 
QuestionHow to send a file after connecting Pinmemberwindvp29-May-09 0:07 
AnswerRe: How to send a file after connecting PinmemberS.Vinothkumar29-May-09 19:57 
GeneralRe: How to send a file after connecting Pinmemberfardins20-Dec-10 22:56 
How to send files here ?
GeneralBluetooth Detection and Data ransfer PinmemberPradip P Thakare5-May-09 0:05 
GeneralTransmitting Text Message to another Bluetooth Device Pinmembermahmoud ankeer14-Apr-09 22:14 
GeneralCode in C# for data transfer between mobile and pc PinmemberMalvikaBahl26-Jan-09 19:46 
GeneralTo send some text to bluetooth printer for printing using InThehand dll PinmemberCoral2824-Oct-07 22:42 
QuestionAn error occur PinmemberChunrenHu9-Oct-07 0:19 
AnswerRe: An error occur Pinmemberdesenfoque21-Apr-10 8:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 28 Jun 2007
Article Copyright 2007 by S.Vinothkumar
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid