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 35tBTA_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 */ 42typedef void (*tBTA_JV_ACTION)(tBTA_JV_MSG *p_data); 43 44/* action function list */ 45const 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_set_discoverability, /* BTA_JV_API_SET_DISCOVERABILITY_EVT */ 50 bta_jv_get_local_device_addr, /* BTA_JV_API_GET_LOCAL_DEVICE_ADDR_EVT */ 51 bta_jv_get_local_device_name, /* BTA_JV_API_GET_LOCAL_DEVICE_NAME_EVT */ 52 bta_jv_get_remote_device_name, /* BTA_JV_API_GET_REMOTE_DEVICE_NAME_EVT */ 53 bta_jv_set_service_class, /* BTA_JV_API_SET_SERVICE_CLASS_EVT */ 54 bta_jv_set_encryption, /* BTA_JV_API_SET_ENCRYPTION_EVT */ 55 bta_jv_get_scn, /* BTA_JV_API_GET_SCN_EVT */ 56 bta_jv_free_scn, /* BTA_JV_API_FREE_SCN_EVT */ 57 bta_jv_start_discovery, /* BTA_JV_API_START_DISCOVERY_EVT */ 58 bta_jv_cancel_discovery, /* BTA_JV_API_CANCEL_DISCOVERY_EVT */ 59 bta_jv_get_services_length, /* BTA_JV_API_GET_SERVICES_LENGTH_EVT */ 60 bta_jv_service_select, /* BTA_JV_API_SERVICE_SELECT_EVT */ 61 bta_jv_create_record, /* BTA_JV_API_CREATE_RECORD_EVT */ 62 bta_jv_update_record, /* BTA_JV_API_UPDATE_RECORD_EVT */ 63 bta_jv_add_attribute, /* BTA_JV_API_ADD_ATTRIBUTE_EVT */ 64 bta_jv_delete_attribute, /* BTA_JV_API_DELETE_ATTRIBUTE_EVT */ 65 bta_jv_delete_record, /* BTA_JV_API_DELETE_RECORD_EVT */ 66 bta_jv_l2cap_connect, /* BTA_JV_API_L2CAP_CONNECT_EVT */ 67 bta_jv_l2cap_close, /* BTA_JV_API_L2CAP_CLOSE_EVT */ 68 bta_jv_l2cap_start_server, /* BTA_JV_API_L2CAP_START_SERVER_EVT */ 69 bta_jv_l2cap_stop_server, /* BTA_JV_API_L2CAP_STOP_SERVER_EVT */ 70 bta_jv_l2cap_read, /* BTA_JV_API_L2CAP_READ_EVT */ 71 bta_jv_l2cap_write, /* BTA_JV_API_L2CAP_WRITE_EVT */ 72 bta_jv_rfcomm_connect, /* BTA_JV_API_RFCOMM_CONNECT_EVT */ 73 bta_jv_rfcomm_close, /* BTA_JV_API_RFCOMM_CLOSE_EVT */ 74 bta_jv_rfcomm_start_server, /* BTA_JV_API_RFCOMM_START_SERVER_EVT */ 75 bta_jv_rfcomm_stop_server, /* BTA_JV_API_RFCOMM_STOP_SERVER_EVT */ 76 bta_jv_rfcomm_read, /* BTA_JV_API_RFCOMM_READ_EVT */ 77 bta_jv_rfcomm_write /* BTA_JV_API_RFCOMM_WRITE_EVT */ 78}; 79 80/******************************************************************************* 81** 82** Function bta_jv_sm_execute 83** 84** Description State machine event handling function for JV 85** 86** 87** Returns void 88** 89*******************************************************************************/ 90BOOLEAN bta_jv_sm_execute(BT_HDR *p_msg) 91{ 92 BOOLEAN ret = FALSE; 93 UINT16 action = (p_msg->event & 0x00ff); 94 /* execute action functions */ 95 96 if(action < BTA_JV_NUM_ACTIONS) 97 { 98 (*bta_jv_action[action])((tBTA_JV_MSG*)p_msg); 99 ret = TRUE; 100 } 101 102 return(ret); 103} 104