uTrack
Loading...
Searching...
No Matches
Data Structures | Macros | Enumerations | Functions | Variables
utBluetooth.h File Reference

The software module for handling the Bluetooth hardware module (WT32). More...

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

Go to the source code of this file.

Data Structures

struct  BT_Profile
 All the information that is requited when creating a new profile/mode. More...
 
struct  BT_Device
 A device that is created when a Bluetooth device is connected to. More...
 
struct  BTCommand
 All the information about a command to send to the Bluetooth module. More...
 

Macros

#define BLUETOOTH_RX_BUFFER_SIZE   256
 The buffer for receiving data.
 
#define BT_RESPONSE_BUFFER_LENGTH   256
 The buffer for the response.
 
#define BT_RESPONSE_DATA_BUFFER_LENGTH   1024
 
#define BLUETOOTH_TX_BUFFER_SIZE   1024
 The transmitting buffer.
 
#define BT_MAX_NUM_MODES   2
 Maximum number of allowable profile (e.g Audio, RFCOMM)
 
#define BT_MAX_NUM_SETUP_COMMANDS   32
 The maximum number of allowable setup commands for the BT module.
 
#define BT_MAX_COMMAND_LENGTH   64
 Max command length for the BT module.
 

Enumerations

enum  ModuleType { BT_MODULE_NONE = 0x00 , BT_MODULE_AUDIO = 0x01 , BT_MODULE_RFCOMM = 0x02 , BT_MODULE_ANY = 0x03 }
 The fixed mode the BT module can connect to.
 
enum  BT_StateType {
  STATE_OFF , STATE_COMMAND , STATE_SETUP , STATE_PAIRING ,
  STATE_RUNNING
}
 The mode this module is running in.
 
enum  BT_SetupStage { BT_WAIT_BANNER , BT_WAIT_COMMANDS }
 The states used internally when in SetupMode.
 
enum  BT_Auth_Mode { BT_AUTH_MODE_DISPLAY , BT_AUTH_MODE_BUTTON , BT_AUTH_MODE_KEYBOARD , BT_AUTH_MODE_NONE }
 The states used internally when in SetupMode.
 

Functions

bool utBT_Notify (UT_DeviceMessage state)
 
bool BTaddMode (BT_Profile b)
 
bool BTaddSetupCommand (char *com)
 
void utBT_SendCommand (const char *format,...)
 
int utBT_SendData (const u8 *data, u32 size)
 
int BTLoggerHasSpace (void)
 
UT_NotificationType BTnotificationType (void)
 
bool isBTOn (void)
 
void BT_switchMode (char *oldProfile, char *newProfile, char *command, u8 commandLength)
 
ModuleType BT_getModuleType (void)
 

Variables

bool bluemix
 
bool processingBTCommands
 
char bluemixAddress [17]
 

Detailed Description

The software module for handling the Bluetooth hardware module (WT32).

Holds commond methods for bluetooth connection. Profiles can be added so they can be connected to.

Authors
Stephen Markham
George Sealy
Oscar Key
Date
24/11/2015
Last Updated: 20/11/2015
Note
-Requires another module to work. This is the main Bluetooth layer which allows different bluetooth profiles (e.g audio, rfcomm) to work
Todo:
-Multiple RFCOMM Devices using TDMA?

Macro Definition Documentation

◆ BLUETOOTH_RX_BUFFER_SIZE

#define BLUETOOTH_RX_BUFFER_SIZE   256

The buffer for receiving data.

◆ BLUETOOTH_TX_BUFFER_SIZE

#define BLUETOOTH_TX_BUFFER_SIZE   1024

The transmitting buffer.

◆ BT_MAX_COMMAND_LENGTH

#define BT_MAX_COMMAND_LENGTH   64

Max command length for the BT module.

◆ BT_MAX_NUM_MODES

#define BT_MAX_NUM_MODES   2

Maximum number of allowable profile (e.g Audio, RFCOMM)

◆ BT_MAX_NUM_SETUP_COMMANDS

#define BT_MAX_NUM_SETUP_COMMANDS   32

The maximum number of allowable setup commands for the BT module.

◆ BT_RESPONSE_BUFFER_LENGTH

#define BT_RESPONSE_BUFFER_LENGTH   256

The buffer for the response.

Function Documentation

◆ BTaddMode()

bool BTaddMode ( BT_Profile  b)

Allows other 'profiles' to add themselves to the bluetooth 'layer'

Parameters
BT_Profile- the BT_Profile struct containing information about the profile.
Returns
bool - True or false depending on whether it was successfull or not.
Note

◆ BTaddSetupCommand()

bool BTaddSetupCommand ( char *  com)

A method for adding in setup commands from different profiles.

Parameters
char*- The setup command.
Returns
bool - True or false depending on whether it was successfull or not.
Note
- This should be called before the bt module has been turned on (e.g at start) or in the setup commands callback

◆ BTLoggerHasSpace()

int BTLoggerHasSpace ( void  )

Returns the amount of space in the buffer for the logger

Parameters
void
Returns
int - space
Note

◆ utBT_Notify()

bool utBT_Notify ( UT_DeviceMessage  state)

Main Loop calls back to here

Parameters
UT_DeviceMessagestate - Current state of the loop
Returns
bool
Note

◆ utBT_SendCommand()

void utBT_SendCommand ( const char *  format,
  ... 
)

Send a command

Parameters
constchar* - the command
Returns
void
Note

◆ utBT_SendData()

int utBT_SendData ( const u8 *  data,
u32  size 
)

Sends a specified amount of data via the Bluetooth UART

Parameters
constu8* - the data to send
u32size - the amount of data to send
Returns
int - the amount sent
Note