Category: Bluetooth

  • Bluetooth Library (March Edition)

    To facilitate using the library in Visual Studio 2005 Betas I have made a few minor updates to the managed Bluetooth library, new/fixed in this release:-



    • Now works under .NETCF 1.0, .NETCF 2.0, .NET 1.1 .NET 2.0 (Not tested under the .NET 1.0 desktop framework but should work).
    • On Windows CE remote name lookups are performed “on-demand” rather than during device discovery to reduce discovery time.
    • Reintroduced the BluetoothSocket helper class which provides a shortcut to create a Socket for working with Bluetooth independently of the existing BluetoothClient / BluetoothListener classes.
    • Removed OpenNETCF.dll dependency, cures deployment problems on desktop machines.

    Download the latest version here:-


    Downloads


     

  • Bluetooth Remote Control

    Mike Hall posted a link on his blog to a channel9 interview with Anil Dhawan from the Windows Mobile team discussing Bluetooth programming, which I recommend you check out. Anil gave a demo of a native code application to remote control PowerPoint on a desktop PC. This inspired me to put some finishing touches to a test application I built for the Bluetooth .NETCF library – It is by no means finished but it works (with the wind blowing in the right direction!).


    There are two components, on the Smartphone an application which you first select Search from the menu and it will do a lookup of local discoverable devices, then select one and select the Connect menu option. Once connected any d-pad or number keys are captured and sent over bluetooth. As I said it was an unfinished project, key items missing are:-



    • Store desktop address in the registry so we only have to search once

    • More intuitive interface 🙂

    • Support for key mapping – map the device keys to application specific commands e.g. for media player etc

    On the desktop a simple listener which listens on a custom service, incoming data is received as keycodes which are broadcast on the system using the SendKeys.Send method.


    On an unrelated note, thanks to Sergey Bogdanov who has contributed an implementation of the SendKeys class to be included in the upcoming SDF v1.3 release.


    With the listener application running and the Smartphone client connected you can automate (within reason) whatever app has the focus. It works great for Powerpoint browsing between slides using the d-pad on the phone. The usual disclaimer applies – this works only with the Microsoft Bluetooth stack on both device and desktop, I tested with an Orange SPV C500.


    The two projects are available to download here.

  • Bluetooth Library (February Edition)

    Not a huge amount of change since last months release but I just wanted to post the latest update. The download includes the same Chat application samples along with the complete solution for the library itself.


    Downloads


    The main changes in this release are:-



    • BluetoothRadio class which handles the radio state on a single or multiple radio device. Multiple radios are only supported on XP, Windows CE supports a single radio device.
    • BluetoothSecurity class which has a couple of methods to automate the pairing (bonding) process between devices. Using SetPin and RevokePin you can specify the PIN to use with a particular remote device. Using PairRequest you can force the device to intiate a connection and bond with the remote device with the specified PIN code. Currently the BluetoothSecurity class is built for Windows CE only, in a future update this functionality will be extended to run on the desktop too.
    • General housekeeping – P/Invokes have been moved into a single NativeMethods class and a few new ones added, though not all are used by the library yet.

    Online documentation for this build can be browsed here.

  • Visually identify your Bluetooth stack

    Since it’s such a frequently asked question I’ve documented it here with some images which should hopefully clear up any confusion. The following screenshots show how to identify the Bluetooth stack on your Pocket Pc without writing any code or delving into the registry or system files.





















    Microsoft


    Widcomm/Broadcom

    Bluetooth Off

    Microsoft Stack (Disabled)


    Widcomm Stack (Disabled)

    Bluetooth On

    Microsoft Stack (Enabled)


    Widcomm Stack (Enabled)

    Settings (Click Icon)

    Microsoft Stack Settings



    Pocket PC 2003 Second Edition


    Microsoft Stack Settings Second Edition


    Widcomm Stack Menu


     


    Finally a quick reminder, the Bluetooth.NET library only works currently with the Microsoft stack, so if you have Widcomm/Broadcom or any other you’ll have to look at third-party APIs.

  • Bluetooth Build 50115

    I’ve posted an updated build of the Bluetooth library here. It adds full support for the desktop, improved class-of-device and other properties.


    The sample app is now supplied in Pocket Pc, Smartphone and Desktop versions which all talk to each other.

  • Rudolph the Bluetoothed Reindeer

    I’ve uploaded a new release of the Bluetooth library which adds the key feature of hosting services over bluetooth. This now allows two-way communications between devices and to demonstrate how this works I’ve included a sample Bluetooth Chat application. This registers a custom bluetooth profile and listens for incoming connections, and creates outgoing connections using this service identifier to other devices. In this way it only communicates with other devices exposing this service and wont interfere with any other applications using Bluetooth.


    Thanks go out to Wei-Meng Lee for giving permission to base the sample on his previous IrDA chat application available with this MSDN article. The Bluetooth version works in a very similar way, with the exception of doing a device discovery when it first loads. An enhancement yet to be added is the ability to periodically discover in a background thread. From the app screen select the target device which must also be running the software and Bluetooth must be Discoverable. Then type your message and click send and it will appear onscreen on the other device. In the below example I had a brief conversation with Santa who was half-way up a chimney at the time – such is the versatility of Bluetooth 🙂

    Bluetooth Chat

    The ZIP file below includes the Bluetooth library project and compiled output, and the BTChat sample project. As I get time to do more work on the library I’ll post some other examples, and include versions for other platforms e.g. Smartphone and XP.


    Known issues:-



    • Hosting services doesn’t yet work on XP (some of the structures are slightly different so this requires a little more work)
    • BluetoothClient.RemoteDeviceName doesn’t work so you can’t retrieve the device name from an open connection (Device names work correctly during discovery on both Windows CE and XP)
    • BluetoothSerialPort (For emulating a COM port) is not fully tested and probably doesn’t work – SerialPortProfile connections work great using sockets (BluetoothClient).

    Requirements:-



    • SDF v1.2
    • Windows CE Device or Windows XP computer using the Microsoft Bluetooth stack (Sorry but Widcomm is not supported).

    Download:-


    Downloads


     


    If you have any comments or questions please drop me an email. For now all that remains is for me to wish you a Very Merry Christmas!

  • Online Bluetooth code updated

    There were some recent enquries on the OpenNETCF Forums about the current Bluetooth code. It seems I had refreshed the website with some development code which would only work if a couple of items were commented out. This is because these classes (Sdp related) are still under development and require COM interop and are currently built against InTheHand.Interop.dll which does COM interop with no native DLL required, and is used in my PocketOutlook and ADOCE products.


    So I’ve updated the code online and attached a .zip of the project below which will build successfully against the v1.2 SDF (and the compiled dll is included in the bin folder). Documentation is in the online library at http://32feet.net/library/


    I’m working on a sample application to accompany the library, but it’s been tested with a Bluetooth GPS unit and a Jabra headset successfully (Before you ask it only uses the control functionality of the headset, not the audio stream). But you can programmatically make the headset ring and capture the event when the user presses the answer button. Not terribly exciting but an interesting start, I guess I need some more unusual Bluetooth devices to test against.


    What isn’t working in this release is the ability to host a service and allow other devices to discover it, since this requires some of the ongoing Sdp work. Once this is in place you will be able to do data transfer between devices which is when the fun will really begin!


    Also bear in mind this is designed to work only with devices with the Microsoft Bluetooth stack, for example HTC Phone Edition devices and most Smartphone 2003 models.


    Downloads

  • Toggle Bluetooth on an iPaq device

    We can already enable and disable Bluetooth on devices equipped with Microsoft’s Bluetooth stack. In the case of iPaq devices, which use the Widcomm stack, it is possible to toggle the radio state using an API provided in HP’s iPAQUtil.dll. This can be P/Invoked from a .NETCF project like so:-


    [DllImport(“iPAQUtil.dll”, SetLastError=true)]


    public static extern bool iPAQSetBlueToothRadio(ref int lpdwValue);


    Which you can then call with:-


    int val = 0;


    iPAQSetBlueToothRadio(ref val);


    Where val is either 0 to disable Bluetooth, or 1 to enable it. Tested on an iPaq 2210 but should work on any other iPaq device with Bluetooth.


    Update:-


    The following should also work for devices with WiFi built in:-


    [DllImport(“iPAQUtil.dll”, SetLastError=true)]


    public static extern bool iPAQSetWLANRadio(ref int lpdwValue);

    But I’ve not been able to test this myself.