hci.c (27741fe78f2cafc0a620dc30f4b91f1da88b3fb2) hci.c (ab4831a308e9ff9d65bb727a0253aef14e6768c3)
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

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

1308 packet[offset++] = bytes_to_copy + 1;
1309 packet[offset++] = BLUETOOTH_DATA_TYPE_COMPLETE_LOCAL_NAME;
1310 (void)memcpy(&packet[6], hci_stack->local_name, bytes_to_copy);
1311 // expand '00:00:00:00:00:00' in name with bd_addr
1312 btstack_replace_bd_addr_placeholder(&packet[offset], bytes_to_copy, hci_stack->local_bd_addr);
1313 }
1314 hci_send_cmd_packet(packet, HCI_CMD_HEADER_SIZE + 1 + EXTENDED_INQUIRY_RESPONSE_DATA_LEN);
1315}
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

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

1308 packet[offset++] = bytes_to_copy + 1;
1309 packet[offset++] = BLUETOOTH_DATA_TYPE_COMPLETE_LOCAL_NAME;
1310 (void)memcpy(&packet[6], hci_stack->local_name, bytes_to_copy);
1311 // expand '00:00:00:00:00:00' in name with bd_addr
1312 btstack_replace_bd_addr_placeholder(&packet[offset], bytes_to_copy, hci_stack->local_bd_addr);
1313 }
1314 hci_send_cmd_packet(packet, HCI_CMD_HEADER_SIZE + 1 + EXTENDED_INQUIRY_RESPONSE_DATA_LEN);
1315}
1316
1317static void hci_run_gap_tasks_classic(void){
1318 if ((hci_stack->gap_tasks & GAP_TASK_SET_CLASS_OF_DEVICE) != 0) {
1319 hci_stack->gap_tasks &= ~GAP_TASK_SET_CLASS_OF_DEVICE;
1320 hci_send_cmd(&hci_write_class_of_device, hci_stack->class_of_device);
1321 return;
1322 }
1323 if ((hci_stack->gap_tasks & GAP_TASK_SET_LOCAL_NAME) != 0) {
1324 hci_stack->gap_tasks &= ~GAP_TASK_SET_LOCAL_NAME;
1325 gap_run_set_local_name();
1326 return;
1327 }
1328 if ((hci_stack->gap_tasks & GAP_TASK_SET_EIR_DATA) != 0) {
1329 hci_stack->gap_tasks &= ~GAP_TASK_SET_EIR_DATA;
1330 gap_run_set_eir_data();
1331 return;
1332 }
1333 if ((hci_stack->gap_tasks & GAP_TASK_SET_DEFAULT_LINK_POLICY) != 0) {
1334 hci_stack->gap_tasks &= ~GAP_TASK_SET_DEFAULT_LINK_POLICY;
1335 hci_send_cmd(&hci_write_default_link_policy_setting, hci_stack->default_link_policy_settings);
1336 return;
1337 }
1338 // write page scan activity
1339 if ((hci_stack->gap_tasks & GAP_TASK_WRITE_PAGE_SCAN_ACTIVITY) != 0) {
1340 hci_stack->gap_tasks &= ~GAP_TASK_WRITE_PAGE_SCAN_ACTIVITY;
1341 hci_send_cmd(&hci_write_page_scan_activity, hci_stack->new_page_scan_interval, hci_stack->new_page_scan_window);
1342 return;
1343 }
1344 // write page scan type
1345 if ((hci_stack->gap_tasks & GAP_TASK_WRITE_PAGE_SCAN_TYPE) != 0) {
1346 hci_stack->gap_tasks &= ~GAP_TASK_WRITE_PAGE_SCAN_TYPE;
1347 hci_send_cmd(&hci_write_page_scan_type, hci_stack->new_page_scan_type);
1348 return;
1349 }
1350 // send scan enable
1351 if ((hci_stack->gap_tasks & GAP_TASK_WRITE_SCAN_ENABLE) != 0) {
1352 hci_stack->gap_tasks &= ~GAP_TASK_WRITE_SCAN_ENABLE;
1353 hci_send_cmd(&hci_write_scan_enable, hci_stack->new_scan_enable_value);
1354 return;
1355 }
1356}
1316#endif
1317
1318#ifndef HAVE_HOST_CONTROLLER_API
1319
1320static uint32_t hci_transport_uart_get_main_baud_rate(void){
1321 if (!hci_stack->config) return 0;
1322 uint32_t baud_rate = ((hci_transport_config_uart_t *)hci_stack->config)->baudrate_main;
1323 // Limit baud rate for Broadcom chipsets to 3 mbps

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

4132 // decline incoming connections
4133 if (hci_stack->decline_reason){
4134 uint8_t reason = hci_stack->decline_reason;
4135 hci_stack->decline_reason = 0;
4136 hci_send_cmd(&hci_reject_connection_request, hci_stack->decline_addr, reason);
4137 return true;
4138 }
4139
1357#endif
1358
1359#ifndef HAVE_HOST_CONTROLLER_API
1360
1361static uint32_t hci_transport_uart_get_main_baud_rate(void){
1362 if (!hci_stack->config) return 0;
1363 uint32_t baud_rate = ((hci_transport_config_uart_t *)hci_stack->config)->baudrate_main;
1364 // Limit baud rate for Broadcom chipsets to 3 mbps

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

4173 // decline incoming connections
4174 if (hci_stack->decline_reason){
4175 uint8_t reason = hci_stack->decline_reason;
4176 hci_stack->decline_reason = 0;
4177 hci_send_cmd(&hci_reject_connection_request, hci_stack->decline_addr, reason);
4178 return true;
4179 }
4180
4140 if ((hci_stack->gap_tasks & GAP_TASK_SET_CLASS_OF_DEVICE) != 0) {
4141 hci_stack->gap_tasks &= ~GAP_TASK_SET_CLASS_OF_DEVICE;
4142 hci_send_cmd(&hci_write_class_of_device, hci_stack->class_of_device);
4181 if (hci_stack->gap_tasks != 0){
4182 hci_run_gap_tasks_classic();
4143 return true;
4144 }
4183 return true;
4184 }
4145 if ((hci_stack->gap_tasks & GAP_TASK_SET_LOCAL_NAME) != 0) {
4146 hci_stack->gap_tasks &= ~GAP_TASK_SET_LOCAL_NAME;
4147 gap_run_set_local_name();
4148 return true;
4149 }
4150 if ((hci_stack->gap_tasks & GAP_TASK_SET_EIR_DATA) != 0) {
4151 hci_stack->gap_tasks &= ~GAP_TASK_SET_EIR_DATA;
4152 gap_run_set_eir_data();
4153 return true;
4154 }
4155 if ((hci_stack->gap_tasks & GAP_TASK_SET_DEFAULT_LINK_POLICY) != 0) {
4156 hci_stack->gap_tasks &= ~GAP_TASK_SET_DEFAULT_LINK_POLICY;
4157 hci_send_cmd(&hci_write_default_link_policy_setting, hci_stack->default_link_policy_settings);
4158 return true;
4159 }
4160 // write page scan activity
4161 if ((hci_stack->gap_tasks & GAP_TASK_WRITE_PAGE_SCAN_ACTIVITY) != 0) {
4162 hci_stack->gap_tasks &= ~GAP_TASK_WRITE_PAGE_SCAN_ACTIVITY;
4163 hci_send_cmd(&hci_write_page_scan_activity, hci_stack->new_page_scan_interval, hci_stack->new_page_scan_window);
4164 return true;
4165 }
4166 // write page scan type
4167 if ((hci_stack->gap_tasks & GAP_TASK_WRITE_PAGE_SCAN_TYPE) != 0) {
4168 hci_stack->gap_tasks &= ~GAP_TASK_WRITE_PAGE_SCAN_TYPE;
4169 hci_send_cmd(&hci_write_page_scan_type, hci_stack->new_page_scan_type);
4170 return true;
4171 }
4172 // send scan enable
4173 if ((hci_stack->gap_tasks & GAP_TASK_WRITE_SCAN_ENABLE) != 0) {
4174 hci_stack->gap_tasks &= ~GAP_TASK_WRITE_SCAN_ENABLE;
4175 hci_send_cmd(&hci_write_scan_enable, hci_stack->new_scan_enable_value);
4176 return true;
4177 }
4178
4179 // start/stop inquiry
4180 if ((hci_stack->inquiry_state >= GAP_INQUIRY_DURATION_MIN) && (hci_stack->inquiry_state <= GAP_INQUIRY_DURATION_MAX)){
4181 uint8_t duration = hci_stack->inquiry_state;
4182 hci_stack->inquiry_state = GAP_INQUIRY_STATE_W4_ACTIVE;
4183 hci_send_cmd(&hci_inquiry, hci_stack->inquiry_lap, duration, 0);
4184 return true;
4185 }

--- 2762 unchanged lines hidden ---
4185
4186 // start/stop inquiry
4187 if ((hci_stack->inquiry_state >= GAP_INQUIRY_DURATION_MIN) && (hci_stack->inquiry_state <= GAP_INQUIRY_DURATION_MAX)){
4188 uint8_t duration = hci_stack->inquiry_state;
4189 hci_stack->inquiry_state = GAP_INQUIRY_STATE_W4_ACTIVE;
4190 hci_send_cmd(&hci_inquiry, hci_stack->inquiry_lap, duration, 0);
4191 return true;
4192 }

--- 2762 unchanged lines hidden ---