Android Bluetooth HF client相关接口以及定义

 2023-09-05 阅读 92 评论 0

摘要:【APP】 应用程序通过BluetoothManager和BluetoothAdapter来操作蓝牙相关接口 【JNI】AdaptorService 中打开蓝牙协议栈的代码片段 static void classInitNative(JNIEnv* env, jclass clazz) {int err;hw_module_t* module;...char value[PROPERTY_VALUE_MAX];property_get(&#

【APP】

应用程序通过BluetoothManagerBluetoothAdapter来操作蓝牙相关接口


【JNI】AdaptorService 中打开蓝牙协议栈的代码片段

static void classInitNative(JNIEnv* env, jclass clazz) {int err;hw_module_t* module;...char value[PROPERTY_VALUE_MAX];property_get("bluetooth.mock_stack", value, "");const char *id = (strcmp(value, "1")? BT_STACK_MODULE_ID : BT_STACK_TEST_MODULE_ID);err = hw_get_module(id, (hw_module_t const**)&module);if (err == 0) {hw_device_t* abstraction;err = module->methods->open(module, id, &abstraction);if (err == 0) {bluetooth_module_t* btStack = (bluetooth_module_t *)abstraction;sBluetoothInterface = btStack->get_bluetooth_interface();} else {ALOGE("Error while opening Bluetooth library");}} else {ALOGE("No Bluetooth Library found");}
}


【HAL】

/system/bt/btif/src/bluetooth.c 
HAL层注册了蓝牙协议栈,它作为一个HAL层的“设备”,为上层服务。

tatic struct hw_module_methods_t bt_stack_module_methods = {.open = open_bluetooth_stack,
};struct hw_module_t HAL_MODULE_INFO_SYM = {.tag = HARDWARE_MODULE_TAG,.version_major = 1,.version_minor = 0,.id = BT_HARDWARE_MODULE_ID,.name = "Bluetooth Stack",.author = "The Android Open Source Project",.methods = &bt_stack_module_methods
};

【Interface】Blutooth接口函数

/system/bt/btif/src/bluetooth.c 

static const bt_interface_t bluetoothInterface = {sizeof(bluetoothInterface),init,enable,disable,cleanup,get_adapter_properties,get_adapter_property,set_adapter_property,get_remote_device_properties,get_remote_device_property,set_remote_device_property,get_remote_service_record,get_remote_services,start_discovery,cancel_discovery,create_bond,remove_bond,cancel_bond,get_connection_state,pin_reply,ssp_reply,get_profile_interface,dut_mode_configure,dut_mode_send,
#if BLE_INCLUDED == TRUEle_test_mode,
#elseNULL,
#endifconfig_hci_snoop_log,set_os_callouts,read_energy_info,dump,config_clear
};


【Profile】HF client侧接口

/system/bt/btif/src/btif_hf_client.c

static const bthf_client_interface_t bthfClientInterface = {sizeof(bthf_client_interface_t),.init = init,.connect = connect,.disconnect = disconnect,.connect_audio = connect_audio,.disconnect_audio = disconnect_audio,.start_voice_recognition = start_voice_recognition,.stop_voice_recognition = stop_voice_recognition,.volume_control = volume_control,.dial = dial,.dial_memory = dial_memory,.handle_call_action = handle_call_action,.query_current_calls = query_current_calls,.query_current_operator_name = query_current_operator_name,.retrieve_subscriber_info = retrieve_subscriber_info,.send_dtmf = send_dtmf,.request_last_voice_tag_number = request_last_voice_tag_number,.cleanup = cleanup,.send_at_cmd = send_at_cmd,
};

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://808629.com/644.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 86后生记录生活 Inc. 保留所有权利。

底部版权信息