hci.c (c69be560a99ce6a268cf27722c6422f5b93b337d) hci.c (61972f0a5991f636a79984a06846aade0648e1e5)
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

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

9030#endif
9031
9032uint8_t gap_disconnect(hci_con_handle_t handle){
9033 hci_connection_t * conn = hci_connection_for_handle(handle);
9034 if (!conn){
9035 hci_emit_disconnection_complete(handle, 0);
9036 return 0;
9037 }
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

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

9030#endif
9031
9032uint8_t gap_disconnect(hci_con_handle_t handle){
9033 hci_connection_t * conn = hci_connection_for_handle(handle);
9034 if (!conn){
9035 hci_emit_disconnection_complete(handle, 0);
9036 return 0;
9037 }
9038 // ignore if already disconnected
9039 if (conn->state == RECEIVED_DISCONNECTION_COMPLETE){
9040 return 0;
9038 uint8_t status = ERROR_CODE_SUCCESS;
9039 switch (conn->state){
9040 case RECEIVED_DISCONNECTION_COMPLETE:
9041 // ignore if remote just disconnected
9042 break;
9043 case SEND_DISCONNECT:
9044 case SENT_DISCONNECT:
9045 // disconnect already requested or sent
9046 status = ERROR_CODE_COMMAND_DISALLOWED;
9047 break;
9048 default:
9049 // trigger hci_disconnect
9050 conn->state = SEND_DISCONNECT;
9051 hci_run();
9052 break;
9041 }
9053 }
9042 conn->state = SEND_DISCONNECT;
9043 hci_run();
9044 return 0;
9054 return status;
9045}
9046
9047int gap_read_rssi(hci_con_handle_t con_handle){
9048 hci_connection_t * hci_connection = hci_connection_for_handle(con_handle);
9049 if (hci_connection == NULL) return 0;
9050 hci_connection->gap_connection_tasks |= GAP_CONNECTION_TASK_READ_RSSI;
9051 hci_run();
9052 return 1;

--- 1842 unchanged lines hidden ---
9055}
9056
9057int gap_read_rssi(hci_con_handle_t con_handle){
9058 hci_connection_t * hci_connection = hci_connection_for_handle(con_handle);
9059 if (hci_connection == NULL) return 0;
9060 hci_connection->gap_connection_tasks |= GAP_CONNECTION_TASK_READ_RSSI;
9061 hci_run();
9062 return 1;

--- 1842 unchanged lines hidden ---