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