RSSI from Bluetooth Low Energy (BLE) Tags?

元气小坏坏 提交于 2019-12-23 05:17:42

问题


I'm writing an app (on android) to read RSSI from bluetooth devices, for location recognition using rssi fingerprinting. I have working code for reading RSSI from non-paired and discoverable bluetooth devices that are not BT4.0/BLE. I would like to know if I get some BLE-based tags (such as stick-n-find) would I be able to read their RSSI only by putting myself (my android phone to be precise), into bt-discovery mode.


回答1:


In BT Low Energy the roles are switched. The Stick-n-find would be Advertising it's service(s) Name or other information. When you receive that Advertisement from your iOS APP you will get an RSSI value with that Advertisement.

So just do something like:

@property (strong, nonatomic) CBCentralManager *CM;

#define SERVICE_ID_STR     "4d1dc300-424d-13e2-a661-0002a55dc51b"

self.CM = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
NSDictionary *scanOptions = [NSDictionary dictionaryWithObject:[NSNumber
   numberWithBool:NO] forKey:CBCentralManagerScanOptionAllowDuplicatesKey];
CBUUID *peripheralUUID = [CBUUID UUIDWithString:@SERVICE_ID_STR];
[self.CM scanForPeripheralsWithServices:[NSArray arrayWithObject:myUUID]
   options:scanOptions];

then when it hears the Advertisement package from a Peripheral you will get

- (void)centralManager:(CBCentralManager *)central 
    didDiscoverPeripheral:(CBPeripheral *)peripheral 
    advertisementData:(NSDictionary *)advertisementData
    RSSI:(NSNumber *)RSSI {

where you get the RSSI.

If you only want a callback to didDiscoverPeripheral for the FIRST time the peripheral is heard then don't use the ScanOptions

[self.CM scanForPeripheralsWithServices:[NSArray arrayWithObject:myUUID] options:nil];



回答2:


From what I gather, some Android phone manufacturers may include BLE support, but it is not currently supported by Android directly (as of 4.2 Jellybean). See Issue 33371 for more info.

It looks like BLE may be coming in the next Android version as hinted in this Google Groups discussion.



来源:https://stackoverflow.com/questions/15493978/rssi-from-bluetooth-low-energy-ble-tags

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!