diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2010-04-18 04:47:52 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2010-04-18 04:47:52 +0000 |
commit | 55db57e1ede3c44a3b027cb442fa12e969b37f4b (patch) | |
tree | 832d0867749304a750e911ded50aaacfc4c7a006 /Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.c | |
parent | 1f682ca2de8df89e3fef0077b33070cf2c85e798 (diff) | |
download | lufa-55db57e1ede3c44a3b027cb442fa12e969b37f4b.tar.gz lufa-55db57e1ede3c44a3b027cb442fa12e969b37f4b.tar.bz2 lufa-55db57e1ede3c44a3b027cb442fa12e969b37f4b.zip |
Add bluetooth channel connection callback to the incomplete BluetoothHost demo.
Diffstat (limited to 'Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.c')
-rw-r--r-- | Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.c b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.c index 108abbf3d..a8145c47d 100644 --- a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.c +++ b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.c @@ -381,14 +381,26 @@ static inline void Bluetooth_Signal_ConnectionReq(BT_Signal_Header_t* SignalComm }
}
}
+
+ uint8_t ChannelStatus = BT_CONNECTION_REFUSED_RESOURCES;
/* Reset the channel item contents only if a channel entry was found for it */
if (ChannelData != NULL)
{
- ChannelData->RemoteNumber = ConnectionRequest.SourceChannel;
- ChannelData->PSM = ConnectionRequest.PSM;
- ChannelData->LocalMTU = MAXIMUM_CHANNEL_MTU;
- ChannelData->State = Channel_Config_WaitConfig;
+ /* Check if the user application will allow the connection based on its PSM */
+ if (Bluetooth_ChannelConnectionRequest(ConnectionRequest.PSM))
+ {
+ ChannelData->RemoteNumber = ConnectionRequest.SourceChannel;
+ ChannelData->PSM = ConnectionRequest.PSM;
+ ChannelData->LocalMTU = MAXIMUM_CHANNEL_MTU;
+ ChannelData->State = Channel_Config_WaitConfig;
+ + ChannelStatus = BT_CONNECTION_SUCCESSFUL;
+ }
+ else
+ {
+ ChannelStatus = BT_CONNECTION_REFUSED_PSM;
+ }
}
struct
@@ -405,8 +417,7 @@ static inline void Bluetooth_Signal_ConnectionReq(BT_Signal_Header_t* SignalComm /* Fill out the Connection Response in the response packet */
ResponsePacket.ConnectionResponse.DestinationChannel = ChannelData->LocalNumber;
ResponsePacket.ConnectionResponse.SourceChannel = ChannelData->RemoteNumber;
- ResponsePacket.ConnectionResponse.Result = (ChannelData == NULL) ? BT_CONNECTION_REFUSED_RESOURCES :
- BT_CONNECTION_SUCCESSFUL;
+ ResponsePacket.ConnectionResponse.Result = ChannelStatus;
ResponsePacket.ConnectionResponse.Status = 0x00;
Bluetooth_SendPacket(&ResponsePacket, sizeof(ResponsePacket), NULL);
|