uTrack
Loading...
Searching...
No Matches
utBluetooth.h
Go to the documentation of this file.
1
24#ifndef __BLUETOOTH_HEAD_H__
25#define __BLUETOOTH_HEAD_H__
26
27#include <stdlib.h>
28#include "uTrack.h"
29#include "utHAL.h"
30#include "utBluetoothAudio.h"
31#include "utBluetoothRFCOMM.h"
32
38#define BLUETOOTH_RX_BUFFER_SIZE 256
39
45#define BT_RESPONSE_BUFFER_LENGTH 256
46
47
48#define BT_RESPONSE_DATA_BUFFER_LENGTH 1024
49
55#define BLUETOOTH_TX_BUFFER_SIZE 1024
56
57
63#define BT_MAX_NUM_MODES 2
64
70#define BT_MAX_NUM_SETUP_COMMANDS 32
71
77#define BT_MAX_COMMAND_LENGTH 64
78
79
101typedef struct
102{
103 char * name;
104 char * profile;
105 char * UUID;
106 void (*SetupCommandsCallback)(void);
107 bool (*ConnectionCallback)(u8 linkid, u8 channelid, char * address);
108 void (*DisconnectionCallback)(u8 linkid, char * errorMessage);
109 void (*PairingCallback)(void);
110 bool (*CommandCallback)(char *argv, u8 size);
111 bool (*DataCallback)(UT_RingBuffer *responseBuffer);
112} BT_Profile;
113
131typedef struct
132{
133 char Address[17];
134 char * Profile;
139} BT_Device;
140
152typedef struct
153{
157} BTCommand;
158
160typedef enum
161{
162 BT_MODULE_NONE = 0x00,
163 BT_MODULE_AUDIO = 0x01,
164 BT_MODULE_RFCOMM = 0x02,
165 BT_MODULE_ANY = 0x03,
166} ModuleType;
167
169typedef enum
170{
171 STATE_OFF, // The device is not powered
172 STATE_COMMAND, // Sending a command from connected mode
173 STATE_SETUP, // Run every start up (not strictly necessary, but safe)
174 STATE_PAIRING, // Manually initiated, attempt to pair with other devices
175 STATE_RUNNING // Default if we're running and setup is finished
177
179typedef enum
180{
181 BT_WAIT_BANNER,
182 BT_WAIT_COMMANDS
184
186typedef enum
187{
188 BT_AUTH_MODE_DISPLAY,
189 BT_AUTH_MODE_BUTTON,
190 BT_AUTH_MODE_KEYBOARD,
191 BT_AUTH_MODE_NONE
193
194
195extern bool bluemix;
196extern bool processingBTCommands;
197extern char bluemixAddress[17];
198
207extern bool utBT_Notify(UT_DeviceMessage state);
208
218extern bool BTaddMode(BT_Profile b);
219
229extern bool BTaddSetupCommand(char * com);
230
239extern void utBT_SendCommand(const char *format,...);
240
250extern int utBT_SendData(const u8 *data, u32 size);
251
260extern int BTLoggerHasSpace(void);
261
262extern UT_NotificationType BTnotificationType(void);
263
264extern bool isBTOn(void);
265
266extern void BT_switchMode(char *oldProfile, char *newProfile, char *command, u8 commandLength);
267
268extern ModuleType BT_getModuleType(void);
269
270
323#endif
A device that is created when a Bluetooth device is connected to.
Definition: utBluetooth.h:132
bool Connected
Definition: utBluetooth.h:138
u8 LinkID
Definition: utBluetooth.h:135
char * Profile
Definition: utBluetooth.h:134
u8 mode
Definition: utBluetooth.h:137
u8 Channel
Definition: utBluetooth.h:136
All the information that is requited when creating a new profile/mode.
Definition: utBluetooth.h:102
All the information about a command to send to the Bluetooth module.
Definition: utBluetooth.h:153
int maxAttempts
Definition: utBluetooth.h:156
int numAttempts
Definition: utBluetooth.h:155
ModuleType
The fixed mode the BT module can connect to.
Definition: utBluetooth.h:161
BT_SetupStage
The states used internally when in SetupMode.
Definition: utBluetooth.h:180
bool BTaddMode(BT_Profile b)
BT_Auth_Mode
The states used internally when in SetupMode.
Definition: utBluetooth.h:187
void utBT_SendCommand(const char *format,...)
bool utBT_Notify(UT_DeviceMessage state)
#define BT_MAX_COMMAND_LENGTH
Max command length for the BT module.
Definition: utBluetooth.h:77
bool BTaddSetupCommand(char *com)
BT_StateType
The mode this module is running in.
Definition: utBluetooth.h:170
int utBT_SendData(const u8 *data, u32 size)
int BTLoggerHasSpace(void)