hci.c (3dce61284ebbd14998272c7ffa97a4fec5c0a16b) hci.c (f8ee30711d382a32d09f62fdcf31e17b8873cde8)
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

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

3458#endif
3459
3460 if (connection->bonding_flags & BONDING_DISCONNECT_SECURITY_BLOCK){
3461 connection->bonding_flags &= ~BONDING_DISCONNECT_SECURITY_BLOCK;
3462 hci_send_cmd(&hci_disconnect, connection->con_handle, 0x0005); // authentication failure
3463 return;
3464 }
3465
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

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

3458#endif
3459
3460 if (connection->bonding_flags & BONDING_DISCONNECT_SECURITY_BLOCK){
3461 connection->bonding_flags &= ~BONDING_DISCONNECT_SECURITY_BLOCK;
3462 hci_send_cmd(&hci_disconnect, connection->con_handle, 0x0005); // authentication failure
3463 return;
3464 }
3465
3466 uint16_t sniff_min_interval;
3467 switch (connection->sniff_min_interval){
3468 case 0:
3469 break;
3470 case 0xffff:
3471 connection->sniff_min_interval = 0;
3472 hci_send_cmd(&hci_exit_sniff_mode, connection->con_handle);
3473 return;
3474 default:
3475 sniff_min_interval = connection->sniff_min_interval;
3476 connection->sniff_min_interval = 0;
3477 hci_send_cmd(&hci_sniff_mode, connection->con_handle, connection->sniff_max_interval, sniff_min_interval, connection->sniff_attempt, connection->sniff_timeout);
3478 break;
3479 }
3480
3466#ifdef ENABLE_BLE
3467 switch (connection->le_con_parameter_update_state){
3468 // response to L2CAP CON PARAMETER UPDATE REQUEST
3469 case CON_PARAMETER_UPDATE_CHANGE_HCI_CON_PARAMETERS:
3470 connection->le_con_parameter_update_state = CON_PARAMETER_UPDATE_NONE;
3471 hci_send_cmd(&hci_le_connection_update, connection->con_handle, connection->le_conn_interval_min,
3472 connection->le_conn_interval_max, connection->le_conn_latency, connection->le_supervision_timeout,
3473 0x0000, 0xffff);

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

4831authorization_state_t gap_authorization_state(hci_con_handle_t con_handle){
4832 sm_connection_t * sm_conn = sm_get_connection_for_handle(con_handle);
4833 if (!sm_conn) return AUTHORIZATION_UNKNOWN; // wrong connection
4834 if (!sm_conn->sm_connection_encrypted) return AUTHORIZATION_UNKNOWN; // unencrypted connection cannot be authorized
4835 if (!sm_conn->sm_connection_authenticated) return AUTHORIZATION_UNKNOWN; // unauthenticatd connection cannot be authorized
4836 return sm_conn->sm_connection_authorization_state;
4837}
4838#endif
3481#ifdef ENABLE_BLE
3482 switch (connection->le_con_parameter_update_state){
3483 // response to L2CAP CON PARAMETER UPDATE REQUEST
3484 case CON_PARAMETER_UPDATE_CHANGE_HCI_CON_PARAMETERS:
3485 connection->le_con_parameter_update_state = CON_PARAMETER_UPDATE_NONE;
3486 hci_send_cmd(&hci_le_connection_update, connection->con_handle, connection->le_conn_interval_min,
3487 connection->le_conn_interval_max, connection->le_conn_latency, connection->le_supervision_timeout,
3488 0x0000, 0xffff);

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

4846authorization_state_t gap_authorization_state(hci_con_handle_t con_handle){
4847 sm_connection_t * sm_conn = sm_get_connection_for_handle(con_handle);
4848 if (!sm_conn) return AUTHORIZATION_UNKNOWN; // wrong connection
4849 if (!sm_conn->sm_connection_encrypted) return AUTHORIZATION_UNKNOWN; // unencrypted connection cannot be authorized
4850 if (!sm_conn->sm_connection_authenticated) return AUTHORIZATION_UNKNOWN; // unauthenticatd connection cannot be authorized
4851 return sm_conn->sm_connection_authorization_state;
4852}
4853#endif
4854
4855#ifdef ENABLE_CLASSIC
4856uint8_t gap_sniff_mode_enter(hci_con_handle_t con_handle, uint16_t sniff_min_interval, uint16_t sniff_max_interval, uint16_t sniff_attempt, uint16_t sniff_timeout){
4857 hci_connection_t * conn = hci_connection_for_handle(con_handle);
4858 if (!conn) return GAP_CONNECTION_INVALID;
4859 conn->sniff_min_interval = sniff_min_interval;
4860 conn->sniff_max_interval = sniff_max_interval;
4861 conn->sniff_attempt = sniff_attempt;
4862 conn->sniff_timeout = sniff_timeout;
4863 hci_run();
4864 return 0;
4865}
4866
4867/**
4868 * @brief Exit Sniff mode
4869 * @param con_handle
4870 @ @return 0 if ok
4871 */
4872uint8_t gap_sniff_mode_exit(hci_con_handle_t con_handle){
4873 hci_connection_t * conn = hci_connection_for_handle(con_handle);
4874 if (!conn) return GAP_CONNECTION_INVALID;
4875 conn->sniff_min_interval = 0xffff;
4876 hci_run();
4877 return 0;
4878}
4879#endif