aboutsummaryrefslogtreecommitdiffstats
path: root/Demos/Host
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2010-06-03 03:58:57 +0000
committerDean Camera <dean@fourwalledcubicle.com>2010-06-03 03:58:57 +0000
commit008e0e2e0a13e64e03f27f1c9a008ef201560878 (patch)
tree53e4c17848b5a295484c00d5df6864956bfc7e0a /Demos/Host
parent5144ea76f646cd9f649de16e3d67dfead2d3c2bf (diff)
downloadlufa-008e0e2e0a13e64e03f27f1c9a008ef201560878.tar.gz
lufa-008e0e2e0a13e64e03f27f1c9a008ef201560878.tar.bz2
lufa-008e0e2e0a13e64e03f27f1c9a008ef201560878.zip
Add start of RFCOMM service layer to the incomplete BluetoothHost demo.
Reduce the size of the attribute search list from 15 ranges to 8 to save RAM.
Diffstat (limited to 'Demos/Host')
-rw-r--r--Demos/Host/Incomplete/BluetoothHost/BluetoothHost.c6
-rw-r--r--Demos/Host/Incomplete/BluetoothHost/BluetoothHost.h1
-rw-r--r--Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothStack.h12
-rw-r--r--Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.c36
-rw-r--r--Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.h57
-rw-r--r--Demos/Host/Incomplete/BluetoothHost/Lib/SDPServices.c2
-rw-r--r--Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.c11
-rw-r--r--Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.h6
-rw-r--r--Demos/Host/Incomplete/BluetoothHost/makefile1
9 files changed, 118 insertions, 14 deletions
diff --git a/Demos/Host/Incomplete/BluetoothHost/BluetoothHost.c b/Demos/Host/Incomplete/BluetoothHost/BluetoothHost.c
index b9b5ec14b..737932cdb 100644
--- a/Demos/Host/Incomplete/BluetoothHost/BluetoothHost.c
+++ b/Demos/Host/Incomplete/BluetoothHost/BluetoothHost.c
@@ -260,7 +260,7 @@ void Bluetooth_DisconnectionComplete(void)
* the user application must indicate if the channel connection should be rejected or not, based on the
* protocol (PSM) value of the requested channel.
*
- * \param PSM Protocol PSM value for the requested channel
+ * \param[in] PSM Protocol PSM value for the requested channel
*
* \return Boolean true to accept the channel connection request, false to reject it
*/
@@ -285,6 +285,10 @@ void Bluetooth_PacketReceived(void* Data, uint16_t DataLen, Bluetooth_Channel_t*
/* Service Discovery Protocol packet */
SDP_ProcessPacket(Data, Channel);
break;
+ case CHANNEL_PSM_RFCOMM:
+ /* RFCOMM (Serial Port) Protocol packet */
+ RFCOMM_ProcessPacket(Data, Channel);
+ break;
default:
/* Unknown Protocol packet */
printf_P(PSTR("Packet Received (Channel 0x%04X, PSM: 0x%02x):\r\n"), Channel->LocalNumber, Channel->PSM);
diff --git a/Demos/Host/Incomplete/BluetoothHost/BluetoothHost.h b/Demos/Host/Incomplete/BluetoothHost/BluetoothHost.h
index 266181db4..ce7d1f500 100644
--- a/Demos/Host/Incomplete/BluetoothHost/BluetoothHost.h
+++ b/Demos/Host/Incomplete/BluetoothHost/BluetoothHost.h
@@ -45,6 +45,7 @@
#include <stdio.h>
#include "Lib/ServiceDiscoveryProtocol.h"
+ #include "Lib/RFCOMM.h"
#include "Lib/BluetoothStack.h"
#include "DeviceDescriptor.h"
diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothStack.h b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothStack.h
index 4b16a8f48..fb25ec77d 100644
--- a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothStack.h
+++ b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothStack.h
@@ -95,12 +95,12 @@
*/
typedef struct
{
- uint8_t State;
- uint16_t LocalNumber;
- uint16_t RemoteNumber;
- uint16_t PSM;
- uint16_t LocalMTU;
- uint16_t RemoteMTU;
+ uint8_t State; /**< Current channel state, a value from the \ref BT_ChannelStates_t enum. */
+ uint16_t LocalNumber; /**< Local channel number on the device. */
+ uint16_t RemoteNumber; /**< Remote channel number on the connected device. */
+ uint16_t PSM; /**< Protocol used on the channel. */
+ uint16_t LocalMTU; /**< MTU of data sent from the connected device to the local device. */
+ uint16_t RemoteMTU; /**< MTU of data sent from the local device to the connected device. */
} Bluetooth_Channel_t;
/** Type define for a Bluetooth device connection information structure. This structure contains all the
diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.c b/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.c
new file mode 100644
index 000000000..052bf3fdb
--- /dev/null
+++ b/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.c
@@ -0,0 +1,36 @@
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2010.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.fourwalledcubicle.com
+*/
+
+/*
+ Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, distribute, and sell this
+ software and its documentation for any purpose is hereby granted
+ without fee, provided that the above copyright notice appear in
+ all copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+#include "RFCOMM.h"
+
+void RFCOMM_ProcessPacket(void* Data, Bluetooth_Channel_t* const Channel)
+{
+ BT_RFCOMM_DEBUG(1, "PACKET RECEIVED");
+}
diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.h b/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.h
new file mode 100644
index 000000000..7f1b6269a
--- /dev/null
+++ b/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.h
@@ -0,0 +1,57 @@
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2010.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.fourwalledcubicle.com
+*/
+
+/*
+ Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, distribute, and sell this
+ software and its documentation for any purpose is hereby granted
+ without fee, provided that the above copyright notice appear in
+ all copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+/** \file
+ *
+ * Header file for RFCOMM.c.
+ */
+
+#ifndef _RFCOMM_H_
+#define _RFCOMM_H_
+
+ /* Includes: */
+ #include <avr/io.h>
+ #include <string.h>
+ #include <stdbool.h>
+ #include <stdio.h>
+
+ #include <LUFA/Common/Common.h>
+ #include <LUFA/Drivers/Peripheral/SerialStream.h>
+
+ #include "BluetoothStack.h"
+
+ /* Macros: */
+ #define BT_RFCOMM_DEBUG(l, s, ...) do { if (RFCOMM_DEBUG_LEVEL >= l) printf_P(PSTR("(RFCOMM) " s "\r\n"), ##__VA_ARGS__); } while (0)
+ #define RFCOMM_DEBUG_LEVEL 2
+
+ /* Function Prototypes: */
+ void RFCOMM_ProcessPacket(void* Data, Bluetooth_Channel_t* const Channel);
+
+#endif
diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/SDPServices.c b/Demos/Host/Incomplete/BluetoothHost/Lib/SDPServices.c
index 908be0c6d..d812252b1 100644
--- a/Demos/Host/Incomplete/BluetoothHost/Lib/SDPServices.c
+++ b/Demos/Host/Incomplete/BluetoothHost/Lib/SDPServices.c
@@ -113,7 +113,7 @@ const struct
{(SDP_DATATYPE_UnsignedInt | SDP_DATASIZE_16Bit), SWAPENDIAN_16(0x0100)},
}
}
- };
+ };
const struct
{
diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.c b/Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.c
index df0db3bed..0ee0784c5 100644
--- a/Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.c
+++ b/Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.c
@@ -119,11 +119,10 @@ static void SDP_ProcessServiceSearch(const SDP_PDUHeader_t* const SDPHeader, Blu
/* Copy over the service record handle to the response list */
uint8_t AttrHeaderSize;
- SDP_GetLocalAttributeContainerSize(AttributeValue, &AttrHeaderSize);
- memcpy_P(CurrResponsePos, AttributeValue + AttrHeaderSize, sizeof(uint32_t));
- CurrResponsePos += AttrHeaderSize + sizeof(uint32_t);
+ uint8_t AttrSize = SDP_GetLocalAttributeContainerSize(AttributeValue, &AttrHeaderSize);
+ memcpy_P(CurrResponsePos, AttributeValue + AttrHeaderSize, AttrSize);
+ CurrResponsePos += AttrHeaderSize + AttrSize;
- /* Increment the total number of service records added to the list */
AddedServiceHandles++;
}
@@ -172,7 +171,7 @@ static void SDP_ProcessServiceAttribute(const SDP_PDUHeader_t* const SDPHeader,
BT_SDP_DEBUG(2, "-- Max Return Attribute Bytes: 0x%04X", MaxAttributeSize);
/* Retrieve the list of Attributes from the request */
- uint16_t AttributeList[15][2];
+ uint16_t AttributeList[8][2];
uint8_t TotalAttributes = SDP_GetAttributeList(AttributeList, &CurrentParameter);
BT_SDP_DEBUG(2, "-- Total Attributes: %d", TotalAttributes);
@@ -263,7 +262,7 @@ static void SDP_ProcessServiceSearchAttribute(const SDP_PDUHeader_t* const SDPHe
BT_SDP_DEBUG(2, "-- Max Return Attribute Bytes: 0x%04X", MaxAttributeSize);
/* Retrieve the list of Attributes from the request */
- uint16_t AttributeList[15][2];
+ uint16_t AttributeList[8][2];
uint8_t TotalAttributes = SDP_GetAttributeList(AttributeList, &CurrentParameter);
BT_SDP_DEBUG(2, "-- Total Attributes: %d", TotalAttributes);
diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.h b/Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.h
index e46729cd9..dd5182c34 100644
--- a/Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.h
+++ b/Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.h
@@ -60,6 +60,12 @@
#define SDP_PDU_SERVICESEARCHATTRIBUTEREQUEST 0x06
#define SDP_PDU_SERVICESEARCHATTRIBUTERESPONSE 0x07
+ /** Convenience macro - read a pointer out of PROGMEM space.
+ *
+ * \param[in] x Address of the pointer to read
+ *
+ * \return Pointer retrieved from PROGMEM space
+ */
#define pgm_read_ptr(x) (void*)pgm_read_word(x)
/* Enums: */
diff --git a/Demos/Host/Incomplete/BluetoothHost/makefile b/Demos/Host/Incomplete/BluetoothHost/makefile
index 76571f8bd..8e3c55a7b 100644
--- a/Demos/Host/Incomplete/BluetoothHost/makefile
+++ b/Demos/Host/Incomplete/BluetoothHost/makefile
@@ -137,6 +137,7 @@ SRC = $(TARGET).c \
Lib/BluetoothACLPackets.c \
Lib/ServiceDiscoveryProtocol.c \
Lib/SDPServices.c \
+ Lib/RFCOMM.c \
$(LUFA_PATH)/LUFA/Drivers/Peripheral/SerialStream.c \
$(LUFA_PATH)/LUFA/Drivers/Peripheral/Serial.c \
$(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/DevChapter9.c \