From e628322d359d2d1b9d94c8b774b0e6ae5553df70 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Fri, 19 Feb 2016 14:01:30 +0100 Subject: [PATCH] rfcomm: move private events to implementation --- src/classic/rfcomm.c | 61 ++++++++++++++++++++++++++++++++++++++------ src/classic/rfcomm.h | 48 ---------------------------------- 2 files changed, 53 insertions(+), 56 deletions(-) diff --git a/src/classic/rfcomm.c b/src/classic/rfcomm.c index 5e0312796..aea38f329 100644 --- a/src/classic/rfcomm.c +++ b/src/classic/rfcomm.c @@ -44,15 +44,14 @@ #include // memcpy #include -#include "hci_cmd.h" -#include "btstack_util.h" - -#include "btstack_util.h" -#include "btstack_memory.h" -#include "hci.h" -#include "hci_dump.h" #include "btstack_debug.h" +#include "btstack_memory.h" +#include "btstack_util.h" #include "classic/rfcomm.h" +#include "hci.h" +#include "hci_cmd.h" +#include "hci_dump.h" +#include "l2cap.h" // workaround for missing PRIxPTR on mspgcc (16/20-bit MCU) #ifndef PRIxPTR @@ -72,7 +71,53 @@ #define BT_RFCOMM_CRC_CHECK_LEN 3 #define BT_RFCOMM_UIHCRC_CHECK_LEN 2 -#include "l2cap.h" + +typedef enum { + CH_EVT_RCVD_SABM = 1, + CH_EVT_RCVD_UA, + CH_EVT_RCVD_PN, + CH_EVT_RCVD_PN_RSP, + CH_EVT_RCVD_DISC, + CH_EVT_RCVD_DM, + CH_EVT_RCVD_MSC_CMD, + CH_EVT_RCVD_MSC_RSP, + CH_EVT_RCVD_NSC_RSP, + CH_EVT_RCVD_RLS_CMD, + CH_EVT_RCVD_RLS_RSP, + CH_EVT_RCVD_RPN_CMD, + CH_EVT_RCVD_RPN_REQ, + CH_EVT_RCVD_CREDITS, + CH_EVT_MULTIPLEXER_READY, + CH_EVT_READY_TO_SEND, +} RFCOMM_CHANNEL_EVENT; + +typedef struct rfcomm_channel_event { + RFCOMM_CHANNEL_EVENT type; + uint16_t dummy; // force rfcomm_channel_event to be 2-byte aligned -> avoid -Wcast-align warning +} rfcomm_channel_event_t; + +typedef struct rfcomm_channel_event_pn { + rfcomm_channel_event_t super; + uint16_t max_frame_size; + uint8_t priority; + uint8_t credits_outgoing; +} rfcomm_channel_event_pn_t; + +typedef struct rfcomm_channel_event_rpn { + rfcomm_channel_event_t super; + rfcomm_rpn_data_t data; +} rfcomm_channel_event_rpn_t; + +typedef struct rfcomm_channel_event_rls { + rfcomm_channel_event_t super; + uint8_t line_status; +} rfcomm_channel_event_rls_t; + +typedef struct rfcomm_channel_event_msc { + rfcomm_channel_event_t super; + uint8_t modem_status; +} rfcomm_channel_event_msc_t; + // global rfcomm data static uint16_t rfcomm_client_cid_generator; // used for client channel IDs diff --git a/src/classic/rfcomm.h b/src/classic/rfcomm.h index edf3913e2..4dd809c26 100644 --- a/src/classic/rfcomm.h +++ b/src/classic/rfcomm.h @@ -71,7 +71,6 @@ typedef enum { typedef enum { MULT_EV_READY_TO_SEND = 1, - } RFCOMM_MULTIPLEXER_EVENT; typedef enum { @@ -88,7 +87,6 @@ typedef enum { RFCOMM_CHANNEL_SEND_DISC, RFCOMM_CHANNEL_W4_UA_AFTER_UA, RFCOMM_CHANNEL_SEND_DM, - } RFCOMM_CHANNEL_STATE; typedef enum { @@ -114,37 +112,6 @@ typedef enum { RFCOMM_CHANNEL_STATE_VAR_SENT_CREDITS = 1 << 15, } RFCOMM_CHANNEL_STATE_VAR; -typedef enum { - CH_EVT_RCVD_SABM = 1, - CH_EVT_RCVD_UA, - CH_EVT_RCVD_PN, - CH_EVT_RCVD_PN_RSP, - CH_EVT_RCVD_DISC, - CH_EVT_RCVD_DM, - CH_EVT_RCVD_MSC_CMD, - CH_EVT_RCVD_MSC_RSP, - CH_EVT_RCVD_NSC_RSP, - CH_EVT_RCVD_RLS_CMD, - CH_EVT_RCVD_RLS_RSP, - CH_EVT_RCVD_RPN_CMD, - CH_EVT_RCVD_RPN_REQ, - CH_EVT_RCVD_CREDITS, - CH_EVT_MULTIPLEXER_READY, - CH_EVT_READY_TO_SEND, -} RFCOMM_CHANNEL_EVENT; - -typedef struct rfcomm_channel_event { - RFCOMM_CHANNEL_EVENT type; - uint16_t dummy; // force rfcomm_channel_event to be 2-byte aligned -> avoid -Wcast-align warning -} rfcomm_channel_event_t; - -typedef struct rfcomm_channel_event_pn { - rfcomm_channel_event_t super; - uint16_t max_frame_size; - uint8_t priority; - uint8_t credits_outgoing; -} rfcomm_channel_event_pn_t; - typedef struct rfcomm_rpn_data { uint8_t baud_rate; uint8_t flags; @@ -155,21 +122,6 @@ typedef struct rfcomm_rpn_data { uint8_t parameter_mask_1; // second byte } rfcomm_rpn_data_t; -typedef struct rfcomm_channel_event_rpn { - rfcomm_channel_event_t super; - rfcomm_rpn_data_t data; -} rfcomm_channel_event_rpn_t; - -typedef struct rfcomm_channel_event_rls { - rfcomm_channel_event_t super; - uint8_t line_status; -} rfcomm_channel_event_rls_t; - -typedef struct rfcomm_channel_event_msc { - rfcomm_channel_event_t super; - uint8_t modem_status; -} rfcomm_channel_event_msc_t; - // info regarding potential connections typedef struct { // linked list - assert: first field