bluetooth_company_id: use scraped defines instead of small set from bluetooth.h before

This commit is contained in:
Matthias Ringwald 2017-03-30 22:19:17 +02:00
parent 6797047d6d
commit 61f37892ce
10 changed files with 33 additions and 40 deletions

View File

@ -87,7 +87,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
uint16_t manufacturer = little_endian_read_16(packet, 10);
uint16_t lmp_subversion = little_endian_read_16(packet, 12);
// assert manufacturer is TI
if (manufacturer != COMPANY_ID_TEXAS_INSTRUMENTS_INC){
if (manufacturer != BLUETOOTH_COMPANY_ID_TEXAS_INSTRUMENTS_INC){
printf("ERROR: Expected Bluetooth Chipset from TI but got manufacturer 0x%04x\n", manufacturer);
break;
}

View File

@ -106,7 +106,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
uint16_t manufacturer = little_endian_read_16(packet, 10);
uint16_t lmp_subversion = little_endian_read_16(packet, 12);
// assert manufacturer is TI
if (manufacturer != COMPANY_ID_TEXAS_INSTRUMENTS_INC){
if (manufacturer != BLUETOOTH_COMPANY_ID_TEXAS_INSTRUMENTS_INC){
printf("ERROR: Expected Bluetooth Chipset from TI but got manufacturer 0x%04x\n", manufacturer);
break;
}

View File

@ -110,7 +110,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
uint16_t manufacturer = little_endian_read_16(packet, 10);
uint16_t lmp_subversion = little_endian_read_16(packet, 12);
// assert manufacturer is TI
if (manufacturer != COMPANY_ID_TEXAS_INSTRUMENTS_INC){
if (manufacturer != BLUETOOTH_COMPANY_ID_TEXAS_INSTRUMENTS_INC){
printf("ERROR: Expected Bluetooth Chipset from TI but got manufacturer 0x%04x\n", manufacturer);
break;
}

View File

@ -156,12 +156,12 @@ static void local_version_information_handler(uint8_t * packet){
printf("- LMP Subversion 0x%04x\n", lmp_subversion);
printf("- Manufacturer 0x%04x\n", manufacturer);
switch (manufacturer){
case COMPANY_ID_CAMBRIDGE_SILICON_RADIO:
case BLUETOOTH_COMPANY_ID_CAMBRIDGE_SILICON_RADIO:
printf("Cambridge Silicon Radio - CSR chipset.\n");
use_fast_uart();
hci_set_chipset(btstack_chipset_csr_instance());
break;
case COMPANY_ID_TEXAS_INSTRUMENTS_INC:
case BLUETOOTH_COMPANY_ID_TEXAS_INSTRUMENTS_INC:
printf("Texas Instruments - CC256x compatible chipset.\n");
if (lmp_subversion != btstack_chipset_cc256x_lmp_subversion()){
printf("Error: LMP Subversion does not match initscript! ");
@ -178,23 +178,23 @@ static void local_version_information_handler(uint8_t * packet){
#endif
break;
case COMPANY_ID_BROADCOM_CORPORATION:
case BLUETOOTH_COMPANY_ID_BROADCOM_CORPORATION:
printf("Broadcom - using BCM driver.\n");
hci_set_chipset(btstack_chipset_bcm_instance());
use_fast_uart();
is_bcm = 1;
break;
case COMPANY_ID_ST_MICROELECTRONICS:
case BLUETOOTH_COMPANY_ID_ST_MICROELECTRONICS:
printf("ST Microelectronics - using STLC2500d driver.\n");
use_fast_uart();
hci_set_chipset(btstack_chipset_stlc2500d_instance());
break;
case COMPANY_ID_EM_MICROELECTRONICS_MARIN:
case BUETOOTH_COMPANY_ID_EM_MICROELECTRONICS_MARIN:
printf("EM Microelectronics - using EM9301 driver.\n");
hci_set_chipset(btstack_chipset_em9301_instance());
break;
case COMPANY_ID_NORDIC_SEMICONDUCTOR_ASA:
case BLUETOOTH_COMPANY_ID_NORDIC_SEMICONDUCTOR_ASA:
printf("Nordic Semiconductor nRF5 chipset.\n");
break;
default:

View File

@ -123,26 +123,26 @@ static void local_version_information_handler(uint8_t * packet){
printf("- LMP Revision 0x%04x\n", lmp_subversion);
printf("- Manufacturer 0x%04x\n", manufacturer);
switch (manufacturer){
case COMPANY_ID_CAMBRIDGE_SILICON_RADIO:
case BLUETOOTH_COMPANY_ID_CAMBRIDGE_SILICON_RADIO:
printf("Cambridge Silicon Radio CSR chipset.\n");
use_fast_uart();
hci_set_chipset(btstack_chipset_csr_instance());
break;
case COMPANY_ID_TEXAS_INSTRUMENTS_INC:
case BLUETOOTH_COMPANY_ID_TEXAS_INSTRUMENTS_INC:
printf("Texas Instruments - CC256x compatible chipset.\n");
use_fast_uart();
hci_set_chipset(btstack_chipset_cc256x_instance());
break;
case COMPANY_ID_BROADCOM_CORPORATION:
case BLUETOOTH_COMPANY_ID_BROADCOM_CORPORATION:
printf("Broadcom chipset. Not supported yet\n");
// hci_set_chipset(btstack_chipset_bcm_instance());
break;
case COMPANY_ID_ST_MICROELECTRONICS:
case BLUETOOTH_COMPANY_ID_ST_MICROELECTRONICS:
printf("ST Microelectronics - using STLC2500d driver.\n");
use_fast_uart();
hci_set_chipset(btstack_chipset_stlc2500d_instance());
break;
case COMPANY_ID_EM_MICROELECTRONICS_MARIN:
case BUETOOTH_COMPANY_ID_EM_MICROELECTRONICS_MARIN:
printf("EM Microelectronics - using EM9301 driver.\n");
hci_set_chipset(btstack_chipset_em9301_instance());
break;

View File

@ -428,7 +428,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
uint16_t manufacturer = little_endian_read_16(packet, 10);
uint16_t lmp_subversion = little_endian_read_16(packet, 12);
// assert manufacturer is TI
if (manufacturer != COMPANY_ID_TEXAS_INSTRUMENTS_INC){
if (manufacturer != BLUETOOTH_COMPANY_ID_TEXAS_INSTRUMENTS_INC){
printf("ERROR: Expected Bluetooth Chipset from TI but got manufacturer 0x%04x\n", manufacturer);
break;
}

View File

@ -146,12 +146,12 @@ static void local_version_information_handler(uint8_t * packet){
printf("- LMP Revision 0x%04x\n", lmp_subversion);
printf("- Manufacturer 0x%04x\n", manufacturer);
switch (manufacturer){
case COMPANY_ID_CAMBRIDGE_SILICON_RADIO:
case BLUETOOTH_COMPANY_ID_CAMBRIDGE_SILICON_RADIO:
printf("Cambridge Silicon Radio - CSR chipset.\n");
use_fast_uart();
hci_set_chipset(btstack_chipset_csr_instance());
break;
case COMPANY_ID_TEXAS_INSTRUMENTS_INC:
case BLUETOOTH_COMPANY_ID_TEXAS_INSTRUMENTS_INC:
printf("Texas Instruments - CC256x compatible chipset.\n");
if (lmp_subversion != btstack_chipset_cc256x_lmp_subversion()){
printf("Error: LMP Subversion does not match initscript!");
@ -167,22 +167,22 @@ static void local_version_information_handler(uint8_t * packet){
printf("eHCILL disable.\n");
#endif
break;
case COMPANY_ID_BROADCOM_CORPORATION:
case BLUETOOTH_COMPANY_ID_BROADCOM_CORPORATION:
printf("Broadcom - using BCM driver.\n");
hci_set_chipset(btstack_chipset_bcm_instance());
use_fast_uart();
is_bcm = 1;
break;
case COMPANY_ID_ST_MICROELECTRONICS:
case BLUETOOTH_COMPANY_ID_ST_MICROELECTRONICS:
printf("ST Microelectronics - using STLC2500d driver.\n");
use_fast_uart();
hci_set_chipset(btstack_chipset_stlc2500d_instance());
break;
case COMPANY_ID_EM_MICROELECTRONICS_MARIN:
case BUETOOTH_COMPANY_ID_EM_MICROELECTRONICS_MARIN:
printf("EM Microelectronics - using EM9301 driver.\n");
hci_set_chipset(btstack_chipset_em9301_instance());
break;
case COMPANY_ID_NORDIC_SEMICONDUCTOR_ASA:
case BLUETOOTH_COMPANY_ID_NORDIC_SEMICONDUCTOR_ASA:
printf("Nordic Semiconductor nRF5 chipset.\n");
break;
default:

View File

@ -44,6 +44,7 @@
#include "ble/le_device_db.h"
#include "ble/core.h"
#include "ble/sm.h"
#include "bluetooth_company_id.h"
#include "btstack_debug.h"
#include "btstack_event.h"
#include "btstack_linked_list.h"
@ -3180,7 +3181,7 @@ static void sm_event_packet_handler (uint8_t packet_type, uint16_t channel, uint
// Hack for Nordic nRF5 series that doesn't have public address:
// - with patches from port/nrf5-zephyr, hci_read_bd_addr returns random static address
// - we use this as default for advertisements/connections
if (hci_get_manufacturer() == COMPANY_ID_NORDIC_SEMICONDUCTOR_ASA){
if (hci_get_manufacturer() == BLUETOOTH_COMPANY_ID_NORDIC_SEMICONDUCTOR_ASA){
log_info("nRF5: using (fake) public address as random static address");
bd_addr_t addr;
reverse_bd_addr(&packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE + 1], addr);

View File

@ -1143,13 +1143,4 @@ typedef enum {
#define SM_KEYPRESS_PASSKEY_ENTRY_COMPLETED 0x04
// Company identifiers / manufacturers
#define COMPANY_ID_CAMBRIDGE_SILICON_RADIO 0x000A
#define COMPANY_ID_TEXAS_INSTRUMENTS_INC 0x000D
#define COMPANY_ID_BROADCOM_CORPORATION 0x000F
#define COMPANY_ID_ST_MICROELECTRONICS 0x0030
#define COMPANY_ID_NORDIC_SEMICONDUCTOR_ASA 0x0059
#define COMPANY_ID_EM_MICROELECTRONICS_MARIN 0x005A
#endif

View File

@ -70,6 +70,7 @@
#include "btstack_event.h"
#include "btstack_linked_list.h"
#include "btstack_memory.h"
#include "bluetooth_company_id.h"
#include "gap.h"
#include "hci.h"
#include "hci_cmd.h"
@ -934,7 +935,7 @@ static uint32_t hci_transport_uart_get_main_baud_rate(void){
if (!hci_stack->config) return 0;
uint32_t baud_rate = ((hci_transport_config_uart_t *)hci_stack->config)->baudrate_main;
// Limit baud rate for Broadcom chipsets to 3 mbps
if (hci_stack->manufacturer == COMPANY_ID_BROADCOM_CORPORATION && baud_rate > 3000000){
if (hci_stack->manufacturer == BLUETOOTH_COMPANY_ID_BROADCOM_CORPORATION && baud_rate > 3000000){
baud_rate = 3000000;
}
return baud_rate;
@ -969,7 +970,7 @@ static void hci_initialization_timeout_handler(btstack_timer_source_t * ds){
hci_stack->hci_transport->set_baudrate(baud_rate);
}
// For CSR, HCI Reset is sent on new baud rate
if (hci_stack->manufacturer == COMPANY_ID_CAMBRIDGE_SILICON_RADIO){
if (hci_stack->manufacturer == BLUETOOTH_COMPANY_ID_CAMBRIDGE_SILICON_RADIO){
hci_stack->substate = HCI_INIT_SEND_RESET_CSR_WARM_BOOT;
hci_run();
}
@ -1039,7 +1040,7 @@ static void hci_initializing_run(void){
hci_send_cmd_packet(hci_stack->hci_packet_buffer, 3 + hci_stack->hci_packet_buffer[2]);
// STLC25000D: baudrate change happens within 0.5 s after command was send,
// use timer to update baud rate after 100 ms (knowing exactly, when command was sent is non-trivial)
if (hci_stack->manufacturer == COMPANY_ID_ST_MICROELECTRONICS){
if (hci_stack->manufacturer == BLUETOOTH_COMPANY_ID_ST_MICROELECTRONICS){
btstack_run_loop_set_timer(&hci_stack->timeout, HCI_RESET_RESEND_TIMEOUT_MS);
btstack_run_loop_add_timer(&hci_stack->timeout);
}
@ -1071,7 +1072,7 @@ static void hci_initializing_run(void){
btstack_run_loop_set_timer(&hci_stack->timeout, HCI_RESET_RESEND_TIMEOUT_MS);
btstack_run_loop_set_timer_handler(&hci_stack->timeout, hci_initialization_timeout_handler);
btstack_run_loop_add_timer(&hci_stack->timeout);
if (hci_stack->manufacturer == COMPANY_ID_CAMBRIDGE_SILICON_RADIO
if (hci_stack->manufacturer == BLUETOOTH_COMPANY_ID_CAMBRIDGE_SILICON_RADIO
&& hci_stack->config
&& hci_stack->chipset
// && hci_stack->chipset->set_baudrate_command -- there's no such command
@ -1089,7 +1090,7 @@ static void hci_initializing_run(void){
log_info("Init script done");
// Init script download on Broadcom chipsets causes:
if (hci_stack->manufacturer == COMPANY_ID_BROADCOM_CORPORATION){
if (hci_stack->manufacturer == BLUETOOTH_COMPANY_ID_BROADCOM_CORPORATION){
// - baud rate to reset, restore UART baud rate if needed
int need_baud_change = hci_stack->config
&& hci_stack->chipset
@ -1381,7 +1382,7 @@ static void hci_initializing_event_handler(uint8_t * packet, uint16_t size){
case HCI_INIT_W4_SEND_BAUD_CHANGE:
// for STLC2500D, baud rate change already happened.
// for others, baud rate gets changed now
if ((hci_stack->manufacturer != COMPANY_ID_ST_MICROELECTRONICS) && need_baud_change){
if ((hci_stack->manufacturer != BLUETOOTH_COMPANY_ID_ST_MICROELECTRONICS) && need_baud_change){
uint32_t baud_rate = hci_transport_uart_get_main_baud_rate();
log_info("Local baud rate change to %"PRIu32"(w4_send_baud_change)", baud_rate);
hci_stack->hci_transport->set_baudrate(baud_rate);
@ -1403,7 +1404,7 @@ static void hci_initializing_event_handler(uint8_t * packet, uint16_t size){
#endif
case HCI_INIT_W4_READ_LOCAL_SUPPORTED_COMMANDS:
if (need_baud_change && hci_stack->manufacturer == COMPANY_ID_BROADCOM_CORPORATION){
if (need_baud_change && hci_stack->manufacturer == BLUETOOTH_COMPANY_ID_BROADCOM_CORPORATION){
hci_stack->substate = HCI_INIT_SEND_BAUD_CHANGE_BCM;
return;
}
@ -1428,7 +1429,7 @@ static void hci_initializing_event_handler(uint8_t * packet, uint16_t size){
return;
case HCI_INIT_W4_SET_BD_ADDR:
// for STLC2500D, bd addr change only gets active after sending reset command
if (hci_stack->manufacturer == COMPANY_ID_ST_MICROELECTRONICS){
if (hci_stack->manufacturer == BLUETOOTH_COMPANY_ID_ST_MICROELECTRONICS){
hci_stack->substate = HCI_INIT_SEND_RESET_ST_WARM_BOOT;
return;
}
@ -1498,7 +1499,7 @@ static void hci_initializing_event_handler(uint8_t * packet, uint16_t size){
case HCI_INIT_W4_WRITE_DEFAULT_ERRONEOUS_DATA_REPORTING:
// skip bcm set sco pcm config on non-Broadcom chipsets
if (hci_stack->manufacturer == COMPANY_ID_BROADCOM_CORPORATION) break;
if (hci_stack->manufacturer == BLUETOOTH_COMPANY_ID_BROADCOM_CORPORATION) break;
hci_stack->substate = HCI_INIT_W4_BCM_WRITE_SCO_PCM_INT;
// explicit fall through to reduce repetitions