VLDBluetoothPeripheralController
Objective-C
@interface VLDBluetoothPeripheralController : NSObject
Swift
class VLDBluetoothPeripheralController : NSObject
VLDBluetoothPeripheralController is the primary interface for detecting
and reading from Bluetooth peripherals. All peripheral updates are given to
the peripheral controller’s delegate object (VLDBluetoothPeripheralControllerDelegate
).
The peripheral controller only performs one operation at a time. Any current operations
must finish or be cancelled before a new operation can be started. The two possible
operations are pairPeripheral:
and readFromPeripheral:
.
If the VLDBluetoothPeripheral has requiresPairing
set to true, then you must first
call pairPeripheral:
to ensure that we are able to communicate with the peripheral and
to do any necessary pairing. When you call pairPeripheral:
, you should then present
to the user VLDBluetoothPeripheral.instructions
. When the
-[VLDBluetoothPeripheralControllerDelegate bluetoothPeripheralController:didPairPeripheral:]
callback is called, you can assume
all pairing has been done and it is now safe to call readFromPeripheral:
.
To get a reading from a peripheral, call readFromPeripheral:
and pass in the
VLDBluetoothPeripheral
object that you want to take a reading from. The reading
operation will have multiple callbacks at different stages that are reported
to the VLDBluetoothPeripheralControllerDelegate
. When the VLDRecord
object
is returned via callback, it is also simultaneously uploaded to Validic. Do
not submit these records to Validic as they have already been submitted.
-
The object that acts as the delegate of the peripheral controller.
Must conform to
VLDBluetoothPeripheralControllerDelegate
protocol.Declaration
Objective-C
@property (nonatomic, weak) id<VLDBluetoothPeripheralControllerDelegate> delegate;
Swift
weak var delegate: (any VLDBluetoothPeripheralControllerDelegate)! { get set }
-
Pairs a Bluetooth peripheral.
Returns NO if the controller is already pairing or reading from a peripheral.
Returns YES if the controller is available.
Declaration
Objective-C
- (BOOL)pairPeripheral:(VLDBluetoothPeripheral *)peripheral;
Swift
func pairPeripheral(_ peripheral: VLDBluetoothPeripheral!) -> Bool
Parameters
peripheral
the peripheral to pair with.
-
Reads from a Bluetooth peripheral
Returns NO if the controller is already pairing or reading from a peripheral
Returns YES if the controller is available
Declaration
Objective-C
- (BOOL)readFromPeripheral:(VLDBluetoothPeripheral *)peripheral;
Swift
func read(from peripheral: VLDBluetoothPeripheral!) -> Bool
Parameters
peripheral
the peripheral to read from.
-
Cancels all Bluetooth operations and disconnects from any connected peripherals
A new read or pair operation cannot begin until the current operation is finished or cancelled.
Declaration
Objective-C
- (void)cancel;
Swift
func cancel()
-
Determines if a read or pair operation is currently in progress
If an operation is in progress, it will need to be cancelled before a new operation can be started.
Declaration
Objective-C
- (BOOL)operationInProgress;
Swift
func operationInProgress() -> Bool