1 /****************************************************************************** 2 * 3 * Copyright (C) 2009-2012 Broadcom Corporation 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ******************************************************************************/ 18 19 #ifndef BTIF_SOCK_THREAD_H 20 #define BTIF_SOCK_THREAD_H 21 22 #include <stdbool.h> 23 24 #include <hardware/bluetooth.h> 25 #include <hardware/bt_sock.h> 26 27 /******************************************************************************* 28 * Constants & Macros 29 ******************************************************************************/ 30 31 #define SOCK_THREAD_FD_RD 1 /* BT socket read signal */ 32 #define SOCK_THREAD_FD_WR (1 << 1) /* BT socket write signal */ 33 #define SOCK_THREAD_FD_EXCEPTION (1 << 2) /* BT socket exception singal */ 34 35 /* Add BT socket fd in current socket poll thread context immediately */ 36 #define SOCK_THREAD_ADD_FD_SYNC (1 << 3) 37 38 /******************************************************************************* 39 * Functions 40 ******************************************************************************/ 41 42 typedef void (*btsock_signaled_cb)(int fd, int type, int flags, 43 uint32_t user_id); 44 typedef void (*btsock_cmd_cb)(int cmd_fd, int type, int size, uint32_t user_id); 45 46 int btsock_thread_init(); 47 int btsock_thread_add_fd(int handle, int fd, int type, int flags, 48 uint32_t user_id); 49 bool btsock_thread_remove_fd_and_close(int thread_handle, int fd); 50 int btsock_thread_wakeup(int handle); 51 int btsock_thread_post_cmd(int handle, int cmd_type, 52 const unsigned char* cmd_data, int data_size, 53 uint32_t user_id); 54 int btsock_thread_create(btsock_signaled_cb callback, 55 btsock_cmd_cb cmd_callback); 56 int btsock_thread_exit(int handle); 57 58 #endif 59