• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Get RSSI Value inconsistent with value returned from bluetooth menu bar
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Get RSSI Value inconsistent with value returned from bluetooth menu bar


  • Subject: Get RSSI Value inconsistent with value returned from bluetooth menu bar
  • From: Tanner Ezell <email@hidden>
  • Date: Wed, 20 Oct 2010 19:07:53 -0700

All,

I've written a fairly basic application that just spits out the RSSI
of a connected device. However, the value I get back is different than
can be found via option clicking the bluetooth icon at the top of the
screen.

Any guidance would be highly appreciated.

#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
#import <IOBluetooth/objc/IOBluetoothDeviceInquiry.h>
#import <IOBluetooth/objc/IOBluetoothDevice.h>
#import <IOBluetooth/objc/IOBluetoothHostController.h>
#import <IOBluetooth/IOBluetoothUtilities.h>

@interface getRSSI: NSObject {}
-(void) readRSSIForDeviceComplete:(id)controller
device:(IOBluetoothDevice*)device

info:(BluetoothHCIRSSIInfo*)info error:(IOReturn)error;
@end

@implementation getRSSI
- (void) readRSSIForDeviceComplete:(id)controller
device:(IOBluetoothDevice*)device

info:(BluetoothHCIRSSIInfo*)info error:(IOReturn)error
{
       if (error != kIOReturnSuccess) {
               NSLog(@"readRSSIForDeviceComplete return error");
               CFRunLoopStop(CFRunLoopGetCurrent());
       }
       if (info->handle == kBluetoothConnectionHandleNone) {
               NSLog(@"readRSSIForDeviceComplete no handle");
               CFRunLoopStop(CFRunLoopGetCurrent());
       }
       [device retain];
       NSLog(@"RSSI = %i dBm", (info->RSSIValue));
       [NSThread sleepUntilDate: [NSDate dateWithTimeIntervalSinceNow: 5]];
       [device closeConnection];
       [device openConnection];
       [controller readRSSIForDevice:device];
}
@end

int main (int argc, const char * argv[]) {
       NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
       NSLog(@"start");

       IOBluetoothHostController *hci = [IOBluetoothHostController
defaultController];
       NSString *addrStr = @"xx:xx:xx:xx:xx:xx";
       BluetoothDeviceAddress addr;
       IOBluetoothNSStringToDeviceAddress(addrStr, &addr);
       IOBluetoothDevice *device = [[IOBluetoothDevice alloc] init];
       device = [IOBluetoothDevice withAddress:&addr];
       [device retain];
       [device openConnection];
       getRSSI *rssi = [[getRSSI alloc] init];
       [hci setDelegate:rssi];
       [hci readRSSIForDevice:device];
       CFRunLoopRun();
       [hci release];
       [rssi release];
       [pool release];
       return 0;
}

Cheers
Tanner Ezell
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Bluetooth-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Next by Date: scatternet
  • Next by thread: scatternet
  • Index(es):
    • Date
    • Thread