Before the BACtrack API can be used to communicate with a BACtrack device, it must first be initialized, like so:
BACTrackAPI bacTrack = [[BacTrackAPI alloc] initWithDelegate:delegate AndAPIKey:@""];
The returned BACTrackAPI instance features all the methods and callbacks you need in order to communicate with BACtrack devices.
A valid API key must be provided to the init method. The API Key can be obtained by signing in to this page with
a valid BACtrack subscription. In the case that
your app has not been approved to use our SDK, the callback (void)[BacTrackAPIKeyDeclined]:(NSString
*)errorMessage will be called. This callback is not optional.
Once you’ve initialized your BacTrackAPI object, you can establish a BTLE connection between iOS and BACtrack
devices calling connectToNearestBreathalyzer on your BacTrackAPI object.
-(id)initWithDelegate:(id<BacTrackAPIDelegate> )delegate AndAPIKey:(NSString*)api_key;
You must initialize the BACtrackAPI delegate before calling any other commands. A valid API key is required, and can be obtained by signing on this page with a valid subscription.
-(void)connectToNearestBreathalyzer
Connect to the nearest breathalyzer device.
-(void)startScan Scan for BACtracks within range. When breathalyzers are discovered, your
BacTrackFoundBreathalyzer callback will be called. Also see: connectBreathalyzer:withTimeout:
-(void)stopScan stopScan cancels any current breathalyzer scan.
-(void)connectBreathalyzer:(Breathalyzer*)breathalyzer withTimeout:(NSTimeInterval)timeout Connect
to a specific breathalyzer. The breathalyzer object is retrieved from your BacTrackFoundBreathalyzer callback
(see: startScan).
-(void)disconnect Disconnects from the connected BACtrack.
-(void)BacTrackAPIKeyAuthorized This is called when the API key passed into initWithDelegate:withAPIKey
is valid.
-(void)BacTrackAPIKeyDeclined:(NSString *)errorMessage This is called when the API key passed into
initWithDelegate:withAPIKey is not valid or has been otherwise declined.
-(void)[BacTrackConnected]:(BACtrackDeviceType)device This is called when the API has successfully
connected to BACtrack and found its services and characteristics.
-(void) BacTrackDisconnected Called when the API has disconnected from the BACtrack device.
-(void)BacTrackConnectTimeout This is called when the BACtrack connection was unsuccessful because
it timed out
-(NSTimeInterval)BacTrackGetTimeout Return the desired timeout, in seconds, when attempting to
connect to a breathalyzer.
-(void)BacTrackFoundBreathalyzer:(Breathalyzer*)breathalyzer This is called when
startScan discovers a breathalyzer. It will be called for each breathalyzer device discovered.