evothings / cordova-ble

Bluetooth Low Energy plugin for Cordova
http://www.evothings.com/
Apache License 2.0
242 stars 103 forks source link

Reading a different UUID depending on which phone is used #64

Closed mzarella closed 9 years ago

mzarella commented 9 years ago

https://forums.estimote.com/t/reading-more-than-one-uuid/1067

The callback to evothings.ble.startScan, function deviceFound(device), is reading different addresses, i.e. device.address is different depending on the phone. Has anyone ever ran into this?

e.g.

iphone5c reads E2B0A070...

iphone5s reads B9401000...

iphone6 reads C7EEF8AC...

and the android reads something that looks like a MAC address: `5F:C7:E2:FF:0A..."

fredrikeldh commented 9 years ago

Yeah, that's a result of how the iOS CoreBluetooth API works. It hides the MAC address, and instead assigns a UUID to each BLE device it detects. These UUIDs are random and temporary; you run the same program again on the same device, you might get different ones.

Android gives you the proper MAC address.

mzarella commented 9 years ago

@fredrikeldh But then how can I associate a randomly generated address with an object in the DB? Or rather, what's the proper way to associate a device with the information you want to present? It doesn't seem like device.address is a reliable way to identify a device with information you want to present.

fredrikeldh commented 9 years ago

"proper" way? That's up for debate. If you have control over the devices' advertisements, you might add some Manufacturer Data, or some Service Data, which you can then read through device.advertisementData.

I see you've mentioned Estimote, so I'll guess you're using iBeacons. In that case, I recommend using one of our iBeacon plugins. They will give you more permanent device identifiers.