aboutsummaryrefslogtreecommitdiffstats
path: root/Demos/Host/Incomplete/BluetoothHost/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Demos/Host/Incomplete/BluetoothHost/Lib')
-rw-r--r--Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.c4
-rw-r--r--Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.h10
-rw-r--r--Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothHCICommands.c8
-rw-r--r--Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothStack.h8
-rw-r--r--Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.c43
-rw-r--r--Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.h9
-rw-r--r--Demos/Host/Incomplete/BluetoothHost/Lib/SDPServices.c2
7 files changed, 62 insertions, 22 deletions
diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.c b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.c
index 698210488..03d0f2aca 100644
--- a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.c
+++ b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.c
@@ -249,7 +249,7 @@ uint8_t Bluetooth_SendPacket(void* Data, const uint16_t DataLen, Bluetooth_Chann
return BT_SENDPACKET_NoError;
}
-/** Opens a bluetooth channel to the currently connected remote device, so that data can be exchanged.
+/** Opens a Bluetooth channel to the currently connected remote device, so that data can be exchanged.
*
* \note The channel is not immediately opened when this function returns - it must undergo a two way
* connection and configuration process first as the main Bluetooth stack processing task is
@@ -312,7 +312,7 @@ Bluetooth_Channel_t* Bluetooth_OpenChannel(const uint16_t PSM)
return ChannelData;
}
-/** Closes a bluetooth channel that is open to the currently connected remote device, so that no further data
+/** Closes a Bluetooth channel that is open to the currently connected remote device, so that no further data
* can be exchanged.
*
* \note The channel is not immediately closed when this function returns - it must undergo an asynchronous
diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.h b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.h
index c655971fc..894c37003 100644
--- a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.h
+++ b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.h
@@ -51,13 +51,13 @@
#define BT_ACL_DEBUG(l, s, ...) do { if (ACL_DEBUG_LEVEL >= l) printf_P(PSTR("(ACL) " s "\r\n"), ##__VA_ARGS__); } while (0)
#define ACL_DEBUG_LEVEL 0
- /** Lowest possible channel number for L2CAP data channels */
+ /** Lowest possible channel number for L2CAP data channels. */
#define BT_CHANNELNUMBER_BASEOFFSET 0x0040
- /** Bluetooth specification defined channel number for signalling commands */
+ /** Bluetooth specification defined channel number for signalling commands. */
#define BT_CHANNEL_SIGNALING 0x0001
- /** Bluetooth specification defined channel number for connectionless data */
+ /** Bluetooth specification defined channel number for connectionless data. */
#define BT_CHANNEL_CONNECTIONLESS 0x0002
#define BT_ACL_FIRST_AUTOFLUSH (1 << 13)
@@ -98,14 +98,14 @@
uint16_t DataLength; /**< Length of the packet payload, in bytes */
} BT_ACL_Header_t;
- /** Bluetooth ACL data packet header structure, for ACL packets containing L2CAP data */
+ /** Bluetooth ACL data packet header structure, for ACL packets containing L2CAP data. */
typedef struct
{
uint16_t PayloadLength; /**< Size of the data payload, in bytes */
uint16_t DestinationChannel; /**< Destination channel in the device the data is directed to */
} BT_DataPacket_Header_t;
- /** Bluetooth signalling command header structure, for all ACL packets containing a signalling command */
+ /** Bluetooth signalling command header structure, for all ACL packets containing a signalling command. */
typedef struct
{
uint8_t Code; /**< Signal code, a BT_SIGNAL_* mask value */
diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothHCICommands.c b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothHCICommands.c
index df97220a2..57b74e089 100644
--- a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothHCICommands.c
+++ b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothHCICommands.c
@@ -182,7 +182,7 @@ void Bluetooth_HCITask(void)
ParameterLength: 0,
};
- /* Send the command to reset the bluetooth dongle controller */
+ /* Send the command to reset the Bluetooth dongle controller */
Bluetooth_SendHCICommand(&HCICommandHeader, NULL, 0);
Bluetooth_State.NextHCIState = Bluetooth_Init_ReadBufferSize;
@@ -197,7 +197,7 @@ void Bluetooth_HCITask(void)
ParameterLength: 0,
};
- /* Send the command to read the bluetooth buffer size (mandatory before device sends any data) */
+ /* Send the command to read the Bluetooth buffer size (mandatory before device sends any data) */
Bluetooth_SendHCICommand(&HCICommandHeader, NULL, 0);
Bluetooth_State.NextHCIState = Bluetooth_Init_GetBDADDR;
@@ -212,7 +212,7 @@ void Bluetooth_HCITask(void)
ParameterLength: 0,
};
- /* Send the command to retrieve the BDADDR of the inserted bluetooth dongle */
+ /* Send the command to retrieve the BDADDR of the inserted Bluetooth dongle */
Bluetooth_SendHCICommand(&HCICommandHeader, NULL, 0);
Bluetooth_State.NextHCIState = Bluetooth_Init_SetLocalName;
@@ -227,7 +227,7 @@ void Bluetooth_HCITask(void)
ParameterLength: 248,
};
- /* Send the command to set the bluetooth dongle's name for other devices to see */
+ /* Send the command to set the Bluetooth dongle's name for other devices to see */
Bluetooth_SendHCICommand(&HCICommandHeader, Bluetooth_DeviceConfiguration.Name, strlen(Bluetooth_DeviceConfiguration.Name));
Bluetooth_State.NextHCIState = Bluetooth_Init_SetDeviceClass;
diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothStack.h b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothStack.h
index fb25ec77d..060f4fffd 100644
--- a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothStack.h
+++ b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothStack.h
@@ -63,7 +63,7 @@
#define MAXIMUM_CHANNEL_MTU 255
/* Enums: */
- /** Enum for the possible states for a bluetooth ACL channel. */
+ /** Enum for the possible states for a Bluetooth ACL channel. */
enum BT_ChannelStates_t
{
Channel_Closed = 0, /**< Channel is closed and inactive. No data may be sent or received. */
@@ -85,7 +85,7 @@
enum BT_SendPacket_ErrorCodes_t
{
BT_SENDPACKET_NoError = 0, /**< The packet was sent sucessfully. */
- BT_SENDPACKET_NotConnected = 1, /**< The bluetooth stack is not currently connected to a remote device. */
+ BT_SENDPACKET_NotConnected = 1, /**< The Bluetooth stack is not currently connected to a remote device. */
BT_SENDPACKET_ChannelNotOpen = 2, /**< The given channel is not currently in the Open state. */
};
@@ -122,7 +122,7 @@
{
uint32_t Class; /**< Class of the local device, a mask of DEVICE_CLASS_* masks. */
char PINCode[16]; /**< Pin code required to send or receive in order to authenticate with a remote device. */
- char Name[]; /**< Name of the local bluetooth device, up to 248 characters. */
+ char Name[]; /**< Name of the local Bluetooth device, up to 248 characters. */
} Bluetooth_Device_t;
/** Bluetooth stack state information structure, for the containment of the Bluetooth stack state. The values in
@@ -136,7 +136,7 @@
bool IsInitialized; /**< Indicates if the Bluetooth stack is currently initialized and ready for connections
* to or from a remote Bluetooth device.
*/
- uint8_t LocalBDADDR[6]; /**< Local bluetooth adapter's BDADDR, valid when the stack is fully initialized. */
+ uint8_t LocalBDADDR[6]; /**< Local Bluetooth adapter's BDADDR, valid when the stack is fully initialized. */
} Bluetooth_Stack_State_t;
/* Includes: */
diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.c b/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.c
index 2d880771f..a441ae156 100644
--- a/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.c
+++ b/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.c
@@ -68,23 +68,56 @@ void RFCOMM_ProcessPacket(void* Data, Bluetooth_Channel_t* const Channel)
switch (FrameHeader->FrameType & ~FRAME_POLL_FINAL)
{
case RFCOMM_Frame_SABM:
- BT_RFCOMM_DEBUG(1, "<< SABM Received");
+ RFCOMM_ProcessSABM(FrameHeader, Channel);
break;
case RFCOMM_Frame_UA:
- BT_RFCOMM_DEBUG(1, "<< UA Received");
+ RFCOMM_ProcessUA(FrameHeader, Channel);
break;
case RFCOMM_Frame_DM:
- BT_RFCOMM_DEBUG(1, "<< DM Received");
+ RFCOMM_ProcessDM(FrameHeader, Channel);
break;
case RFCOMM_Frame_DISC:
- BT_RFCOMM_DEBUG(1, "<< DISC Received");
+ RFCOMM_ProcessDISC(FrameHeader, Channel);
break;
case RFCOMM_Frame_UIH:
- BT_RFCOMM_DEBUG(1, "<< UIH Received");
+ RFCOMM_ProcessUIH(FrameHeader, Channel);
break;
}
}
+static void RFCOMM_ProcessSABM(const RFCOMM_Header_t* const FrameHeader, Bluetooth_Channel_t* const Channel)
+{
+ uint8_t* CurrBufferPos = ((uint8_t*)FrameHeader + sizeof(RFCOMM_Header_t));
+ uint16_t DataLen = RFCOMM_GetFrameDataLength(&CurrBufferPos);
+
+ BT_RFCOMM_DEBUG(1, "<< SABM Received");
+ BT_RFCOMM_DEBUG(2, "-- Data Length 0x%04X", DataLen);
+
+ for (uint16_t i = 0; i < DataLen; i++)
+ printf("0x%02X ", CurrBufferPos[i]);
+ printf("\r\n");
+}
+
+static void RFCOMM_ProcessUA(const RFCOMM_Header_t* const FrameHeader, Bluetooth_Channel_t* const Channel)
+{
+ BT_RFCOMM_DEBUG(1, "<< UA Received");
+}
+
+static void RFCOMM_ProcessDM(const RFCOMM_Header_t* const FrameHeader, Bluetooth_Channel_t* const Channel)
+{
+ BT_RFCOMM_DEBUG(1, "<< DM Received");
+}
+
+static void RFCOMM_ProcessDISC(const RFCOMM_Header_t* const FrameHeader, Bluetooth_Channel_t* const Channel)
+{
+ BT_RFCOMM_DEBUG(1, "<< DISC Received");
+}
+
+static void RFCOMM_ProcessUIH(const RFCOMM_Header_t* const FrameHeader, Bluetooth_Channel_t* const Channel)
+{
+ BT_RFCOMM_DEBUG(1, "<< UIH Received");
+}
+
static uint16_t RFCOMM_GetFrameDataLength(void** BufferPos)
{
uint8_t FirstOctet = *((uint8_t*)*BufferPos);
diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.h b/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.h
index ff04ed5a9..45f29ac21 100644
--- a/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.h
+++ b/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.h
@@ -55,6 +55,7 @@
#define FRAME_POLL_FINAL (1 << 5)
/* Enums: */
+ /** Enum for the types of RFCOMM frames which can be exchanged on a Bluetooth channel. */
enum RFCOMM_Frame_Types_t
{
RFCOMM_Frame_SABM = 0x2F, /**< Set Asynchronous Balance Mode Field */
@@ -70,7 +71,7 @@
struct
{
unsigned char LogicalChannel : 6;
- unsigned char CommandResponse : 1;
+ unsigned char PollResponse : 1;
unsigned char LastAddressOctet : 1;
} Header;
@@ -82,6 +83,12 @@
void RFCOMM_ProcessPacket(void* Data, Bluetooth_Channel_t* const Channel);
#if defined(INCLUDE_FROM_RFCOMM_C)
+ static void RFCOMM_ProcessSABM(const RFCOMM_Header_t* const FrameHeader, Bluetooth_Channel_t* const Channel);
+ static void RFCOMM_ProcessUA(const RFCOMM_Header_t* const FrameHeader, Bluetooth_Channel_t* const Channel);
+ static void RFCOMM_ProcessDM(const RFCOMM_Header_t* const FrameHeader, Bluetooth_Channel_t* const Channel);
+ static void RFCOMM_ProcessDISC(const RFCOMM_Header_t* const FrameHeader, Bluetooth_Channel_t* const Channel);
+ static void RFCOMM_ProcessUIH(const RFCOMM_Header_t* const FrameHeader, Bluetooth_Channel_t* const Channel);
+
static uint16_t RFCOMM_GetFrameDataLength(void** BufferPos);
#endif
diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/SDPServices.c b/Demos/Host/Incomplete/BluetoothHost/Lib/SDPServices.c
index a06ebfede..ca47f9084 100644
--- a/Demos/Host/Incomplete/BluetoothHost/Lib/SDPServices.c
+++ b/Demos/Host/Incomplete/BluetoothHost/Lib/SDPServices.c
@@ -77,7 +77,7 @@ const struct
(sizeof(ItemUUID_t) + sizeof(Item8Bit_t)),
{
{(SDP_DATATYPE_UUID | SDP_DATASIZE_128Bit), RFCOMM_UUID},
- {(SDP_DATATYPE_UnsignedInt | SDP_DATASIZE_8Bit), 0x03},
+ {(SDP_DATATYPE_UnsignedInt | SDP_DATASIZE_8Bit), 0x00},
},
},
};