Skip to end of metadata
Go to start of metadata
You are viewing an old version of this page. View the current version.
Compare with Current
View Page History
Version 1
Current »
There are two phases to a bluetooth device: pair and connect.
Pair links a BLE device to a phone. Connect allows communication.
When you have a brand new VP3300, the first time you try to use it, a pairing happens. This is when the iPhone finds the VP3300, assigns a unique UUID, and then pairs to it. Then you can communicate with it.
After it is paired, it appears in the iPhone bluetooth settings. Anytime your phone is near that device, the iPhone automatically pairs.
This means you cannot use that device on another iPhone if your iPhone is nearby, because your iphone is paired. To use that VP3300 on another device, you either need to make sure you iPhone is no where near, or off, or on your iPhone, you need to go to your bluetooth setting and unpair.
The thing is you cannot pair from bluetooth control panel. You can only pair in code. But you can unpair from bluetooth control panel.
When you start your application, search your setting to see if you have ever connected to a VP3300 before. This is a first time.So you need to connect to a VP3300. Since our VP3300 do not have a bluetooth name label on them, you need to scan the area for our devices.
First, you set the friendly name to NOTHING, by executing device_setBLEFriendlyName with a name of empty string You then do a search for BLE devices by calling device_enableBLEDeviceSearch, passing nil as a identifier. Since there is no BLE friendly name set, nothing will be paired. But while it is searching, the SDK is reporting back to the deviceMessages delegate all the devices it is finding in the area. It is reporting back "BLE DEVICE FOUND:" followed by device names.
The application needs to collect all these names it finds. Once the application thinks it found all available names (like let the scanning happen for 20 seconds or so), then execute device_disableBLEDeviceSearch (to stop phone from draining battery scanning).
Now the application needs to present those name to the user and have them pick a device to connect to.Once the application knows what device to connect to, it passes that device name to device_setBLEFriendlyName. Now the application asks the SDK to scan again, calling device_enableBLEDeviceSearch, passing nil as a identifier. This time, it will connect to the device with that matching name.
Once connected, the application asks the SDK what NSUUID the Apple device assigned to our VP3300 by calling device_connectedBLEDevice. This will return the device UUID. The program must store this number in memory When you quit your program, then can execute device_disconnectBLE.
The next day, when the program starts, now the program will see there is VP3300 UUID in memory already (the program has previously paired with a VP3300), so now, on program startup, it executes device_enableBLEDeviceSearch, but this time, it passes the UUID.
The program will automatically reconnect to the device from now on by doing this on startup each time.