BlueParrott iOS SDK

Introduction

This document is an introduction to the BlueParrott iOS SDK that allows access to the programmable Parrott ButtonTM on selected BlueParrott headsets.

The Parrott Button on the headset has an initial factory setting that allows the user to mute the headset microphone. This Parrott Button can be accessed from a mobile application to program alternative functions.

The BlueParrott SDK enables developers to create apps that interact with this Parrott Button thus allowing the headset user to access functions of your application by pressing the Parrott Button.

SDK Purpose

The purpose of the BlueParrott SDK is to let you, a corporate or independent developer, develop applications that allow the headset user to benefit from alternative functions for the Parrott Button found on BlueParrott headsets.

Through use of the BlueParrott SDK you can access the programmable Parrott Button. When your mobile application has been published the headset user may then control programmed activities within your mobile application directly from the headset via the Parrott Button.

Typical uses of the BlueParrott SDK include integration with:

  • Push to Talk and Voice Messaging Applications, where recording is triggered by pressing the Parrott Button
  • Voice Recognition and custom Voice Assistant applications, where the Voice Assistant is triggered by tapping the Parrott button
  • Other Enterprise Applications, where custom features can be triggered based on one or more button event

The Parrott Button can be configured to trigger up to five Button Events in your application:

  • Press (for example to start a Push to Talk Call)
  • Release (for example to end a Push to Talk Call)
  • Single Tap (to invoke a voice recognition or other enterprise application)
  • Double Tap
  • Long Press

You may program each of these events for individual functions within your mobile application. The SDK can also report changes in the proximity sensor on the headset (where available).

The Parrott Button may also be programmed to a number of functions that do not result in events being sent to the application (e.g. Speed Dial).

You may limit your application to operating in the foreground only or you may wish to offer a smoother more integrated experience for the headset user by extending your application to offer handling of button events even when your application is in the background.

SDK Scope

This document covers BlueParrott iOS 1.0.11.4.

The BlueParrott SDK provides interfaces to the following functions in compatible BlueParrott devices:

  • Configuration of the Parrott Button for use with the application.
  • Setting the BlueParrott Button into 'SDK Mode', this will result in button events being sent to your application.
  • Event Handlers for Parrott Button events.
  • Configuring the Parrott Button to Speed Dial: Dials the specified phone number when the button is pressed.
  • Configuring the Parrott Button to Mute: Disables the microphone on the headset during a phone call. Pressing the Parrott Button again will un-mute the headset.
  • Setting the Parrott Button to "App Mode" with a specific App ID and App Name. This allows another app using the SDK to receive button events, and if multiple apps are installed that make use of the Parrott Button, each can check if they are the currently configured app.
  • Setting the Parrott Button to a custom mode. Some headsets may offer features that can be accessed through the Parrott Button by configuring it to a custom mode. Contact BlueParrott for more details on this topic.

The package includes the following development tools:

  • SDK Library.
  • Example test application to show connectivity and connected device Parrott Button state.
  • Notes and documentation.

Not in Scope

This document does not cover iOS programming specifics, the developer should access the relevant sites for the development language.

Updates

The BlueParrott SDK will be updated from time to time, please check for updates.

Supported Headsets

The following is a list of devices which have a Parrott Button and are supported by the BlueParrott SDK.

Headset
BlueParrott B550-XT
BlueParrott B450-XT Classic
BlueParrott B350-XT
BlueParrott B450-XT
BlueParrott C400-XT
BlueParrott Reveal Pro
BlueParrott S450-XT
BlueParrott C300-XT

Supported Operating Systems

The BlueParrott iOS SDK supports iOS 9.1 and higher.

Getting Started

Including the SDK

The minimum iOS version is 9.1.

Add the BlueParrott SDK to your project by dragging the framework file into your project.

In your project's Target, enable Background Modes and tick 'Uses Bluetooth LE accessories' if you will be using the button while the app is in the background.

Permissions

Enable Bluetooth

The BlueParrott SDK manages the Bluetooth connection but you must manage the enabling of Bluetooth in your code. An approach to this is to alert the application user if Bluetooth is not available and ask the user to turn Bluetooth on in their handset settings, you must then provide another opportunity to connect.

Use specific permissions

There are many different permissions depending on the function of the application program in question it is up to the programmer to ensure that all other permissions for your program are included (e.g. microphone).

Connect to the Parrott Button

Connect to the Parrott Button using methods from the BlueParrott SDK.

The first step is to get a handle to the Parrott Button on the BlueParrott Headset.

Now you have the ability to check the connection and connect or disconnect to the headset.

The BlueParrott SDK method connect manages the Parrott Button connection and ensures that the Bluetooth LE connection is available.

// ViewController.h

#import <BPHeadset/BPHeadset.h>
@interface ViewController : UIViewController <BPHeadsetListener>
// ...
@end
// ViewController.m

@implementation ViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    // To instantiate, just use `sharedInstance`:
    headset = [BPHeadset sharedInstance];
    [headset addListener:self];
}

// To connect, set a listener that conforms to the BPHeadsetListener protocol, then call connect:
- (IBAction)connectButtonTouched:(id)sender {
    [headset connect];
}
@end

Listen for Connection Events

Through the BlueParrott SDK your app can get a handle to the Parrott Button on the headset, you can then add a Blue Parrott Headset Listener.

// ViewController.h

#import <BPHeadset/BPHeadset.h>
@interface ViewController : UIViewController <BPHeadsetListener>
// ...
@end
// ViewController.m

@implementation ViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    // To instantiate, just use `sharedInstance`:
    headset = [BPHeadset sharedInstance];
    [headset addListener:self];
}

// Headset is connected and mode can be set, but not all
// values have been read yet
- (void) onConnect {
    NSLog(@"Connected");
    // Update UI etc.
}

// Values have been read from headset (e.g. Speed Dial number etc.)
- (void) onValuesRead {
    NSLog(@"Finished reading values");
    // Can now read App Name, Speed Dial number etc.
}
@end

The Blue Parrott listener allows your app to listen and manage activities associated with establishing a connection to the Parrott Button:

  • Connected
  • Connection Progress
  • Connection Failure
  • Connected
  • Values read from headset

When your app is successfully connected to the Parrott Button a connected event is triggered.

Connection Progress

You may retrieve the status of progress during the connection process, as connection may take time it is advisable to keep your user informed of progress.

// Method from protocol: BPHeadsetListener
// --------------------------------------------------------------------

public void onConnectProgress:(BPConnectProgress) status { 
    logStatus(getStatusDescription(progressCode));
}

// Note: Constants from BPConnectProgress are as per table
Status Value Meaning
BPConnectProgressStarted 0 Connection attempt has started
BPConnectProgressScanning 1 Scanning for BLE services
BPConnectProgressFound 2 The BlueParrott service has been found
BPConnectProgressReading 3 BLE connection established, reading settings from headset

Connection Failure

If the connection attempt fails the following error codes may be returned and should be handled in your code.

// Method from protocol: BPHeadsetListener
// --------------------------------------------------------------------

- (void) onConnectFailure:(BPConnectError) reasonCode { 
    //handle the connection failure here
    //this may include instruction "Retry or turn headset off then on"
}
    // Note: Constants from BPConnectError are as per table
Reason Code Value Meaning
BPConnectErrorUnknown 0 Unknown error occurred
BPConnectErrorBluetoothDisabled 1 Bluetooth is not turned on
BPConnectErrorFirmwareTooOld 2 Firmware on the headset is not offering Parrott Button Service. Firmware may be too old
BPConnectErrorSDKTooOld 3 This SDK version is too old to connect to the firmware version on headset

Setting the Parrott Button SDK Mode

Once connected to the Parrott Button the next step is to enable the Parrott Button in order to send events from the Parrott Button on the headset to your application on the handset. It is possible to check to see if the Parrott Button has been enabled previously and if not you may proceed to enable it.

// ViewController.m
    // Enable SDK Mode
    if (!headset.sdkModeEnabled) {
       [headset enableSDKMode];
   }

    // Disable SDK Mode
    if (headset.sdkModeEnabled) {
       [headset disableSDKMode];
   }

If required by your program you may also disable the Parrott Button SDK this would reset the Parrott Button to the factory setting of a mute button.

enableSDKMode Method

Signature:

enableSDKMode()

enableSDKMode(String appName)

Description:

There are now two methods to enable SDK mode in the SDK: enableSDKMode() and enableSDKMode(String appName). The new method allows the app to set the App Name while still putting the headset into SDK mode. This can allow the current app to know if it was the last app to put the headset into SDK mode.

Callbacks:

Results in a call to onModeUpdate() or onModeUpdateFailure()

setMuteMode Method

Signature:

setMuteMode()

Description:

This sets the headset into the default Mute mode.

Callbacks:

Results in a call to onModeUpdate() or onModeUpdateFailure()

setCustomMode Method

Signature:

setCustomMode(Integer mode)

Description:

This sets the headset into a custom mode.

Callbacks:

Results in a call to onModeUpdate() or onModeUpdateFailure()

Discussion:

The mode can be set to one of several preset modes, or a custom integer more can be set (if supported by the headset). For more details on custom modes, contact your BlueParrott representative.

Preset modes are as follows:

Reason Code Value Meaning
BPButtonModeUnknown -1 An unknown mode. This can be returned if the current mode has not been read yet.
BPButtonModeMute 0 Mute on call mode. This is the default mode.
BPButtonModeSpeedDial 1 Speed dial a specific number.
BPButtonModeApp 2 Compatible App or SDK Mode.

Listen for Parrott Button Mode Update

You can monitor the success of enabling the SDK using the mode update methods from the BlueParrott Headset Listener.

// Methods from protocol: BPHeadsetListener
// ---------------------------------------------------------------------

    - (void) onModeUpdate {
        NSLog(@"Mode Updated"); 
    }

Listen for Parrott Button Mode Update Failure

If mode update fails you may look for one of the following update errors to provide feedback to the user.

// Methods from protocol: BPHeadsetListener
// ---------------------------------------------------------------------
    - (void) onModeUpdateFailure:(BPModeUpdateError) reasonCode {
        NSLog(@"Mode Update Failed. Reason %@", [self getUpdateErrorDescription:reasonCode]);
        //handle error 
    }
Reason Code Value Meaning
BPModeUpdateErrorUnknown 0 Writing to headset over BLE failed
BPModeUpdateErrorDisconnected 1 BLE connection not available

Once you enable the SDK on the Parrott Button data can be sent over Bluetooth from the headset to your app for Parrott Button events.

You can then use BlueParrott Headset listener to monitor the traffic from the headset.

Listening for Parrott Button Events

Once connected to the Parrott Button, with the button enabled to send events the BlueParrott Listener for the BlueParrottSDK may be used to monitor clicks of the Parrott Button.

When the user clicks on the headset Parrott Button your app will receive an event and can react to the users interactions.

The BlueParrott Listener provides methods to allow your code to interact with the users headset Parrott Button clicks:

  • Button Down - button has been pressed
  • Button Up - button has been released
  • Tap - single tap
  • Double Tap
  • Long Press
// Methods from protocol: BPHeadsetListener
// ---------------------------------------------------------------------

- (void) onButtonDown:(BPButtonID) buttonID {
    NSLog(@"Button Down");
    //your code goes here
}

- (void) onButtonUp:(BPButtonID) buttonID {
    NSLog(@"Button Up");
    //your code goes here
}

- (void) onTap:(BPButtonID) buttonID {
    NSLog(@"Tap");
    //your code goes here
}

- (void) onDoubleTap:(BPButtonID) buttonID {
    NSLog(@"Double Tap");
    //your code goes here
}

- (void) onLongPress:(BPButtonID)buttonID {
    NSLog(@"Long Press");
    //your code goes here
}

Listening for Proximity Events

Once connected to the Parrott Button, the BlueParrottSDK may be used to monitor changes in the proximity sensor on the headset.

Possible values for the proximity state are BPProximityStateOff, BPProximityStateOn and BPProximityStateUnknown.

// Methods from protocol: BPHeadsetListener
// ---------------------------------------------------------------------
- (void) onProximityChanged:(BPProximityState) proximityState {
    NSLog(@"Proximity State Changed.");
    //your code goes here
}

Disconnecting from the Parrott Button

Generally at this point you will have established a handle to the BlueParrott Headset Button in order to connect to the Parrott Button.

Now you have the ability to check if the Parrott Button is connected and you can disconnect the Parrott Button in your code if required.

// ViewController.m

- (IBAction)disconnectButtonTouched:(id)sender {
    if (headset.connected) {
        [headset disconnect];
    }
}
@end

Listen for Disconnect

Using the BlueParrott Headset Listener you may listen for a disconnect event in your program and carry out any appropriate actions and housekeeping at this point.

// ViewController.h

#import <BPHeadset/BPHeadset.h>
@interface ViewController : UIViewController <BPHeadsetListener>
// ...
@end
// ViewController.m

@implementation ViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    // To instantiate, just use `sharedInstance`:
    headset = [BPHeadset sharedInstance];
    [headset addListener:self];
}

// Called when the headset is disconnected (e.g. out of range)
- (void) onDisconnect {
    // Notify the user
}
@end

Other Parrott Button Functions

After the application has received the onValuesRead callback, the application can query the current state of the Parrott Button configuration.

appKey Property (Readonly)

The current App Key for the headset (if the headset is in BPButtonModeApp), as a String. If the headset is currently in SDK mode, this will return "sdk". This can be set by an application, and then later queried to check if another app has configured the Parrott Button (and then possibly ignore button events).

appName Property (Readonly)

The current App Name for the headset (if the headset is in BPButtonModeApp), as a String. If the headset is currently in SDK mode, this will return "SDK" unless the app has set the App Name to something different.

speedDialNumber Property (Readonly)

The number that will be dialed by the headset when the Parrott Button is pressed, if the headset is in BPButtonModeSpeedDial, as a String.

valuesRead Property (Readonly)

Indicates whether the SDK has finished retrieving all values from the headset. After the app receives the onConnect() event, this will be FALSE. After the onValuesRead() event, this will return TRUE.

The SDK can also be used to set the mode of the headset, which can change the behavior of the BlueParrott Button or potentially change the headset function (e.g. using a Custom Mode could change whether the headset resets its pairing list on being connected to a power source).

Some of the methods that can affect the mode of the Parrott Button or headset are described below:

setBondable Method

Signature:

setBondable(BOOL enabled)

Description:

This sets whether the headset is BLE bondable or not. If bondable is disabled by the app, the headset will need to be unpaired and re-paired in order to remove any existing bond with the phone. If bonding is enabled on a headset where it was previously disabled, the headset will need to be powered off and then powered on again (so that it reconnects) in order to trigger the bonding.

Callbacks:

Results in a call to onBondableUpdate() or onBondableUpdateFailure()

setAppMode Method

Signature:

setAppModeWithAppKey(String appKey, String appName)

Description:

This sets the headset into App Mode with the given App ID and App Name.

Callbacks:

Results in a call to onModeUpdate() or onModeUpdateFailure()

setSpeedDialMode Method

Signature:

setSpeedDialMode(String phoneNumber)

Description:

This sets the headset into a Speed Dial mode with the given number.

Callbacks:

Results in a call to onModeUpdate() or onModeUpdateFailure()

Simple Sample Application

The iOS SDK Sample Application is a sample of a simple integration, allowing the developer to get up and running quickly while using the BlueParrott SDK.

The BPSDKSample application runs in the foreground only. It allows you to connect to and disconnect from the Parrott Button. You may enable and disable the SDK Mode on the Parrott Button as well as enable or disable whether the headset is BLE Bondable. When the SDK is enabled the app gives feedback on the presses of the Parrott Button through the log and UI.

This simple demo includes the following features:

  • Displays the version of the SDK being used in the app
  • Connects to headset Parrott Button
  • Enables BlueParrott SDK mode
  • Utilises BlueParrott listener recognising the Parrott Button clicks
  • Disables BlueParrott SDK mode
  • Disconnects from the headset Parrott Button

Below is a sample screen from the application:

BlueParrot SDK Demo