tags:

views:

2499

answers:

2

Does anyone have any idea how to track the signal strength of a bluetooth connection perferably in C#?

I was thinking using a WMI query but couldn't track down the WMI class encapsulating the connection.

The idea is when I leave my machine with my cellphone in pocket the bluetooth signal weakens and my machine locks and I don't get goated.

+2  A: 

The Link Manager Protocol (LMP) running in a Bluetooth device looks after the link setup and configuration. This is all done by two devices exchanging Protocol Data Units (PDUs).The hardware and software functionality of the RSSI is provided at the LMP level that permits you to manage the RSSI Data. It allows you to read the RSSI level and control the TX RF output power (the LMP power commands) LMP for control and to get at status information.

So what you are actually looking for is defined in the LMP when using the MS Bluetooth stack. The MS Bluetooth Stack HCI interface already supports functions below i.e

HCI_READHCIPARAMETERS
HCI_STARTHARDWARE
HCI_STOPHARDWARE
HCI_SETCALLBACK
HCI_OPENCONNECTION
HCI_READPACKET
HCI_WRITEPACKET
HCI_CLOSECONNECTION

I suppose microsoft could have implemented a function called HCI_Read_RSSI but they didn't.

To obtain the the RSSI data you will have to use the LMP to get the info you need.

Example psuedocode to read RSSI Data

// Read HCI Parameters

#include <windows.h>
#include <windev.h>
#include <bt_buffer.h>
#include <bt_hcip.h>
#include <bt_os.h>
#include <bt_debug.h>
#include <svsutil.hxx>
#include <bt_tdbg.h>

unsigned short hci_subversion, lmp_subversion, manufacturer;
unsigned char hci_version, lmp_version, lmp_features[8];

if (BthReadLocalVersion (&hci_version, &hci_subversion, &lmp_version, &lmp_subversion, &manufacturer, lmp_features) != ERROR_SUCCESS) {
            SetUnloadedState ();
            return 0;
      }
WCHAR szLine[MAX_PATH]
unsigned char *pf = lmp_features;

if ((*pf) & 0x02) {
wsprintf (szLine, L"   RSSI");
}

This will ONLY work with the Microsoft bluetooth stack. This is C++ code also. I got this from the experts exchange post(I know) at the bottom of the page. http://www.experts-exchange.com/Programming/Wireless_Programming/Bluetooth/Q_21267430.html

There is no specific function that does it for you.

Also there is this library that may help you, I haven't looked through the documentation completely but I've heard good things about it. http://inthehand.com/content/32feet.aspx

Goodluck man!

peregrine
A: 

is there any way to implement this on iphone application.....

Lokesh