Add TEST RFCOMM command handler. Remove the RFCOMM channel UseUIFrame element, as...
[pub/USBasp.git] / Demos / Host / Incomplete / BluetoothHost / Lib / RFCOMMControl.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2010.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
7 */
8
9 /*
10 Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
11
12 Permission to use, copy, modify, distribute, and sell this
13 software and its documentation for any purpose is hereby granted
14 without fee, provided that the above copyright notice appear in
15 all copies and that both that the copyright notice and this
16 permission notice and warranty disclaimer appear in supporting
17 documentation, and that the name of the author not be used in
18 advertising or publicity pertaining to distribution of the
19 software without specific, written prior permission.
20
21 The author disclaim all warranties with regard to this
22 software, including all implied warranties of merchantability
23 and fitness. In no event shall the author be liable for any
24 special, indirect or consequential damages or any damages
25 whatsoever resulting from loss of use, data or profits, whether
26 in an action of contract, negligence or other tortious action,
27 arising out of or in connection with the use or performance of
28 this software.
29 */
30
31 /** \file
32 *
33 * Header file for RFCOMMControl.c.
34 */
35
36 #ifndef _RFCOMM_CONTROL_H_
37 #define _RFCOMM_CONTROL_H_
38
39 /* Includes: */
40 #include <avr/io.h>
41 #include <avr/pgmspace.h>
42 #include <string.h>
43 #include <stdbool.h>
44 #include <stdio.h>
45
46 #include <LUFA/Common/Common.h>
47 #include <LUFA/Drivers/Peripheral/SerialStream.h>
48
49 #include "BluetoothStack.h"
50 #include "RFCOMM.h"
51
52 /* Macros: */
53 #define RFCOMM_STATUSFLAG_FC (1 << 1)
54 #define RFCOMM_STATUSFLAG_RTC (1 << 2)
55 #define RFCOMM_STATUSFLAG_RTR (1 << 3)
56 #define RFCOMM_STATUSFLAG_IC (1 << 6)
57 #define RFCOMM_STATUSFLAG_DV (1 << 7)
58
59 /* Enums: */
60 enum RFCOMM_Control_Commands_t
61 {
62 RFCOMM_Control_Test = (0x20 >> 2),
63 RFCOMM_Control_FlowControlEnable = (0xA0 >> 2),
64 RFCOMM_Control_FlowControlDisable = (0x60 >> 2),
65 RFCOMM_Control_ModemStatus = (0xE0 >> 2),
66 RFCOMM_Control_RemotePortNegotiation = (0x90 >> 2),
67 RFCOMM_Control_RemoteLineStatus = (0x50 >> 2),
68 RFCOMM_Control_DLCParameterNegotiation = (0x80 >> 2),
69 RFCOMM_Control_NonSupportedCommand = (0x10 >> 2),
70 };
71
72 /* Type Defines: */
73 typedef struct
74 {
75 unsigned char EA : 1;
76 unsigned char CR : 1;
77 unsigned char DLCI : 6;
78 } RFCOMM_Address_t;
79
80 typedef struct
81 {
82 RFCOMM_Address_t Address;
83 uint8_t Control;
84 } RFCOMM_Header_t;
85
86 typedef struct
87 {
88 unsigned char EA : 1;
89 unsigned char CR : 1;
90 unsigned char Command : 6;
91 } RFCOMM_Command_t;
92
93 typedef struct
94 {
95 uint8_t DLCI;
96 unsigned char FrameType : 4;
97 unsigned char ConvergenceLayer : 4;
98 uint8_t Priority;
99 uint8_t ACKTimerTicks;
100 uint16_t MaximumFrameSize;
101 uint8_t MaxRetransmissions;
102 uint8_t RecoveryWindowSize;
103 } RFCOMM_DPN_Parameters_t;
104
105 typedef struct
106 {
107 RFCOMM_Address_t Channel;
108 uint8_t Signals;
109 uint8_t BreakSignals;
110 } RFCOMM_MS_Parameters_t;
111
112 /* Function Prototypes: */
113 void RFCOMM_ProcessControlCommand(const uint8_t* Command, Bluetooth_Channel_t* const Channel);
114
115 #if defined(INCLUDE_FROM_RFCOMM_CONTROL_C)
116 static void RFCOMM_ProcessTestCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t CommandDataLen,
117 const uint8_t* CommandData, Bluetooth_Channel_t* const Channel);
118 static void RFCOMM_ProcessFCECommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t* CommandData,
119 Bluetooth_Channel_t* const Channel);
120 static void RFCOMM_ProcessFCDCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t* CommandData,
121 Bluetooth_Channel_t* const Channel);
122 static void RFCOMM_ProcessMSCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t CommandDataLen,
123 const uint8_t* CommandData, Bluetooth_Channel_t* const Channel);
124 static void RFCOMM_ProcessRPNCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t* CommandData,
125 Bluetooth_Channel_t* const Channel);
126 static void RFCOMM_ProcessRLSCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t* CommandData,
127 Bluetooth_Channel_t* const Channel);
128 static void RFCOMM_ProcessDPNCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t* CommandData,
129 Bluetooth_Channel_t* const Channel);
130 #endif
131
132 #endif