e12c74c763a5e8ba6e55f9d9b84b4cc44e7a5c79
[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_
54
55 /* Enums: */
56 enum RFCOMM_Control_Commands_t
57 {
58 RFCOMM_Control_Test = (0x20 >> 2),
59 RFCOMM_Control_FlowControlEnable = (0xA0 >> 2),
60 RFCOMM_Control_FlowControlDisable = (0x60 >> 2),
61 RFCOMM_Control_ModemStatus = (0xE0 >> 2),
62 RFCOMM_Control_RemotePortNegotiation = (0x90 >> 2),
63 RFCOMM_Control_RemoteLineStatus = (0x50 >> 2),
64 RFCOMM_Control_DLCParameterNegotiation = (0x80 >> 2),
65 RFCOMM_Control_NonSupportedCommand = (0x10 >> 2),
66 };
67
68 /* Type Defines: */
69 typedef struct
70 {
71 unsigned char EA : 1;
72 unsigned char CR : 1;
73 unsigned char DLCI : 6;
74 } RFCOMM_Address_t;
75
76 typedef struct
77 {
78 RFCOMM_Address_t Address;
79 uint8_t Control;
80 } RFCOMM_Header_t;
81
82 typedef struct
83 {
84 unsigned char EA : 1;
85 unsigned char CR : 1;
86 unsigned char Command : 6;
87 } RFCOMM_Command_t;
88
89 typedef struct
90 {
91 uint8_t DLCI;
92 unsigned char FrameType : 4;
93 unsigned char ConvergenceLayer : 4;
94 uint8_t Priority;
95 uint8_t ACKTimerTicks;
96 uint16_t MaximumFrameSize;
97 uint8_t MaxRetransmissions;
98 uint8_t RecoveryWindowSize;
99 } RFCOMM_DPN_Parameters_t;
100
101 /* Function Prototypes: */
102 void RFCOMM_ProcessControlCommand(const uint8_t* Command, Bluetooth_Channel_t* const Channel);
103
104 #if defined(INCLUDE_FROM_RFCOMM_CONTROL_C)
105 static void RFCOMM_ProcessTestCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t* CommandData,
106 Bluetooth_Channel_t* const Channel);
107 static void RFCOMM_ProcessFCECommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t* CommandData,
108 Bluetooth_Channel_t* const Channel);
109 static void RFCOMM_ProcessFCDCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t* CommandData,
110 Bluetooth_Channel_t* const Channel);
111 static void RFCOMM_ProcessMSCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t* CommandData,
112 Bluetooth_Channel_t* const Channel);
113 static void RFCOMM_ProcessRPNCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t* CommandData,
114 Bluetooth_Channel_t* const Channel);
115 static void RFCOMM_ProcessRLSCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t* CommandData,
116 Bluetooth_Channel_t* const Channel);
117 static void RFCOMM_ProcessDPNCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t* CommandData,
118 Bluetooth_Channel_t* const Channel);
119 #endif
120
121 #endif