uTrack
Loading...
Searching...
No Matches
Data Structures | Macros | Enumerations | Functions | Variables
utBluetoothAudio.c File Reference

Is a profile for Audio via bluetooth (HFP-AG). More...

#include "uTrack.h"
#include "utBluetoothAudio.h"
#include "utHAL.h"
#include <stdlib.h>

Data Structures

struct  BT_ModeHandler
 Handler type for running modes. More...
 
struct  BTDeviceData
 Information about a Bluetooth device. More...
 

Macros

#define BLUETOOTH_AUDIO_RX_BUFFER_SIZE   128
 Receive buffer for the Bluetooth Audio module.
 
#define RESPONSE_BUFFER_LENGTH   150
 The maximum length, in bytes, of the buffer handling command responses from the BT module.
 
#define ABS_MAX_CHANNELS   1
 The maximum number of audio channels the current implementation supports.
 
#define MAX_WRITE_RETRIES   10
 The maximum number of times to retry recording to file within the time period specified by RETRY_RATE_TIMER .
 
#define RETRY_RATE_TIMER   15.0f * 60.0f
 The time, in seconds, that the retry rate should be measured over.
 
#define MAX_DEVICE_LISTING   6
 The maximum number of devices to store IDs for when listing stored pairings with the SET command.
 
#define INQUIRY_RESULTS_WAIT_MS   10000
 The time to wait before cancelling an INQUIRY command because it has taken too long.
 
#define MAX_INQUIRY_IDS   6
 The maximum number of devices to store IDs for when listing visible devices with an INQUIRY command.
 

Enumerations

enum  BT_ModeType { MODE_OFF , MODE_PAIRING , MODE_RUNNING , MODE_MAX }
 The mode this module is running in.
 
enum  BTState {
  BT_ON , LISTING , SINGLE_LINK , SINGLE_SCO ,
  DOUBLE_LINK , MULTI_SCO , RECORDING , ERROR ,
  BTSTATEMAX
}
 The state this module is in, primarily used in Running Mode. BTSTATEMAX is a sentinel value.
 
enum  BTConnectionState {
  CLOSED = 0 , REQUEST_CLOSE , WAIT_CLOSE , REQUEST_OPEN ,
  WAIT_OPEN , OPEN , BTCON_MAX
}
 The states a connection between two Bluetooth devices can be in, as handled here. BTCON_MAX is a sentinel value.
 
enum  BTPairState {
  NOT_PAIRED , LOOKING , REQUEST_PROFILE , WAIT_PROFILE ,
  REQUEST_PAIR , WAIT_PAIR , PAIRED
}
 The states used internally when in Pairing Mode.
 

Functions

bool utBluetoothAudio_isRecording (void)
 
void utBTAudio_UpdateTimestamp (UT_DateTime timestamp)
 
bool utBTAudio_Notify (UT_DeviceMessage state)
 
bool BT_Audio_On (void)
 
void utBTAudio_OnOff (bool isOn, bool stayOn)
 
void utBTAudio_BeginRecording (void)
 
void utBTAudio_EndRecording (void)
 

Variables

u32 startTimeBTA
 

Detailed Description

Is a profile for Audio via bluetooth (HFP-AG).

See also utI2S_3287.c

Authors
George Sealy
Oscar Key
Stephen Markham
Date
23/05/2011
Last Updated: 14/12/2015
Note
To use this module INCLUDE_BT_AUDIO_CODE must be defined along with NUM_AUDIO_BUFFERS=X where 8<X<14
Todo:

Macro Definition Documentation

◆ ABS_MAX_CHANNELS

#define ABS_MAX_CHANNELS   1

The maximum number of audio channels the current implementation supports.

\TODO usrChannels #1104

◆ BLUETOOTH_AUDIO_RX_BUFFER_SIZE

#define BLUETOOTH_AUDIO_RX_BUFFER_SIZE   128

Receive buffer for the Bluetooth Audio module.

◆ RESPONSE_BUFFER_LENGTH

#define RESPONSE_BUFFER_LENGTH   150

The maximum length, in bytes, of the buffer handling command responses from the BT module.

The response buffer must be at least 131 bytes for the Jabra headsets, but other devices, such as the WT32, may hve a longer SDP response string.

Function Documentation

◆ BT_Audio_On()

bool BT_Audio_On ( void  )

Returns the on/off status of the module

Parameters
void
Returns
bool - ON (true) or OFF (false)
Note

◆ utBTAudio_BeginRecording()

void utBTAudio_BeginRecording ( void  )

Tell the state engine to start writing audio to file as soon as it has data

Parameters
void
Returns
void
Note

◆ utBTAudio_EndRecording()

void utBTAudio_EndRecording ( void  )

Tell the state engine to stop writing audio

Parameters
void
Returns
void
Note

◆ utBTAudio_Notify()

bool utBTAudio_Notify ( UT_DeviceMessage  state)

The Notify function passes a message to the software module, informing it of expected module state. It returns a value that is considered a response to a query about the specified state.

Parameters
stateA state message.
Returns
Whether or not this software module is in the desired state.

◆ utBTAudio_OnOff()

void utBTAudio_OnOff ( bool  isOn,
bool  stayOn 
)

OnOff turns this software module on or off.

Parameters
isOnWhether to turn on or off.
stayOnWhether to leave the software module on after the power is turned off.

◆ utBTAudio_UpdateTimestamp()

void utBTAudio_UpdateTimestamp ( UT_DateTime  timestamp)

Updates the timestamp that will be written in the current audio file metadata.

Parameters
timestampThe new timestamp.