hci.c (d70217a22813c347630b2fb8f4c29c8d4dc007e3) hci.c (e8c8828ea55576056ea633aba7da6f4f10c12e02)
1/*
2 * Copyright (C) 2014 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 91 unchanged lines hidden (view full) ---

100static void hci_emit_dedicated_bonding_result(bd_addr_t address, uint8_t status);
101static void hci_emit_event(uint8_t * event, uint16_t size, int dump);
102static void hci_emit_acl_packet(uint8_t * packet, uint16_t size);
103static void hci_run(void);
104static int hci_is_le_connection(hci_connection_t * connection);
105static int hci_number_free_acl_slots_for_connection_type( bd_addr_type_t address_type);
106
107#ifdef ENABLE_BLE
1/*
2 * Copyright (C) 2014 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 91 unchanged lines hidden (view full) ---

100static void hci_emit_dedicated_bonding_result(bd_addr_t address, uint8_t status);
101static void hci_emit_event(uint8_t * event, uint16_t size, int dump);
102static void hci_emit_acl_packet(uint8_t * packet, uint16_t size);
103static void hci_run(void);
104static int hci_is_le_connection(hci_connection_t * connection);
105static int hci_number_free_acl_slots_for_connection_type( bd_addr_type_t address_type);
106
107#ifdef ENABLE_BLE
108#ifdef ENABLE_LE_CENTRAL
108// called from test/ble_client/advertising_data_parser.c
109void le_handle_advertisement_report(uint8_t *packet, int size);
109// called from test/ble_client/advertising_data_parser.c
110void le_handle_advertisement_report(uint8_t *packet, int size);
110#ifdef ENABLE_LE_CENTRAL
111static void hci_remove_from_whitelist(bd_addr_type_t address_type, bd_addr_t address);
112#endif
113#endif
114
115// the STACK is here
116#ifndef HAVE_MALLOC
117static hci_stack_t hci_stack_static;
118#endif

--- 742 unchanged lines hidden (view full) ---

861 if (hci_stack->adv_addr_type){
862 memcpy(addr, hci_stack->adv_address, 6);
863 } else {
864 memcpy(addr, hci_stack->local_bd_addr, 6);
865 }
866}
867
868#ifdef ENABLE_BLE
111static void hci_remove_from_whitelist(bd_addr_type_t address_type, bd_addr_t address);
112#endif
113#endif
114
115// the STACK is here
116#ifndef HAVE_MALLOC
117static hci_stack_t hci_stack_static;
118#endif

--- 742 unchanged lines hidden (view full) ---

861 if (hci_stack->adv_addr_type){
862 memcpy(addr, hci_stack->adv_address, 6);
863 } else {
864 memcpy(addr, hci_stack->local_bd_addr, 6);
865 }
866}
867
868#ifdef ENABLE_BLE
869#ifdef ENABLE_LE_CENTRAL
869void le_handle_advertisement_report(uint8_t *packet, int size){
870
871 UNUSED(size);
872
873 int offset = 3;
874 int num_reports = packet[offset];
875 offset += 1;
876

--- 13 unchanged lines hidden (view full) ---

890 event[pos++] = packet[offset++]; //data_length;
891 memcpy(&event[pos], &packet[offset], data_length);
892 pos += data_length;
893 offset += data_length + 1; // rssi
894 hci_emit_event(event, pos, 1);
895 }
896}
897#endif
870void le_handle_advertisement_report(uint8_t *packet, int size){
871
872 UNUSED(size);
873
874 int offset = 3;
875 int num_reports = packet[offset];
876 offset += 1;
877

--- 13 unchanged lines hidden (view full) ---

891 event[pos++] = packet[offset++]; //data_length;
892 memcpy(&event[pos], &packet[offset], data_length);
893 pos += data_length;
894 offset += data_length + 1; // rssi
895 hci_emit_event(event, pos, 1);
896 }
897}
898#endif
899#endif
898
899#if !defined(HAVE_PLATFORM_IPHONE_OS) && !defined (HAVE_HOST_CONTROLLER_API)
900
901static uint32_t hci_transport_uart_get_main_baud_rate(void){
902 if (!hci_stack->config) return 0;
903 uint32_t baud_rate = ((hci_transport_config_uart_t *)hci_stack->config)->baudrate_main;
904 // Limit baud rate for Broadcom chipsets to 3 mbps
905 if (hci_stack->manufacturer == COMPANY_ID_BROADCOM_CORPORATION && baud_rate > 3000000){

--- 664 unchanged lines hidden (view full) ---

1570 if (HCI_EVENT_IS_COMMAND_COMPLETE(packet, hci_read_local_supported_commands)){
1571 hci_stack->local_supported_commands[0] =
1572 (packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE+1+14] & 0x80) >> 7 | // bit 0 = Octet 14, bit 7
1573 (packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE+1+24] & 0x40) >> 5 | // bit 1 = Octet 24, bit 6
1574 (packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE+1+10] & 0x10) >> 2 | // bit 2 = Octet 10, bit 4
1575 (packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE+1+18] & 0x08); // bit 3 = Octet 18, bit 3
1576 log_info("Local supported commands summary 0x%02x", hci_stack->local_supported_commands[0]);
1577 }
900
901#if !defined(HAVE_PLATFORM_IPHONE_OS) && !defined (HAVE_HOST_CONTROLLER_API)
902
903static uint32_t hci_transport_uart_get_main_baud_rate(void){
904 if (!hci_stack->config) return 0;
905 uint32_t baud_rate = ((hci_transport_config_uart_t *)hci_stack->config)->baudrate_main;
906 // Limit baud rate for Broadcom chipsets to 3 mbps
907 if (hci_stack->manufacturer == COMPANY_ID_BROADCOM_CORPORATION && baud_rate > 3000000){

--- 664 unchanged lines hidden (view full) ---

1572 if (HCI_EVENT_IS_COMMAND_COMPLETE(packet, hci_read_local_supported_commands)){
1573 hci_stack->local_supported_commands[0] =
1574 (packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE+1+14] & 0x80) >> 7 | // bit 0 = Octet 14, bit 7
1575 (packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE+1+24] & 0x40) >> 5 | // bit 1 = Octet 24, bit 6
1576 (packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE+1+10] & 0x10) >> 2 | // bit 2 = Octet 10, bit 4
1577 (packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE+1+18] & 0x08); // bit 3 = Octet 18, bit 3
1578 log_info("Local supported commands summary 0x%02x", hci_stack->local_supported_commands[0]);
1579 }
1580#ifdef ENABLE_CLASSIC
1578 if (HCI_EVENT_IS_COMMAND_COMPLETE(packet, hci_write_synchronous_flow_control_enable)){
1579 if (packet[5] == 0){
1580 hci_stack->synchronous_flow_control_enabled = 1;
1581 }
1582 }
1581 if (HCI_EVENT_IS_COMMAND_COMPLETE(packet, hci_write_synchronous_flow_control_enable)){
1582 if (packet[5] == 0){
1583 hci_stack->synchronous_flow_control_enabled = 1;
1584 }
1585 }
1586#endif
1583 break;
1584
1585 case HCI_EVENT_COMMAND_STATUS:
1586 // get num cmd packets - limit to 1 to reduce complexity
1587 hci_stack->num_cmd_packets = packet[3] ? 1 : 0;
1588 break;
1589
1590 case HCI_EVENT_NUMBER_OF_COMPLETED_PACKETS:{

--- 2289 unchanged lines hidden ---
1587 break;
1588
1589 case HCI_EVENT_COMMAND_STATUS:
1590 // get num cmd packets - limit to 1 to reduce complexity
1591 hci_stack->num_cmd_packets = packet[3] ? 1 : 0;
1592 break;
1593
1594 case HCI_EVENT_NUMBER_OF_COMPLETED_PACKETS:{

--- 2289 unchanged lines hidden ---