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