diff --git a/src/classic/hfp.c b/src/classic/hfp.c index ce07bd4ef..8399f917f 100644 --- a/src/classic/hfp.c +++ b/src/classic/hfp.c @@ -2105,29 +2105,6 @@ void hfp_register_custom_ag_command(hfp_custom_at_command_t * custom_at_command) btstack_linked_list_add(&hfp_custom_commands_ag, (btstack_linked_item_t *) custom_at_command); } -// HFP H2 Framing - might get moved into a hfp_h2.c - -// const -static const uint8_t hfp_h2_header_h2_byte_0 = 1; -static const uint8_t hfp_h2_header_h2_byte_1_table[] = {0x08, 0x38, 0xc8, 0xf8 }; - -void hfp_h2_framing_init(hfp_h2_framing_t * hfp_h2_framing){ - hfp_h2_framing->sequence_number = 0; -} - -/** - * @brief Add next H2 Header - * @param hfp_h2_framing - * @param buffer [2] - */ -void hfp_h2_framing_add_header(hfp_h2_framing_t * hfp_h2_framing, uint8_t * buffer){ - // Synchronization Header H2 - buffer[0] = hfp_h2_header_h2_byte_0; - buffer[1] = hfp_h2_header_h2_byte_1_table[hfp_h2_framing->sequence_number]; - hfp_h2_framing->sequence_number = (hfp_h2_framing->sequence_number + 1) & 3; -} - - // HFP H2 Synchronization - might get moved into a hfp_h2.c // find position of h2 sync header, returns -1 if not found, or h2 sync position diff --git a/src/classic/hfp.h b/src/classic/hfp.h index ff664f932..278af9883 100644 --- a/src/classic/hfp.h +++ b/src/classic/hfp.h @@ -760,29 +760,7 @@ int get_bit(uint16_t bitmap, int position); int store_bit(uint32_t bitmap, int position, uint8_t value); // UTILS_END -// HFP H2 - #define HFP_H2_SYNC_FRAME_SIZE 60 - -// HFP H2 Framing -typedef struct { - uint8_t sequence_number; -} hfp_h2_framing_t; - -/** - * @brief Init HFP H2 Framing state - * @param hfp_h2_framing - */ -void hfp_h2_framing_init(hfp_h2_framing_t * hfp_h2_framing); - -/** - * @brief Add next H2 Header - * @param hfp_h2_framing - * @param buffer [2] - */ -void hfp_h2_framing_add_header(hfp_h2_framing_t * hfp_h2_framing, uint8_t * buffer); - - // HFP H2 Synchronization typedef struct { // callback returns true if data was valid diff --git a/src/classic/hfp_codec.c b/src/classic/hfp_codec.c index 2155be85d..438c7150d 100644 --- a/src/classic/hfp_codec.c +++ b/src/classic/hfp_codec.c @@ -64,6 +64,28 @@ static void hfp_codec_encode_msbc(hfp_codec_t * hfp_codec, int16_t * pcm_samples static void hfp_codec_encode_lc3swb(hfp_codec_t * hfp_codec, int16_t * pcm_samples); #endif +// HFP H2 Framing - might get moved into a hfp_h2.c + +// const +static const uint8_t hfp_h2_header_h2_byte_0 = 1; +static const uint8_t hfp_h2_header_h2_byte_1_table[] = {0x08, 0x38, 0xc8, 0xf8 }; + +void hfp_h2_framing_init(hfp_h2_framing_t * hfp_h2_framing){ + hfp_h2_framing->sequence_number = 0; +} + +/** + * @brief Add next H2 Header + * @param hfp_h2_framing + * @param buffer [2] + */ +void hfp_h2_framing_add_header(hfp_h2_framing_t * hfp_h2_framing, uint8_t * buffer){ + // Synchronization Header H2 + buffer[0] = hfp_h2_header_h2_byte_0; + buffer[1] = hfp_h2_header_h2_byte_1_table[hfp_h2_framing->sequence_number]; + hfp_h2_framing->sequence_number = (hfp_h2_framing->sequence_number + 1) & 3; +} + void hfp_codec_init(hfp_codec_t * hfp_codec, uint8_t codec_id){ memset(hfp_codec, 0, sizeof(hfp_codec_t)); diff --git a/src/classic/hfp_codec.h b/src/classic/hfp_codec.h index d6b11aeb2..2c9b578f5 100644 --- a/src/classic/hfp_codec.h +++ b/src/classic/hfp_codec.h @@ -44,9 +44,8 @@ #define HFP_CODEC_H #include "btstack_config.h" -#include "hfp.h" // hfp_h2_framing -#include +#include "hfp.h" // HFP_CODEC_xxx #ifdef ENABLE_HFP_WIDE_BAND_SPEECH #include "btstack_sbc.h" @@ -56,12 +55,37 @@ #include "btstack_lc3_google.h" #endif +#include + #if defined __cplusplus extern "C" { #endif #define SCO_FRAME_SIZE 60 +// HFP H2 + +#define HFP_H2_SYNC_FRAME_SIZE 60 + +// HFP H2 Framing +typedef struct { + uint8_t sequence_number; +} hfp_h2_framing_t; + +/** + * @brief Init HFP H2 Framing state + * @param hfp_h2_framing + */ +void hfp_h2_framing_init(hfp_h2_framing_t * hfp_h2_framing); + +/** + * @brief Add next H2 Header + * @param hfp_h2_framing + * @param buffer [2] + */ +void hfp_h2_framing_add_header(hfp_h2_framing_t * hfp_h2_framing, uint8_t * buffer); + + struct hfp_codec { // to allow for 24 byte USB payloads, we encode up to two SCO packets uint8_t sco_packet[2*SCO_FRAME_SIZE];