mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-14 01:27:41 +00:00
SCO: add hci_get_sco_packet_length to query SCO packet size needed for USB and use in hsp_hs_test
This commit is contained in:
parent
d5422c82dc
commit
b3aad8da60
@ -43,12 +43,19 @@
|
||||
//
|
||||
// Tested working setups:
|
||||
// - Ubuntu 14 64-bit, CC2564B connected via FTDI USB-2-UART adapter, 921600 baud
|
||||
//
|
||||
// Non working setups:
|
||||
// - Ubuntu 14 64-bit, CSR dongle
|
||||
// - OS X 10.11, CSR dongle
|
||||
|
||||
// Broken setups:
|
||||
// - OS X 10.11, CC2564B connected via FDTI USB-2-UART adapter, 921600 baud
|
||||
// - select(..) blocks > 400 ms -> num completed is received to late -> gaps between audio
|
||||
// - looks like bug in select->FTDI driver as it works correct on Linux
|
||||
// - OS X 10.11, USB Bluetooth Dongles...
|
||||
//
|
||||
// SCO not routed over HCI (yet)
|
||||
// - CSR UART dongle
|
||||
// - Broadcom USB dongle
|
||||
// - Broadcom UART chipset
|
||||
// - ..
|
||||
// *****************************************************************************
|
||||
|
||||
#include "btstack-config.h"
|
||||
@ -115,20 +122,24 @@ static void try_send_sco(void){
|
||||
// printf("try_send_sco, cannot send now\n");
|
||||
return;
|
||||
}
|
||||
const int frames_per_packet = 24;
|
||||
|
||||
const int sco_packet_length = hci_get_sco_packet_length();
|
||||
const int sco_payload_length = sco_packet_length - 3;
|
||||
const int frames_per_packet = sco_payload_length; // for 8-bit data. for 16-bit data it's /2
|
||||
|
||||
hci_reserve_packet_buffer();
|
||||
uint8_t * sco_packet = hci_get_outgoing_packet_buffer();
|
||||
// set handle + flags
|
||||
bt_store_16(sco_packet, 0, sco_handle);
|
||||
// set len
|
||||
sco_packet[2] = frames_per_packet;
|
||||
sco_packet[2] = sco_payload_length;
|
||||
int i;
|
||||
for (i=0;i<frames_per_packet;i++){
|
||||
sco_packet[3+i] = sine[phase];
|
||||
phase++;
|
||||
if (phase >= sizeof(sine)) phase = 0;
|
||||
}
|
||||
hci_send_sco_packet_buffer(3 + frames_per_packet);
|
||||
hci_send_sco_packet_buffer(sco_packet_length);
|
||||
static int count = 0;
|
||||
count++;
|
||||
if ((count & 15) == 0) printf("Sent %u\n", count);
|
||||
|
10
src/hci.c
10
src/hci.c
@ -3458,6 +3458,16 @@ uint16_t hci_get_sco_voice_setting(){
|
||||
return hci_stack->sco_voice_setting;
|
||||
}
|
||||
|
||||
/** @brief Get SCO packet length for current SCO Voice setting
|
||||
* @note Using SCO packets of the exact length is required for USB transfer
|
||||
* @return Length of SCO packets in bytes (not audio frames)
|
||||
*/
|
||||
int hci_get_sco_packet_length(void){
|
||||
// see Core Spec for H2 USB Transfer.
|
||||
if (hci_stack->sco_voice_setting & 0x0020) return 51;
|
||||
return 27;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set callback for Bluetooth Hardware Error
|
||||
*/
|
||||
|
@ -970,6 +970,12 @@ void hci_set_sco_voice_setting(uint16_t voice_setting);
|
||||
*/
|
||||
uint16_t hci_get_sco_voice_setting(void);
|
||||
|
||||
/** @brief Get SCO packet length for current SCO Voice setting
|
||||
* @note Using SCO packets of the exact length is required for USB transfer
|
||||
* @return Length of SCO packets in bytes (not audio frames) incl. 3 byte header
|
||||
*/
|
||||
int hci_get_sco_packet_length(void);
|
||||
|
||||
/* API_END */
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user