swift - Possible to generate a list of connected bluetooth devices for iOS? -


i'm trying determine devices connected via bluetooth in ios can't seem figure out. ideally i'd generate list of connected bluetooth devices.

i've tried using "retrieveconnectedperipheralswithservices" requires specific service search for. i'd generate list of connected bluetooth devices, not specific-service bluetooth devices. there way search services without looping through possible services?

any ideas?

here solution ios (thank larme) :

nsarray *connectedaccessories = [[eaaccessorymanager sharedaccessorymanager] connectedaccessories];  

documentation :

https://developer.apple.com/library/prerelease/ios/documentation/externalaccessory/reference/eaaccessorymanager_class/index.html#//apple_ref/occ/instp/eaaccessorymanager/connectedaccessories

also if needs, documentation mac :

https://developer.apple.com/library/mac/documentation/devicedrivers/conceptual/bluetooth/bt_intro/bt_intro.html

and code snippet mac

nsarray *devices = [iobluetoothdevice paireddevices]; 

for alan478's ble question :

the core bluetooth framework provides classes needed ios , mac apps communicate devices equipped bluetooth low energy wireless technology. can take tutorial :

http://www.raywenderlich.com/52080/introduction-core-bluetooth-building-heart-rate-monitor

and ble code snippet :

// in case need tell uuid serching specific device cbuuid *hrate = [cbuuid uuidwithstring:@"1800"];  // create dictionary passing down scan service method nsdictionary *scanoptions = [nsdictionary dictionarywithobject:[nsnumber numberwithbool:no] forkey:cbcentralmanagerscanoptionallowduplicateskey];  // tell central manager (cm) scan heart rate service [cm scanforperipheralswithservices:[nsarray arraywithobject:hrate] options:scanoptions] 

please read document on developer.apple.com :

https://developer.apple.com/library/ios/documentation/networkinginternetweb/conceptual/corebluetooth_concepts/bestpracticesforinteractingwitharemoteperipheraldevice/bestpracticesforinteractingwitharemoteperipheraldevice.html

here interesting paragraph :

explore peripheral’s data wisely peripheral device may have many more services , characteristics may interested in when developing app fulfill specific use case. discovering of peripheral’s services , associated characteristics can negatively affect battery life , app’s performance. therefore, should , discover services , associated characteristics app needs.

for example, imagine connected peripheral device has many services available, app needs access 2 of them. can , discover these 2 services only, passing in array of service uuids (represented cbuuid objects) discoverservices: method of cbperipheral class, this:

[peripheral discoverservices:@[firstserviceuuid, secondserviceuuid]]; 

after have discovered 2 services interested in, can , discover characteristics of these services interested in. again, pass in array of uuids identify characteristics want discover (for each service) discovercharacteristics:forservice: method of cbperipheral class.

also there comment :

"think apple forbids thing. can list of devices specific cbuuid. if want list devices(same bluetooth settings natively) not possible. please correct me if wrong. – mrug mar 11 @ 13:24"

under question :

how list of available bluetooth devices?


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -