mbed base bard check program for BlueTooth USB dongle module (3 switches, 6 leds, I2C LCD, A/D)
Fork of BTstack by
BTstack/rfcomm.h@0:1ed23ab1345f, 2012-06-26 (annotated)
- Committer:
- va009039
- Date:
- Tue Jun 26 14:27:45 2012 +0000
- Revision:
- 0:1ed23ab1345f
fix overflow spp_service_buffer
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
va009039 | 0:1ed23ab1345f | 1 | /* |
va009039 | 0:1ed23ab1345f | 2 | * Copyright (C) 2009-2012 by Matthias Ringwald |
va009039 | 0:1ed23ab1345f | 3 | * |
va009039 | 0:1ed23ab1345f | 4 | * Redistribution and use in source and binary forms, with or without |
va009039 | 0:1ed23ab1345f | 5 | * modification, are permitted provided that the following conditions |
va009039 | 0:1ed23ab1345f | 6 | * are met: |
va009039 | 0:1ed23ab1345f | 7 | * |
va009039 | 0:1ed23ab1345f | 8 | * 1. Redistributions of source code must retain the above copyright |
va009039 | 0:1ed23ab1345f | 9 | * notice, this list of conditions and the following disclaimer. |
va009039 | 0:1ed23ab1345f | 10 | * 2. Redistributions in binary form must reproduce the above copyright |
va009039 | 0:1ed23ab1345f | 11 | * notice, this list of conditions and the following disclaimer in the |
va009039 | 0:1ed23ab1345f | 12 | * documentation and/or other materials provided with the distribution. |
va009039 | 0:1ed23ab1345f | 13 | * 3. Neither the name of the copyright holders nor the names of |
va009039 | 0:1ed23ab1345f | 14 | * contributors may be used to endorse or promote products derived |
va009039 | 0:1ed23ab1345f | 15 | * from this software without specific prior written permission. |
va009039 | 0:1ed23ab1345f | 16 | * 4. Any redistribution, use, or modification is done solely for |
va009039 | 0:1ed23ab1345f | 17 | * personal benefit and not for any commercial purpose or for |
va009039 | 0:1ed23ab1345f | 18 | * monetary gain. |
va009039 | 0:1ed23ab1345f | 19 | * |
va009039 | 0:1ed23ab1345f | 20 | * THIS SOFTWARE IS PROVIDED BY MATTHIAS RINGWALD AND CONTRIBUTORS |
va009039 | 0:1ed23ab1345f | 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
va009039 | 0:1ed23ab1345f | 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
va009039 | 0:1ed23ab1345f | 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS |
va009039 | 0:1ed23ab1345f | 24 | * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
va009039 | 0:1ed23ab1345f | 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
va009039 | 0:1ed23ab1345f | 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS |
va009039 | 0:1ed23ab1345f | 27 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
va009039 | 0:1ed23ab1345f | 28 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
va009039 | 0:1ed23ab1345f | 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF |
va009039 | 0:1ed23ab1345f | 30 | * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
va009039 | 0:1ed23ab1345f | 31 | * SUCH DAMAGE. |
va009039 | 0:1ed23ab1345f | 32 | * |
va009039 | 0:1ed23ab1345f | 33 | * Please inquire about commercial licensing options at btstack@ringwald.ch |
va009039 | 0:1ed23ab1345f | 34 | * |
va009039 | 0:1ed23ab1345f | 35 | */ |
va009039 | 0:1ed23ab1345f | 36 | |
va009039 | 0:1ed23ab1345f | 37 | /* |
va009039 | 0:1ed23ab1345f | 38 | * RFCOMM.h |
va009039 | 0:1ed23ab1345f | 39 | */ |
va009039 | 0:1ed23ab1345f | 40 | |
va009039 | 0:1ed23ab1345f | 41 | #include <btstack/btstack.h> |
va009039 | 0:1ed23ab1345f | 42 | #include <btstack/utils.h> |
va009039 | 0:1ed23ab1345f | 43 | |
va009039 | 0:1ed23ab1345f | 44 | #include <stdint.h> |
va009039 | 0:1ed23ab1345f | 45 | |
va009039 | 0:1ed23ab1345f | 46 | #if defined __cplusplus |
va009039 | 0:1ed23ab1345f | 47 | extern "C" { |
va009039 | 0:1ed23ab1345f | 48 | #endif |
va009039 | 0:1ed23ab1345f | 49 | |
va009039 | 0:1ed23ab1345f | 50 | void rfcomm_init(void); |
va009039 | 0:1ed23ab1345f | 51 | |
va009039 | 0:1ed23ab1345f | 52 | // register packet handler |
va009039 | 0:1ed23ab1345f | 53 | void rfcomm_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size); |
va009039 | 0:1ed23ab1345f | 54 | void rfcomm_register_packet_handler(void (*handler)(void * connection, uint8_t packet_type, |
va009039 | 0:1ed23ab1345f | 55 | uint16_t channel, uint8_t *packet, uint16_t size)); |
va009039 | 0:1ed23ab1345f | 56 | |
va009039 | 0:1ed23ab1345f | 57 | // BTstack Internal RFCOMM API |
va009039 | 0:1ed23ab1345f | 58 | void rfcomm_create_channel_internal(void * connection, bd_addr_t *addr, uint8_t channel); |
va009039 | 0:1ed23ab1345f | 59 | void rfcomm_create_channel_with_initial_credits_internal(void * connection, bd_addr_t *addr, uint8_t server_channel, uint8_t initial_credits); |
va009039 | 0:1ed23ab1345f | 60 | void rfcomm_disconnect_internal(uint16_t rfcomm_cid); |
va009039 | 0:1ed23ab1345f | 61 | void rfcomm_register_service_internal(void * connection, uint8_t channel, uint16_t max_frame_size); |
va009039 | 0:1ed23ab1345f | 62 | void rfcomm_register_service_with_initial_credits_internal(void * connection, uint8_t channel, uint16_t max_frame_size, uint8_t initial_credits); |
va009039 | 0:1ed23ab1345f | 63 | void rfcomm_unregister_service_internal(uint8_t service_channel); |
va009039 | 0:1ed23ab1345f | 64 | void rfcomm_accept_connection_internal(uint16_t rfcomm_cid); |
va009039 | 0:1ed23ab1345f | 65 | void rfcomm_decline_connection_internal(uint16_t rfcomm_cid); |
va009039 | 0:1ed23ab1345f | 66 | void rfcomm_grant_credits(uint16_t rfcomm_cid, uint8_t credits); |
va009039 | 0:1ed23ab1345f | 67 | int rfcomm_send_internal(uint16_t rfcomm_cid, uint8_t *data, uint16_t len); |
va009039 | 0:1ed23ab1345f | 68 | void rfcomm_close_connection(void *connection); |
va009039 | 0:1ed23ab1345f | 69 | |
va009039 | 0:1ed23ab1345f | 70 | #define UNLIMITED_INCOMING_CREDITS 0xff |
va009039 | 0:1ed23ab1345f | 71 | |
va009039 | 0:1ed23ab1345f | 72 | // private structs |
va009039 | 0:1ed23ab1345f | 73 | typedef enum { |
va009039 | 0:1ed23ab1345f | 74 | RFCOMM_MULTIPLEXER_CLOSED = 1, |
va009039 | 0:1ed23ab1345f | 75 | RFCOMM_MULTIPLEXER_W4_CONNECT, // outgoing |
va009039 | 0:1ed23ab1345f | 76 | RFCOMM_MULTIPLEXER_SEND_SABM_0, // " |
va009039 | 0:1ed23ab1345f | 77 | RFCOMM_MULTIPLEXER_W4_UA_0, // " |
va009039 | 0:1ed23ab1345f | 78 | RFCOMM_MULTIPLEXER_W4_SABM_0, // incoming |
va009039 | 0:1ed23ab1345f | 79 | RFCOMM_MULTIPLEXER_SEND_UA_0, |
va009039 | 0:1ed23ab1345f | 80 | RFCOMM_MULTIPLEXER_OPEN, |
va009039 | 0:1ed23ab1345f | 81 | RFCOMM_MULTIPLEXER_SEND_UA_0_AND_DISC |
va009039 | 0:1ed23ab1345f | 82 | } RFCOMM_MULTIPLEXER_STATE; |
va009039 | 0:1ed23ab1345f | 83 | |
va009039 | 0:1ed23ab1345f | 84 | typedef enum { |
va009039 | 0:1ed23ab1345f | 85 | MULT_EV_READY_TO_SEND = 1, |
va009039 | 0:1ed23ab1345f | 86 | |
va009039 | 0:1ed23ab1345f | 87 | } RFCOMM_MULTIPLEXER_EVENT; |
va009039 | 0:1ed23ab1345f | 88 | |
va009039 | 0:1ed23ab1345f | 89 | typedef enum { |
va009039 | 0:1ed23ab1345f | 90 | RFCOMM_CHANNEL_CLOSED = 1, |
va009039 | 0:1ed23ab1345f | 91 | RFCOMM_CHANNEL_W4_MULTIPLEXER, |
va009039 | 0:1ed23ab1345f | 92 | RFCOMM_CHANNEL_SEND_UIH_PN, |
va009039 | 0:1ed23ab1345f | 93 | RFCOMM_CHANNEL_W4_PN_RSP, |
va009039 | 0:1ed23ab1345f | 94 | RFCOMM_CHANNEL_SEND_SABM_W4_UA, |
va009039 | 0:1ed23ab1345f | 95 | RFCOMM_CHANNEL_W4_UA, |
va009039 | 0:1ed23ab1345f | 96 | RFCOMM_CHANNEL_INCOMING_SETUP, |
va009039 | 0:1ed23ab1345f | 97 | RFCOMM_CHANNEL_DLC_SETUP, |
va009039 | 0:1ed23ab1345f | 98 | RFCOMM_CHANNEL_OPEN, |
va009039 | 0:1ed23ab1345f | 99 | RFCOMM_CHANNEL_SEND_UA_AFTER_DISC, |
va009039 | 0:1ed23ab1345f | 100 | RFCOMM_CHANNEL_SEND_DISC, |
va009039 | 0:1ed23ab1345f | 101 | RFCOMM_CHANNEL_SEND_DM, |
va009039 | 0:1ed23ab1345f | 102 | |
va009039 | 0:1ed23ab1345f | 103 | } RFCOMM_CHANNEL_STATE; |
va009039 | 0:1ed23ab1345f | 104 | |
va009039 | 0:1ed23ab1345f | 105 | /* |
va009039 | 0:1ed23ab1345f | 106 | typedef enum { |
va009039 | 0:1ed23ab1345f | 107 | RFCOMM_CHANNEL_STATE_VAR_NONE = 0, |
va009039 | 0:1ed23ab1345f | 108 | RFCOMM_CHANNEL_STATE_VAR_CLIENT_ACCEPTED = 1 << 0, |
va009039 | 0:1ed23ab1345f | 109 | RFCOMM_CHANNEL_STATE_VAR_RCVD_PN = 1 << 1, |
va009039 | 0:1ed23ab1345f | 110 | RFCOMM_CHANNEL_STATE_VAR_RCVD_RPN = 1 << 2, |
va009039 | 0:1ed23ab1345f | 111 | RFCOMM_CHANNEL_STATE_VAR_RCVD_SABM = 1 << 3, |
va009039 | 0:1ed23ab1345f | 112 | |
va009039 | 0:1ed23ab1345f | 113 | RFCOMM_CHANNEL_STATE_VAR_RCVD_MSC_CMD = 1 << 4, |
va009039 | 0:1ed23ab1345f | 114 | RFCOMM_CHANNEL_STATE_VAR_RCVD_MSC_RSP = 1 << 5, |
va009039 | 0:1ed23ab1345f | 115 | RFCOMM_CHANNEL_STATE_VAR_SEND_PN_RSP = 1 << 6, |
va009039 | 0:1ed23ab1345f | 116 | RFCOMM_CHANNEL_STATE_VAR_SEND_RPN_INFO = 1 << 7, |
va009039 | 0:1ed23ab1345f | 117 | |
va009039 | 0:1ed23ab1345f | 118 | RFCOMM_CHANNEL_STATE_VAR_SEND_RPN_RSP = 1 << 8, |
va009039 | 0:1ed23ab1345f | 119 | RFCOMM_CHANNEL_STATE_VAR_SEND_UA = 1 << 9, |
va009039 | 0:1ed23ab1345f | 120 | RFCOMM_CHANNEL_STATE_VAR_SEND_MSC_CMD = 1 << 10, |
va009039 | 0:1ed23ab1345f | 121 | RFCOMM_CHANNEL_STATE_VAR_SEND_MSC_RSP = 1 << 11, |
va009039 | 0:1ed23ab1345f | 122 | |
va009039 | 0:1ed23ab1345f | 123 | RFCOMM_CHANNEL_STATE_VAR_SEND_CREDITS = 1 << 12, |
va009039 | 0:1ed23ab1345f | 124 | RFCOMM_CHANNEL_STATE_VAR_SENT_MSC_CMD = 1 << 13, |
va009039 | 0:1ed23ab1345f | 125 | RFCOMM_CHANNEL_STATE_VAR_SENT_MSC_RSP = 1 << 14, |
va009039 | 0:1ed23ab1345f | 126 | RFCOMM_CHANNEL_STATE_VAR_SENT_CREDITS = 1 << 15, |
va009039 | 0:1ed23ab1345f | 127 | } RFCOMM_CHANNEL_STATE_VAR; |
va009039 | 0:1ed23ab1345f | 128 | */ |
va009039 | 0:1ed23ab1345f | 129 | |
va009039 | 0:1ed23ab1345f | 130 | enum { |
va009039 | 0:1ed23ab1345f | 131 | RFCOMM_CHANNEL_STATE_VAR_NONE = 0, |
va009039 | 0:1ed23ab1345f | 132 | RFCOMM_CHANNEL_STATE_VAR_CLIENT_ACCEPTED = 1 << 0, |
va009039 | 0:1ed23ab1345f | 133 | RFCOMM_CHANNEL_STATE_VAR_RCVD_PN = 1 << 1, |
va009039 | 0:1ed23ab1345f | 134 | RFCOMM_CHANNEL_STATE_VAR_RCVD_RPN = 1 << 2, |
va009039 | 0:1ed23ab1345f | 135 | RFCOMM_CHANNEL_STATE_VAR_RCVD_SABM = 1 << 3, |
va009039 | 0:1ed23ab1345f | 136 | |
va009039 | 0:1ed23ab1345f | 137 | RFCOMM_CHANNEL_STATE_VAR_RCVD_MSC_CMD = 1 << 4, |
va009039 | 0:1ed23ab1345f | 138 | RFCOMM_CHANNEL_STATE_VAR_RCVD_MSC_RSP = 1 << 5, |
va009039 | 0:1ed23ab1345f | 139 | RFCOMM_CHANNEL_STATE_VAR_SEND_PN_RSP = 1 << 6, |
va009039 | 0:1ed23ab1345f | 140 | RFCOMM_CHANNEL_STATE_VAR_SEND_RPN_INFO = 1 << 7, |
va009039 | 0:1ed23ab1345f | 141 | |
va009039 | 0:1ed23ab1345f | 142 | RFCOMM_CHANNEL_STATE_VAR_SEND_RPN_RSP = 1 << 8, |
va009039 | 0:1ed23ab1345f | 143 | RFCOMM_CHANNEL_STATE_VAR_SEND_UA = 1 << 9, |
va009039 | 0:1ed23ab1345f | 144 | RFCOMM_CHANNEL_STATE_VAR_SEND_MSC_CMD = 1 << 10, |
va009039 | 0:1ed23ab1345f | 145 | RFCOMM_CHANNEL_STATE_VAR_SEND_MSC_RSP = 1 << 11, |
va009039 | 0:1ed23ab1345f | 146 | |
va009039 | 0:1ed23ab1345f | 147 | RFCOMM_CHANNEL_STATE_VAR_SEND_CREDITS = 1 << 12, |
va009039 | 0:1ed23ab1345f | 148 | RFCOMM_CHANNEL_STATE_VAR_SENT_MSC_CMD = 1 << 13, |
va009039 | 0:1ed23ab1345f | 149 | RFCOMM_CHANNEL_STATE_VAR_SENT_MSC_RSP = 1 << 14, |
va009039 | 0:1ed23ab1345f | 150 | RFCOMM_CHANNEL_STATE_VAR_SENT_CREDITS = 1 << 15, |
va009039 | 0:1ed23ab1345f | 151 | }; |
va009039 | 0:1ed23ab1345f | 152 | typedef uint16_t RFCOMM_CHANNEL_STATE_VAR; |
va009039 | 0:1ed23ab1345f | 153 | |
va009039 | 0:1ed23ab1345f | 154 | typedef enum { |
va009039 | 0:1ed23ab1345f | 155 | CH_EVT_RCVD_SABM = 1, |
va009039 | 0:1ed23ab1345f | 156 | CH_EVT_RCVD_UA, |
va009039 | 0:1ed23ab1345f | 157 | CH_EVT_RCVD_PN, |
va009039 | 0:1ed23ab1345f | 158 | CH_EVT_RCVD_PN_RSP, |
va009039 | 0:1ed23ab1345f | 159 | CH_EVT_RCVD_DISC, |
va009039 | 0:1ed23ab1345f | 160 | CH_EVT_RCVD_DM, |
va009039 | 0:1ed23ab1345f | 161 | CH_EVT_RCVD_MSC_CMD, |
va009039 | 0:1ed23ab1345f | 162 | CH_EVT_RCVD_MSC_RSP, |
va009039 | 0:1ed23ab1345f | 163 | CH_EVT_RCVD_RPN_CMD, |
va009039 | 0:1ed23ab1345f | 164 | CH_EVT_RCVD_RPN_REQ, |
va009039 | 0:1ed23ab1345f | 165 | CH_EVT_RCVD_CREDITS, |
va009039 | 0:1ed23ab1345f | 166 | CH_EVT_MULTIPLEXER_READY, |
va009039 | 0:1ed23ab1345f | 167 | CH_EVT_READY_TO_SEND, |
va009039 | 0:1ed23ab1345f | 168 | } RFCOMM_CHANNEL_EVENT; |
va009039 | 0:1ed23ab1345f | 169 | |
va009039 | 0:1ed23ab1345f | 170 | typedef struct rfcomm_channel_event { |
va009039 | 0:1ed23ab1345f | 171 | RFCOMM_CHANNEL_EVENT type; |
va009039 | 0:1ed23ab1345f | 172 | } rfcomm_channel_event_t; |
va009039 | 0:1ed23ab1345f | 173 | |
va009039 | 0:1ed23ab1345f | 174 | typedef struct rfcomm_channel_event_pn { |
va009039 | 0:1ed23ab1345f | 175 | rfcomm_channel_event_t super; |
va009039 | 0:1ed23ab1345f | 176 | uint16_t max_frame_size; |
va009039 | 0:1ed23ab1345f | 177 | uint8_t priority; |
va009039 | 0:1ed23ab1345f | 178 | uint8_t credits_outgoing; |
va009039 | 0:1ed23ab1345f | 179 | } rfcomm_channel_event_pn_t; |
va009039 | 0:1ed23ab1345f | 180 | |
va009039 | 0:1ed23ab1345f | 181 | typedef struct rfcomm_rpn_data { |
va009039 | 0:1ed23ab1345f | 182 | uint8_t baud_rate; |
va009039 | 0:1ed23ab1345f | 183 | uint8_t flags; |
va009039 | 0:1ed23ab1345f | 184 | uint8_t flow_control; |
va009039 | 0:1ed23ab1345f | 185 | uint8_t xon; |
va009039 | 0:1ed23ab1345f | 186 | uint8_t xoff; |
va009039 | 0:1ed23ab1345f | 187 | uint8_t parameter_mask_0; // first byte |
va009039 | 0:1ed23ab1345f | 188 | uint8_t parameter_mask_1; // second byte |
va009039 | 0:1ed23ab1345f | 189 | } rfcomm_rpn_data_t; |
va009039 | 0:1ed23ab1345f | 190 | |
va009039 | 0:1ed23ab1345f | 191 | typedef struct rfcomm_channel_event_rpn { |
va009039 | 0:1ed23ab1345f | 192 | rfcomm_channel_event_t super; |
va009039 | 0:1ed23ab1345f | 193 | rfcomm_rpn_data_t data; |
va009039 | 0:1ed23ab1345f | 194 | } rfcomm_channel_event_rpn_t; |
va009039 | 0:1ed23ab1345f | 195 | |
va009039 | 0:1ed23ab1345f | 196 | // info regarding potential connections |
va009039 | 0:1ed23ab1345f | 197 | typedef struct { |
va009039 | 0:1ed23ab1345f | 198 | // linked list - assert: first field |
va009039 | 0:1ed23ab1345f | 199 | linked_item_t item; |
va009039 | 0:1ed23ab1345f | 200 | |
va009039 | 0:1ed23ab1345f | 201 | // server channel |
va009039 | 0:1ed23ab1345f | 202 | uint8_t server_channel; |
va009039 | 0:1ed23ab1345f | 203 | |
va009039 | 0:1ed23ab1345f | 204 | // incoming max frame size |
va009039 | 0:1ed23ab1345f | 205 | uint16_t max_frame_size; |
va009039 | 0:1ed23ab1345f | 206 | |
va009039 | 0:1ed23ab1345f | 207 | // use incoming flow control |
va009039 | 0:1ed23ab1345f | 208 | uint8_t incoming_flow_control; |
va009039 | 0:1ed23ab1345f | 209 | |
va009039 | 0:1ed23ab1345f | 210 | // initial incoming credits |
va009039 | 0:1ed23ab1345f | 211 | uint8_t incoming_initial_credits; |
va009039 | 0:1ed23ab1345f | 212 | |
va009039 | 0:1ed23ab1345f | 213 | // client connection |
va009039 | 0:1ed23ab1345f | 214 | void *connection; |
va009039 | 0:1ed23ab1345f | 215 | |
va009039 | 0:1ed23ab1345f | 216 | // internal connection |
va009039 | 0:1ed23ab1345f | 217 | btstack_packet_handler_t packet_handler; |
va009039 | 0:1ed23ab1345f | 218 | |
va009039 | 0:1ed23ab1345f | 219 | } rfcomm_service_t; |
va009039 | 0:1ed23ab1345f | 220 | |
va009039 | 0:1ed23ab1345f | 221 | // info regarding multiplexer |
va009039 | 0:1ed23ab1345f | 222 | // note: spec mandates single multplexer per device combination |
va009039 | 0:1ed23ab1345f | 223 | typedef struct { |
va009039 | 0:1ed23ab1345f | 224 | // linked list - assert: first field |
va009039 | 0:1ed23ab1345f | 225 | linked_item_t item; |
va009039 | 0:1ed23ab1345f | 226 | |
va009039 | 0:1ed23ab1345f | 227 | timer_source_t timer; |
va009039 | 0:1ed23ab1345f | 228 | int timer_active; |
va009039 | 0:1ed23ab1345f | 229 | |
va009039 | 0:1ed23ab1345f | 230 | RFCOMM_MULTIPLEXER_STATE state; |
va009039 | 0:1ed23ab1345f | 231 | |
va009039 | 0:1ed23ab1345f | 232 | uint16_t l2cap_cid; |
va009039 | 0:1ed23ab1345f | 233 | uint8_t l2cap_credits; |
va009039 | 0:1ed23ab1345f | 234 | |
va009039 | 0:1ed23ab1345f | 235 | bd_addr_t remote_addr; |
va009039 | 0:1ed23ab1345f | 236 | hci_con_handle_t con_handle; |
va009039 | 0:1ed23ab1345f | 237 | |
va009039 | 0:1ed23ab1345f | 238 | uint8_t outgoing; |
va009039 | 0:1ed23ab1345f | 239 | |
va009039 | 0:1ed23ab1345f | 240 | // hack to deal with authentication failure only observed by remote side |
va009039 | 0:1ed23ab1345f | 241 | uint8_t at_least_one_connection; |
va009039 | 0:1ed23ab1345f | 242 | |
va009039 | 0:1ed23ab1345f | 243 | uint16_t max_frame_size; |
va009039 | 0:1ed23ab1345f | 244 | |
va009039 | 0:1ed23ab1345f | 245 | // send DM for DLCI != 0 |
va009039 | 0:1ed23ab1345f | 246 | uint8_t send_dm_for_dlci; |
va009039 | 0:1ed23ab1345f | 247 | |
va009039 | 0:1ed23ab1345f | 248 | } rfcomm_multiplexer_t; |
va009039 | 0:1ed23ab1345f | 249 | |
va009039 | 0:1ed23ab1345f | 250 | // info regarding an actual coneection |
va009039 | 0:1ed23ab1345f | 251 | typedef struct { |
va009039 | 0:1ed23ab1345f | 252 | // linked list - assert: first field |
va009039 | 0:1ed23ab1345f | 253 | linked_item_t item; |
va009039 | 0:1ed23ab1345f | 254 | |
va009039 | 0:1ed23ab1345f | 255 | rfcomm_multiplexer_t *multiplexer; |
va009039 | 0:1ed23ab1345f | 256 | uint16_t rfcomm_cid; |
va009039 | 0:1ed23ab1345f | 257 | uint8_t outgoing; |
va009039 | 0:1ed23ab1345f | 258 | uint8_t dlci; |
va009039 | 0:1ed23ab1345f | 259 | |
va009039 | 0:1ed23ab1345f | 260 | // number of packets granted to client |
va009039 | 0:1ed23ab1345f | 261 | uint8_t packets_granted; |
va009039 | 0:1ed23ab1345f | 262 | |
va009039 | 0:1ed23ab1345f | 263 | // credits for outgoing traffic |
va009039 | 0:1ed23ab1345f | 264 | uint8_t credits_outgoing; |
va009039 | 0:1ed23ab1345f | 265 | |
va009039 | 0:1ed23ab1345f | 266 | // number of packets remote will be granted |
va009039 | 0:1ed23ab1345f | 267 | uint8_t new_credits_incoming; |
va009039 | 0:1ed23ab1345f | 268 | |
va009039 | 0:1ed23ab1345f | 269 | // credits for incoming traffic |
va009039 | 0:1ed23ab1345f | 270 | uint8_t credits_incoming; |
va009039 | 0:1ed23ab1345f | 271 | |
va009039 | 0:1ed23ab1345f | 272 | // use incoming flow control |
va009039 | 0:1ed23ab1345f | 273 | uint8_t incoming_flow_control; |
va009039 | 0:1ed23ab1345f | 274 | |
va009039 | 0:1ed23ab1345f | 275 | // channel state |
va009039 | 0:1ed23ab1345f | 276 | RFCOMM_CHANNEL_STATE state; |
va009039 | 0:1ed23ab1345f | 277 | |
va009039 | 0:1ed23ab1345f | 278 | // state variables used in RFCOMM_CHANNEL_INCOMING |
va009039 | 0:1ed23ab1345f | 279 | RFCOMM_CHANNEL_STATE_VAR state_var; |
va009039 | 0:1ed23ab1345f | 280 | |
va009039 | 0:1ed23ab1345f | 281 | // priority set by incoming side in PN |
va009039 | 0:1ed23ab1345f | 282 | uint8_t pn_priority; |
va009039 | 0:1ed23ab1345f | 283 | |
va009039 | 0:1ed23ab1345f | 284 | // negotiated frame size |
va009039 | 0:1ed23ab1345f | 285 | uint16_t max_frame_size; |
va009039 | 0:1ed23ab1345f | 286 | |
va009039 | 0:1ed23ab1345f | 287 | // rpn data |
va009039 | 0:1ed23ab1345f | 288 | rfcomm_rpn_data_t rpn_data; |
va009039 | 0:1ed23ab1345f | 289 | |
va009039 | 0:1ed23ab1345f | 290 | // server channel (see rfcomm_service_t) - NULL => outgoing channel |
va009039 | 0:1ed23ab1345f | 291 | rfcomm_service_t * service; |
va009039 | 0:1ed23ab1345f | 292 | |
va009039 | 0:1ed23ab1345f | 293 | // internal connection |
va009039 | 0:1ed23ab1345f | 294 | btstack_packet_handler_t packet_handler; |
va009039 | 0:1ed23ab1345f | 295 | |
va009039 | 0:1ed23ab1345f | 296 | // client connection |
va009039 | 0:1ed23ab1345f | 297 | void * connection; |
va009039 | 0:1ed23ab1345f | 298 | |
va009039 | 0:1ed23ab1345f | 299 | } rfcomm_channel_t; |
va009039 | 0:1ed23ab1345f | 300 | |
va009039 | 0:1ed23ab1345f | 301 | |
va009039 | 0:1ed23ab1345f | 302 | #if defined __cplusplus |
va009039 | 0:1ed23ab1345f | 303 | } |
va009039 | 0:1ed23ab1345f | 304 | #endif |