1 /****************************************************************************** 2 * 3 * Copyright (C) 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 /****************************************************************************** 20 * 21 * This is the main implementation file for the BTA Java I/F 22 * 23 ******************************************************************************/ 24 25 #include "bta_api.h" 26 #include "bta_jv_api.h" 27 #include "bta_jv_int.h" 28 #include "bta_sys.h" 29 30 /***************************************************************************** 31 * Constants and types 32 ****************************************************************************/ 33 34 tBTA_JV_CB bta_jv_cb; 35 36 /* state machine action enumeration list */ 37 #define BTA_JV_NUM_ACTIONS (BTA_JV_MAX_INT_EVT & 0x00ff) 38 39 /* type for action functions */ 40 typedef void (*tBTA_JV_ACTION)(tBTA_JV_MSG* p_data); 41 42 /* action function list */ 43 const tBTA_JV_ACTION bta_jv_action[] = { 44 bta_jv_enable, /* BTA_JV_API_ENABLE_EVT */ 45 bta_jv_disable, /* BTA_JV_API_DISABLE_EVT */ 46 bta_jv_get_channel_id, /* BTA_JV_API_GET_CHANNEL_EVT */ 47 bta_jv_free_scn, /* BTA_JV_API_FREE_SCN_EVT */ 48 bta_jv_start_discovery, /* BTA_JV_API_START_DISCOVERY_EVT */ 49 bta_jv_create_record, /* BTA_JV_API_CREATE_RECORD_EVT */ 50 bta_jv_delete_record, /* BTA_JV_API_DELETE_RECORD_EVT */ 51 bta_jv_l2cap_connect, /* BTA_JV_API_L2CAP_CONNECT_EVT */ 52 bta_jv_l2cap_close, /* BTA_JV_API_L2CAP_CLOSE_EVT */ 53 bta_jv_l2cap_start_server, /* BTA_JV_API_L2CAP_START_SERVER_EVT */ 54 bta_jv_l2cap_stop_server, /* BTA_JV_API_L2CAP_STOP_SERVER_EVT */ 55 bta_jv_l2cap_read, /* BTA_JV_API_L2CAP_READ_EVT */ 56 bta_jv_l2cap_write, /* BTA_JV_API_L2CAP_WRITE_EVT */ 57 bta_jv_rfcomm_connect, /* BTA_JV_API_RFCOMM_CONNECT_EVT */ 58 bta_jv_rfcomm_close, /* BTA_JV_API_RFCOMM_CLOSE_EVT */ 59 bta_jv_rfcomm_start_server, /* BTA_JV_API_RFCOMM_START_SERVER_EVT */ 60 bta_jv_rfcomm_stop_server, /* BTA_JV_API_RFCOMM_STOP_SERVER_EVT */ 61 bta_jv_rfcomm_write, /* BTA_JV_API_RFCOMM_WRITE_EVT */ 62 bta_jv_set_pm_profile, /* BTA_JV_API_SET_PM_PROFILE_EVT */ 63 bta_jv_change_pm_state, /* BTA_JV_API_PM_STATE_CHANGE_EVT */ 64 bta_jv_l2cap_connect_le, /* BTA_JV_API_L2CAP_CONNECT_LE_EVT */ 65 bta_jv_l2cap_start_server_le, /* BTA_JV_API_L2CAP_START_SERVER_LE_EVT */ 66 bta_jv_l2cap_stop_server_le, /* BTA_JV_API_L2CAP_STOP_SERVER_LE_EVT */ 67 bta_jv_l2cap_write_fixed, /* BTA_JV_API_L2CAP_WRITE_FIXED_EVT */ 68 bta_jv_l2cap_close_fixed, /* BTA_JV_API_L2CAP_CLOSE_FIXED_EVT */ 69 }; 70 71 /******************************************************************************* 72 * 73 * Function bta_jv_sm_execute 74 * 75 * Description State machine event handling function for JV 76 * 77 * 78 * Returns void 79 * 80 ******************************************************************************/ 81 bool bta_jv_sm_execute(BT_HDR* p_msg) { 82 bool ret = false; 83 uint16_t action = (p_msg->event & 0x00ff); 84 /* execute action functions */ 85 86 if (action < BTA_JV_NUM_ACTIONS) { 87 (*bta_jv_action[action])((tBTA_JV_MSG*)p_msg); 88 ret = true; 89 } 90 91 return (ret); 92 } 93