├── Android.mk ├── CleanSpec.mk ├── audio_a2dp_hw ├── Android.mk ├── audio_a2dp_hw.c └── audio_a2dp_hw.h ├── bta ├── Android.mk ├── ag │ ├── bta_ag_act.c │ ├── bta_ag_api.c │ ├── bta_ag_at.c │ ├── bta_ag_at.h │ ├── bta_ag_cfg.c │ ├── bta_ag_ci.c │ ├── bta_ag_cmd.c │ ├── bta_ag_int.h │ ├── bta_ag_main.c │ ├── bta_ag_rfc.c │ ├── bta_ag_sco.c │ └── bta_ag_sdp.c ├── ar │ ├── bta_ar.c │ └── bta_ar_int.h ├── av │ ├── bta_av_aact.c │ ├── bta_av_act.c │ ├── bta_av_api.c │ ├── bta_av_cfg.c │ ├── bta_av_ci.c │ ├── bta_av_int.h │ ├── bta_av_main.c │ ├── bta_av_sbc.c │ └── bta_av_ssm.c ├── dm │ ├── bta_dm_act.c │ ├── bta_dm_api.c │ ├── bta_dm_cfg.c │ ├── bta_dm_ci.c │ ├── bta_dm_int.h │ ├── bta_dm_main.c │ ├── bta_dm_pm.c │ └── bta_dm_sco.c ├── fs │ ├── bta_fs_cfg.c │ └── bta_fs_ci.c ├── gatt │ ├── bta_gattc_act.c │ ├── bta_gattc_api.c │ ├── bta_gattc_cache.c │ ├── bta_gattc_ci.c │ ├── bta_gattc_int.h │ ├── bta_gattc_main.c │ ├── bta_gattc_utils.c │ ├── bta_gatts_act.c │ ├── bta_gatts_api.c │ ├── bta_gatts_int.h │ ├── bta_gatts_main.c │ └── bta_gatts_utils.c ├── hd │ ├── bta_hd_act.c │ ├── bta_hd_api.c │ ├── bta_hd_int.h │ └── bta_hd_main.c ├── hf_client │ ├── bta_hf_client_act.c │ ├── bta_hf_client_api.c │ ├── bta_hf_client_at.c │ ├── bta_hf_client_at.h │ ├── bta_hf_client_cmd.c │ ├── bta_hf_client_int.h │ ├── bta_hf_client_main.c │ ├── bta_hf_client_rfc.c │ ├── bta_hf_client_sco.c │ └── bta_hf_client_sdp.c ├── hh │ ├── bta_hh_act.c │ ├── bta_hh_api.c │ ├── bta_hh_cfg.c │ ├── bta_hh_int.h │ ├── bta_hh_le.c │ ├── bta_hh_main.c │ └── bta_hh_utils.c ├── hl │ ├── bta_hl_act.c │ ├── bta_hl_api.c │ ├── bta_hl_ci.c │ ├── bta_hl_int.h │ ├── bta_hl_main.c │ ├── bta_hl_sdp.c │ └── bta_hl_utils.c ├── include │ ├── bd.h │ ├── bta_ag_api.h │ ├── bta_ag_ci.h │ ├── bta_ag_co.h │ ├── bta_api.h │ ├── bta_ar_api.h │ ├── bta_av_api.h │ ├── bta_av_ci.h │ ├── bta_av_co.h │ ├── bta_av_sbc.h │ ├── bta_dm_ci.h │ ├── bta_dm_co.h │ ├── bta_fs_api.h │ ├── bta_fs_ci.h │ ├── bta_fs_co.h │ ├── bta_gatt_api.h │ ├── bta_gattc_ci.h │ ├── bta_gattc_co.h │ ├── bta_gatts_co.h │ ├── bta_hd_api.h │ ├── bta_hf_client_api.h │ ├── bta_hh_api.h │ ├── bta_hh_co.h │ ├── bta_hl_api.h │ ├── bta_hl_ci.h │ ├── bta_hl_co.h │ ├── bta_jv_api.h │ ├── bta_jv_co.h │ ├── bta_mce_api.h │ ├── bta_op_api.h │ ├── bta_pan_api.h │ ├── bta_pan_ci.h │ ├── bta_pan_co.h │ ├── bta_pbs_api.h │ ├── bta_sys_ci.h │ ├── bta_sys_co.h │ ├── ptim.h │ └── utl.h ├── jv │ ├── bta_jv_act.c │ ├── bta_jv_api.c │ ├── bta_jv_cfg.c │ ├── bta_jv_int.h │ └── bta_jv_main.c ├── mce │ ├── bta_mce_act.c │ ├── bta_mce_api.c │ ├── bta_mce_cfg.c │ ├── bta_mce_int.h │ └── bta_mce_main.c ├── pan │ ├── bta_pan_act.c │ ├── bta_pan_api.c │ ├── bta_pan_ci.c │ ├── bta_pan_int.h │ └── bta_pan_main.c ├── pb │ ├── bta_pbs_cfg.c │ └── bta_pbs_int.h └── sys │ ├── bd.c │ ├── bta_sys.h │ ├── bta_sys_cfg.c │ ├── bta_sys_ci.c │ ├── bta_sys_conn.c │ ├── bta_sys_int.h │ ├── bta_sys_main.c │ ├── ptim.c │ └── utl.c ├── btif ├── co │ ├── bta_ag_co.c │ ├── bta_av_co.c │ ├── bta_dm_co.c │ ├── bta_fs_co.c │ ├── bta_gattc_co.c │ ├── bta_gatts_co.c │ ├── bta_hh_co.c │ ├── bta_hl_co.c │ ├── bta_pan_co.c │ └── bta_sys_co.c ├── include │ ├── bluetoothTrack.h │ ├── btif_api.h │ ├── btif_av.h │ ├── btif_av_api.h │ ├── btif_av_co.h │ ├── btif_common.h │ ├── btif_config.h │ ├── btif_config_util.h │ ├── btif_dm.h │ ├── btif_gatt.h │ ├── btif_gatt_multi_adv_util.h │ ├── btif_gatt_util.h │ ├── btif_hd.h │ ├── btif_hh.h │ ├── btif_hl.h │ ├── btif_mce.h │ ├── btif_media.h │ ├── btif_pan.h │ ├── btif_pan_internal.h │ ├── btif_profile_queue.h │ ├── btif_sm.h │ ├── btif_sock.h │ ├── btif_sock_l2cap.h │ ├── btif_sock_rfc.h │ ├── btif_sock_sdp.h │ ├── btif_sock_thread.h │ ├── btif_sock_util.h │ ├── btif_storage.h │ ├── btif_util.h │ └── uinput.h └── src │ ├── bluetooth.c │ ├── bluetoothTrack.cpp │ ├── btif_av.c │ ├── btif_config.c │ ├── btif_config_util.cpp │ ├── btif_core.c │ ├── btif_dm.c │ ├── btif_gap.c │ ├── btif_gatt.c │ ├── btif_gatt_client.c │ ├── btif_gatt_multi_adv_util.c │ ├── btif_gatt_qual.c │ ├── btif_gatt_server.c │ ├── btif_gatt_test.c │ ├── btif_gatt_util.c │ ├── btif_hd.c │ ├── btif_hf.c │ ├── btif_hf_client.c │ ├── btif_hh.c │ ├── btif_hl.c │ ├── btif_l2cap.c │ ├── btif_mce.c │ ├── btif_media_task.c │ ├── btif_pan.c │ ├── btif_profile_queue.c │ ├── btif_rc.c │ ├── btif_rfcomm.c │ ├── btif_sdp.c │ ├── btif_sm.c │ ├── btif_smp.c │ ├── btif_sock.c │ ├── btif_sock_l2cap.c │ ├── btif_sock_rfc.c │ ├── btif_sock_sdp.c │ ├── btif_sock_thread.c │ ├── btif_sock_util.c │ ├── btif_storage.c │ └── btif_util.c ├── conf ├── Android.mk ├── auto_pair_devlist.conf ├── bt_did.conf └── bt_stack.conf ├── doc ├── btsnoop_net.md └── properties.md ├── embdrv ├── Android.mk └── sbc │ ├── Android.mk │ ├── decoder │ ├── Android.mk │ ├── include │ │ ├── oi_assert.h │ │ ├── oi_bitstream.h │ │ ├── oi_bt_spec.h │ │ ├── oi_codec_sbc.h │ │ ├── oi_codec_sbc_private.h │ │ ├── oi_common.h │ │ ├── oi_cpu_dep.h │ │ ├── oi_modules.h │ │ ├── oi_osinterface.h │ │ ├── oi_status.h │ │ ├── oi_stddefs.h │ │ ├── oi_string.h │ │ ├── oi_time.h │ │ └── oi_utils.h │ └── srce │ │ ├── alloc.c │ │ ├── bitalloc-sbc.c │ │ ├── bitalloc.c │ │ ├── bitstream-decode.c │ │ ├── decoder-oina.c │ │ ├── decoder-private.c │ │ ├── decoder-sbc.c │ │ ├── dequant.c │ │ ├── framing-sbc.c │ │ ├── framing.c │ │ ├── oi_codec_version.c │ │ ├── readsamplesjoint.inc │ │ ├── synthesis-8-generated.c │ │ ├── synthesis-dct8.c │ │ └── synthesis-sbc.c │ └── encoder │ ├── include │ ├── sbc_dct.h │ ├── sbc_enc_func_declare.h │ ├── sbc_encoder.h │ ├── sbc_if.h │ └── sbc_types.h │ └── srce │ ├── sbc_analysis.c │ ├── sbc_dct.c │ ├── sbc_dct_coeffs.c │ ├── sbc_enc_bit_alloc_mono.c │ ├── sbc_enc_bit_alloc_ste.c │ ├── sbc_enc_coeffs.c │ ├── sbc_encoder.c │ └── sbc_packing.c ├── gki ├── Android.mk ├── common │ ├── gki.h │ ├── gki_buffer.c │ ├── gki_common.h │ ├── gki_debug.c │ └── gki_time.c └── ulinux │ ├── data_types.h │ ├── gki_int.h │ └── gki_ulinux.c ├── hci ├── Android.mk ├── include │ ├── bt_hci_bdroid.h │ ├── bt_hci_lib.h │ ├── bt_vendor_lib.h │ ├── btsnoop.h │ ├── hci.h │ ├── userial.h │ ├── utils.h │ └── vendor.h └── src │ ├── bt_hci_bdroid.c │ ├── btsnoop.c │ ├── btsnoop_net.c │ ├── hci_h4.c │ ├── hci_mct.c │ ├── lpm.c │ ├── userial.c │ ├── userial_mct.c │ ├── utils.c │ └── vendor.c ├── include ├── bt_target.h ├── bt_testapp.h ├── bt_trace.h ├── bte.h ├── bte_appl.h └── gki_target.h ├── main ├── Android.mk ├── bte_conf.c ├── bte_init.c ├── bte_logmsg.c └── bte_main.c ├── osi ├── Android.mk ├── include │ ├── alarm.h │ ├── config.h │ ├── fixed_queue.h │ ├── list.h │ ├── osi.h │ ├── reactor.h │ ├── semaphore.h │ └── thread.h ├── src │ ├── alarm.c │ ├── config.c │ ├── fixed_queue.c │ ├── list.c │ ├── reactor.c │ ├── semaphore.c │ └── thread.c └── test │ ├── alarm_test.cpp │ ├── config_test.cpp │ ├── list_test.cpp │ ├── reactor_test.cpp │ └── thread_test.cpp ├── stack ├── Android.mk ├── a2dp │ ├── a2d_api.c │ ├── a2d_int.h │ └── a2d_sbc.c ├── avct │ ├── avct_api.c │ ├── avct_ccb.c │ ├── avct_defs.h │ ├── avct_int.h │ ├── avct_l2c.c │ ├── avct_lcb.c │ └── avct_lcb_act.c ├── avdt │ ├── avdt_ad.c │ ├── avdt_api.c │ ├── avdt_ccb.c │ ├── avdt_ccb_act.c │ ├── avdt_defs.h │ ├── avdt_int.h │ ├── avdt_l2c.c │ ├── avdt_msg.c │ ├── avdt_scb.c │ └── avdt_scb_act.c ├── avrc │ ├── avrc_api.c │ ├── avrc_bld_ct.c │ ├── avrc_bld_tg.c │ ├── avrc_int.h │ ├── avrc_opt.c │ ├── avrc_pars_ct.c │ ├── avrc_pars_tg.c │ ├── avrc_sdp.c │ └── avrc_utils.c ├── bnep │ ├── bnep_api.c │ ├── bnep_int.h │ ├── bnep_main.c │ └── bnep_utils.c ├── btm │ ├── btm_acl.c │ ├── btm_ble.c │ ├── btm_ble_addr.c │ ├── btm_ble_adv_filter.c │ ├── btm_ble_batchscan.c │ ├── btm_ble_bgconn.c │ ├── btm_ble_cont_energy.c │ ├── btm_ble_gap.c │ ├── btm_ble_int.h │ ├── btm_ble_multi_adv.c │ ├── btm_dev.c │ ├── btm_devctl.c │ ├── btm_inq.c │ ├── btm_int.h │ ├── btm_main.c │ ├── btm_pm.c │ ├── btm_sco.c │ └── btm_sec.c ├── btu │ ├── btu_hcif.c │ ├── btu_init.c │ └── btu_task.c ├── gap │ ├── gap_api.c │ ├── gap_ble.c │ ├── gap_conn.c │ ├── gap_int.h │ └── gap_utils.c ├── gatt │ ├── att_protocol.c │ ├── gatt_api.c │ ├── gatt_attr.c │ ├── gatt_auth.c │ ├── gatt_cl.c │ ├── gatt_db.c │ ├── gatt_int.h │ ├── gatt_main.c │ ├── gatt_sr.c │ └── gatt_utils.c ├── hcic │ ├── hciblecmds.c │ └── hcicmds.c ├── hid │ ├── hid_conn.h │ ├── hidd_api.c │ ├── hidd_conn.c │ ├── hidd_int.h │ ├── hidh_api.c │ ├── hidh_conn.c │ └── hidh_int.h ├── include │ ├── a2d_api.h │ ├── a2d_sbc.h │ ├── avct_api.h │ ├── avdt_api.h │ ├── avdtc_api.h │ ├── avrc_api.h │ ├── avrc_defs.h │ ├── bnep_api.h │ ├── bt_types.h │ ├── btm_api.h │ ├── btm_ble_api.h │ ├── btu.h │ ├── dyn_mem.h │ ├── gap_api.h │ ├── gatt_api.h │ ├── gattdefs.h │ ├── goep_fs.h │ ├── hcidefs.h │ ├── hcimsgs.h │ ├── hidd_api.h │ ├── hiddefs.h │ ├── hidh_api.h │ ├── l2c_api.h │ ├── l2c_sock_api.h │ ├── l2cdefs.h │ ├── mca_api.h │ ├── mca_defs.h │ ├── obx_api.h │ ├── pan_api.h │ ├── port_api.h │ ├── port_ext.h │ ├── profiles_api.h │ ├── rfcdefs.h │ ├── sdp_api.h │ ├── sdpdefs.h │ ├── smp_api.h │ ├── srvc_api.h │ ├── uipc_msg.h │ ├── utfc.h │ ├── wbt_api.h │ └── wcassert.h ├── l2cap │ ├── l2c_api.c │ ├── l2c_ble.c │ ├── l2c_csm.c │ ├── l2c_fcr.c │ ├── l2c_int.h │ ├── l2c_link.c │ ├── l2c_main.c │ ├── l2c_sock_api.c │ ├── l2c_sock_fsm.c │ ├── l2c_sock_int.h │ ├── l2c_sock_l2cap_if.c │ ├── l2c_ucd.c │ └── l2c_utils.c ├── mcap │ ├── mca_api.c │ ├── mca_cact.c │ ├── mca_csm.c │ ├── mca_dact.c │ ├── mca_dsm.c │ ├── mca_int.h │ ├── mca_l2c.c │ └── mca_main.c ├── pan │ ├── pan_api.c │ ├── pan_int.h │ ├── pan_main.c │ └── pan_utils.c ├── rfcomm │ ├── port_api.c │ ├── port_int.h │ ├── port_rfc.c │ ├── port_utils.c │ ├── rfc_int.h │ ├── rfc_l2cap_if.c │ ├── rfc_mx_fsm.c │ ├── rfc_port_fsm.c │ ├── rfc_port_if.c │ ├── rfc_ts_frames.c │ └── rfc_utils.c ├── sdp │ ├── sdp_api.c │ ├── sdp_db.c │ ├── sdp_discovery.c │ ├── sdp_main.c │ ├── sdp_server.c │ ├── sdp_utils.c │ └── sdpint.h ├── smp │ ├── aes.c │ ├── aes.h │ ├── smp_act.c │ ├── smp_api.c │ ├── smp_cmac.c │ ├── smp_int.h │ ├── smp_keys.c │ ├── smp_l2c.c │ ├── smp_main.c │ └── smp_utils.c └── srvc │ ├── srvc_battery.c │ ├── srvc_battery_int.h │ ├── srvc_dis.c │ ├── srvc_dis_int.h │ ├── srvc_eng.c │ └── srvc_eng_int.h ├── test ├── Android.mk ├── blegatt_test │ ├── Android.mk │ ├── README.txt │ └── gatt_test.c ├── bluedroidtest │ ├── Android.mk │ ├── README.txt │ └── bluedroidtest.c ├── l2test_ertm │ ├── Android.mk │ ├── README.txt │ └── l2test_ertm.c ├── rfcommtest │ ├── Android.mk │ ├── README.txt │ └── rfcommtest.c ├── sdptest │ ├── Android.mk │ ├── README.txt │ └── sdptool.c └── suite │ ├── Android.mk │ ├── base.h │ ├── cases │ ├── adapter.c │ ├── cases.c │ ├── cases.h │ └── pan.c │ ├── main.c │ └── support │ ├── adapter.c │ ├── adapter.h │ ├── callbacks.c │ ├── callbacks.h │ ├── hal.c │ ├── hal.h │ ├── pan.c │ ├── pan.h │ ├── property.c │ └── property.h ├── tools └── gen-buildcfg.sh ├── udrv ├── include │ └── uipc.h └── ulinux │ ├── uipc.c │ └── uipc_linux.h ├── utils ├── Android.mk ├── include │ └── bt_utils.h └── src │ └── bt_utils.c ├── vnd ├── ble │ ├── vendor_ble.c │ └── vendor_hcidefs.h └── include │ ├── vendor_api.h │ └── vendor_ble.h └── wipowerif ├── include └── wipower_const.h └── src └── wipower.c /Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | bdroid_CFLAGS := -Wno-unused-parameter 4 | 5 | # Setup bdroid local make variables for handling configuration 6 | ifneq ($(BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR),) 7 | bdroid_C_INCLUDES := $(BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR) 8 | bdroid_CFLAGS += -DHAS_BDROID_BUILDCFG 9 | else 10 | bdroid_C_INCLUDES := 11 | bdroid_CFLAGS += -DHAS_NO_BDROID_BUILDCFG 12 | endif 13 | 14 | bdroid_CFLAGS += -Wall -Werror 15 | bdroid_CFLAGS += -DAVK_BACKPORT 16 | 17 | ifneq ($(BOARD_BLUETOOTH_BDROID_HCILP_INCLUDED),) 18 | bdroid_CFLAGS += -DHCILP_INCLUDED=$(BOARD_BLUETOOTH_BDROID_HCILP_INCLUDED) 19 | endif 20 | 21 | include $(call all-subdir-makefiles) 22 | 23 | # Cleanup our locals 24 | bdroid_C_INCLUDES := 25 | bdroid_CFLAGS := 26 | -------------------------------------------------------------------------------- /CleanSpec.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2007 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | 16 | # If you don't need to do a full clean build but would like to touch 17 | # a file or delete some intermediate files, add a clean step to the end 18 | # of the list. These steps will only be run once, if they haven't been 19 | # run before. 20 | # 21 | # E.g.: 22 | # $(call add-clean-step, touch -c external/sqlite/sqlite3.h) 23 | # $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates) 24 | # 25 | # Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with 26 | # files that are missing or have been moved. 27 | # 28 | # Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory. 29 | # Use $(OUT_DIR) to refer to the "out" directory. 30 | # 31 | # If you need to re-do something that's already mentioned, just copy 32 | # the command and add it to the bottom of the list. E.g., if a change 33 | # that you made last week required touching a file and a change you 34 | # made today requires touching the same file, just copy the old 35 | # touch step and add it to the end of the list. 36 | # 37 | # ************************************************ 38 | # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST 39 | # ************************************************ 40 | 41 | # For example: 42 | #$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates) 43 | #$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates) 44 | #$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f) 45 | #$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*) 46 | 47 | # Start of Clean Step list: 48 | $(call add-clean-step, find $(OUT_DIR) -type f -iname "*blue*" -print0 | xargs -0 rm -f) 49 | $(call add-clean-step, find $(OUT_DIR) -type f -iname "*bdroid*" -print0 | xargs -0 rm -f) 50 | 51 | # ************************************************ 52 | # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST 53 | # ************************************************ 54 | -------------------------------------------------------------------------------- /audio_a2dp_hw/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_SRC_FILES := \ 6 | audio_a2dp_hw.c 7 | 8 | LOCAL_C_INCLUDES += \ 9 | . \ 10 | $(LOCAL_PATH)/../utils/include 11 | 12 | LOCAL_CFLAGS += -std=c99 13 | 14 | LOCAL_MODULE := audio.a2dp.default 15 | LOCAL_MODULE_RELATIVE_PATH := hw 16 | 17 | LOCAL_SHARED_LIBRARIES := libcutils liblog 18 | 19 | LOCAL_MODULE_TAGS := optional 20 | 21 | include $(BUILD_SHARED_LIBRARY) 22 | -------------------------------------------------------------------------------- /bta/ag/bta_ag_cfg.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2003-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 file contains compile-time configurable constants for the audio 22 | * gateway. 23 | * 24 | ******************************************************************************/ 25 | 26 | #include "gki.h" 27 | #include "bta_api.h" 28 | #include "bta_ag_api.h" 29 | 30 | #ifndef BTA_AG_CIND_INFO 31 | #define BTA_AG_CIND_INFO "(\"call\",(0,1)),(\"callsetup\",(0-3)),(\"service\",(0-3)),(\"signal\",(0-6)),(\"roam\",(0,1)),(\"battchg\",(0-5)),(\"callheld\",(0-2)),(\"bearer\",(0-7))" 32 | #endif 33 | 34 | #ifndef BTA_AG_CHLD_VAL_ECC 35 | #define BTA_AG_CHLD_VAL_ECC "(0,1,1x,2,2x,3,4)" 36 | #endif 37 | 38 | #ifndef BTA_AG_CHLD_VAL 39 | #define BTA_AG_CHLD_VAL "(0,1,2,3,4)" 40 | #endif 41 | 42 | #ifndef BTA_AG_CONN_TIMEOUT 43 | #define BTA_AG_CONN_TIMEOUT 5000 44 | #endif 45 | 46 | #ifndef BTA_AG_SCO_PKT_TYPES 47 | /* S1 packet type setting from HFP 1.5 spec */ 48 | #define BTA_AG_SCO_PKT_TYPES /* BTM_SCO_LINK_ALL_PKT_MASK */ (BTM_SCO_LINK_ONLY_MASK | \ 49 | BTM_SCO_PKT_TYPES_MASK_EV3 | \ 50 | BTM_SCO_PKT_TYPES_MASK_NO_3_EV3 | \ 51 | BTM_SCO_PKT_TYPES_MASK_NO_2_EV5 | \ 52 | BTM_SCO_PKT_TYPES_MASK_NO_3_EV5) 53 | #endif 54 | 55 | const tBTA_AG_CFG bta_ag_cfg = 56 | { 57 | BTA_AG_CIND_INFO, 58 | BTA_AG_CONN_TIMEOUT, 59 | BTA_AG_SCO_PKT_TYPES, 60 | BTA_AG_CHLD_VAL_ECC, 61 | BTA_AG_CHLD_VAL 62 | }; 63 | 64 | tBTA_AG_CFG *p_bta_ag_cfg = (tBTA_AG_CFG *) &bta_ag_cfg; 65 | -------------------------------------------------------------------------------- /bta/ar/bta_ar_int.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2008-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 private interface file for the BTA audio/video registration 22 | * module. 23 | * 24 | ******************************************************************************/ 25 | #ifndef BTA_AR_INT_H 26 | #define BTA_AR_INT_H 27 | 28 | #include "bta_av_api.h" 29 | 30 | 31 | #ifndef BTA_AR_DEBUG 32 | #define BTA_AR_DEBUG FALSE 33 | #endif 34 | 35 | #define BTA_AR_AV_MASK 0x01 36 | #define BTA_AR_AVK_MASK 0x02 37 | 38 | /* data associated with BTA_AR */ 39 | typedef struct 40 | { 41 | tAVDT_CTRL_CBACK *p_av_conn_cback; /* av connection callback function */ 42 | tAVDT_CTRL_CBACK *p_avk_conn_cback; /* avk connection callback function */ 43 | UINT8 avdt_registered; 44 | UINT8 avct_registered; 45 | UINT32 sdp_tg_handle; 46 | UINT32 sdp_ct_handle; 47 | UINT16 ct_categories[2]; 48 | UINT8 tg_registered; 49 | tBTA_AV_HNDL hndl; /* Handle associated with the stream that rejected the connection. */ 50 | } tBTA_AR_CB; 51 | 52 | /***************************************************************************** 53 | ** Global data 54 | *****************************************************************************/ 55 | 56 | /* control block declaration */ 57 | #if BTA_DYNAMIC_MEMORY == FALSE 58 | extern tBTA_AR_CB bta_ar_cb; 59 | #else 60 | extern tBTA_AR_CB *bta_ar_cb_ptr; 61 | #define bta_ar_cb (*bta_ar_cb_ptr) 62 | #endif 63 | 64 | #endif /* BTA_AR_INT_H */ 65 | -------------------------------------------------------------------------------- /bta/fs/bta_fs_cfg.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2003-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 file contains compile-time configurable constants for the BTA File 22 | * System. 23 | * 24 | ******************************************************************************/ 25 | 26 | #include "bt_target.h" 27 | #include "bta_fs_api.h" 28 | 29 | /* Character used as path separator */ 30 | #ifndef BTA_FS_PATH_SEPARATOR 31 | #define BTA_FS_PATH_SEPARATOR ((char) 0x2f) /* 0x2f ('/'), or 0x5c ('\') */ 32 | #endif 33 | 34 | /* Maximum path length supported by MMI */ 35 | #ifndef BTA_FS_PATH_LEN 36 | #define BTA_FS_PATH_LEN 294 37 | #endif 38 | 39 | #ifndef BTA_FS_FILE_LEN 40 | #define BTA_FS_FILE_LEN 256 41 | #endif 42 | 43 | const tBTA_FS_CFG bta_fs_cfg = 44 | { 45 | BTA_FS_FILE_LEN, 46 | BTA_FS_PATH_LEN, 47 | BTA_FS_PATH_SEPARATOR 48 | }; 49 | 50 | tBTA_FS_CFG *p_bta_fs_cfg = (tBTA_FS_CFG *)&bta_fs_cfg; 51 | 52 | -------------------------------------------------------------------------------- /bta/hh/bta_hh_cfg.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2005-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 file contains compile-time configurable constants for the BTA Hid 22 | * Host. 23 | * 24 | ******************************************************************************/ 25 | 26 | #include "bt_target.h" 27 | #include "bta_hh_api.h" 28 | 29 | /* max number of device types supported by BTA */ 30 | #define BTA_HH_MAX_DEVT_SPT 9 31 | 32 | /* size of database for service discovery */ 33 | #ifndef BTA_HH_DISC_BUF_SIZE 34 | #define BTA_HH_DISC_BUF_SIZE GKI_MAX_BUF_SIZE 35 | #endif 36 | 37 | 38 | 39 | /* The type of devices supported by BTA HH and corresponding application ID */ 40 | tBTA_HH_SPT_TOD p_devt_list[BTA_HH_MAX_DEVT_SPT] = 41 | { 42 | {BTA_HH_DEVT_MIC, BTA_HH_APP_ID_MI}, 43 | {BTA_HH_DEVT_KBD, BTA_HH_APP_ID_KB}, 44 | {BTA_HH_DEVT_KBD|BTA_HH_DEVT_MIC, BTA_HH_APP_ID_KB}, 45 | {BTA_HH_DEVT_RMC, BTA_HH_APP_ID_RMC}, 46 | {BTA_HH_DEVT_RMC | BTA_HH_DEVT_KBD, BTA_HH_APP_ID_RMC}, 47 | {BTA_HH_DEVT_MIC | BTA_HH_DEVT_DGT, BTA_HH_APP_ID_MI}, 48 | {BTA_HH_DEVT_JOS, BTA_HH_APP_ID_JOY}, 49 | {BTA_HH_DEVT_GPD, BTA_HH_APP_ID_GPAD}, 50 | {BTA_HH_DEVT_UNKNOWN, BTA_HH_APP_ID_3DSG} 51 | }; 52 | 53 | 54 | const tBTA_HH_CFG bta_hh_cfg = 55 | { 56 | BTA_HH_MAX_DEVT_SPT, /* number of supported type of devices */ 57 | p_devt_list, /* ToD & AppID list */ 58 | BTA_HH_DISC_BUF_SIZE /* HH SDP discovery database size */ 59 | }; 60 | 61 | 62 | tBTA_HH_CFG *p_bta_hh_cfg = (tBTA_HH_CFG *)&bta_hh_cfg; 63 | -------------------------------------------------------------------------------- /bta/include/bta_ag_api.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_external_bluetooth_bluedroid/5e99e49bb0c62169ac7a1f6a30ff16fa9fa38507/bta/include/bta_ag_api.h -------------------------------------------------------------------------------- /bta/include/bta_ag_ci.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2003-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 interface file for audio gateway call-in functions. 22 | * 23 | ******************************************************************************/ 24 | #ifndef BTA_AG_CI_H 25 | #define BTA_AG_CI_H 26 | 27 | #include "bta_ag_api.h" 28 | 29 | /***************************************************************************** 30 | ** Function Declarations 31 | *****************************************************************************/ 32 | #ifdef __cplusplus 33 | extern "C" 34 | { 35 | #endif 36 | 37 | /******************************************************************************* 38 | ** 39 | ** Function bta_ag_ci_rx_write 40 | ** 41 | ** Description This function is called to send data to the AG when the AG 42 | ** is configured for AT command pass-through. The function 43 | ** copies data to an event buffer and sends it. 44 | ** 45 | ** Returns void 46 | ** 47 | *******************************************************************************/ 48 | BTA_API extern void bta_ag_ci_rx_write(UINT16 handle, char *p_data, UINT16 len); 49 | 50 | /****************************************************************************** 51 | ** 52 | ** Function bta_ag_ci_slc_ready 53 | ** 54 | ** Description This function is called to notify AG that SLC is up at 55 | ** the application. This funcion is only used when the app 56 | ** is running in pass-through mode. 57 | ** 58 | ** Returns void 59 | ** 60 | ******************************************************************************/ 61 | BTA_API extern void bta_ag_ci_slc_ready(UINT16 handle); 62 | 63 | // btla-specific ++ 64 | /****************************************************************************** 65 | ** 66 | ** Function bta_ag_ci_wbs_command 67 | ** 68 | ** Description This function is called to notify AG that a WBS command is 69 | ** received 70 | ** 71 | ** Returns void 72 | ** 73 | ******************************************************************************/ 74 | BTA_API extern void bta_ag_ci_wbs_command (UINT16 handle, char *p_data, UINT16 len); 75 | // btla-specific -- 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | 81 | #endif /* BTA_AG_CI_H */ 82 | 83 | -------------------------------------------------------------------------------- /bta/include/bta_ag_co.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_external_bluetooth_bluedroid/5e99e49bb0c62169ac7a1f6a30ff16fa9fa38507/bta/include/bta_ag_co.h -------------------------------------------------------------------------------- /bta/include/bta_av_ci.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2005-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 interface file for advanced audio/video call-in functions. 22 | * 23 | ******************************************************************************/ 24 | #ifndef BTA_AV_CI_H 25 | #define BTA_AV_CI_H 26 | 27 | #include "bta_av_api.h" 28 | 29 | /***************************************************************************** 30 | ** Function Declarations 31 | *****************************************************************************/ 32 | #ifdef __cplusplus 33 | extern "C" 34 | { 35 | #endif 36 | 37 | /******************************************************************************* 38 | ** 39 | ** Function bta_av_ci_src_data_ready 40 | ** 41 | ** Description This function sends an event to the AV indicating that 42 | ** the phone has audio stream data ready to send and AV 43 | ** should call bta_av_co_audio_src_data_path() or 44 | ** bta_av_co_video_src_data_path(). 45 | ** 46 | ** Returns void 47 | ** 48 | *******************************************************************************/ 49 | BTA_API extern void bta_av_ci_src_data_ready(tBTA_AV_CHNL chnl); 50 | 51 | /******************************************************************************* 52 | ** 53 | ** Function bta_av_ci_setconfig 54 | ** 55 | ** Description This function must be called in response to function 56 | ** bta_av_co_audio_setconfig() or bta_av_co_video_setconfig. 57 | ** Parameter err_code is set to an AVDTP status value; 58 | ** AVDT_SUCCESS if the codec configuration is ok, 59 | ** otherwise error. 60 | ** 61 | ** Returns void 62 | ** 63 | *******************************************************************************/ 64 | BTA_API extern void bta_av_ci_setconfig(tBTA_AV_HNDL hndl, UINT8 err_code, 65 | UINT8 category, UINT8 num_seid, UINT8 *p_seid, 66 | BOOLEAN recfg_needed, UINT8 avdt_handle); 67 | 68 | 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | 73 | #endif /* BTA_AV_CI_H */ 74 | 75 | -------------------------------------------------------------------------------- /bta/include/bta_dm_ci.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2006-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 interface file for device mananger call-in functions. 22 | * 23 | ******************************************************************************/ 24 | #ifndef BTA_DM_CI_H 25 | #define BTA_DM_CI_H 26 | 27 | #include "bta_api.h" 28 | 29 | /***************************************************************************** 30 | ** Function Declarations 31 | *****************************************************************************/ 32 | #ifdef __cplusplus 33 | extern "C" 34 | { 35 | #endif 36 | 37 | /******************************************************************************* 38 | ** 39 | ** Function bta_dm_ci_io_req 40 | ** 41 | ** Description This function must be called in response to function 42 | ** bta_dm_co_io_req(), if *p_oob_data is set to BTA_OOB_UNKNOWN 43 | ** by bta_dm_co_io_req(). 44 | ** 45 | ** Returns void 46 | ** 47 | *******************************************************************************/ 48 | BTA_API extern void bta_dm_ci_io_req(BD_ADDR bd_addr, tBTA_IO_CAP io_cap, 49 | tBTA_OOB_DATA oob_data, tBTA_AUTH_REQ auth_req); 50 | 51 | /******************************************************************************* 52 | ** 53 | ** Function bta_dm_ci_rmt_oob 54 | ** 55 | ** Description This function must be called in response to function 56 | ** bta_dm_co_rmt_oob() to provide the OOB data associated 57 | ** with the remote device. 58 | ** 59 | ** Returns void 60 | ** 61 | *******************************************************************************/ 62 | BTA_API extern void bta_dm_ci_rmt_oob(BOOLEAN accept, BD_ADDR bd_addr, 63 | BT_OCTET16 c, BT_OCTET16 r); 64 | /******************************************************************************* 65 | ** 66 | ** Function bta_dm_sco_ci_data_ready 67 | ** 68 | ** Description This function sends an event to indicating that the phone 69 | ** has SCO data ready.. 70 | ** 71 | ** Returns void 72 | ** 73 | *******************************************************************************/ 74 | BTA_API extern void bta_dm_sco_ci_data_ready(UINT16 event, UINT16 sco_handle); 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | 80 | #endif 81 | 82 | -------------------------------------------------------------------------------- /bta/include/bta_fs_api.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2003-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 public interface file for the file system of BTA, Broadcom's 22 | * Bluetooth application layer for mobile phones. 23 | * 24 | ******************************************************************************/ 25 | #ifndef BTA_FS_API_H 26 | #define BTA_FS_API_H 27 | 28 | #include "bta_api.h" 29 | 30 | /***************************************************************************** 31 | ** Constants and data types 32 | *****************************************************************************/ 33 | 34 | /* Configuration structure */ 35 | typedef struct 36 | { 37 | UINT16 max_file_len; /* Maximum size file name */ 38 | UINT16 max_path_len; /* Maximum path length (includes appended file name) */ 39 | char path_separator; /* 0x2f ('/'), or 0x5c ('\') */ 40 | } tBTA_FS_CFG; 41 | 42 | extern tBTA_FS_CFG * p_bta_fs_cfg; 43 | 44 | #endif /* BTA_FS_API_H */ 45 | -------------------------------------------------------------------------------- /bta/include/bta_jv_co.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2007-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 interface file for java interface call-out functions. 22 | * 23 | ******************************************************************************/ 24 | #ifndef BTA_JV_CO_H 25 | #define BTA_JV_CO_H 26 | 27 | #include "bta_jv_api.h" 28 | 29 | /***************************************************************************** 30 | ** Function Declarations 31 | *****************************************************************************/ 32 | 33 | 34 | /******************************************************************************* 35 | ** 36 | ** Function bta_jv_co_rfc_data 37 | ** 38 | ** Description This function is called by JV to send data to the java glue 39 | ** code when the RX data path is configured to use a call-out 40 | ** 41 | ** Returns void 42 | ** 43 | *******************************************************************************/ 44 | 45 | BTA_API extern int bta_co_rfc_data_incoming(void *user_data, BT_HDR *p_buf); 46 | BTA_API extern int bta_co_rfc_data_outgoing_size(void *user_data, int *size); 47 | BTA_API extern int bta_co_rfc_data_outgoing(void *user_data, UINT8* buf, UINT16 size); 48 | 49 | #if (defined(OBX_OVER_L2CAP_INCLUDED) && OBX_OVER_L2CAP_INCLUDED == TRUE) 50 | BTA_API extern int bta_co_l2c_data_incoming(void *user_data, BT_HDR *p_buf); 51 | BTA_API extern int bta_co_l2c_data_outgoing_size(void *user_data, int *size); 52 | BTA_API extern int bta_co_l2c_data_outgoing(void *user_data, UINT8* buf, UINT16 size); 53 | #endif 54 | 55 | #endif /* BTA_DG_CO_H */ 56 | 57 | -------------------------------------------------------------------------------- /bta/include/bta_op_api.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2003-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 public interface file for the object push (OP) client and 22 | * server subsystem of BTA, Broadcom's Bluetooth application layer for 23 | * mobile phones. 24 | * 25 | ******************************************************************************/ 26 | #ifndef BTA_OP_API_H 27 | #define BTA_OP_API_H 28 | 29 | #include "bta_api.h" 30 | 31 | /***************************************************************************** 32 | ** Constants and data types 33 | *****************************************************************************/ 34 | /* Extra Debug Code */ 35 | #ifndef BTA_OPS_DEBUG 36 | #define BTA_OPS_DEBUG FALSE 37 | #endif 38 | 39 | #ifndef BTA_OPC_DEBUG 40 | #define BTA_OPC_DEBUG FALSE 41 | #endif 42 | 43 | 44 | /* Object format */ 45 | #define BTA_OP_VCARD21_FMT 1 /* vCard 2.1 */ 46 | #define BTA_OP_VCARD30_FMT 2 /* vCard 3.0 */ 47 | #define BTA_OP_VCAL_FMT 3 /* vCal 1.0 */ 48 | #define BTA_OP_ICAL_FMT 4 /* iCal 2.0 */ 49 | #define BTA_OP_VNOTE_FMT 5 /* vNote */ 50 | #define BTA_OP_VMSG_FMT 6 /* vMessage */ 51 | #define BTA_OP_OTHER_FMT 0xFF /* other format */ 52 | 53 | typedef UINT8 tBTA_OP_FMT; 54 | 55 | /* Object format mask */ 56 | #define BTA_OP_VCARD21_MASK 0x01 /* vCard 2.1 */ 57 | #define BTA_OP_VCARD30_MASK 0x02 /* vCard 3.0 */ 58 | #define BTA_OP_VCAL_MASK 0x04 /* vCal 1.0 */ 59 | #define BTA_OP_ICAL_MASK 0x08 /* iCal 2.0 */ 60 | #define BTA_OP_VNOTE_MASK 0x10 /* vNote */ 61 | #define BTA_OP_VMSG_MASK 0x20 /* vMessage */ 62 | #define BTA_OP_ANY_MASK 0x40 /* Any type of object. */ 63 | 64 | typedef UINT8 tBTA_OP_FMT_MASK; 65 | 66 | #endif /* BTA_OP_API_H */ 67 | 68 | -------------------------------------------------------------------------------- /bta/include/bta_pbs_api.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2003-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 public interface file for the phone book access (PB) server 22 | * subsystem of BTA, Broadcom's Bluetooth application layer for mobile 23 | * phones. 24 | * 25 | ******************************************************************************/ 26 | #ifndef BTA_PB_API_H 27 | #define BTA_PB_API_H 28 | 29 | #include "bta_api.h" 30 | #include "btm_api.h" 31 | #include "bta_sys.h" 32 | 33 | /***************************************************************************** 34 | ** Constants and data types 35 | *****************************************************************************/ 36 | 37 | /************************** 38 | ** Common Definitions 39 | ***************************/ 40 | 41 | /* Profile supported features */ 42 | #define BTA_PBS_SUPF_DOWNLOAD 0x0001 43 | #define BTA_PBS_SURF_BROWSE 0x0002 44 | 45 | /* Profile supported repositories */ 46 | #define BTA_PBS_REPOSIT_LOCAL 0x01 /* Local PhoneBook */ 47 | #define BTA_PBS_REPOSIT_SIM 0x02 /* SIM card PhoneBook */ 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /bta/include/bta_sys_ci.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2010-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 interface file for system call-in functions. 22 | * 23 | ******************************************************************************/ 24 | #ifndef BTA_SYS_CI_H 25 | #define BTA_SYS_CI_H 26 | 27 | #include "bta_api.h" 28 | 29 | /***************************************************************************** 30 | ** Function Declarations 31 | *****************************************************************************/ 32 | #ifdef __cplusplus 33 | extern "C" 34 | { 35 | #endif 36 | 37 | /******************************************************************************* 38 | ** 39 | ** Function bta_sys_hw_ci_enabled 40 | ** 41 | ** Description This function must be called in response to function 42 | ** bta_sys_hw_co_enable(), when HW is indeed enabled 43 | ** 44 | ** 45 | ** Returns void 46 | ** 47 | *******************************************************************************/ 48 | BTA_API void bta_sys_hw_ci_enabled(tBTA_SYS_HW_MODULE module ); 49 | 50 | 51 | /******************************************************************************* 52 | ** 53 | ** Function bta_sys_hw_ci_disabled 54 | ** 55 | ** Description This function must be called in response to function 56 | ** bta_sys_hw_co_disable() when HW is really OFF 57 | ** 58 | ** 59 | ** Returns void 60 | ** 61 | *******************************************************************************/ 62 | BTA_API void bta_sys_hw_ci_disabled( tBTA_SYS_HW_MODULE module ); 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | 68 | #endif 69 | 70 | -------------------------------------------------------------------------------- /bta/include/bta_sys_co.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2010-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 interface file for system callout functions. 22 | * 23 | ******************************************************************************/ 24 | #ifndef BTA_SYS_CO_H 25 | #define BTA_SYS_CO_H 26 | 27 | #include "bta_sys.h" 28 | 29 | 30 | 31 | /***************************************************************************** 32 | ** Function Declarations 33 | *****************************************************************************/ 34 | 35 | 36 | /******************************************************************************* 37 | ** 38 | ** Function bta_sys_hw_co_enable 39 | ** 40 | ** Description This function is called by the stack to power up the HW 41 | ** 42 | ** Returns void 43 | ** 44 | *******************************************************************************/ 45 | BTA_API void bta_sys_hw_co_enable( tBTA_SYS_HW_MODULE module ); 46 | 47 | /******************************************************************************* 48 | ** 49 | ** Function bta_sys_hw_co_disable 50 | ** 51 | ** Description This function is called by the stack to power down the HW 52 | ** 53 | ** Returns void 54 | ** 55 | *******************************************************************************/ 56 | BTA_API void bta_sys_hw_co_disable( tBTA_SYS_HW_MODULE module ); 57 | 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /bta/jv/bta_jv_cfg.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2014 The Android Open Source Project 4 | * Copyright (C) 2004-2012 Broadcom Corporation 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at: 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | ******************************************************************************/ 19 | 20 | /****************************************************************************** 21 | * 22 | * This file contains compile-time configurable constants for advanced 23 | * audio 24 | * 25 | ******************************************************************************/ 26 | 27 | #include "gki.h" 28 | #include "bta_api.h" 29 | #include "bd.h" 30 | #include "bta_jv_api.h" 31 | 32 | #ifndef BTA_JV_SDP_DB_SIZE 33 | #define BTA_JV_SDP_DB_SIZE 4500 34 | #endif 35 | 36 | #ifndef BTA_JV_SDP_RAW_DATA_SIZE 37 | #define BTA_JV_SDP_RAW_DATA_SIZE 1800 38 | #endif 39 | 40 | /* The platform may choose to use dynamic memory for these data buffers. 41 | * p_bta_jv_cfg->p_sdp_db must be allocated/stay allocated 42 | * between BTA_JvEnable and BTA_JvDisable 43 | * p_bta_jv_cfg->p_sdp_raw_data can be allocated before calling BTA_JvStartDiscovery 44 | * it can be de-allocated after the last call to access the database */ 45 | static UINT8 bta_jv_sdp_raw_data[BTA_JV_SDP_RAW_DATA_SIZE]; 46 | static UINT8 __attribute__ ((aligned(4))) bta_jv_sdp_db_data[BTA_JV_SDP_DB_SIZE]; 47 | 48 | /* JV configuration structure */ 49 | const tBTA_JV_CFG bta_jv_cfg = 50 | { 51 | BTA_JV_SDP_RAW_DATA_SIZE, /* The size of p_sdp_raw_data */ 52 | BTA_JV_SDP_DB_SIZE, /* The size of p_sdp_db_data */ 53 | bta_jv_sdp_raw_data, /* The data buffer to keep raw data */ 54 | (tSDP_DISCOVERY_DB *)bta_jv_sdp_db_data /* The data buffer to keep SDP database */ 55 | }; 56 | 57 | tBTA_JV_CFG *p_bta_jv_cfg = (tBTA_JV_CFG *) &bta_jv_cfg; 58 | 59 | 60 | -------------------------------------------------------------------------------- /bta/mce/bta_mce_cfg.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2014 The Android Open Source Project 4 | * Copyright (C) 2003-2012 Broadcom Corporation 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at: 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | ******************************************************************************/ 19 | 20 | /****************************************************************************** 21 | * 22 | * This file contains compile-time configurable constants for MCE 23 | * 24 | ******************************************************************************/ 25 | 26 | #include "gki.h" 27 | #include "bta_api.h" 28 | #include "bd.h" 29 | #include "bta_mce_api.h" 30 | 31 | #ifndef BTA_MCE_SDP_DB_SIZE 32 | #define BTA_MCE_SDP_DB_SIZE 4500 33 | #endif 34 | 35 | static UINT8 __attribute__ ((aligned(4))) bta_mce_sdp_db_data[BTA_MCE_SDP_DB_SIZE]; 36 | 37 | /* MCE configuration structure */ 38 | const tBTA_MCE_CFG bta_mce_cfg = 39 | { 40 | BTA_MCE_SDP_DB_SIZE, 41 | (tSDP_DISCOVERY_DB *)bta_mce_sdp_db_data /* The data buffer to keep SDP database */ 42 | }; 43 | 44 | tBTA_MCE_CFG *p_bta_mce_cfg = (tBTA_MCE_CFG *) &bta_mce_cfg; 45 | -------------------------------------------------------------------------------- /bta/mce/bta_mce_int.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2014 The Android Open Source Project 4 | * Copyright (C) 2003-2012 Broadcom Corporation 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at: 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | ******************************************************************************/ 19 | 20 | /****************************************************************************** 21 | * 22 | * This is the private interface file for the BTA MCE I/F 23 | * 24 | ******************************************************************************/ 25 | #ifndef BTA_MCE_INT_H 26 | #define BTA_MCE_INT_H 27 | 28 | #include "bta_sys.h" 29 | #include "bta_api.h" 30 | #include "bta_mce_api.h" 31 | 32 | /***************************************************************************** 33 | ** Constants 34 | *****************************************************************************/ 35 | 36 | enum 37 | { 38 | /* these events are handled by the state machine */ 39 | BTA_MCE_API_ENABLE_EVT = BTA_SYS_EVT_START(BTA_ID_MCE), 40 | BTA_MCE_API_GET_REMOTE_MAS_INSTANCES_EVT, 41 | BTA_MCE_MAX_INT_EVT 42 | }; 43 | 44 | /* data type for BTA_MCE_API_ENABLE_EVT */ 45 | typedef struct 46 | { 47 | BT_HDR hdr; 48 | tBTA_MCE_DM_CBACK *p_cback; 49 | } tBTA_MCE_API_ENABLE; 50 | 51 | /* data type for BTA_MCE_API_GET_REMOTE_MAS_INSTANCES_EVT */ 52 | typedef struct 53 | { 54 | BT_HDR hdr; 55 | BD_ADDR bd_addr; 56 | } tBTA_MCE_API_GET_REMOTE_MAS_INSTANCES; 57 | 58 | /* union of all data types */ 59 | typedef union 60 | { 61 | /* GKI event buffer header */ 62 | BT_HDR hdr; 63 | tBTA_MCE_API_ENABLE enable; 64 | tBTA_MCE_API_GET_REMOTE_MAS_INSTANCES get_rmt_mas; 65 | } tBTA_MCE_MSG; 66 | 67 | /* MCE control block */ 68 | typedef struct 69 | { 70 | UINT8 sdp_active; /* see BTA_MCE_SDP_ACT_* */ 71 | BD_ADDR remote_addr; 72 | tBTA_MCE_DM_CBACK *p_dm_cback; 73 | } tBTA_MCE_CB; 74 | 75 | enum 76 | { 77 | BTA_MCE_SDP_ACT_NONE = 0, 78 | BTA_MCE_SDP_ACT_YES /* waiting for SDP result */ 79 | }; 80 | 81 | /* MCE control block */ 82 | #if BTA_DYNAMIC_MEMORY == FALSE 83 | extern tBTA_MCE_CB bta_mce_cb; 84 | #else 85 | extern tBTA_MCE_CB *bta_mce_cb_ptr; 86 | #define bta_mce_cb (*bta_mce_cb_ptr) 87 | #endif 88 | 89 | /* config struct */ 90 | extern tBTA_MCE_CFG *p_bta_mce_cfg; 91 | 92 | extern BOOLEAN bta_mce_sm_execute(BT_HDR *p_msg); 93 | 94 | extern void bta_mce_enable (tBTA_MCE_MSG *p_data); 95 | extern void bta_mce_get_remote_mas_instances (tBTA_MCE_MSG *p_data); 96 | 97 | #endif /* BTA_MCE_INT_H */ 98 | -------------------------------------------------------------------------------- /bta/mce/bta_mce_main.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2014 The Android Open Source Project 4 | * Copyright (C) 2003-2012 Broadcom Corporation 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at: 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | ******************************************************************************/ 19 | 20 | /****************************************************************************** 21 | * 22 | * This is the main implementation file for the BTA MCE I/F 23 | * 24 | ******************************************************************************/ 25 | 26 | #include "bta_api.h" 27 | #include "bta_sys.h" 28 | #include "bta_mce_api.h" 29 | #include "bta_mce_int.h" 30 | 31 | /***************************************************************************** 32 | ** Constants and types 33 | *****************************************************************************/ 34 | 35 | #if BTA_DYNAMIC_MEMORY == FALSE 36 | tBTA_MCE_CB bta_mce_cb; 37 | #endif 38 | 39 | /* state machine action enumeration list */ 40 | #define BTA_MCE_NUM_ACTIONS (BTA_MCE_MAX_INT_EVT & 0x00ff) 41 | 42 | /* type for action functions */ 43 | typedef void (*tBTA_MCE_ACTION)(tBTA_MCE_MSG *p_data); 44 | 45 | /* action function list */ 46 | const tBTA_MCE_ACTION bta_mce_action[] = 47 | { 48 | bta_mce_enable, /* BTA_MCE_API_ENABLE_EVT */ 49 | bta_mce_get_remote_mas_instances, /* BTA_MCE_API_GET_REMOTE_MAS_INSTANCES_EVT */ 50 | }; 51 | 52 | /******************************************************************************* 53 | ** 54 | ** Function bta_mce_sm_execute 55 | ** 56 | ** Description State machine event handling function for MCE 57 | ** 58 | ** 59 | ** Returns void 60 | ** 61 | *******************************************************************************/ 62 | BOOLEAN bta_mce_sm_execute(BT_HDR *p_msg) 63 | { 64 | if(p_msg == NULL) return FALSE; 65 | 66 | BOOLEAN ret = FALSE; 67 | UINT16 action = (p_msg->event & 0x00ff); 68 | 69 | /* execute action functions */ 70 | if(action < BTA_MCE_NUM_ACTIONS) 71 | { 72 | (*bta_mce_action[action])((tBTA_MCE_MSG*)p_msg); 73 | ret = TRUE; 74 | } 75 | 76 | return(ret); 77 | } 78 | -------------------------------------------------------------------------------- /bta/pb/bta_pbs_cfg.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2003-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 file contains compile-time configurable constants for the BTA Phone 22 | * Book Access Server. 23 | * 24 | ******************************************************************************/ 25 | 26 | #include "bt_target.h" 27 | 28 | #if defined(BTA_PBS_INCLUDED) && (BTA_PBS_INCLUDED == TRUE) 29 | 30 | #include "bta_pbs_int.h" 31 | 32 | /* Realm Character Set */ 33 | #ifndef BTA_PBS_REALM_CHARSET 34 | #define BTA_PBS_REALM_CHARSET 0 /* ASCII */ 35 | #endif 36 | 37 | /* Specifies whether or not client's user id is required during obex authentication */ 38 | #ifndef BTA_PBS_USERID_REQ 39 | #define BTA_PBS_USERID_REQ FALSE 40 | #endif 41 | 42 | const tBTA_PBS_CFG bta_pbs_cfg = 43 | { 44 | BTA_PBS_REALM_CHARSET, /* Server only */ 45 | BTA_PBS_USERID_REQ, /* Server only */ 46 | (BTA_PBS_SUPF_DOWNLOAD | BTA_PBS_SURF_BROWSE), 47 | BTA_PBS_REPOSIT_LOCAL, 48 | }; 49 | 50 | tBTA_PBS_CFG *p_bta_pbs_cfg = (tBTA_PBS_CFG *)&bta_pbs_cfg; 51 | #endif /* BTA_PBS_INCLUDED */ 52 | -------------------------------------------------------------------------------- /bta/pb/bta_pbs_int.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2003-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 private file for the phone book access server (PBS). 22 | * 23 | ******************************************************************************/ 24 | #ifndef BTA_PBS_INT_H 25 | #define BTA_PBS_INT_H 26 | 27 | #include "bt_target.h" 28 | #include "bta_pbs_api.h" 29 | 30 | /***************************************************************************** 31 | ** Constants and data types 32 | *****************************************************************************/ 33 | 34 | #define BTA_PBS_TARGET_UUID "\x79\x61\x35\xf0\xf0\xc5\x11\xd8\x09\x66\x08\x00\x20\x0c\x9a\x66" 35 | #define BTA_PBS_UUID_LENGTH 16 36 | #define BTA_PBS_MAX_AUTH_KEY_SIZE 16 /* Must not be greater than OBX_MAX_AUTH_KEY_SIZE */ 37 | 38 | #define BTA_PBS_DEFAULT_VERSION 0x0101 /* for PBAP PSE version 1.1 */ 39 | 40 | 41 | /* Configuration structure */ 42 | typedef struct 43 | { 44 | UINT8 realm_charset; /* Server only */ 45 | BOOLEAN userid_req; /* TRUE if user id is required during obex authentication (Server only) */ 46 | UINT8 supported_features; /* Server supported features */ 47 | UINT8 supported_repositories; /* Server supported repositories */ 48 | 49 | } tBTA_PBS_CFG; 50 | 51 | 52 | /***************************************************************************** 53 | ** Global data 54 | *****************************************************************************/ 55 | 56 | 57 | #endif /* BTA_PBS_INT_H */ 58 | -------------------------------------------------------------------------------- /bta/sys/bta_sys_cfg.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2003-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 file contains compile-time configurable constants for the BTA 22 | * system manager. 23 | * 24 | ******************************************************************************/ 25 | 26 | #include "bt_target.h" 27 | #include "gki.h" 28 | #include "bta_sys.h" 29 | 30 | /* GKI task mailbox event for BTA. */ 31 | #ifndef BTA_MBOX_EVT 32 | #define BTA_MBOX_EVT TASK_MBOX_2_EVT_MASK 33 | #endif 34 | 35 | /* GKI task mailbox for BTA. */ 36 | #ifndef BTA_MBOX 37 | #define BTA_MBOX TASK_MBOX_2 38 | #endif 39 | 40 | /* GKI timer id used for protocol timer for BTA. */ 41 | #ifndef BTA_TIMER 42 | #define BTA_TIMER TIMER_1 43 | #endif 44 | 45 | const tBTA_SYS_CFG bta_sys_cfg = 46 | { 47 | BTA_MBOX_EVT, /* GKI mailbox event */ 48 | BTA_MBOX, /* GKI mailbox id */ 49 | BTA_TIMER, /* GKI timer id */ 50 | APPL_INITIAL_TRACE_LEVEL /* initial trace level */ 51 | }; 52 | 53 | tBTA_SYS_CFG *p_bta_sys_cfg = (tBTA_SYS_CFG *)&bta_sys_cfg; 54 | 55 | 56 | -------------------------------------------------------------------------------- /bta/sys/bta_sys_ci.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2010-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 implementation file for BTA system call-in functions. 22 | * 23 | ******************************************************************************/ 24 | 25 | #include "bta_sys.h" 26 | #include "bta_sys_ci.h" 27 | 28 | 29 | /******************************************************************************* 30 | ** 31 | ** Function bta_sys_hw_ci_enabled 32 | ** 33 | ** Description This function must be called in response to function 34 | ** bta_sys_hw_enable_co(), when HW is indeed enabled 35 | ** 36 | ** 37 | ** Returns void 38 | ** 39 | *******************************************************************************/ 40 | void bta_sys_hw_ci_enabled(tBTA_SYS_HW_MODULE module ) 41 | 42 | { 43 | tBTA_SYS_HW_MSG *p_msg; 44 | 45 | if ((p_msg = (tBTA_SYS_HW_MSG *) GKI_getbuf(sizeof(tBTA_SYS_HW_MSG))) != NULL) 46 | { 47 | p_msg->hdr.event = BTA_SYS_EVT_ENABLED_EVT; 48 | p_msg->hw_module = module; 49 | 50 | bta_sys_sendmsg(p_msg); 51 | } 52 | } 53 | 54 | /******************************************************************************* 55 | ** 56 | ** Function bta_sys_hw_ci_disabled 57 | ** 58 | ** Description This function must be called in response to function 59 | ** bta_sys_hw_disable_co() when HW is really OFF 60 | ** 61 | ** 62 | ** Returns void 63 | ** 64 | *******************************************************************************/ 65 | void bta_sys_hw_ci_disabled( tBTA_SYS_HW_MODULE module ) 66 | { 67 | tBTA_SYS_HW_MSG *p_msg; 68 | 69 | if ((p_msg = (tBTA_SYS_HW_MSG *) GKI_getbuf(sizeof(tBTA_SYS_HW_MSG))) != NULL) 70 | { 71 | p_msg->hdr.event = BTA_SYS_EVT_DISABLED_EVT; 72 | p_msg->hw_module = module; 73 | 74 | bta_sys_sendmsg(p_msg); 75 | } 76 | } 77 | 78 | -------------------------------------------------------------------------------- /btif/co/bta_sys_co.c: -------------------------------------------------------------------------------- 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 | #include "bta_sys.h" 19 | #include "bta_sys_ci.h" 20 | 21 | /******************************************************************************* 22 | ** 23 | ** Function bta_sys_hw_co_enable 24 | ** 25 | ** Description This function is called by the stack to power up the HW 26 | ** 27 | ** Returns void 28 | ** 29 | *******************************************************************************/ 30 | void bta_sys_hw_co_enable( tBTA_SYS_HW_MODULE module ) 31 | { 32 | /* platform specific implementation to power-up the HW */ 33 | 34 | 35 | /* if no client/server asynchronous system like linux-based OS, directly call the ci here */ 36 | bta_sys_hw_ci_enabled( module ); 37 | } 38 | 39 | 40 | /******************************************************************************* 41 | ** 42 | ** Function bta_sys_hw_co_disable 43 | ** 44 | ** Description This function is called by the stack to power down the HW 45 | ** 46 | ** Returns void 47 | ** 48 | *******************************************************************************/ 49 | void bta_sys_hw_co_disable( tBTA_SYS_HW_MODULE module ) 50 | { 51 | /* platform specific implementation to power-down the HW */ 52 | 53 | 54 | /* if no client/server asynchronous system like linux-based OS, directly call the ci here */ 55 | bta_sys_hw_ci_disabled( module ); 56 | 57 | } 58 | -------------------------------------------------------------------------------- /btif/include/bluetoothTrack.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013, The Linux Foundation. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * Neither the name of The Linux Foundation nor 12 | * the names of its contributors may be used to endorse or promote 13 | * products derived from this software without specific prior written 14 | * permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 20 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 23 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 25 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #if defined (__cplusplus) || (cplusplus) 30 | extern "C" { 31 | #endif 32 | 33 | int btCreateTrack(int trackFreq, int channelType); 34 | void btDeleteTrack(); 35 | void btStopTrack(); 36 | void btStartTrack(); 37 | void btPauseTrack(); 38 | int btWriteData(void *audioBuffer, int bufferlen); 39 | 40 | #if defined (__cplusplus) || (cplusplus) 41 | } 42 | #endif 43 | -------------------------------------------------------------------------------- /btif/include/btif_config_util.h: -------------------------------------------------------------------------------- 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 | /************************************************************************************ 20 | * 21 | * Filename: btif_config_util.h 22 | * 23 | * Description: Bluetooth configuration utility api 24 | * 25 | ***********************************************************************************/ 26 | 27 | #ifndef BTIF_CONFIG_UTIL_H 28 | #define BTIF_CONFIG_UTIL_H 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | /******************************************************************************* 35 | ** Constants & Macros 36 | ********************************************************************************/ 37 | 38 | #define BLUEZ_PATH "/data/misc/bluetoothd/" 39 | #define BLUEZ_PATH_BAK "/data/misc/bluetoothd_bak" 40 | #define BLUEZ_LINKKEY "linkkeys" 41 | #define BLUEZ_NAMES "names" 42 | #define BLUEZ_PROFILES "profiles" 43 | #define BLUEZ_CLASSES "classes" 44 | #define BLUEZ_TYPES "types" 45 | #define BLUEZ_CONFIG "config" 46 | #define BLUEZ_ALIASES "aliases" 47 | #define BLUEZ_SDP "sdp" 48 | 49 | /******************************************************************************* 50 | ** Functions 51 | ********************************************************************************/ 52 | 53 | int btif_config_save_file(const char* file_name); 54 | int btif_config_load_file(const char* file_name); 55 | int load_bluez_adapter_info(char* adapter_path, int size); 56 | int load_bluez_linkkeys(const char* adapter_path); 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /btif/include/btif_gatt.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2009-2013 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 | ** 22 | ** Name: btif_gatt.h 23 | ** 24 | ** Description: 25 | ** 26 | ******************************************************************************/ 27 | 28 | #ifndef BTIF_GATT_H 29 | #define BTIF_GATT_H 30 | 31 | 32 | 33 | #endif 34 | 35 | -------------------------------------------------------------------------------- /btif/include/btif_gatt_util.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2009-2013 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 | #ifndef BTIF_GATT_UTIL_H 21 | #define BTIF_GATT_UTIL_H 22 | 23 | #include "bta_api.h" 24 | 25 | void btif_to_bta_uuid(tBT_UUID *p_dest, bt_uuid_t *p_src); 26 | void btif_to_bta_gatt_id(tBTA_GATT_ID *p_dest, btgatt_gatt_id_t *p_src); 27 | void btif_to_bta_srvc_id(tBTA_GATT_SRVC_ID *p_dest, btgatt_srvc_id_t *p_src); 28 | void btif_to_bta_response(tBTA_GATTS_RSP *p_dest, btgatt_response_t* p_src); 29 | void btif_to_bta_uuid_mask(tBTA_DM_BLE_PF_COND_MASK *p_mask, bt_uuid_t *p_src); 30 | 31 | void bta_to_btif_uuid(bt_uuid_t *p_dest, tBT_UUID *p_src); 32 | void bta_to_btif_srvc_id(btgatt_srvc_id_t *p_dest, tBTA_GATT_SRVC_ID *p_src); 33 | void bta_to_btif_gatt_id(btgatt_gatt_id_t *p_dest, tBTA_GATT_ID *p_src); 34 | 35 | uint16_t set_read_value(btgatt_read_params_t *p_dest, tBTA_GATTC_READ *p_src); 36 | uint16_t get_uuid16(tBT_UUID *p_uuid); 37 | 38 | void btif_gatt_check_encrypted_link(BD_ADDR bd_addr); 39 | 40 | BOOLEAN btif_get_device_type(BD_ADDR bd_addr, int *addr_type, int *device_type); 41 | 42 | #endif 43 | 44 | -------------------------------------------------------------------------------- /btif/include/btif_hd.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (c) 2013, The Linux Foundation. All rights reserved. 4 | * Not a Contribution. 5 | * Copyright (C) 2009-2012 Broadcom Corporation 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at: 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * 19 | ******************************************************************************/ 20 | 21 | #ifndef BTIF_HD_H 22 | #define BTIF_HD_H 23 | 24 | #include 25 | #include 26 | #include 27 | #include "bta_hd_api.h" 28 | 29 | typedef enum 30 | { 31 | BTIF_HD_DISABLED = 0, 32 | BTIF_HD_ENABLED, 33 | BTIF_HD_DISABLING 34 | } BTIF_HD_STATUS; 35 | 36 | /** BTIF-HD control block */ 37 | typedef struct 38 | { 39 | BTIF_HD_STATUS status; 40 | BOOLEAN app_registered; 41 | } btif_hd_cb_t; 42 | 43 | extern btif_hd_cb_t btif_hd_cb; 44 | 45 | extern void btif_hd_remove_device(bt_bdaddr_t bd_addr); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /btif/include/btif_mce.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2014 The Android Open Source Project 4 | * Copyright (C) 2009-2012 Broadcom Corporation 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at: 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | ******************************************************************************/ 19 | 20 | /******************************************************************************* 21 | * 22 | * Filename: btif_mce.h 23 | * 24 | * Description: Bluetooth MCE Interface 25 | * 26 | *******************************************************************************/ 27 | 28 | #ifndef BTIF_MCE_H 29 | #define BTIF_MCE_H 30 | 31 | #include 32 | 33 | btmce_interface_t *btif_mce_get_interface(); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /btif/include/btif_pan.h: -------------------------------------------------------------------------------- 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 | /******************************************************************************* 20 | * 21 | * Filename: btif_pan.h 22 | * 23 | * Description: Bluetooth pan Interface 24 | * 25 | *******************************************************************************/ 26 | 27 | #ifndef BTIF_PAN_H 28 | #define BTIF_PAN_H 29 | 30 | #include 31 | 32 | btpan_interface_t *btif_pan_interface(); 33 | void btif_pan_init(); 34 | void btif_pan_cleanup(); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /btif/include/btif_profile_queue.h: -------------------------------------------------------------------------------- 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 | /******************************************************************************* 20 | * 21 | * Filename: btif_profile_queue.h 22 | * 23 | * Description: Bluetooth remote device connection queuing 24 | * 25 | *******************************************************************************/ 26 | 27 | #ifndef BTIF_PROFILE_QUEUE_H 28 | #define BTIF_PROFILE_QUEUE_H 29 | 30 | typedef bt_status_t (*btif_connect_cb_t) (bt_bdaddr_t *bda, uint16_t uuid); 31 | 32 | typedef enum { 33 | BTIF_QUEUE_CONNECT_EVT, 34 | BTIF_QUEUE_ADVANCE_EVT, 35 | BTIF_QUEUE_CHECK_CONNECT_REQ, 36 | } btif_queue_event_t; 37 | 38 | bt_status_t btif_queue_connect(uint16_t uuid, const bt_bdaddr_t *bda, btif_connect_cb_t connect_cb); 39 | 40 | void btif_queue_advance(); 41 | void btif_queue_release(); 42 | void btif_queue_remove_connect(uint16_t uuid, uint8_t check_connect_req); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /btif/include/btif_sock.h: -------------------------------------------------------------------------------- 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 | /******************************************************************************* 20 | * 21 | * Filename: btif_sock.h 22 | * 23 | * Description: Bluetooth socket Interface 24 | * 25 | *******************************************************************************/ 26 | 27 | #ifndef BTIF_SOCK_H 28 | #define BTIF_SOCK_H 29 | 30 | #include 31 | 32 | bt_status_t btif_sock_init(); 33 | btsock_interface_t *btif_sock_get_interface(); 34 | void btif_sock_cleanup(); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /btif/include/btif_sock_l2cap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, The Linux Foundation. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * Neither the name of The Linux Foundation nor 12 | * the names of its contributols may be used to endolse or promote 13 | * products derived from this software without specific prior written 14 | * permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 20 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 23 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 25 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /****************************************************************************** 30 | * This file contains L2cap Socket interface function prototypes 31 | * 32 | ******************************************************************************/ 33 | 34 | 35 | #ifndef BTIF_SOCK_L2C_H 36 | #define BTIF_SOCK_L2C_H 37 | 38 | #include "bt_target.h" 39 | 40 | #if (defined(OBX_OVER_L2CAP_INCLUDED) && OBX_OVER_L2CAP_INCLUDED == TRUE) 41 | 42 | bt_status_t btsock_l2c_init(int handle); 43 | bt_status_t btsock_l2c_cleanup(); 44 | bt_status_t btsock_l2c_listen(const char* name, const uint8_t* uuid, int channel, 45 | int* sock_fd, int flags); 46 | bt_status_t btsock_l2c_connect(const bt_bdaddr_t *bd_addr, const uint8_t* uuid, 47 | int channel, int* sock_fd, int flags); 48 | void btsock_l2c_signaled(int fd, int flags, uint32_t user_id); 49 | bt_status_t btsock_l2c_set_sockopt(int psm, btsock_option_type_t option_name, 50 | void *option_value, int option_len); 51 | 52 | #endif 53 | 54 | #endif 55 | 56 | -------------------------------------------------------------------------------- /btif/include/btif_sock_rfc.h: -------------------------------------------------------------------------------- 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 | /******************************************************************************* 20 | * 21 | * Filename: btif_sock.h 22 | * 23 | * Description: Bluetooth socket Interface 24 | * 25 | *******************************************************************************/ 26 | 27 | #ifndef BTIF_SOCK_RFC_H 28 | #define BTIF_SOCK_RFC_H 29 | 30 | bt_status_t btsock_rfc_init(int handle); 31 | bt_status_t btsock_rfc_cleanup(); 32 | bt_status_t btsock_rfc_listen(const char* name, const uint8_t* uuid, int channel, 33 | int* sock_fd, int flags); 34 | bt_status_t btsock_rfc_connect(const bt_bdaddr_t *bd_addr, const uint8_t* uuid, 35 | int channel, int* sock_fd, int flags); 36 | bt_status_t btsock_rfc_get_sockopt(int channel, btsock_option_type_t option_name, 37 | void *option_value, int *option_len); 38 | bt_status_t btsock_rfc_set_sockopt(int channel, btsock_option_type_t option_name, 39 | void *option_value, int option_len); 40 | void btsock_rfc_signaled(int fd, int flags, uint32_t user_id); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /btif/include/btif_sock_sdp.h: -------------------------------------------------------------------------------- 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 | #include "bt_target.h" 20 | #ifndef BTIF_SOCK_SDP_H 21 | #define BTIF_SOCK_SDP_H 22 | static const UINT8 UUID_OBEX_OBJECT_PUSH[] = {0x00, 0x00, 0x11, 0x05, 0x00, 0x00, 0x10, 0x00, 23 | 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB}; 24 | static const UINT8 UUID_PBAP_PSE[] = {0x00, 0x00, 0x11, 0x2F, 0x00, 0x00, 0x10, 0x00, 25 | 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB}; 26 | static const UINT8 UUID_MAPS_MAS[] = {0x00, 0x00, 0x11, 0x32, 0x00, 0x00, 0x10, 0x00, 27 | 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB}; 28 | static const UINT8 UUID_SPP[] = {0x00, 0x00, 0x11, 0x01, 0x00, 0x00, 0x10, 0x00, 29 | 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB}; 30 | static const UINT8 UUID_FTP[] = {0x00, 0x00, 0x11, 0x06, 0x00, 0x00, 0x10, 0x00, 31 | 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB}; 32 | static const UINT8 UUID_DUN[] = {0x00, 0x00, 0x11, 0x03, 0x00, 0x00, 0x10, 0x00, 33 | 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB}; 34 | static const UINT8 UUID_SAP[] = {0x00, 0x00, 0x11, 0x2D, 0x00, 0x00, 0x10, 0x00, 35 | 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB}; 36 | #define RESERVED_SCN_FTP 20 37 | 38 | static inline BOOLEAN is_uuid_empty(const uint8_t* uuid) 39 | { 40 | static uint8_t empty_uuid[16]; 41 | return uuid == NULL || memcmp(uuid, empty_uuid, sizeof(empty_uuid)) == 0; 42 | } 43 | 44 | int add_rfc_sdp_rec(const char* name, const uint8_t* uuid, int scn); 45 | void del_rfc_sdp_rec(int handle); 46 | BOOLEAN is_reserved_rfc_channel(int channel); 47 | int get_reserved_rfc_channel(const uint8_t* uuid); 48 | 49 | #if (defined(OBX_OVER_L2CAP_INCLUDED) && OBX_OVER_L2CAP_INCLUDED == TRUE) 50 | int add_l2c_sdp_rec(const char* name, const uint8_t* uuid, int psm); 51 | int get_reserved_l2c_channel(const uint8_t* uuid); 52 | void del_l2c_sdp_rec(int handle, const uint8_t* uuid); 53 | #endif 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /btif/include/btif_sock_thread.h: -------------------------------------------------------------------------------- 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 23 | 24 | /******************************************************************************* 25 | ** Constants & Macros 26 | ********************************************************************************/ 27 | 28 | #define SOCK_THREAD_FD_RD 1 /* BT socket read signal */ 29 | #define SOCK_THREAD_FD_WR (1 << 1) /* BT socket write signal */ 30 | #define SOCK_THREAD_FD_EXCEPTION (1 << 2) /* BT socket exception singal */ 31 | #define SOCK_THREAD_ADD_FD_SYNC (1 << 3) /* Add BT socket fd in current socket 32 | poll thread context immediately */ 33 | 34 | /******************************************************************************* 35 | ** Functions 36 | ********************************************************************************/ 37 | 38 | typedef void (*btsock_signaled_cb)(int fd, int type, int flags, uint32_t user_id); 39 | typedef void (*btsock_cmd_cb)(int cmd_fd, int type, int size, uint32_t user_id); 40 | 41 | int btsock_thread_init(); 42 | int btsock_thread_add_fd(int handle, int fd, int type, int flags, uint32_t user_id); 43 | int btsock_thread_wakeup(int handle); 44 | int btsock_thread_post_cmd(int handle, int cmd_type, const unsigned char* cmd_data, 45 | int data_size, uint32_t user_id); 46 | int btsock_thread_create(btsock_signaled_cb callback, btsock_cmd_cb cmd_callback); 47 | int btsock_thread_exit(int handle); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /btif/include/btif_sock_util.h: -------------------------------------------------------------------------------- 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 | /******************************************************************************* 20 | * 21 | * Filename: btif_sock_util.h 22 | * 23 | * Description: Bluetooth socket Interface Helper functions 24 | * 25 | *******************************************************************************/ 26 | 27 | #ifndef BTIF_SOCK_UTIL_H 28 | #define BTIF_SOCK_UTIL_H 29 | 30 | #include 31 | #include 32 | 33 | /******************************************************************************* 34 | ** Functions 35 | ********************************************************************************/ 36 | 37 | static inline void init_slot_lock( pthread_mutex_t* mutex) 38 | { 39 | pthread_mutexattr_t attr; 40 | pthread_mutexattr_init(&attr); 41 | pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP); 42 | pthread_mutex_init(mutex, &attr); 43 | } 44 | 45 | static inline void lock_slot(pthread_mutex_t* mutex) 46 | { 47 | if(mutex->value) 48 | pthread_mutex_lock(mutex); 49 | else ALOGE("mutex: %p is not initialized", mutex); 50 | } 51 | 52 | static inline void unlock_slot(pthread_mutex_t* mutex) 53 | { 54 | if(mutex->value) 55 | pthread_mutex_unlock(mutex); 56 | else ALOGE("mutex: %p is not initialized", mutex); 57 | } 58 | 59 | void dump_bin(const char* title, const char* data, int size); 60 | 61 | int sock_send_fd(int sock_fd, const uint8_t* buffer, int len, int send_fd); 62 | int sock_send_all(int sock_fd, const uint8_t* buf, int len); 63 | int sock_recv_all(int sock_fd, uint8_t* buf, int len); 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /conf/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | LOCAL_MODULE := bt_stack.conf 5 | LOCAL_MODULE_CLASS := ETC 6 | LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/bluetooth 7 | LOCAL_MODULE_TAGS := optional 8 | LOCAL_SRC_FILES := $(LOCAL_MODULE) 9 | include $(BUILD_PREBUILT) 10 | 11 | 12 | include $(CLEAR_VARS) 13 | LOCAL_MODULE := bt_did.conf 14 | LOCAL_MODULE_CLASS := ETC 15 | LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/bluetooth 16 | LOCAL_MODULE_TAGS := optional 17 | LOCAL_SRC_FILES := $(LOCAL_MODULE) 18 | include $(BUILD_PREBUILT) 19 | 20 | 21 | include $(CLEAR_VARS) 22 | LOCAL_MODULE := auto_pair_devlist.conf 23 | LOCAL_MODULE_CLASS := ETC 24 | LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/bluetooth 25 | LOCAL_MODULE_TAGS := optional 26 | LOCAL_SRC_FILES := $(LOCAL_MODULE) 27 | include $(BUILD_PREBUILT) 28 | 29 | -------------------------------------------------------------------------------- /conf/auto_pair_devlist.conf: -------------------------------------------------------------------------------- 1 | # Do NOT change this file format without updating the parsing logic in 2 | # BT IF module implementation (btif_storage.c) 3 | 4 | # This file contains information to prevent auto pairing with Bluetooth devices. 5 | # Blacklisting by vendor prefix address: 6 | # The following companies are included in the list below: 7 | # ALPS (lexus), Murata (Prius 2007, Nokia 616), TEMIC SDS (Porsche, Audi), 8 | # Parrot, Zhongshan General K-mate Electronics, Great Well 9 | # Electronics, Flaircomm Electronics, Jatty Electronics, Delphi, 10 | # Clarion, Novero, Denso (Lexus, Toyota), Johnson Controls (Acura), 11 | # Continental Automotive, Harman/Becker, Panasonic/Kyushu Ten, 12 | # BMW (Motorola PCS), Visteon, Peugeot, BMW (MINI10013), Venza (Toyota) 13 | AddressBlacklist=00:02:C7,00:16:FE,00:19:C1,00:1B:FB,00:1E:3D,00:21:4F,00:23:06,00:24:33,00:A0:79,00:0E:6D,00:13:E0,00:21:E8,00:60:57,00:0E:9F,00:12:1C,00:18:91,00:18:96,00:13:04,00:16:FD,00:22:A0,00:0B:4C,00:60:6F,00:23:3D,00:C0:59,00:0A:30,00:1E:AE,00:1C:D7,00:80:F0,00:12:8A,00:09:93,00:80:37,00:26:7E,00:26:e8 14 | 15 | # Blacklisting by Exact Name: 16 | ExactNameBlacklist=Motorola IHF1000,i.TechBlueBAND,X5 Stereo v1.3,KML_CAN 17 | 18 | # Blacklisting by Partial Name (if name starts with) 19 | PartialNameBlacklist=BMW,Audi,Parrot,Car 20 | 21 | # Fixed PIN keyboard blacklist. Keyboards should have variable PIN 22 | # The keyboards below have a fixed PIN of 0000, so we will auto pair. 23 | # Note the reverse logic in this case compared to other's in this file 24 | # where its a blacklist for not auto pairing. 25 | FixedPinZerosKeyboardBlacklist=00:0F:F6 26 | 27 | # Blacklisting by addition of the address during usage 28 | -------------------------------------------------------------------------------- /conf/bt_did.conf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_external_bluetooth_bluedroid/5e99e49bb0c62169ac7a1f6a30ff16fa9fa38507/conf/bt_did.conf -------------------------------------------------------------------------------- /conf/bt_stack.conf: -------------------------------------------------------------------------------- 1 | # Enable BtSnoop logging function 2 | # valid value : true, false 3 | BtSnoopLogOutput=false 4 | 5 | # BtSnoop log output file 6 | BtSnoopFileName=/sdcard/btsnoop_hci.log 7 | 8 | # Preserve existing BtSnoop log before overwriting 9 | BtSnoopSaveLog=false 10 | 11 | # Enable trace level reconfiguration function 12 | # Must be present before any TRC_ trace level settings 13 | TraceConf=true 14 | 15 | # Trace level configuration 16 | # BT_TRACE_LEVEL_NONE 0 ( No trace messages to be generated ) 17 | # BT_TRACE_LEVEL_ERROR 1 ( Error condition trace messages ) 18 | # BT_TRACE_LEVEL_WARNING 2 ( Warning condition trace messages ) 19 | # BT_TRACE_LEVEL_API 3 ( API traces ) 20 | # BT_TRACE_LEVEL_EVENT 4 ( Debug messages for events ) 21 | # BT_TRACE_LEVEL_DEBUG 5 ( Full debug messages ) 22 | # BT_TRACE_LEVEL_VERBOSE 6 ( Verbose messages ) - Currently supported for TRC_BTAPP only. 23 | TRC_BTM=2 24 | TRC_HCI=2 25 | TRC_L2CAP=2 26 | TRC_RFCOMM=2 27 | TRC_OBEX=2 28 | TRC_AVCT=2 29 | TRC_AVDT=2 30 | TRC_AVRC=2 31 | TRC_AVDT_SCB=2 32 | TRC_AVDT_CCB=2 33 | TRC_A2D=2 34 | TRC_SDP=2 35 | TRC_GATT=2 36 | TRC_SMP=2 37 | TRC_BTAPP=2 38 | TRC_BTIF=2 39 | TRC_HID_HOST=2 40 | TRC_HID_DEV=2 41 | -------------------------------------------------------------------------------- /doc/btsnoop_net.md: -------------------------------------------------------------------------------- 1 | btsnoop_net 2 | ==== 3 | btsnoop_net exposes Bluetooth snoop logs over a local TCP socket which enables 4 | real-time debugging of HCI data with hcidump. 5 | 6 | This feature is enabled by setting `BtSnoopLogOutput=true` in `bt_stack.conf`. 7 | Once it has been enabled and the stack restarted, bluedroid will listen for 8 | incoming TCP connections on port 8872. 9 | 10 | To use this feature with hcidump on a Linux host, you can run: 11 | 12 | ``` 13 | $ adb forward tcp:8872 tcp:8872 14 | $ nc localhost 8872 | hcidump -r /dev/stdin 15 | ``` 16 | -------------------------------------------------------------------------------- /doc/properties.md: -------------------------------------------------------------------------------- 1 | Properties 2 | === 3 | This document describes all of the Android properties used by bluedroid. 4 | 5 | Please keep the following list in alphabetical order. 6 | 7 | ### TODO (Broadcom): write descriptions of what each property means and how 8 | it's used. 9 | 10 | * ``` debug.sys.noschedgroups ``` 11 | * ``` persist.service.bdroid.bdaddr ``` 12 | * ``` ro.bluetooth.hfp.ver ``` 13 | * ``` ro.bt.bdaddr_path ``` 14 | * ``` ro.product.model ``` 15 | * ``` service.brcm.bt.oob ``` 16 | -------------------------------------------------------------------------------- /embdrv/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(call all-subdir-makefiles) 4 | 5 | # Cleanup our locals 6 | #bdroid_C_INCLUDES := 7 | #bdroid_CFLaGS := 8 | -------------------------------------------------------------------------------- /embdrv/sbc/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(call all-subdir-makefiles) 4 | 5 | # Cleanup our locals 6 | #bdroid_C_INCLUDES := 7 | #bdroid_CFLaGS := 8 | -------------------------------------------------------------------------------- /embdrv/sbc/decoder/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | include $(CLEAR_VARS) 3 | 4 | # sbc decoder 5 | LOCAL_SRC_FILES+= \ 6 | ./srce/alloc.c \ 7 | ./srce/bitalloc.c \ 8 | ./srce/bitalloc-sbc.c \ 9 | ./srce/bitstream-decode.c \ 10 | ./srce/decoder-oina.c \ 11 | ./srce/decoder-private.c \ 12 | ./srce/decoder-sbc.c \ 13 | ./srce/dequant.c \ 14 | ./srce/framing.c \ 15 | ./srce/framing-sbc.c \ 16 | ./srce/oi_codec_version.c \ 17 | ./srce/synthesis-sbc.c \ 18 | ./srce/synthesis-dct8.c \ 19 | ./srce/synthesis-8-generated.c \ 20 | 21 | LOCAL_C_INCLUDES += $(LOCAL_PATH)/include 22 | LOCAL_C_INCLUDES += $(LOCAL_PATH)/srce 23 | 24 | LOCAL_MODULE:= libbt-qcom_sbc_decoder 25 | LOCAL_MODULE_TAGS := optional 26 | LOCAL_MODULE_CLASS := STATIC_LIBRARIES 27 | 28 | include $(BUILD_STATIC_LIBRARY) 29 | -------------------------------------------------------------------------------- /embdrv/sbc/decoder/include/oi_assert.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2014 The Android Open Source Project 4 | * Copyright 2002 - 2004 Open Interface North America, Inc. All rights reserved. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at: 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | ******************************************************************************/ 19 | #ifndef _OI_ASSERT_H 20 | #define _OI_ASSERT_H 21 | /** @file 22 | This file provides macros and functions for compile-time and run-time assertions. 23 | 24 | When the OI_DEBUG preprocessor value is defined, the macro OI_ASSERT is compiled into 25 | the program, providing for a runtime assertion failure check. 26 | C_ASSERT is a macro that can be used to perform compile time checks. 27 | */ 28 | /********************************************************************************** 29 | $Revision: #1 $ 30 | ***********************************************************************************/ 31 | 32 | 33 | /** \addtogroup Debugging Debugging APIs */ 34 | /**@{*/ 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | 41 | #ifdef OI_DEBUG 42 | 43 | /** The macro OI_ASSERT takes a condition argument. If the asserted condition 44 | does not evaluate to true, the OI_ASSERT macro calls the host-dependent function, 45 | OI_AssertFail(), which reports the failure and generates a runtime error. 46 | */ 47 | void OI_AssertFail(char* file, int line, char* reason); 48 | 49 | 50 | #define OI_ASSERT(condition) \ 51 | { if (!(condition)) OI_AssertFail(__FILE__, __LINE__, #condition); } 52 | 53 | #define OI_ASSERT_FAIL(msg) \ 54 | { OI_AssertFail(__FILE__, __LINE__, msg); } 55 | 56 | #else 57 | 58 | 59 | #define OI_ASSERT(condition) 60 | #define OI_ASSERT_FAIL(msg) 61 | 62 | #endif 63 | 64 | 65 | /** 66 | C_ASSERT() can be used to perform many compile-time assertions: type sizes, field offsets, etc. 67 | An assertion failure results in compile time error C2118: negative subscript. 68 | Unfortunately, this elegant macro doesn't work with GCC, so it's all commented out 69 | for now. Perhaps later..... 70 | */ 71 | 72 | #ifndef C_ASSERT 73 | // #define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1] 74 | // #define C_ASSERT(e) 75 | #endif 76 | 77 | 78 | /*****************************************************************************/ 79 | #ifdef __cplusplus 80 | } 81 | #endif 82 | 83 | /**@}*/ 84 | 85 | #endif /* _OI_ASSERT_H */ 86 | 87 | -------------------------------------------------------------------------------- /embdrv/sbc/decoder/include/oi_common.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2014 The Android Open Source Project 4 | * Copyright 2002 - 2004 Open Interface North America, Inc. All rights reserved. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at: 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | ******************************************************************************/ 19 | #ifndef _OI_COMMON_H 20 | #define _OI_COMMON_H 21 | /** 22 | * @file 23 | * 24 | * This file is used to group commonly used BLUEmagic 3.0 software 25 | * header files. 26 | * 27 | * This file should be included in application source code along with the header 28 | * files for the specific modules of the protocol stack being used. 29 | */ 30 | 31 | /********************************************************************************** 32 | $Revision: #1 $ 33 | ***********************************************************************************/ 34 | 35 | #include "oi_bt_spec.h" 36 | #include "oi_stddefs.h" 37 | #include "oi_status.h" 38 | #include "oi_time.h" 39 | #include "oi_osinterface.h" 40 | 41 | 42 | /*****************************************************************************/ 43 | #endif /* _OI_COMMON_H */ 44 | -------------------------------------------------------------------------------- /embdrv/sbc/decoder/srce/alloc.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2014 The Android Open Source Project 4 | * Copyright 2003 - 2004 Open Interface North America, Inc. All rights reserved. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at: 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | ******************************************************************************/ 19 | 20 | #include 21 | #include 22 | 23 | /********************************************************************************** 24 | $Revision: #1 $ 25 | ***********************************************************************************/ 26 | 27 | PRIVATE OI_STATUS OI_CODEC_SBC_Alloc(OI_CODEC_SBC_COMMON_CONTEXT *common, 28 | OI_UINT32 *codecDataAligned, 29 | OI_UINT32 codecDataBytes, 30 | OI_UINT8 maxChannels, 31 | OI_UINT8 pcmStride) 32 | { 33 | int i; 34 | size_t filterBufferCount; 35 | size_t subdataSize; 36 | OI_BYTE *codecData = (OI_BYTE*)codecDataAligned; 37 | 38 | if (maxChannels < 1 || maxChannels > 2) { 39 | return OI_STATUS_INVALID_PARAMETERS; 40 | } 41 | 42 | if (pcmStride < 1 || pcmStride > maxChannels) { 43 | return OI_STATUS_INVALID_PARAMETERS; 44 | } 45 | 46 | common->maxChannels = maxChannels; 47 | common->pcmStride = pcmStride; 48 | 49 | /* Compute sizes needed for the memory regions, and bail if we don't have 50 | * enough memory for them. */ 51 | subdataSize = maxChannels * sizeof(common->subdata[0]) * SBC_MAX_BANDS * SBC_MAX_BLOCKS; 52 | if (subdataSize > codecDataBytes) { 53 | return OI_STATUS_OUT_OF_MEMORY; 54 | } 55 | 56 | filterBufferCount = (codecDataBytes - subdataSize) / (sizeof(common->filterBuffer[0][0]) * SBC_MAX_BANDS * maxChannels); 57 | if (filterBufferCount < SBC_CODEC_MIN_FILTER_BUFFERS) { 58 | return OI_STATUS_OUT_OF_MEMORY; 59 | } 60 | common->filterBufferLen = filterBufferCount * SBC_MAX_BANDS; 61 | 62 | /* Allocate memory for the subband data */ 63 | common->subdata = (OI_INT32*)codecData; 64 | codecData += subdataSize; 65 | OI_ASSERT(codecDataBytes >= subdataSize); 66 | codecDataBytes -= subdataSize; 67 | 68 | /* Allocate memory for the synthesis buffers */ 69 | for (i = 0; i < maxChannels; ++i) { 70 | size_t allocSize = common->filterBufferLen * sizeof(common->filterBuffer[0][0]); 71 | common->filterBuffer[i] = (SBC_BUFFER_T*)codecData; 72 | OI_ASSERT(codecDataBytes >= allocSize); 73 | codecData += allocSize; 74 | codecDataBytes -= allocSize; 75 | } 76 | 77 | return OI_OK; 78 | } 79 | -------------------------------------------------------------------------------- /embdrv/sbc/decoder/srce/bitstream-decode.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2014 The Android Open Source Project 4 | * Copyright 2003 - 2004 Open Interface North America, Inc. All rights reserved. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at: 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | ******************************************************************************/ 19 | 20 | /********************************************************************************** 21 | $Revision: #1 $ 22 | ***********************************************************************************/ 23 | 24 | /** 25 | @file 26 | Functions for manipulating input bitstreams. 27 | 28 | @ingroup codec_internal 29 | */ 30 | 31 | /** 32 | @addtogroup codec_internal 33 | @{ 34 | */ 35 | 36 | #include "oi_stddefs.h" 37 | #include "oi_bitstream.h" 38 | #include "oi_assert.h" 39 | 40 | PRIVATE void OI_BITSTREAM_ReadInit(OI_BITSTREAM *bs, 41 | const OI_BYTE *buffer) 42 | { 43 | bs->value = ((OI_INT32)buffer[0] << 16) | ((OI_INT32)buffer[1] << 8) | (buffer[2]); 44 | bs->ptr.r = buffer + 3; 45 | bs->bitPtr = 8; 46 | } 47 | 48 | PRIVATE OI_UINT32 OI_BITSTREAM_ReadUINT(OI_BITSTREAM *bs, OI_UINT bits) 49 | { 50 | OI_UINT32 result; 51 | 52 | OI_BITSTREAM_READUINT(result, bits, bs->ptr.r, bs->value, bs->bitPtr); 53 | 54 | return result; 55 | } 56 | 57 | PRIVATE OI_UINT8 OI_BITSTREAM_ReadUINT4Aligned(OI_BITSTREAM *bs) 58 | { 59 | OI_UINT32 result; 60 | 61 | OI_ASSERT(bs->bitPtr < 16); 62 | OI_ASSERT(bs->bitPtr % 4 == 0); 63 | 64 | if (bs->bitPtr == 8) { 65 | result = bs->value << 8; 66 | bs->bitPtr = 12; 67 | } else { 68 | result = bs->value << 12; 69 | bs->value = (bs->value << 8) | *bs->ptr.r++; 70 | bs->bitPtr = 8; 71 | } 72 | result >>= 28; 73 | OI_ASSERT(result < (1u << 4)); 74 | return (OI_UINT8)result; 75 | } 76 | 77 | PRIVATE OI_UINT8 OI_BITSTREAM_ReadUINT8Aligned(OI_BITSTREAM *bs) 78 | { 79 | OI_UINT32 result; 80 | OI_ASSERT(bs->bitPtr == 8); 81 | 82 | result = bs->value >> 16; 83 | bs->value = (bs->value << 8) | *bs->ptr.r++; 84 | 85 | return (OI_UINT8)result; 86 | } 87 | 88 | /** 89 | @} 90 | */ 91 | 92 | 93 | -------------------------------------------------------------------------------- /embdrv/sbc/decoder/srce/framing-sbc.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2014 The Android Open Source Project 4 | * Copyright 2003 - 2004 Open Interface North America, Inc. All rights reserved. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at: 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | ******************************************************************************/ 19 | 20 | /********************************************************************************** 21 | $Revision: #1 $ 22 | ***********************************************************************************/ 23 | 24 | /** @file 25 | @ingroup codec_internal 26 | */ 27 | 28 | /**@addgroup codec_internal*/ 29 | /**@{*/ 30 | 31 | #include "oi_codec_sbc_private.h" 32 | 33 | const OI_CHAR* const OI_CODEC_SBC_FreqText[] = { "SBC_FREQ_16000", "SBC_FREQ_32000", "SBC_FREQ_44100", "SBC_FREQ_48000" }; 34 | const OI_CHAR* const OI_CODEC_SBC_ModeText[] = { "SBC_MONO", "SBC_DUAL_CHANNEL", "SBC_STEREO", "SBC_JOINT_STEREO" }; 35 | const OI_CHAR* const OI_CODEC_SBC_SubbandsText[] = { "SBC_SUBBANDS_4", "SBC_SUBBANDS_8" }; 36 | const OI_CHAR* const OI_CODEC_SBC_BlocksText[] = { "SBC_BLOCKS_4", "SBC_BLOCKS_8", "SBC_BLOCKS_12", "SBC_BLOCKS_16" }; 37 | const OI_CHAR* const OI_CODEC_SBC_AllocText[] = { "SBC_LOUDNESS", "SBC_SNR" }; 38 | 39 | #ifdef OI_DEBUG 40 | void OI_CODEC_SBC_DumpConfig(OI_CODEC_SBC_FRAME_INFO *frameInfo) 41 | { 42 | printf("SBC configuration\n"); 43 | printf(" enhanced: %s\n", frameInfo->enhanced ? "TRUE" : "FALSE"); 44 | printf(" frequency: %d\n", frameInfo->frequency); 45 | printf(" subbands: %d\n", frameInfo->nrof_subbands); 46 | printf(" blocks: %d\n", frameInfo->nrof_blocks); 47 | printf(" channels: %d\n", frameInfo->nrof_channels); 48 | printf(" mode: %s\n", OI_CODEC_SBC_ModeText[frameInfo->mode]); 49 | printf(" alloc: %s\n", OI_CODEC_SBC_AllocText[frameInfo->alloc]); 50 | printf(" bitpool: %d\n", frameInfo->bitpool); 51 | } 52 | #endif /* OI_DEBUG */ 53 | 54 | /**@}*/ 55 | -------------------------------------------------------------------------------- /embdrv/sbc/decoder/srce/oi_codec_version.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2014 The Android Open Source Project 4 | * Copyright 2002 - 2004 Open Interface North America, Inc. All rights reserved. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at: 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | ******************************************************************************/ 19 | 20 | /** 21 | @file 22 | This file contains a single function, which returns a string indicating the 23 | version number of the eSBC codec 24 | 25 | @ingroup codec_internal 26 | */ 27 | 28 | /** 29 | @addtogroup codec_internal 30 | @{ 31 | */ 32 | 33 | /********************************************************************************** 34 | $Revision: #1 $ 35 | ***********************************************************************************/ 36 | 37 | #include "oi_stddefs.h" 38 | #include "oi_codec_sbc_private.h" 39 | 40 | /** Version string for the BLUEmagic 3.0 protocol stack and profiles */ 41 | PRIVATE OI_CHAR * const codecVersion = "v1.5" 42 | #ifdef OI_SBC_EVAL 43 | " (Evaluation version)" 44 | #endif 45 | ; 46 | 47 | /** This function returns the version string for the BLUEmagic 3.0 protocol stack 48 | and profiles */ 49 | OI_CHAR *OI_CODEC_Version(void) { 50 | return codecVersion; 51 | } 52 | 53 | /**********************************************************************************/ 54 | 55 | /** 56 | @} 57 | */ 58 | -------------------------------------------------------------------------------- /embdrv/sbc/encoder/include/sbc_enc_func_declare.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 1999-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 | * Function declarations. 22 | * 23 | ******************************************************************************/ 24 | 25 | #ifndef SBC_FUNCDECLARE_H 26 | #define SBC_FUNCDECLARE_H 27 | 28 | /*#include "sbc_encoder.h"*/ 29 | /* Global data */ 30 | #if (SBC_IS_64_MULT_IN_WINDOW_ACCU == FALSE) 31 | extern const SINT16 gas32CoeffFor4SBs[]; 32 | extern const SINT16 gas32CoeffFor8SBs[]; 33 | #else 34 | extern const SINT32 gas32CoeffFor4SBs[]; 35 | extern const SINT32 gas32CoeffFor8SBs[]; 36 | #endif 37 | 38 | /* Global functions*/ 39 | 40 | extern void sbc_enc_bit_alloc_mono(SBC_ENC_PARAMS *CodecParams); 41 | extern void sbc_enc_bit_alloc_ste(SBC_ENC_PARAMS *CodecParams); 42 | 43 | extern void SbcAnalysisInit (void); 44 | 45 | extern void SbcAnalysisFilter4(SBC_ENC_PARAMS *strEncParams); 46 | extern void SbcAnalysisFilter8(SBC_ENC_PARAMS *strEncParams); 47 | 48 | extern void SBC_FastIDCT8 (SINT32 *pInVect, SINT32 *pOutVect); 49 | extern void SBC_FastIDCT4 (SINT32 *x0, SINT32 *pOutVect); 50 | 51 | extern void EncPacking(SBC_ENC_PARAMS *strEncParams); 52 | extern void EncQuantizer(SBC_ENC_PARAMS *); 53 | #if (SBC_DSP_OPT==TRUE) 54 | SINT32 SBC_Multiply_32_16_Simplified(SINT32 s32In2Temp,SINT32 s32In1Temp); 55 | #endif 56 | #endif 57 | 58 | -------------------------------------------------------------------------------- /embdrv/sbc/encoder/include/sbc_if.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 1999-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 _SBC_IF_H 20 | #define _SBC_IF_H 21 | 22 | #define PCM_BUFFER_SIZE 512 23 | 24 | /* 25 | SBC_Init - called once for each track played 26 | 27 | pcm_sample_freq - 4000 to 48000 28 | channels - 1 mono 2 stereo 29 | bits_per_sample - 8 or 16 30 | return - 0 sucess 31 | */ 32 | 33 | int SBC_init(int pcm_sample_freq, int channels, int bits_per_sample); 34 | 35 | /* 36 | SBC_write - called repeatedly with pcm_in pointer 37 | increasing by length until track is finished. 38 | 39 | pcm_in - pointer to PCM buffer 40 | length - any 41 | sbc_out - pointer to SBC output buffer 42 | return - number of bytes written to sbc_out 43 | */ 44 | 45 | int SBC_write(unsigned char *pcm_in, int length, unsigned char *sbc_out); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /embdrv/sbc/encoder/include/sbc_types.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 1999-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 | * Data type declarations. 22 | * 23 | ******************************************************************************/ 24 | 25 | #ifndef SBC_TYPES_H 26 | #define SBC_TYPES_H 27 | 28 | #ifdef BUILDCFG 29 | #include "bt_target.h" 30 | #endif 31 | 32 | #include "data_types.h" 33 | 34 | typedef short SINT16; 35 | typedef long SINT32; 36 | 37 | #if (SBC_IPAQ_OPT == TRUE) 38 | 39 | #if (SBC_FOR_EMBEDDED_LINUX == TRUE) 40 | typedef long long SINT64; 41 | #else 42 | typedef __int64 SINT64; 43 | #endif 44 | 45 | #elif (SBC_IS_64_MULT_IN_WINDOW_ACCU == TRUE) || (SBC_IS_64_MULT_IN_IDCT == TRUE) 46 | 47 | #if (SBC_FOR_EMBEDDED_LINUX == TRUE) 48 | typedef long long SINT64; 49 | #else 50 | typedef __int64 SINT64; 51 | #endif 52 | 53 | #endif 54 | 55 | #define abs32(x) ( (x >= 0) ? x : (-x) ) 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /gki/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_C_INCLUDES := \ 6 | $(LOCAL_PATH)/common \ 7 | $(LOCAL_PATH)/ulinux \ 8 | $(LOCAL_PATH)/../include \ 9 | $(LOCAL_PATH)/../stack/include \ 10 | $(LOCAL_PATH)/../utils/include \ 11 | $(bdroid_C_INCLUDES) 12 | 13 | LOCAL_CFLAGS += -Wno-error=unused-parameter $(bdroid_CFLAGS) -std=c99 14 | 15 | ifeq ($(BOARD_HAVE_BLUETOOTH_BCM),true) 16 | LOCAL_CFLAGS += \ 17 | -DBOARD_HAVE_BLUETOOTH_BCM 18 | endif 19 | 20 | LOCAL_PRELINK_MODULE := false 21 | LOCAL_SRC_FILES := \ 22 | ./common/gki_buffer.c \ 23 | ./common/gki_debug.c \ 24 | ./common/gki_time.c \ 25 | ./ulinux/gki_ulinux.c 26 | 27 | LOCAL_MODULE := libbt-brcm_gki 28 | LOCAL_MODULE_TAGS := optional 29 | LOCAL_MODULE_CLASS := STATIC_LIBRARIES 30 | LOCAL_MULTILIB := 32 31 | 32 | include $(BUILD_STATIC_LIBRARY) 33 | -------------------------------------------------------------------------------- /gki/ulinux/data_types.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 1999-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 DATA_TYPES_H 20 | #define DATA_TYPES_H 21 | 22 | #include 23 | #include 24 | 25 | #ifndef FALSE 26 | # define FALSE false 27 | #endif 28 | 29 | #ifndef TRUE 30 | # define TRUE true 31 | #endif 32 | 33 | typedef uint8_t UINT8; 34 | typedef uint16_t UINT16; 35 | typedef uint32_t UINT32; 36 | typedef uint64_t UINT64; 37 | 38 | typedef int8_t INT8; 39 | typedef int16_t INT16; 40 | typedef int32_t INT32; 41 | typedef bool BOOLEAN; 42 | 43 | typedef UINT32 TIME_STAMP; 44 | 45 | #ifdef __arm 46 | # define PACKED __packed 47 | # define INLINE __inline 48 | #else 49 | # define PACKED 50 | # define INLINE 51 | #endif 52 | 53 | #define BCM_STRCPY_S(x1,x2,x3) strcpy((x1),(x3)) 54 | #define BCM_STRNCPY_S(x1,x2,x3,x4) strncpy((x1),(x3),(x4)) 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /gki/ulinux/gki_int.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 1999-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 | #ifndef GKI_INT_H 19 | #define GKI_INT_H 20 | 21 | #include "gki_common.h" 22 | #include 23 | #include 24 | 25 | /********************************************************************** 26 | ** OS specific definitions 27 | */ 28 | /* The base priority used for pthread based GKI task. below value is to keep it retro compatible. 29 | * It is recommended to use (GKI_MAX_TASKS+3), this will assign real time priorities GKI_MAX_TASKS- 30 | * task_id -2 to the thread */ 31 | #ifndef GKI_LINUX_BASE_PRIORITY 32 | #define GKI_LINUX_BASE_PRIORITY 30 33 | #endif 34 | 35 | /* The base policy used for pthread based GKI task. the sched defines are defined here to avoid undefined values due 36 | * to missing header file, see pthread functions! Overall it is recommend however to use SCHED_NOMRAL */ 37 | #define GKI_SCHED_NORMAL 0 38 | #define GKI_SCHED_FIFO 1 39 | #define GKI_SCHED_RR 2 40 | #ifndef GKI_LINUX_BASE_POLICY 41 | #define GKI_LINUX_BASE_POLICY GKI_SCHED_NORMAL 42 | #endif 43 | 44 | /* GKI timer bases should use GKI_SCHED_FIFO to ensure the least jitter possible */ 45 | #ifndef GKI_LINUX_TIMER_POLICY 46 | #define GKI_LINUX_TIMER_POLICY GKI_SCHED_FIFO 47 | #endif 48 | 49 | /* the GKI_timer_update() thread should have the highest real time priority to ensue correct 50 | * timer expiry. 51 | */ 52 | #ifndef GKI_LINUX_TIMER_TICK_PRIORITY 53 | #define GKI_LINUX_TIMER_TICK_PRIORITY GKI_LINUX_BASE_PRIORITY+2 54 | #endif 55 | 56 | typedef struct 57 | { 58 | pthread_mutex_t GKI_mutex; 59 | pthread_t thread_id[GKI_MAX_TASKS]; 60 | pthread_mutex_t thread_evt_mutex[GKI_MAX_TASKS]; 61 | pthread_cond_t thread_evt_cond[GKI_MAX_TASKS]; 62 | pthread_mutex_t thread_timeout_mutex[GKI_MAX_TASKS]; 63 | pthread_cond_t thread_timeout_cond[GKI_MAX_TASKS]; 64 | #if (GKI_DEBUG == TRUE) 65 | pthread_mutex_t GKI_trace_mutex; 66 | #endif 67 | } tGKI_OS; 68 | 69 | extern void gki_system_tick_start_stop_cback(BOOLEAN start); 70 | 71 | /* Contains common control block as well as OS specific variables */ 72 | typedef struct 73 | { 74 | tGKI_OS os; 75 | tGKI_COM_CB com; 76 | } tGKI_CB; 77 | 78 | 79 | #ifdef __cplusplus 80 | extern "C" { 81 | #endif 82 | 83 | #if GKI_DYNAMIC_MEMORY == FALSE 84 | GKI_API extern tGKI_CB gki_cb; 85 | #else 86 | GKI_API extern tGKI_CB *gki_cb_ptr; 87 | #define gki_cb (*gki_cb_ptr) 88 | #endif 89 | 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /hci/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_CFLAGS += $(bdroid_CFLAGS) 6 | 7 | LOCAL_SRC_FILES := \ 8 | src/bt_hci_bdroid.c \ 9 | src/btsnoop.c \ 10 | src/btsnoop_net.c \ 11 | src/lpm.c \ 12 | src/utils.c \ 13 | src/vendor.c 14 | 15 | LOCAL_CFLAGS := -Wno-unused-parameter 16 | 17 | ifeq ($(BLUETOOTH_HCI_USE_MCT),true) 18 | 19 | LOCAL_CFLAGS += -DHCI_USE_MCT 20 | 21 | ifeq ($(QCOM_BT_USE_SMD_TTY),true) 22 | 23 | LOCAL_CFLAGS += -DQCOM_WCN_SSR 24 | 25 | endif 26 | 27 | LOCAL_SRC_FILES += \ 28 | src/hci_mct.c \ 29 | src/userial_mct.c 30 | 31 | else 32 | LOCAL_SRC_FILES += \ 33 | src/hci_h4.c \ 34 | src/userial.c 35 | endif 36 | 37 | LOCAL_CFLAGS += -std=c99 38 | 39 | LOCAL_C_INCLUDES += \ 40 | $(LOCAL_PATH)/include \ 41 | $(LOCAL_PATH)/../osi/include \ 42 | $(LOCAL_PATH)/../utils/include \ 43 | $(bdroid_C_INCLUDES) 44 | 45 | LOCAL_MODULE := libbt-hci 46 | LOCAL_MODULE_TAGS := optional 47 | LOCAL_MODULE_CLASS := STATIC_LIBRARIES 48 | 49 | include $(BUILD_STATIC_LIBRARY) 50 | -------------------------------------------------------------------------------- /hci/include/btsnoop.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "bt_hci_bdroid.h" 6 | 7 | void btsnoop_open(const char *p_path, const bool save_existing); 8 | void btsnoop_close(void); 9 | 10 | void btsnoop_capture(const HC_BT_HDR *p_buf, bool is_rcvd); 11 | -------------------------------------------------------------------------------- /hci/include/hci.h: -------------------------------------------------------------------------------- 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 | /****************************************************************************** 20 | * 21 | * Filename: hci.h 22 | * 23 | * Description: Contains definitions used for HCI transport controls 24 | * 25 | ******************************************************************************/ 26 | 27 | #ifndef HCI_H 28 | #define HCI_H 29 | 30 | /****************************************************************************** 31 | ** Constants & Macros 32 | ******************************************************************************/ 33 | 34 | /****************************************************************************** 35 | ** Type definitions 36 | ******************************************************************************/ 37 | 38 | /** Prototypes for HCI Service interface functions **/ 39 | 40 | /* Initialize transport's control block */ 41 | typedef void (*tHCI_INIT)(void); 42 | 43 | /* Do transport's control block clean-up */ 44 | typedef void (*tHCI_CLEANUP)(void); 45 | 46 | /* Send HCI command/data to the transport */ 47 | typedef void (*tHCI_SEND)(HC_BT_HDR *p_msg); 48 | 49 | /* Handler for HCI upstream path */ 50 | typedef uint16_t (*tHCI_RCV)(void); 51 | 52 | /* Callback function for the returned event of internally issued command */ 53 | typedef void (*tINT_CMD_CBACK)(void *p_mem); 54 | 55 | /* Handler for sending HCI command from the local module */ 56 | typedef uint8_t (*tHCI_SEND_INT)(uint16_t opcode, HC_BT_HDR *p_buf, \ 57 | tINT_CMD_CBACK p_cback); 58 | 59 | /* Handler for getting acl data length */ 60 | typedef void (*tHCI_ACL_DATA_LEN_HDLR)(void); 61 | 62 | /****************************************************************************** 63 | ** Extern variables and functions 64 | ******************************************************************************/ 65 | 66 | typedef struct { 67 | tHCI_INIT init; 68 | tHCI_CLEANUP cleanup; 69 | tHCI_SEND send; 70 | tHCI_SEND_INT send_int_cmd; 71 | tHCI_ACL_DATA_LEN_HDLR get_acl_max_len; 72 | #ifdef HCI_USE_MCT 73 | tHCI_RCV evt_rcv; 74 | tHCI_RCV acl_rcv; 75 | #else 76 | tHCI_RCV rcv; 77 | #endif 78 | } tHCI_IF; 79 | 80 | /****************************************************************************** 81 | ** Functions 82 | ******************************************************************************/ 83 | 84 | 85 | #endif /* HCI_H */ 86 | 87 | -------------------------------------------------------------------------------- /hci/include/userial.h: -------------------------------------------------------------------------------- 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 | // This module manages the serial port over which HCI commands 20 | // and data are sent/received. 21 | 22 | #pragma once 23 | 24 | #include 25 | #include 26 | 27 | typedef enum { 28 | USERIAL_PORT_1, 29 | USERIAL_PORT_2, 30 | USERIAL_PORT_3, 31 | USERIAL_PORT_4, 32 | USERIAL_PORT_5, 33 | USERIAL_PORT_6, 34 | USERIAL_PORT_7, 35 | USERIAL_PORT_8, 36 | USERIAL_PORT_9, 37 | USERIAL_PORT_10, 38 | USERIAL_PORT_11, 39 | USERIAL_PORT_12, 40 | USERIAL_PORT_13, 41 | USERIAL_PORT_14, 42 | USERIAL_PORT_15, 43 | USERIAL_PORT_16, 44 | USERIAL_PORT_17, 45 | USERIAL_PORT_18, 46 | } userial_port_t; 47 | 48 | // Initializes the userial module. This function should only ever be called once. 49 | // It returns true if the module could be initialized, false if there was an error. 50 | bool userial_init(void); 51 | 52 | // Opens the given serial port. Returns true if successful, false otherwise. 53 | // Once this function is called, the userial module will begin producing 54 | // buffers from data read off the serial port. If you wish to pause the 55 | // production of buffers, call |userial_pause_reading|. You can then resume 56 | // by calling |userial_resume_reading|. This function returns true if the 57 | // serial port was successfully opened and buffer production has started. It 58 | // returns false if there was an error. 59 | bool userial_open(userial_port_t port); 60 | void userial_close(void); 61 | void userial_close_reader(void); 62 | 63 | // Reads a maximum of |len| bytes from the serial port into |p_buffer|. 64 | // This function returns the number of bytes actually read, which may be 65 | // less than |len|. This function will not block. 66 | uint16_t userial_read(uint16_t msg_id, uint8_t *p_buffer, uint16_t len); 67 | 68 | // Writes a maximum of |len| bytes from |p_data| to the serial port. 69 | // This function returns the number of bytes actually written, which may be 70 | // less than |len|. This function may block. 71 | uint16_t userial_write(uint16_t msg_id, const uint8_t *p_data, uint16_t len); 72 | 73 | #ifdef QCOM_WCN_SSR 74 | uint8_t userial_dev_inreset(); 75 | #endif 76 | -------------------------------------------------------------------------------- /hci/include/vendor.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2014 Google, Inc. 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 | #pragma once 20 | 21 | #include 22 | #include 23 | 24 | #include "bt_vendor_lib.h" 25 | 26 | // Opens the vendor-specific library and sets the Bluetooth 27 | // address of the adapter to |local_bdaddr|. 28 | bool vendor_open(const uint8_t *local_bdaddr); 29 | 30 | // Closes the vendor-specific library and frees all associated resources. 31 | // Only |vendor_open| may be called after |vendor_close|. 32 | void vendor_close(void); 33 | 34 | // SSR cleanup to close transport FDs and power off the chip 35 | // This function is invoked to recover from error enabling/disabling BT 36 | // and to during hardware failure 37 | void vendor_ssrcleanup(void); 38 | 39 | // Sends a vendor-specific command to the library. 40 | int vendor_send_command(bt_vendor_opcode_t opcode, void *param); 41 | -------------------------------------------------------------------------------- /osi/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_C_INCLUDES := \ 6 | $(LOCAL_PATH)/include 7 | 8 | LOCAL_SRC_FILES := \ 9 | ./src/alarm.c \ 10 | ./src/config.c \ 11 | ./src/fixed_queue.c \ 12 | ./src/list.c \ 13 | ./src/reactor.c \ 14 | ./src/semaphore.c \ 15 | ./src/thread.c 16 | 17 | LOCAL_CFLAGS := -std=c99 -Wall -Werror 18 | LOCAL_MODULE := libosi 19 | LOCAL_MODULE_TAGS := optional 20 | LOCAL_SHARED_LIBRARIES := libc liblog 21 | LOCAL_MODULE_CLASS := STATIC_LIBRARIES 22 | 23 | include $(BUILD_STATIC_LIBRARY) 24 | 25 | ##################################################### 26 | 27 | include $(CLEAR_VARS) 28 | 29 | LOCAL_C_INCLUDES := \ 30 | $(LOCAL_PATH)/include 31 | 32 | LOCAL_SRC_FILES := \ 33 | ./test/alarm_test.cpp \ 34 | ./test/config_test.cpp \ 35 | ./test/list_test.cpp \ 36 | ./test/reactor_test.cpp \ 37 | ./test/thread_test.cpp 38 | 39 | LOCAL_CFLAGS := -Wall -Werror 40 | LOCAL_MODULE := ositests 41 | LOCAL_MODULE_TAGS := tests 42 | LOCAL_SHARED_LIBRARIES := liblog 43 | LOCAL_STATIC_LIBRARIES := libosi 44 | 45 | include $(BUILD_NATIVE_TEST) 46 | -------------------------------------------------------------------------------- /osi/include/alarm.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2014 Google, Inc. 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 | #pragma once 20 | 21 | typedef struct alarm_t alarm_t; 22 | typedef uint64_t period_ms_t; 23 | 24 | // Prototype for the callback function. 25 | typedef void (*alarm_callback_t)(void *data); 26 | 27 | // Creates a new alarm object. The returned object must be freed by calling 28 | // |alarm_free|. Returns NULL on failure. 29 | alarm_t *alarm_new(void); 30 | 31 | // Frees an alarm object created by |alarm_new|. |alarm| may be NULL. If the 32 | // alarm is pending, it will be cancelled. It is not safe to call |alarm_free| 33 | // from inside the callback of |alarm|. 34 | void alarm_free(alarm_t *alarm); 35 | 36 | // Sets an alarm to fire |cb| after the given |deadline|. Note that |deadline| is the 37 | // number of milliseconds relative to the current time. |data| is a context variable 38 | // for the callback and may be NULL. |cb| will be called back in the context of an 39 | // unspecified thread (i.e. it will not be called back in the same thread as the caller). 40 | // |alarm| and |cb| may not be NULL. 41 | void alarm_set(alarm_t *alarm, period_ms_t deadline, alarm_callback_t cb, void *data); 42 | 43 | // This function cancels the |alarm| if it was previously set. When this call 44 | // returns, the caller has a guarantee that the callback is not in progress and 45 | // will not be called if it hasn't already been called. This function is idempotent. 46 | // |alarm| may not be NULL. 47 | void alarm_cancel(alarm_t *alarm); 48 | -------------------------------------------------------------------------------- /osi/include/list.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | struct list_node_t; 7 | typedef struct list_node_t list_node_t; 8 | 9 | struct list_t; 10 | typedef struct list_t list_t; 11 | 12 | typedef void (*list_free_cb)(void *data); 13 | typedef bool (*list_iter_cb)(void *data); 14 | typedef bool (*list_iter_cb_ext)(void *data, void *cb_data); 15 | 16 | // Lifecycle. 17 | list_t *list_new(list_free_cb callback); 18 | void list_free(list_t *list); 19 | 20 | // Accessors. 21 | bool list_is_empty(const list_t *list); 22 | size_t list_length(const list_t *list); 23 | void *list_front(const list_t *list); 24 | void *list_back(const list_t *list); 25 | 26 | // Mutators. 27 | bool list_insert_after(list_t *list, list_node_t *prev_node, void *data); 28 | bool list_prepend(list_t *list, void *data); 29 | bool list_append(list_t *list, void *data); 30 | bool list_remove(list_t *list, void *data); 31 | void list_clear(list_t *list); 32 | 33 | // Iteration. 34 | void list_foreach(const list_t *list, list_iter_cb callback); 35 | void list_foreach_ext(const list_t *list, list_iter_cb_ext callback, void *cb_data); 36 | 37 | list_node_t *list_begin(const list_t *list); 38 | list_node_t *list_end(const list_t *list); 39 | list_node_t *list_next(const list_node_t *node); 40 | void *list_node(const list_node_t *node); 41 | -------------------------------------------------------------------------------- /osi/include/osi.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #define UNUSED_ATTR __attribute__((unused)) 7 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 8 | 9 | typedef uint32_t timeout_t; 10 | -------------------------------------------------------------------------------- /osi/include/semaphore.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2014 Google, Inc. 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 | #pragma once 20 | 21 | #include 22 | 23 | struct semaphore_t; 24 | typedef struct semaphore_t semaphore_t; 25 | 26 | // Creates a new semaphore with an initial value of |value|. 27 | // Returns NULL on failure. The returned object must be released 28 | // with |semaphore_free|. 29 | semaphore_t *semaphore_new(unsigned int value); 30 | 31 | // Frees a semaphore allocated with |semaphore_new|. |semaphore| may 32 | // be NULL. 33 | void semaphore_free(semaphore_t *semaphore); 34 | 35 | // Decrements the value of |semaphore|. If it is 0, this call blocks until 36 | // it becomes non-zero. |semaphore| may not be NULL. 37 | void semaphore_wait(semaphore_t *semaphore); 38 | 39 | // Tries to decrement the value of |semaphore|. Returns true if the value was 40 | // decremented, false if the value was 0. This function never blocks. |semaphore| 41 | // may not be NULL. 42 | bool semaphore_try_wait(semaphore_t *semaphore); 43 | 44 | // Increments the value of |semaphore|. |semaphore| may not be NULL. 45 | void semaphore_post(semaphore_t *semaphore); 46 | 47 | // Returns a file descriptor representing this semaphore. The caller may 48 | // only perform one operation on the file descriptor: select(2). If |select| 49 | // indicates the fd is readable, the caller may call |semaphore_wait| 50 | // without blocking. If select indicates the fd is writable, the caller may 51 | // call |semaphore_post| without blocking. Note that there may be a race 52 | // condition between calling |select| and |semaphore_wait| or |semaphore_post| 53 | // which results in blocking behaviour. 54 | // 55 | // The caller must not close the returned file descriptor. |semaphore| may not 56 | // be NULL. 57 | int semaphore_get_fd(const semaphore_t *semaphore); 58 | -------------------------------------------------------------------------------- /osi/include/thread.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2014 Google, Inc. 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 | #pragma once 20 | 21 | #define THREAD_NAME_MAX 16 22 | 23 | typedef struct thread_t thread_t; 24 | typedef void (*thread_fn)(void *context); 25 | 26 | // Creates and starts a new thread with the given name. Only THREAD_NAME_MAX 27 | // bytes from |name| will be assigned to the newly-created thread. Returns a 28 | // thread object if the thread was successfully started, NULL otherwise. The 29 | // returned thread object must be freed with |thread_free|. |name| may not 30 | // be NULL. 31 | thread_t *thread_new(const char *name); 32 | 33 | // Frees the given |thread|. If the thread is still running, it is stopped 34 | // and the calling thread will block until |thread| terminates. |thread| 35 | // may be NULL. 36 | void thread_free(thread_t *thread); 37 | 38 | // Call |func| with the argument |context| on |thread|. This function typically 39 | // does not block unless there are an excessive number of functions posted to 40 | // |thread| that have not been dispatched yet. Neither |thread| nor |func| may 41 | // be NULL. |context| may be NULL. 42 | bool thread_post(thread_t *thread, thread_fn func, void *context); 43 | 44 | // Requests |thread| to stop. Only |thread_free| and |thread_name| may be called 45 | // after calling |thread_stop|. This function is guaranteed to not block. 46 | // |thread| may not be NULL. 47 | void thread_stop(thread_t *thread); 48 | 49 | // Returns the name of the given |thread|. |thread| may not be NULL. 50 | const char *thread_name(const thread_t *thread); 51 | -------------------------------------------------------------------------------- /osi/test/reactor_test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | extern "C" { 7 | #include "reactor.h" 8 | } 9 | 10 | static pthread_t thread; 11 | static volatile bool thread_running; 12 | 13 | static void *reactor_thread(void *ptr) { 14 | reactor_t *reactor = (reactor_t *)ptr; 15 | 16 | thread_running = true; 17 | reactor_start(reactor); 18 | thread_running = false; 19 | 20 | return NULL; 21 | } 22 | 23 | static void spawn_reactor_thread(reactor_t *reactor) { 24 | int ret = pthread_create(&thread, NULL, reactor_thread, reactor); 25 | EXPECT_EQ(ret, 0); 26 | } 27 | 28 | static void join_reactor_thread() { 29 | pthread_join(thread, NULL); 30 | } 31 | 32 | static uint64_t get_timestamp(void) { 33 | struct timeval tv; 34 | gettimeofday(&tv, NULL); 35 | return tv.tv_sec * 1000 + tv.tv_usec / 1000; 36 | } 37 | 38 | TEST(ReactorTest, reactor_new) { 39 | reactor_t *reactor = reactor_new(); 40 | EXPECT_TRUE(reactor != NULL); 41 | reactor_free(reactor); 42 | } 43 | 44 | TEST(ReactorTest, reactor_free_null) { 45 | reactor_free(NULL); 46 | } 47 | 48 | TEST(ReactorTest, reactor_stop_start) { 49 | reactor_t *reactor = reactor_new(); 50 | reactor_stop(reactor); 51 | reactor_start(reactor); 52 | reactor_free(reactor); 53 | } 54 | 55 | TEST(ReactorTest, reactor_repeated_stop_start) { 56 | reactor_t *reactor = reactor_new(); 57 | for (int i = 0; i < 10; ++i) { 58 | reactor_stop(reactor); 59 | reactor_start(reactor); 60 | } 61 | reactor_free(reactor); 62 | } 63 | 64 | TEST(ReactorTest, reactor_multi_stop_start) { 65 | reactor_t *reactor = reactor_new(); 66 | 67 | reactor_stop(reactor); 68 | reactor_stop(reactor); 69 | reactor_stop(reactor); 70 | 71 | reactor_start(reactor); 72 | reactor_start(reactor); 73 | reactor_start(reactor); 74 | 75 | reactor_free(reactor); 76 | } 77 | 78 | TEST(ReactorTest, reactor_start_wait_stop) { 79 | reactor_t *reactor = reactor_new(); 80 | 81 | spawn_reactor_thread(reactor); 82 | usleep(50 * 1000); 83 | EXPECT_TRUE(thread_running); 84 | 85 | reactor_stop(reactor); 86 | join_reactor_thread(); 87 | EXPECT_FALSE(thread_running); 88 | 89 | reactor_free(reactor); 90 | } 91 | 92 | TEST(ReactorTest, reactor_run_once_timeout) { 93 | reactor_t *reactor = reactor_new(); 94 | 95 | uint64_t start = get_timestamp(); 96 | reactor_status_t status = reactor_run_once_timeout(reactor, 50); 97 | EXPECT_GE(get_timestamp() - start, static_cast(50)); 98 | EXPECT_EQ(status, REACTOR_STATUS_TIMEOUT); 99 | 100 | reactor_free(reactor); 101 | } 102 | -------------------------------------------------------------------------------- /osi/test/thread_test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern "C" { 4 | #include "thread.h" 5 | #include "osi.h" 6 | } 7 | 8 | TEST(ThreadTest, test_new_simple) { 9 | thread_t *thread = thread_new("test_thread"); 10 | ASSERT_TRUE(thread != NULL); 11 | thread_free(thread); 12 | } 13 | 14 | TEST(ThreadTest, test_free_simple) { 15 | thread_t *thread = thread_new("test_thread"); 16 | thread_free(thread); 17 | } 18 | 19 | TEST(ThreadTest, test_name) { 20 | thread_t *thread = thread_new("test_name"); 21 | ASSERT_STREQ(thread_name(thread), "test_name"); 22 | thread_free(thread); 23 | } 24 | 25 | TEST(ThreadTest, test_long_name) { 26 | thread_t *thread = thread_new("0123456789abcdef"); 27 | ASSERT_STREQ("0123456789abcdef", thread_name(thread)); 28 | thread_free(thread); 29 | } 30 | 31 | TEST(ThreadTest, test_very_long_name) { 32 | thread_t *thread = thread_new("0123456789abcdefg"); 33 | ASSERT_STREQ("0123456789abcdef", thread_name(thread)); 34 | thread_free(thread); 35 | } 36 | -------------------------------------------------------------------------------- /stack/a2dp/a2d_int.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2002-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 | * 2DP internal header file 22 | * 23 | ******************************************************************************/ 24 | #ifndef A2D_INT_H 25 | #define A2D_INT_H 26 | 27 | #include "a2d_api.h" 28 | 29 | /***************************************************************************** 30 | ** Constants 31 | *****************************************************************************/ 32 | #define A2D_VERSION 0x0102 33 | 34 | /* Number of attributes in A2D SDP record. */ 35 | #define A2D_NUM_ATTR 6 36 | 37 | /* Number of protocol elements in protocol element list. */ 38 | #define A2D_NUM_PROTO_ELEMS 2 39 | 40 | /***************************************************************************** 41 | ** Type definitions 42 | *****************************************************************************/ 43 | 44 | /* Control block used by A2D_FindService(). */ 45 | typedef struct 46 | { 47 | tA2D_FIND_CBACK *p_cback; /* pointer to application callback */ 48 | tSDP_DISCOVERY_DB *p_db; /* pointer to discovery database */ 49 | UINT16 service_uuid; /* service UUID of search */ 50 | } tA2D_FIND_CB; 51 | 52 | typedef struct 53 | { 54 | tA2D_FIND_CB find; /* find service control block */ 55 | UINT8 trace_level; 56 | BOOLEAN use_desc; 57 | UINT16 avdt_sdp_ver; /* AVDTP version */ 58 | } tA2D_CB; 59 | 60 | 61 | #ifdef __cplusplus 62 | extern "C" 63 | { 64 | #endif 65 | 66 | /****************************************************************************** 67 | ** Main Control Block 68 | *******************************************************************************/ 69 | #if A2D_DYNAMIC_MEMORY == FALSE 70 | A2D_API extern tA2D_CB a2d_cb; 71 | #else 72 | A2D_API extern tA2D_CB *a2d_cb_ptr; 73 | #define a2d_cb (*a2d_cb_ptr) 74 | #endif 75 | 76 | /* Used only for conformance testing */ 77 | A2D_API extern void a2d_set_avdt_sdp_ver (UINT16 avdt_sdp_ver); 78 | 79 | #ifdef __cplusplus 80 | } 81 | #endif 82 | 83 | #endif /* A2D_INT_H */ 84 | -------------------------------------------------------------------------------- /stack/avct/avct_defs.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2003-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 contains constants definitions and other information from the AVCTP 22 | * specification. This file is intended for use internal to AVCT only. 23 | * 24 | ******************************************************************************/ 25 | #ifndef AVCT_DEFS_H 26 | #define AVCT_DEFS_H 27 | 28 | /***************************************************************************** 29 | ** constants 30 | *****************************************************************************/ 31 | 32 | /* packet type */ 33 | #define AVCT_PKT_TYPE_SINGLE 0 /* single packet */ 34 | #define AVCT_PKT_TYPE_START 1 /* start packet */ 35 | #define AVCT_PKT_TYPE_CONT 2 /* continue packet */ 36 | #define AVCT_PKT_TYPE_END 3 /* end packet */ 37 | 38 | /* header lengths for different packet types */ 39 | #define AVCT_HDR_LEN_SINGLE 3 40 | #define AVCT_HDR_LEN_START 4 41 | #define AVCT_HDR_LEN_CONT 1 42 | #define AVCT_HDR_LEN_END 1 43 | 44 | /* invalid cr+ipid value */ 45 | #define AVCT_CR_IPID_INVALID 1 46 | 47 | /***************************************************************************** 48 | ** message parsing and building macros 49 | *****************************************************************************/ 50 | 51 | #define AVCT_BLD_HDR(p, label, type, cr_ipid) \ 52 | *(p)++ = ((label) << 4) | ((type) << 2) | (cr_ipid); 53 | 54 | #define AVCT_PRS_HDR(p, label, type, cr_ipid) \ 55 | label = *(p) >> 4; \ 56 | type = (*(p) >> 2) & 3; \ 57 | cr_ipid = *(p)++ & 3; 58 | 59 | #define AVCT_PRS_PKT_TYPE(p, type) \ 60 | type = (*(p) >> 2) & 3; 61 | 62 | #endif /* AVCT_DEFS_H */ 63 | -------------------------------------------------------------------------------- /stack/btm/btm_main.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2002-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 file contains the definition of the btm control block when 22 | * BTM_DYNAMIC_MEMORY is used. 23 | * 24 | ******************************************************************************/ 25 | 26 | #include "bt_types.h" 27 | #include "bt_target.h" 28 | #include 29 | #include "btm_int.h" 30 | 31 | /* Global BTM control block structure 32 | */ 33 | #if BTM_DYNAMIC_MEMORY == FALSE 34 | tBTM_CB btm_cb; 35 | #endif 36 | 37 | /******************************************************************************* 38 | ** 39 | ** Function btm_init 40 | ** 41 | ** Description This function is called at BTM startup to allocate the 42 | ** control block (if using dynamic memory), and initializes the 43 | ** tracing level. It then initializes the various components of 44 | ** btm. 45 | ** 46 | ** Returns void 47 | ** 48 | *******************************************************************************/ 49 | void btm_init (void) 50 | { 51 | /* All fields are cleared; nonzero fields are reinitialized in appropriate function */ 52 | memset(&btm_cb, 0, sizeof(tBTM_CB)); 53 | 54 | #if defined(BTM_INITIAL_TRACE_LEVEL) 55 | btm_cb.trace_level = BTM_INITIAL_TRACE_LEVEL; 56 | #else 57 | btm_cb.trace_level = BT_TRACE_LEVEL_NONE; /* No traces */ 58 | #endif 59 | /* Initialize BTM component structures */ 60 | btm_inq_db_init(); /* Inquiry Database and Structures */ 61 | btm_acl_init(); /* ACL Database and Structures */ 62 | btm_sec_init(BTM_SEC_MODE_SP); /* Security Manager Database and Structures */ 63 | #if BTM_SCO_INCLUDED == TRUE 64 | btm_sco_init(); /* SCO Database and Structures (If included) */ 65 | #endif 66 | 67 | btm_dev_init(); /* Device Manager Structures & HCI_Reset */ 68 | } 69 | 70 | 71 | -------------------------------------------------------------------------------- /stack/hid/hid_conn.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2002-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 file contains HID connection internal definitions 22 | * 23 | ******************************************************************************/ 24 | 25 | #ifndef HID_CONN_H 26 | #define HID_CONN_H 27 | 28 | 29 | /* Define the HID Connection Block 30 | */ 31 | typedef struct hid_conn 32 | { 33 | #define HID_CONN_STATE_UNUSED (0) 34 | #define HID_CONN_STATE_CONNECTING_CTRL (1) 35 | #define HID_CONN_STATE_CONNECTING_INTR (2) 36 | #define HID_CONN_STATE_CONFIG (3) 37 | #define HID_CONN_STATE_CONNECTED (4) 38 | #define HID_CONN_STATE_DISCONNECTING (5) 39 | #define HID_CONN_STATE_SECURITY (6) 40 | #define HID_CONN_STATE_REMOVING (7) 41 | 42 | UINT8 conn_state; 43 | 44 | #define HID_CONN_FLAGS_IS_ORIG (0x01) 45 | #define HID_CONN_FLAGS_HIS_CTRL_CFG_DONE (0x02) 46 | #define HID_CONN_FLAGS_MY_CTRL_CFG_DONE (0x04) 47 | #define HID_CONN_FLAGS_HIS_INTR_CFG_DONE (0x08) 48 | #define HID_CONN_FLAGS_MY_INTR_CFG_DONE (0x10) 49 | #define HID_CONN_FLAGS_ALL_CONFIGURED (0x1E) /* All the config done */ 50 | #define HID_CONN_FLAGS_CONGESTED (0x20) 51 | #define HID_CONN_FLAGS_INACTIVE (0x40) 52 | 53 | UINT8 conn_flags; 54 | 55 | UINT8 ctrl_id; 56 | UINT16 ctrl_cid; 57 | UINT16 intr_cid; 58 | UINT16 rem_mtu_size; 59 | UINT16 disc_reason; /* Reason for disconnecting (for HID_HDEV_EVT_CLOSE) */ 60 | TIMER_LIST_ENT timer_entry; 61 | 62 | } tHID_CONN; 63 | 64 | #define HID_SEC_CHN 1 65 | #define HID_NOSEC_CHN 2 66 | 67 | #define HIDD_SEC_CHN 3 68 | #define HIDD_NOSEC_CHN 4 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /stack/hid/hidd_int.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (c) 2013, The Linux Foundation. All rights reserved. 4 | * Not a Contribution. 5 | * Copyright (C) 2002-2012 Broadcom Corporation 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at: 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * 19 | ******************************************************************************/ 20 | 21 | /****************************************************************************** 22 | * 23 | * This file contains HID DEVICE internal definitions 24 | * 25 | ******************************************************************************/ 26 | 27 | #ifndef HIDD_INT_H 28 | #define HIDD_INT_H 29 | 30 | #include "hidd_api.h" 31 | #include "hid_conn.h" 32 | #include "l2c_api.h" 33 | 34 | enum { 35 | HIDD_DEV_NO_CONN, 36 | HIDD_DEV_CONNECTED 37 | }; 38 | 39 | typedef struct device_ctb 40 | { 41 | BOOLEAN in_use; 42 | BD_ADDR addr; 43 | 44 | UINT8 state; 45 | 46 | tHID_CONN conn; 47 | 48 | BOOLEAN boot_mode; 49 | 50 | UINT8 idle_time; 51 | } tHID_DEV_DEV_CTB; 52 | 53 | typedef struct dev_ctb 54 | { 55 | tHID_DEV_DEV_CTB device; 56 | 57 | tHID_DEV_HOST_CALLBACK *callback; 58 | tL2CAP_CFG_INFO l2cap_cfg; 59 | tL2CAP_CFG_INFO l2cap_intr_cfg; 60 | 61 | BOOLEAN use_in_qos; 62 | FLOW_SPEC in_qos; 63 | 64 | BOOLEAN reg_flag; 65 | UINT8 trace_level; 66 | 67 | BOOLEAN allow_incoming; 68 | 69 | BT_HDR *pending_data; 70 | 71 | BOOLEAN pending_vc_unplug; 72 | } tHID_DEV_CTB; 73 | 74 | extern tHID_STATUS hidd_conn_reg(void); 75 | extern void hidd_conn_dereg(void); 76 | extern tHID_STATUS hidd_conn_initiate(void); 77 | extern tHID_STATUS hidd_conn_disconnect(void); 78 | extern tHID_STATUS hidd_conn_send_data(UINT8 channel, UINT8 msg_type, UINT8 param, 79 | UINT8 data, UINT16 len, UINT8 *p_data); 80 | 81 | #ifdef __cplusplus 82 | extern "C" 83 | { 84 | #endif 85 | 86 | /****************************************************************************** 87 | ** Main Control Block 88 | *******************************************************************************/ 89 | #if HID_DYNAMIC_MEMORY == FALSE 90 | HID_API extern tHID_DEV_CTB hd_cb; 91 | #else 92 | HID_API extern tHID_DEV_CTB *hidd_cb_ptr; 93 | #define hd_cb (*hidd_cb_ptr) 94 | #endif 95 | 96 | #ifdef __cplusplus 97 | } 98 | #endif 99 | 100 | #endif 101 | 102 | -------------------------------------------------------------------------------- /stack/include/avrc_defs.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_external_bluetooth_bluedroid/5e99e49bb0c62169ac7a1f6a30ff16fa9fa38507/stack/include/avrc_defs.h -------------------------------------------------------------------------------- /stack/include/port_ext.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 1999-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 file contains external definitions of Port Emulation entity unit 22 | * 23 | ******************************************************************************/ 24 | 25 | #ifndef PORTEXT_H 26 | #define PORTEXT_H 27 | 28 | #include "gki.h" 29 | 30 | /* Port emulation entity Entry Points */ 31 | extern void rfcomm_process_timeout (TIMER_LIST_ENT *p_tle); 32 | #endif 33 | -------------------------------------------------------------------------------- /stack/include/utfc.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2003-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 | * UTF conversion utilities. 22 | * 23 | ******************************************************************************/ 24 | #ifndef UTFC_H 25 | #define UTFC_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" 29 | { 30 | #endif 31 | 32 | /******************************************************************************* 33 | ** 34 | ** Function utfc_16_to_8 35 | ** 36 | ** Description Convert a UTF-16 array to a null-terminated UTF-8 string. 37 | ** Illegal characters are skipped. 38 | ** 39 | ** Returns Length of UTF-8 string in bytes. 40 | ** 41 | *******************************************************************************/ 42 | extern UINT16 utfc_16_to_8(UINT8 *p_utf8, UINT16 utf8_len, UINT16 *p_utf16, UINT16 utf16_len); 43 | 44 | /******************************************************************************* 45 | ** 46 | ** Function utfc_8_to_16 47 | ** 48 | ** Description Convert a null-terminated UTF-8 string to a UTF-16 array. 49 | ** Illegal characters are skipped. The UTF-16 array is 50 | ** appended with a zero (null) character. 51 | ** 52 | ** Returns Length of UTF-16 array including null character. 53 | ** 54 | *******************************************************************************/ 55 | extern UINT16 utfc_8_to_16(UINT16 *p_utf16, UINT16 utf16_len, UINT8 *p_utf8); 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #endif /* UTFC_H */ 62 | -------------------------------------------------------------------------------- /stack/include/wbt_api.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2003-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 file contains definitions and constants used by the Broadcom 22 | * Bluetooth Extensions API software. 23 | * 24 | ******************************************************************************/ 25 | #ifndef WBT_API_H 26 | #define WBT_API_H 27 | 28 | #include "bt_target.h" 29 | 30 | /***************************************************************************** 31 | ** Constants and Types 32 | *****************************************************************************/ 33 | 34 | /************************** 35 | * SDP Attribute IDs * 36 | ***************************/ 37 | #define ATTR_ID_EXT_BRCM_VERSION 0x8001 /* UINT16 (0xmmnn - major, minor [0x0001]) mandatory */ 38 | #define ATTR_ID_EXT_PIN_CODE 0x8002 /* UINT32 4 - digit pin */ 39 | 40 | /************************** 41 | * SDP Attribute ID Values * 42 | ***************************/ 43 | /* Version Attribute Value */ 44 | #define BRCM_EXT_VERSION 0x0001 /* UINT16 (0xmmnn - major, minor [0x0001]) mandatory */ 45 | 46 | /* Pin Code Attribute Value */ 47 | #define BRCM_EXT_PIN_CODE 0x00000000 /* UINT32 ('0000') */ 48 | 49 | /***************************************************************************** 50 | ** External Function Declarations 51 | *****************************************************************************/ 52 | #ifdef __cplusplus 53 | extern "C" 54 | { 55 | #endif 56 | 57 | BT_API extern BOOLEAN WBT_ExtCreateRecord(void); 58 | 59 | /*** Features ***/ 60 | BT_API extern BOOLEAN WBT_ExtAddPinCode(void); 61 | 62 | 63 | BT_API extern UINT32 wbt_sdp_show_ext(UINT8 scn, char *service_name, 64 | UINT8 pin_code_ext, 65 | UINT8 active_sync_ext); 66 | 67 | #ifdef __cplusplus 68 | } 69 | #endif 70 | 71 | #endif /* WBT_API_H */ 72 | -------------------------------------------------------------------------------- /stack/include/wcassert.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 1999-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 | #ifndef WC_ASSERT_H 19 | #define WC_ASSERT_H 20 | 21 | 22 | #ifdef _DEBUG 23 | 24 | #include "bt_target.h" 25 | 26 | 27 | 28 | /* debug settings*/ 29 | #ifndef WC_DEBUG_LEVEL 30 | #define WC_DEBUG_LEVEL 0 31 | #endif 32 | 33 | #if WC_DEBUG_LEVEL == 0 34 | 35 | #include "stdio.h" /* for printf()*/ 36 | 37 | #ifdef __cplusplus 38 | extern "C" wc_assert(char *message, char *file, UINT32 line); 39 | #else 40 | void wc_assert(char *message, char *file, UINT32 line); 41 | #endif 42 | 43 | #define WC_ASSERT(_x) if ( !(_x) ) wc_assert("ASSERT at %s line %d\n", __FILE__, __LINE__); 44 | #define WC_ASSERT_ALWAYS() wc_assert("ASSERT! at %s line %d\n", __FILE__, __LINE__); 45 | 46 | #elif WC_DEBUG_LEVEL == 1 47 | 48 | #include "assert.h" 49 | 50 | #define WC_ASSERT(_x) assert(_x); 51 | #define WC_ASSERT_ALWAYS() assert(0); 52 | #endif /* WC_DEBUG_LEVEL*/ 53 | 54 | #else /* _DEBUG*/ 55 | 56 | #ifndef WC_ASSERT 57 | #define WC_ASSERT(_x) ; 58 | #endif 59 | 60 | #ifndef WC_ASSERT_ALWAYS 61 | #define WC_ASSERT_ALWAYS() ; 62 | #endif 63 | 64 | #endif /* _DEBUG*/ 65 | #endif /* WC_ASSERT_H*/ 66 | -------------------------------------------------------------------------------- /stack/srvc/srvc_battery_int.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 1999-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 SRVC_BATTERY_INT_H 20 | #define SRVC_BATTERY_INT_H 21 | 22 | #include "bt_target.h" 23 | #include "srvc_api.h" 24 | #include "gatt_api.h" 25 | 26 | #ifndef BA_MAX_INT_NUM 27 | #define BA_MAX_INT_NUM 4 28 | #endif 29 | 30 | #define BATTERY_LEVEL_SIZE 1 31 | 32 | 33 | typedef struct 34 | { 35 | UINT8 app_id; 36 | UINT16 ba_level_hdl; 37 | UINT16 clt_cfg_hdl; 38 | UINT16 rpt_ref_hdl; 39 | UINT16 pres_fmt_hdl; 40 | 41 | tBA_CBACK *p_cback; 42 | 43 | UINT16 pending_handle; 44 | UINT8 pending_clcb_idx; 45 | UINT8 pending_evt; 46 | 47 | }tBA_INST; 48 | 49 | typedef struct 50 | { 51 | tBA_INST battery_inst[BA_MAX_INT_NUM]; 52 | UINT8 inst_id; 53 | BOOLEAN enabled; 54 | 55 | }tBATTERY_CB; 56 | 57 | #ifdef __cplusplus 58 | extern "C" { 59 | #endif 60 | 61 | /* Global GATT data */ 62 | #if GATT_DYNAMIC_MEMORY == FALSE 63 | GATT_API extern tBATTERY_CB battery_cb; 64 | #else 65 | GATT_API extern tBATTERY_CB *battery_cb_ptr; 66 | #define battery_cb (*battery_cb_ptr) 67 | #endif 68 | 69 | 70 | extern BOOLEAN battery_valid_handle_range(UINT16 handle); 71 | 72 | extern UINT8 battery_s_write_attr_value(UINT8 clcb_idx, tGATT_WRITE_REQ * p_value, 73 | tGATT_STATUS *p_status); 74 | extern UINT8 battery_s_read_attr_value (UINT8 clcb_idx, UINT16 handle, tGATT_VALUE *p_value, BOOLEAN is_long, tGATT_STATUS* p_status); 75 | 76 | 77 | 78 | #ifdef __cplusplus 79 | } 80 | #endif 81 | #endif 82 | -------------------------------------------------------------------------------- /stack/srvc/srvc_dis_int.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 1999-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 SRVC_DIS_INT_H 20 | #define SRVC_DIS_INT_H 21 | 22 | #include "bt_target.h" 23 | #include "srvc_api.h" 24 | #include "gatt_api.h" 25 | 26 | #define DIS_MAX_CHAR_NUM 9 27 | 28 | 29 | typedef struct 30 | { 31 | UINT16 uuid; 32 | UINT16 handle; 33 | }tDIS_DB_ENTRY; 34 | 35 | #define DIS_SYSTEM_ID_SIZE 8 36 | #define DIS_PNP_ID_SIZE 7 37 | 38 | 39 | 40 | typedef struct 41 | { 42 | tDIS_DB_ENTRY dis_attr[DIS_MAX_CHAR_NUM]; 43 | tDIS_VALUE dis_value; 44 | 45 | tDIS_READ_CBACK *p_read_dis_cback; 46 | 47 | UINT16 service_handle; 48 | UINT16 max_handle; 49 | 50 | BOOLEAN enabled; 51 | 52 | UINT8 dis_read_uuid_idx; 53 | 54 | tDIS_ATTR_MASK request_mask; 55 | }tDIS_CB; 56 | 57 | 58 | 59 | #ifdef __cplusplus 60 | extern "C" { 61 | #endif 62 | 63 | /* Global GATT data */ 64 | #if GATT_DYNAMIC_MEMORY == FALSE 65 | GATT_API extern tDIS_CB dis_cb; 66 | #else 67 | GATT_API extern tDIS_CB *dis_cb_ptr; 68 | #define dis_cb (*dis_cb_ptr) 69 | #endif 70 | 71 | 72 | extern BOOLEAN dis_valid_handle_range(UINT16 handle); 73 | extern UINT8 dis_read_attr_value (UINT8 clcb_idx, UINT16 handle, tGATT_VALUE *p_value, 74 | BOOLEAN is_long, tGATT_STATUS *p_status); 75 | extern UINT8 dis_write_attr_value(tGATT_WRITE_REQ * p_data, tGATT_STATUS *p_status); 76 | 77 | extern void dis_c_cmpl_cback (tSRVC_CLCB *p_clcb, tGATTC_OPTYPE op, 78 | tGATT_STATUS status, tGATT_CL_COMPLETE *p_data); 79 | 80 | 81 | #ifdef __cplusplus 82 | } 83 | #endif 84 | #endif 85 | -------------------------------------------------------------------------------- /stack/srvc/srvc_eng_int.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 1999-2013 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 SRVC_ENG_INT_H 20 | #define SRVC_ENG_INT_H 21 | 22 | #include "bt_target.h" 23 | #include "gatt_api.h" 24 | #include "srvc_api.h" 25 | 26 | #define SRVC_MAX_APPS GATT_CL_MAX_LCB 27 | 28 | #define SRVC_ID_NONE 0 29 | #define SRVC_ID_DIS 1 30 | #define SRVC_ID_MAX SRVC_ID_DIS 31 | 32 | #define SRVC_ACT_IGNORE 0 33 | #define SRVC_ACT_RSP 1 34 | #define SRVC_ACT_PENDING 2 35 | 36 | typedef struct 37 | { 38 | BOOLEAN in_use; 39 | UINT16 conn_id; 40 | BOOLEAN connected; 41 | BD_ADDR bda; 42 | UINT32 trans_id; 43 | UINT8 cur_srvc_id; 44 | 45 | tDIS_VALUE dis_value; 46 | 47 | }tSRVC_CLCB; 48 | 49 | 50 | /* service engine control block */ 51 | typedef struct 52 | { 53 | tSRVC_CLCB clcb[SRVC_MAX_APPS]; /* connection link*/ 54 | tGATT_IF gatt_if; 55 | BOOLEAN enabled; 56 | 57 | }tSRVC_ENG_CB; 58 | 59 | 60 | 61 | #ifdef __cplusplus 62 | extern "C" { 63 | #endif 64 | 65 | /* Global GATT data */ 66 | #if GATT_DYNAMIC_MEMORY == FALSE 67 | GATT_API extern tSRVC_ENG_CB srvc_eng_cb; 68 | #else 69 | GATT_API extern tSRVC_ENG_CB srvc_eng_cb_ptr; 70 | #define srvc_eng_cb (*srvc_eng_cb_ptr) 71 | 72 | #endif 73 | 74 | extern tSRVC_CLCB *srvc_eng_find_clcb_by_conn_id(UINT16 conn_id); 75 | extern tSRVC_CLCB *srvc_eng_find_clcb_by_bd_addr(BD_ADDR bda); 76 | extern UINT16 srvc_eng_find_conn_id_by_bd_addr(BD_ADDR bda); 77 | 78 | 79 | extern void srvc_eng_release_channel (UINT16 conn_id) ; 80 | extern BOOLEAN srvc_eng_request_channel (BD_ADDR remote_bda, UINT8 srvc_id ); 81 | extern void srvc_sr_rsp(UINT8 clcb_idx, tGATT_STATUS st, tGATTS_RSP *p_rsp); 82 | extern void srvc_sr_notify(BD_ADDR remote_bda, UINT16 handle, UINT16 len, UINT8 *p_value); 83 | 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | #endif 89 | -------------------------------------------------------------------------------- /test/Android.mk: -------------------------------------------------------------------------------- 1 | include $(call all-subdir-makefiles) 2 | -------------------------------------------------------------------------------- /test/blegatt_test/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | 6 | LOCAL_SRC_FILES:= gatt_test.c 7 | 8 | LOCAL_C_INCLUDES := . \ 9 | $(LOCAL_PATH)/../../stack/include \ 10 | $(LOCAL_PATH)/../../include \ 11 | $(LOCAL_PATH)/../../stack/l2cap \ 12 | $(LOCAL_PATH)/../../stack/gatt \ 13 | $(LOCAL_PATH)/../../stack/a2dp \ 14 | $(LOCAL_PATH)/../../stack/btm \ 15 | $(LOCAL_PATH)/../../stack/avdt \ 16 | $(LOCAL_PATH)/../../stack/btm \ 17 | $(LOCAL_PATH)/../../gki/common \ 18 | $(LOCAL_PATH)/../../gki/ulinux \ 19 | $(LOCAL_PATH)/../../udrv/include \ 20 | $(LOCAL_PATH)/../../rpc/include \ 21 | $(LOCAL_PATH)/../../hcis \ 22 | $(LOCAL_PATH)/../../hci/include \ 23 | $(LOCAL_PATH)/../../ctrlr/include \ 24 | $(LOCAL_PATH)/../../bta/include \ 25 | $(LOCAL_PATH)/../../bta/sys \ 26 | $(LOCAL_PATH)/../../brcm/include \ 27 | $(LOCAL_PATH)/../../utils/include \ 28 | $(LOCAL_PATH)/btif/include \ 29 | $(LOCAL_PATH)/embdrv/sbc/encoder/include \ 30 | $(bdroid_C_INCLUDES) \ 31 | external/tinyxml2 32 | 33 | LOCAL_CFLAGS += -std=c99 34 | 35 | LOCAL_CFLAGS += $(bdroid_CFLAGS) 36 | LOCAL_MODULE_TAGS := debug optional 37 | 38 | LOCAL_MODULE:= gatt_testtool 39 | 40 | LOCAL_LDLIBS += -ldl -llog 41 | LIBS_c += -lreadline 42 | 43 | LOCAL_SHARED_LIBRARIES += libcutils \ 44 | libutils \ 45 | libhardware \ 46 | libhardware_legacy 47 | 48 | LOCAL_MULTILIB := 32 49 | 50 | include $(BUILD_EXECUTABLE) 51 | -------------------------------------------------------------------------------- /test/blegatt_test/README.txt: -------------------------------------------------------------------------------- 1 | Bluedroid Test Application 2 | ========================== 3 | The test application provides a small console shell interface that allows 4 | access to the Bluetooth HAL API library though ASCII commands. This is similar 5 | to how the real JNI service would operate. The primary objective of this 6 | application is to allow Bluetooth to be put in DUT Mode for RF/BB BQB test purposes. 7 | 8 | This application is mutually exclusive with the Java based Bluetooth.apk. Hence 9 | before launching the application, it should be ensured that the Settings->Bluetooth is OFF. 10 | 11 | This application is built as 'bdt' and shall be available in '/system/bin/bdt' 12 | 13 | Limitations 14 | =========== 15 | 1.) Settings->Bluetooth must be OFF for this application to work 16 | 2.) Currently, only the SIG 'HCI Test Mode' commands are supported. The vendor 17 | specific HCI test mode commands to be added. 18 | 19 | Usage instructions 20 | ================== 21 | The following section describes the various commands and their usage 22 | 23 | Launching the test application 24 | ============================== 25 | $ adb shell 26 | root@android:/ # /system/bin/bdt 27 | set_aid_and_cap : pid 1183, uid 0 gid 0 28 | ::::::::::::::::::::::::::::::::::::::::::::::::::: 29 | :: Bluedroid test app starting 30 | Loading HAL lib + extensions 31 | HAL library loaded (Success) 32 | INIT BT 33 | HAL REQUEST SUCCESS 34 | 35 | Enabling Bluetooth 36 | ================== 37 | >enable 38 | ENABLE BT 39 | HAL REQUEST SUCCESS 40 | >ADAPTER STATE UPDATED : ON 41 | 42 | Enabling Test Mode (Bluetooth must be enabled for this command to work) 43 | ====================================================================== 44 | >dut_mode_configure 1 45 | BT DUT MODE CONFIGURE 46 | HAL REQUEST SUCCESS 47 | > 48 | 49 | Disabling Test Mode 50 | =================== 51 | >dut_mode_configure 0 52 | BT DUT MODE CONFIGURE 53 | HAL REQUEST SUCCESS 54 | > 55 | 56 | Running BLE Test commands (Bluetooth must be enabled) 57 | ===================================================== 58 | NOTE: Unlike BR/EDR, there is no explicit DUT mode to run these BLE tests. 59 | 60 | > le_test_mode 1 61 | 62 | > le_test_mode 2 63 | 64 | > le_test_mode 3 65 | Please refer to the BT Core spec pages-1099 to 1102 for possible values for 66 | the above parameters. These values need to be provided in Decimal format. 67 | 68 | Exit the test application 69 | ========================= 70 | >quit 71 | shutdown bdroid test app 72 | Unloading HAL lib 73 | HAL library unloaded (Success) 74 | :: Bluedroid test app terminating 75 | 76 | Help (Lists the available commands) 77 | =================================== 78 | >help 79 | help lists all available console commands 80 | 81 | quit 82 | enable :: enables bluetooth 83 | disable :: disables bluetooth 84 | dut_mode_configure :: DUT mode - 1 to enter,0 to exit 85 | le_test_mode :: LE Test Mode - RxTest - 1 , 86 | TxTest - 2 , 87 | End Test - 3 88 | 89 | -------------------------------------------------------------------------------- /test/bluedroidtest/Android.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2009-2012 Broadcom Corporation 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at: 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | LOCAL_PATH:= $(call my-dir) 18 | 19 | include $(CLEAR_VARS) 20 | 21 | LOCAL_SRC_FILES:= \ 22 | bluedroidtest.c 23 | 24 | LOCAL_C_INCLUDES := 25 | LOCAL_CFLAGS := -Wno-unused-parameter 26 | 27 | LOCAL_CFLAGS += -std=c99 28 | 29 | LOCAL_CFLAGS += -std=c99 30 | 31 | LOCAL_MODULE_TAGS := debug optional 32 | 33 | LOCAL_MODULE:= bdt 34 | 35 | LOCAL_SHARED_LIBRARIES += libcutils \ 36 | libutils \ 37 | libhardware \ 38 | libhardware_legacy 39 | 40 | LOCAL_MULTILIB := 32 41 | 42 | include $(BUILD_EXECUTABLE) 43 | -------------------------------------------------------------------------------- /test/bluedroidtest/README.txt: -------------------------------------------------------------------------------- 1 | Bluedroid Test Application 2 | ========================== 3 | The test application provides a small console shell interface that allows 4 | access to the Bluetooth HAL API library though ASCII commands. This is similar 5 | to how the real JNI service would operate. The primary objective of this 6 | application is to allow Bluetooth to be put in DUT Mode for RF/BB BQB test purposes. 7 | 8 | This application is mutually exclusive with the Java based Bluetooth.apk. Hence 9 | before launching the application, it should be ensured that the Settings->Bluetooth is OFF. 10 | 11 | This application is built as 'bdt' and shall be available in '/system/bin/bdt' 12 | 13 | Limitations 14 | =========== 15 | 1.) Settings->Bluetooth must be OFF for this application to work 16 | 2.) Currently, only the SIG 'HCI Test Mode' commands are supported. The vendor 17 | specific HCI test mode commands to be added. 18 | 19 | Usage instructions 20 | ================== 21 | The following section describes the various commands and their usage 22 | 23 | Launching the test application 24 | ============================== 25 | $ adb shell 26 | root@android:/ # /system/bin/bdt 27 | set_aid_and_cap : pid 1183, uid 0 gid 0 28 | ::::::::::::::::::::::::::::::::::::::::::::::::::: 29 | :: Bluedroid test app starting 30 | Loading HAL lib + extensions 31 | HAL library loaded (Success) 32 | INIT BT 33 | HAL REQUEST SUCCESS 34 | 35 | Enabling Bluetooth 36 | ================== 37 | >enable 38 | ENABLE BT 39 | HAL REQUEST SUCCESS 40 | >ADAPTER STATE UPDATED : ON 41 | 42 | Enabling Test Mode (Bluetooth must be enabled for this command to work) 43 | ====================================================================== 44 | >dut_mode_configure 1 45 | BT DUT MODE CONFIGURE 46 | HAL REQUEST SUCCESS 47 | > 48 | 49 | Disabling Test Mode 50 | =================== 51 | >dut_mode_configure 0 52 | BT DUT MODE CONFIGURE 53 | HAL REQUEST SUCCESS 54 | > 55 | 56 | Running BLE Test commands (Bluetooth must be enabled) 57 | ===================================================== 58 | NOTE: Unlike BR/EDR, there is no explicit DUT mode to run these BLE tests. 59 | 60 | > le_test_mode 1 61 | 62 | > le_test_mode 2 63 | 64 | > le_test_mode 3 65 | Please refer to the BT Core spec pages-1099 to 1102 for possible values for 66 | the above parameters. These values need to be provided in Decimal format. 67 | 68 | Exit the test application 69 | ========================= 70 | >quit 71 | shutdown bdroid test app 72 | Unloading HAL lib 73 | HAL library unloaded (Success) 74 | :: Bluedroid test app terminating 75 | 76 | Help (Lists the available commands) 77 | =================================== 78 | >help 79 | help lists all available console commands 80 | 81 | quit 82 | enable :: enables bluetooth 83 | disable :: disables bluetooth 84 | dut_mode_configure :: DUT mode - 1 to enter,0 to exit 85 | le_test_mode :: LE Test Mode - RxTest - 1 , 86 | TxTest - 2 , 87 | End Test - 3 88 | 89 | -------------------------------------------------------------------------------- /test/l2test_ertm/Android.mk: -------------------------------------------------------------------------------- 1 | 2 | LOCAL_PATH:= $(call my-dir) 3 | 4 | include $(CLEAR_VARS) 5 | 6 | LOCAL_SRC_FILES:= l2test_ertm.c 7 | 8 | LOCAL_C_INCLUDES += . \ 9 | $(LOCAL_PATH)/../../stack/include \ 10 | $(LOCAL_PATH)/../../include \ 11 | $(LOCAL_PATH)/../../stack/l2cap \ 12 | $(LOCAL_PATH)/../../gki/ulinux \ 13 | $(LOCAL_PATH)/../../utils/include \ 14 | $(LOCAL_PATH)/btif/include \ 15 | $(bdroid_C_INCLUDES) 16 | 17 | LOCAL_CFLAGS += $(bdroid_CFLAGS) 18 | LOCAL_MODULE_PATH := $(TARGET_OUT_EXECUTABLES) 19 | LOCAL_MODULE_TAGS := debug optional 20 | LOCAL_MODULE:= l2test_ertm 21 | 22 | LOCAL_SHARED_LIBRARIES += libcutils \ 23 | libutils \ 24 | libhardware \ 25 | libhardware_legacy 26 | 27 | LOCAL_MULTILIB := 32 28 | 29 | include $(BUILD_EXECUTABLE) 30 | -------------------------------------------------------------------------------- /test/l2test_ertm/README.txt: -------------------------------------------------------------------------------- 1 | Bluedroid Test Application 2 | ========================== 3 | The test application provides a small console shell interface that allows 4 | access to the Bluetooth HAL API library though ASCII commands. This is similar 5 | to how the real JNI service would operate. The primary objective of this 6 | application is to allow Bluetooth to be put in DUT Mode for RF/BB BQB test purposes. 7 | 8 | This application is mutually exclusive with the Java based Bluetooth.apk. Hence 9 | before launching the application, it should be ensured that the Settings->Bluetooth is OFF. 10 | 11 | This application is built as 'bdt' and shall be available in '/system/bin/bdt' 12 | 13 | Limitations 14 | =========== 15 | 1.) Settings->Bluetooth must be OFF for this application to work 16 | 2.) Currently, only the SIG 'HCI Test Mode' commands are supported. The vendor 17 | specific HCI test mode commands to be added. 18 | 19 | Usage instructions 20 | ================== 21 | The following section describes the various commands and their usage 22 | 23 | Launching the test application 24 | ============================== 25 | $ adb shell 26 | root@android:/ # /system/bin/bdt 27 | set_aid_and_cap : pid 1183, uid 0 gid 0 28 | ::::::::::::::::::::::::::::::::::::::::::::::::::: 29 | :: Bluedroid test app starting 30 | Loading HAL lib + extensions 31 | HAL library loaded (Success) 32 | INIT BT 33 | HAL REQUEST SUCCESS 34 | 35 | Enabling Bluetooth 36 | ================== 37 | >enable 38 | ENABLE BT 39 | HAL REQUEST SUCCESS 40 | >ADAPTER STATE UPDATED : ON 41 | 42 | Enabling Test Mode (Bluetooth must be enabled for this command to work) 43 | ====================================================================== 44 | >enable_test_mode 45 | ENABLE BT TEST MODE 46 | HAL REQUEST SUCCESS 47 | > 48 | 49 | Disabling Test Mode 50 | =================== 51 | >disable_test_mode 52 | DISABLE BT TEST MODE 53 | HAL REQUEST SUCCESS 54 | 55 | Exit the test application 56 | ========================= 57 | >quit 58 | shutdown bdroid test app 59 | Unloading HAL lib 60 | HAL library unloaded (Success) 61 | :: Bluedroid test app terminating 62 | 63 | Help (Lists the available commands) 64 | =================================== 65 | >help 66 | help lists all available console commands 67 | 68 | quit 69 | enable :: enables bluetooth 70 | disable :: disables bluetooth 71 | enable_test_mode :: enters bluedroid test mode 72 | disable_test_mode :: exits bluedroid test mode 73 | 74 | -------------------------------------------------------------------------------- /test/rfcommtest/Android.mk: -------------------------------------------------------------------------------- 1 | # 2 | # 3 | 4 | LOCAL_PATH:= $(call my-dir) 5 | 6 | include $(CLEAR_VARS) 7 | 8 | LOCAL_SRC_FILES:= \ 9 | rfcommtest.c 10 | 11 | LOCAL_C_INCLUDES += . \ 12 | $(LOCAL_PATH)/../../stack/include \ 13 | $(LOCAL_PATH)/../../include \ 14 | $(LOCAL_PATH)/../../stack/l2cap \ 15 | $(LOCAL_PATH)/../../gki/ulinux \ 16 | $(LOCAL_PATH)/../../utils/include \ 17 | $(LOCAL_PATH)/btif/include \ 18 | $(bdroid_C_INCLUDES) 19 | 20 | LOCAL_CFLAGS += $(bdroid_CFLAGS) 21 | LOCAL_MODULE_PATH := $(TARGET_OUT_EXECUTABLES) 22 | LOCAL_MODULE_TAGS := debug optional 23 | LOCAL_MODULE:= rfc 24 | 25 | LOCAL_SHARED_LIBRARIES += libcutils \ 26 | libutils \ 27 | libhardware \ 28 | libhardware_legacy 29 | 30 | LOCAL_MULTILIB := 32 31 | 32 | include $(BUILD_EXECUTABLE) 33 | 34 | -------------------------------------------------------------------------------- /test/rfcommtest/README.txt: -------------------------------------------------------------------------------- 1 | RFCOMM Test Application 2 | ========================== 3 | The test application provides a small console shell interface that allows 4 | access to the Bluetooth HAL API library though ASCII commands. This is similar 5 | to how the real JNI service would operate. The primary objective of this 6 | application ise for RFCOMM certification 7 | 8 | This application is mutually exclusive with the Java based Bluetooth.apk. Hence 9 | before launching the application, it should be ensured that the Settings->Bluetooth is OFF. 10 | 11 | This application is built as 'rfc' and shall be available in '/system/bin/rfc' 12 | 13 | Limitations 14 | =========== 15 | 1.) Settings->Bluetooth must be OFF for this application to work 16 | 2.) Currently, only the SIG 'HCI Test Mode' commands are supported. The vendor 17 | specific HCI test mode commands to be added. 18 | 19 | Usage instructions 20 | ================== 21 | The following section describes the various commands and their usage 22 | 23 | Launching the test application 24 | ============================== 25 | $ adb shell 26 | root@android:/ # /system/bin/bdt 27 | set_aid_and_cap : pid 1183, uid 0 gid 0 28 | ::::::::::::::::::::::::::::::::::::::::::::::::::: 29 | :: RFC test app starting 30 | Loading HAL lib + extensions 31 | HAL library loaded (Success) 32 | INIT BT 33 | HAL REQUEST SUCCESS 34 | 35 | Enabling Bluetooth 36 | ================== 37 | >enable 38 | ENABLE BT 39 | HAL REQUEST SUCCESS 40 | >ADAPTER STATE UPDATED : ON 41 | 42 | Enabling Test Mode (Bluetooth must be enabled for this command to work) 43 | ====================================================================== 44 | >dut_mode_configure 1 45 | BT DUT MODE CONFIGURE 46 | HAL REQUEST SUCCESS 47 | > 48 | 49 | Disabling Test Mode 50 | =================== 51 | >dut_mode_configure 0 52 | BT DUT MODE CONFIGURE 53 | HAL REQUEST SUCCESS 54 | > 55 | 56 | 57 | Exit the test application 58 | ========================= 59 | >quit 60 | shutdown bdroid test app 61 | Unloading HAL lib 62 | HAL library unloaded (Success) 63 | :: RFC test app terminating 64 | 65 | Help (Lists the available commands) 66 | =================================== 67 | >help 68 | help lists all available console commands 69 | 70 | quit 71 | enable :: enables bluetooth 72 | disable :: disables bluetooth 73 | dut_mode_configure :: DUT mode - 1 to enter,0 to exit 74 | 75 | -------------------------------------------------------------------------------- /test/sdptest/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | LOCAL_SRC_FILES:= sdptool.c 5 | 6 | LOCAL_C_INCLUDES += . \ 7 | $(LOCAL_PATH)/../../stack/include \ 8 | $(LOCAL_PATH)/../../include \ 9 | $(LOCAL_PATH)/../../stack/l2cap \ 10 | $(LOCAL_PATH)/../../gki/ulinux \ 11 | $(LOCAL_PATH)/../../utils/include \ 12 | $(LOCAL_PATH)/btif/include \ 13 | $(bdroid_C_INCLUDES) 14 | 15 | LOCAL_CFLAGS += $(bdroid_CFLAGS) 16 | LOCAL_MODULE_PATH := $(TARGET_OUT_EXECUTABLES) 17 | LOCAL_MODULE_TAGS := debug optional 18 | LOCAL_MODULE:= sdptool 19 | 20 | LOCAL_SHARED_LIBRARIES += libcutils \ 21 | libutils \ 22 | libhardware \ 23 | libhardware_legacy 24 | 25 | LOCAL_MULTILIB := 32 26 | 27 | include $(BUILD_EXECUTABLE) 28 | -------------------------------------------------------------------------------- /test/sdptest/README.txt: -------------------------------------------------------------------------------- 1 | Bluedroid Test Application 2 | ========================== 3 | The test application provides a small console shell interface that allows 4 | access to the Bluetooth HAL API library though ASCII commands. This is similar 5 | to how the real JNI service would operate. The primary objective of this 6 | application is to allow Bluetooth to be put in DUT Mode for RF/BB BQB test purposes. 7 | 8 | This application is mutually exclusive with the Java based Bluetooth.apk. Hence 9 | before launching the application, it should be ensured that the Settings->Bluetooth is OFF. 10 | 11 | This application is built as 'sdptool' and shall be available in '/system/bin/sdptool' 12 | 13 | Limitations 14 | =========== 15 | 1.) Settings->Bluetooth must be OFF for this application to work 16 | 2.) Currently, only the SIG 'HCI Test Mode' commands are supported. The vendor 17 | specific HCI test mode commands to be added. 18 | 19 | Usage instructions 20 | ================== 21 | The following section describes the various commands and their usage 22 | 23 | Launching the test application 24 | ============================== 25 | $ adb root 26 | $ adb shell 27 | root@android:/ # /system/bin/sdptool 28 | 29 | set_aid_and_cap : pid 4374, uid 0 gid 0 30 | Loading HAL lib + extensions 31 | HAL library loaded (Success) 32 | >INIT BT HAL REQUEST SUCCESS 33 | 34 | Enabling Bluetooth 35 | ================== 36 | >enablebt 37 | ENABLE BT 38 | adapter_properties_changed status= 0, num_properties=1 39 | adapter_properties_changed status= 0, num_properties=6 40 | Local Bd Addr = 0:0:0:f6:48:46 41 | Setinng it to scan 42 | adapter_properties_changed status= 0, num_properties=1 43 | >adapter_properties_changed status= 0, num_properties=1 44 | 45 | Initializing SDP interface 46 | ======================== 47 | >init 48 | Initializing SDP interface 49 | Get SDP interface 50 | btif_sdp_get_interface 51 | >Registering SDP Calbacks 52 | 53 | SDP the remote device 54 | ================================ 55 | >searchservices fc:f8:ae:d7:c2:e6 56 | The parameter passed is : fc:f8:ae:d7:c2:e6 57 | Search Services started for fc:f8:ae:d7:c2:e6 58 | Wait for the SDP to complete 59 | sdp started succeessfully 60 | sdp completed .Result=0 61 | 62 | Remote Device Service(s) UUID(s) = 0x1105 63 | Remote Device Service(s) UUID(s) = 0x110a 64 | Remote Device Service(s) UUID(s) = 0x110c 65 | Remote Device Service(s) UUID(s) = 0x1115 66 | Remote Device Service(s) UUID(s) = 0x112f 67 | Remote Device Service(s) UUID(s) = 0x1132 68 | Remote Device Service(s) UUID(s) = 0x1112 69 | Remote Device Service(s) UUID(s) = 0x111f 70 | Remote Device Service(s) UUID(s) = 0x1203 71 | Remote Device Service(s) UUID(s) = 0x1132 72 | >Remote Device Service(s) UUID(s) = 0x1800 73 | 74 | Close every thing gracefully, otherwise adaptor/stack goes into undefined state and starting sdptool again may not work as expected. 75 | ================================= 76 | >quit 77 | -------------------------------------------------------------------------------- /test/suite/Android.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2014 Google, Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at: 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | LOCAL_PATH := $(call my-dir) 18 | 19 | include $(CLEAR_VARS) 20 | 21 | LOCAL_MODULE_TAGS := optional 22 | LOCAL_MODULE := bdtest 23 | 24 | LOCAL_SRC_FILES := \ 25 | cases/adapter.c \ 26 | cases/cases.c \ 27 | cases/pan.c \ 28 | support/adapter.c \ 29 | support/callbacks.c \ 30 | support/hal.c \ 31 | support/pan.c \ 32 | support/property.c \ 33 | main.c 34 | 35 | LOCAL_SHARED_LIBRARIES += \ 36 | libhardware \ 37 | libhardware_legacy 38 | 39 | LOCAL_CFLAGS += -std=c99 -Wall -Wno-unused-parameter -Wno-missing-field-initializers -Werror 40 | 41 | LOCAL_MULTILIB := 32 42 | 43 | include $(BUILD_EXECUTABLE) 44 | -------------------------------------------------------------------------------- /test/suite/base.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2014 Google, Inc. 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 | #pragma once 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | #ifndef ARRAY_SIZE 30 | # define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 31 | #endif 32 | 33 | #define TASSERT(c, ...) if (!(c)) { fprintf(stderr, "%s:%d: ", __func__, __LINE__); fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n"); return false; } 34 | 35 | extern const bt_interface_t *bt_interface; 36 | extern bt_bdaddr_t bt_remote_bdaddr; 37 | -------------------------------------------------------------------------------- /test/suite/cases/cases.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2014 Google, Inc. 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 | #include "base.h" 20 | #include "cases/cases.h" 21 | 22 | TEST_CASE_DECL(adapter_enable_disable); 23 | TEST_CASE_DECL(adapter_repeated_enable_disable); 24 | TEST_CASE_DECL(adapter_set_name); 25 | TEST_CASE_DECL(adapter_get_name); 26 | TEST_CASE_DECL(adapter_start_discovery); 27 | TEST_CASE_DECL(adapter_cancel_discovery); 28 | 29 | TEST_CASE_DECL(pan_enable); 30 | TEST_CASE_DECL(pan_connect); 31 | TEST_CASE_DECL(pan_disconnect); 32 | TEST_CASE_DECL(pan_quick_reconnect); 33 | 34 | // These are run with the Bluetooth adapter disabled. 35 | const test_case_t sanity_suite[] = { 36 | TEST_CASE(adapter_enable_disable), 37 | TEST_CASE(adapter_repeated_enable_disable), 38 | }; 39 | 40 | // The normal test suite is run with the adapter enabled. 41 | const test_case_t test_suite[] = { 42 | TEST_CASE(adapter_set_name), 43 | TEST_CASE(adapter_get_name), 44 | TEST_CASE(adapter_start_discovery), 45 | TEST_CASE(adapter_cancel_discovery), 46 | 47 | TEST_CASE(pan_enable), 48 | TEST_CASE(pan_connect), 49 | TEST_CASE(pan_disconnect), 50 | }; 51 | 52 | const size_t sanity_suite_size = ARRAY_SIZE(sanity_suite); 53 | const size_t test_suite_size = ARRAY_SIZE(test_suite); 54 | -------------------------------------------------------------------------------- /test/suite/cases/cases.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2014 Google, Inc. 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 | #pragma once 20 | 21 | #include "base.h" 22 | 23 | #define TEST_CASE_DECL(x) bool x() 24 | #define TEST_CASE(x) { x, #x } 25 | 26 | typedef struct { 27 | bool (*function)(); 28 | const char *function_name; 29 | } test_case_t; 30 | 31 | extern const test_case_t test_suite[]; 32 | extern const test_case_t sanity_suite[]; 33 | extern const size_t test_suite_size; 34 | extern const size_t sanity_suite_size; 35 | -------------------------------------------------------------------------------- /test/suite/support/adapter.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2014 Google, Inc. 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 | #include "base.h" 20 | #include "support/adapter.h" 21 | #include "support/callbacks.h" 22 | #include "support/property.h" 23 | 24 | static bt_state_t state; 25 | static int property_count = 0; 26 | static bt_property_t *properties = NULL; 27 | static bt_discovery_state_t discovery_state; 28 | 29 | bt_state_t adapter_get_state() { 30 | return state; 31 | } 32 | 33 | int adapter_get_property_count() { 34 | return property_count; 35 | } 36 | 37 | bt_property_t *adapter_get_property(bt_property_type_t type) { 38 | for (int i = 0; i < property_count; ++i) { 39 | if (properties[i].type == type) { 40 | return &properties[i]; 41 | } 42 | } 43 | 44 | return NULL; 45 | } 46 | 47 | bt_discovery_state_t adapter_get_discovery_state() { 48 | return discovery_state; 49 | } 50 | 51 | // callback 52 | void adapter_state_changed(bt_state_t new_state) { 53 | state = new_state; 54 | CALLBACK_RET(); 55 | } 56 | 57 | // callback 58 | void adapter_properties(bt_status_t status, 59 | int num_properties, 60 | bt_property_t *new_properties) { 61 | property_free_array(properties, property_count); 62 | properties = property_copy_array(new_properties, num_properties); 63 | property_count = num_properties; 64 | 65 | CALLBACK_RET(); 66 | } 67 | 68 | // callback 69 | void discovery_state_changed(bt_discovery_state_t state) { 70 | discovery_state = state; 71 | CALLBACK_RET(); 72 | } 73 | -------------------------------------------------------------------------------- /test/suite/support/adapter.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2014 Google, Inc. 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 | #pragma once 20 | 21 | #include "base.h" 22 | 23 | bt_state_t adapter_get_state(); 24 | int adapter_get_property_count(); 25 | bt_property_t *adapter_get_property(bt_property_type_t type); 26 | bt_discovery_state_t adapter_get_discovery_state(); 27 | -------------------------------------------------------------------------------- /test/suite/support/callbacks.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2014 Google, Inc. 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 | #pragma once 20 | 21 | #include "base.h" 22 | 23 | #include 24 | 25 | #define WAIT(callback) \ 26 | do { \ 27 | sem_t *semaphore = callbacks_get_semaphore(#callback); \ 28 | sem_wait(semaphore); \ 29 | } while (0) 30 | 31 | #define CALL_AND_WAIT(expression, callback) \ 32 | do { \ 33 | sem_t *semaphore = callbacks_get_semaphore(#callback); \ 34 | while (!sem_trywait(semaphore)); \ 35 | expression; \ 36 | sem_wait(semaphore); \ 37 | } while(0) 38 | 39 | // To be called from every exit point of the callback. This macro 40 | // takes 0 or 1 arguments, the return value of the callback. 41 | #define CALLBACK_RET(...) do { \ 42 | sem_t *semaphore = callbacks_get_semaphore(__func__); \ 43 | sem_post(semaphore); \ 44 | return __VA_ARGS__; \ 45 | } while (0) 46 | 47 | void callbacks_init(); 48 | void callbacks_cleanup(); 49 | 50 | bt_callbacks_t *callbacks_get_adapter_struct(); 51 | btpan_callbacks_t *callbacks_get_pan_struct(); 52 | sem_t *callbacks_get_semaphore(const char *name); 53 | -------------------------------------------------------------------------------- /test/suite/support/hal.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2014 Google, Inc. 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 | #pragma once 20 | 21 | #include "base.h" 22 | 23 | bool hal_open(bt_callbacks_t *callbacks); 24 | void hal_close(); 25 | -------------------------------------------------------------------------------- /test/suite/support/pan.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2014 Google, Inc. 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 | #include "base.h" 20 | #include "support/callbacks.h" 21 | #include "support/pan.h" 22 | 23 | const btpan_interface_t *pan_interface; 24 | 25 | static btpan_control_state_t pan_control_state; 26 | static btpan_connection_state_t pan_connection_state; 27 | static int pan_local_role; 28 | static int pan_remote_role; 29 | static bt_status_t pan_error; 30 | static char *pan_ifname; 31 | 32 | bool pan_init() { 33 | pan_interface = bt_interface->get_profile_interface(BT_PROFILE_PAN_ID); 34 | return pan_interface->init(callbacks_get_pan_struct()) == BT_STATUS_SUCCESS; 35 | } 36 | 37 | btpan_control_state_t pan_get_control_state() { 38 | return pan_control_state; 39 | } 40 | 41 | btpan_connection_state_t pan_get_connection_state() { 42 | return pan_connection_state; 43 | } 44 | 45 | int pan_get_local_role() { 46 | return pan_local_role; 47 | } 48 | 49 | int pan_get_remote_role() { 50 | return pan_remote_role; 51 | } 52 | 53 | bt_status_t pan_get_error() { 54 | return pan_error; 55 | } 56 | 57 | // callback 58 | void pan_control_state_changed(btpan_control_state_t state, bt_status_t error, int local_role, const char *ifname) { 59 | free(pan_ifname); 60 | 61 | pan_control_state = state; 62 | pan_local_role = local_role; 63 | pan_error = error; 64 | pan_ifname = strdup(ifname); 65 | 66 | CALLBACK_RET(); 67 | } 68 | 69 | // callback 70 | void pan_connection_state_changed(btpan_connection_state_t state, bt_status_t error, const bt_bdaddr_t *bd_addr, int local_role, int remote_role) { 71 | pan_connection_state = state; 72 | pan_error = error; 73 | pan_local_role = local_role; 74 | pan_remote_role = remote_role; 75 | CALLBACK_RET(); 76 | } 77 | -------------------------------------------------------------------------------- /test/suite/support/pan.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2014 Google, Inc. 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 | #pragma once 20 | 21 | #include "base.h" 22 | 23 | extern const btpan_interface_t *pan_interface; 24 | 25 | bool pan_init(); 26 | 27 | btpan_control_state_t pan_get_control_state(); 28 | btpan_connection_state_t pan_get_connection_state(); 29 | int pan_get_local_role(); 30 | int pan_get_remote_role(); 31 | bt_status_t pan_get_error(); 32 | -------------------------------------------------------------------------------- /test/suite/support/property.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2014 Google, Inc. 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 | #pragma once 20 | 21 | #include "base.h" 22 | 23 | bt_property_t *property_copy_array(const bt_property_t *properties, size_t count); 24 | bt_property_t *property_new_name(const char *name); 25 | bt_property_t *property_new_discovery_timeout(uint32_t timeout); 26 | 27 | const char *property_extract_name(const bt_property_t *property); 28 | 29 | bool property_equals(const bt_property_t *p1, const bt_property_t *p2); 30 | 31 | void property_free(bt_property_t *property); 32 | void property_free_array(bt_property_t *properties, size_t count); 33 | -------------------------------------------------------------------------------- /tools/gen-buildcfg.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [[ "" == "$2" ]] 4 | then 5 | echo "Usage: $0 " 6 | exit 1 7 | fi 8 | 9 | if [ ! -f "$1" ] 10 | then 11 | echo "Error: Can't find input file $1..." 12 | exit 2 13 | fi 14 | 15 | DATE=`/usr/bin/env date` 16 | BASE=`basename $2` 17 | BASE=`echo ${BASE} | tr "[:lower:]" "[:upper:]"` 18 | BASE=`echo ${BASE} | sed -e "s/\\./_/"` 19 | PROTECT="_${BASE}" 20 | 21 | echo "/* Auto-generated from $1 on ${DATE} */" > $2 22 | echo "#ifndef ${PROTECT}" >> $2 23 | echo "#define ${PROTECT}" >> $2 24 | sed -e '/^#/d' -e '/^$$/d' -e '/# Makefile only$$/d' -e 's/^/#define /' -e 's/=/ /' $1 >> $2 25 | echo "#endif" >> $2 26 | 27 | -------------------------------------------------------------------------------- /udrv/ulinux/uipc_linux.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2007-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 | #ifndef _UIPC_LINUX_H_ 19 | #define _UIPC_LINUX_H_ 20 | 21 | typedef int SOCKET; 22 | #define INVALID_SOCKET (SOCKET)(-1) 23 | #define SOCKET_ERROR (-1) 24 | 25 | /* tcp/ip socket configuration */ 26 | typedef struct { 27 | char *p_address; 28 | unsigned int port; 29 | } tUIPC_LINUX_CFG_TCP ; 30 | 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Socket configuration for GLGPS interface */ 37 | extern tUIPC_LINUX_CFG_TCP uipc_linux_cfg_glgps; 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | #endif /* _UIPC_LINUX_H_ */ 43 | -------------------------------------------------------------------------------- /utils/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_C_INCLUDES := \ 6 | $(LOCAL_PATH)/include \ 7 | $(LOCAL_PATH)/../gki/ulinux \ 8 | $(bdroid_C_INCLUDES) 9 | 10 | LOCAL_CFLAGS += $(bdroid_CFLAGS) -std=c99 11 | 12 | LOCAL_PRELINK_MODULE :=false 13 | LOCAL_SRC_FILES := \ 14 | ./src/bt_utils.c 15 | 16 | LOCAL_MODULE := libbt-utils 17 | LOCAL_MODULE_TAGS := optional 18 | LOCAL_MODULE_CLASS := STATIC_LIBRARIES 19 | 20 | include $(BUILD_STATIC_LIBRARY) 21 | -------------------------------------------------------------------------------- /utils/include/bt_utils.h: -------------------------------------------------------------------------------- 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 BT_UTILS_H 20 | #define BT_UTILS_H 21 | 22 | /******************************************************************************* 23 | ** Type definitions 24 | ********************************************************************************/ 25 | 26 | typedef enum { 27 | TASK_HIGH_MEDIA = 0, 28 | TASK_HIGH_GKI_TIMER, 29 | TASK_HIGH_BTU, 30 | TASK_HIGH_HCI_WORKER, 31 | TASK_HIGH_USERIAL_READ, 32 | TASK_UIPC_READ, 33 | TASK_JAVA_ALARM, 34 | TASK_HIGH_MAX 35 | } tHIGH_PRIORITY_TASK; 36 | 37 | /******************************************************************************* 38 | ** Functions 39 | ********************************************************************************/ 40 | 41 | void bt_utils_init(); 42 | void bt_utils_cleanup(); 43 | void raise_priority_a2dp(tHIGH_PRIORITY_TASK high_task); 44 | void adjust_priority_a2dp(int start); 45 | #define UNUSED(x) (void)(x) 46 | #endif /* BT_UTILS_H */ 47 | -------------------------------------------------------------------------------- /vnd/ble/vendor_hcidefs.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Copyright (C) 2003-2014 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 | ** Name vendor_hcidefs.h 22 | ** 23 | ** Function This file contains Broadcom Specific Host Controller Interface 24 | ** definitions. 25 | ** 26 | ******************************************************************************/ 27 | 28 | #ifndef VENDOR_HCIDEFS_H 29 | #define VENDOR_HCIDEFS_H 30 | 31 | /***************************************************************************** 32 | ** Private address resolution VSC 33 | ******************************************************************************/ 34 | 35 | /* VSC */ 36 | #define HCI_VENDOR_BLE_RPA_VSC (0x0155 | HCI_GRP_VENDOR_SPECIFIC) 37 | 38 | /* Sub codes */ 39 | #define HCI_VENDOR_BLE_RPA_ENABLE 0x01 40 | #define HCI_VENDOR_BLE_RPA_ADD_IRK 0x02 41 | #define HCI_VENDOR_BLE_RPA_REMOVE_IRK 0x03 42 | #define HCI_VENDOR_BLE_RPA_CLEAR_IRK 0x04 43 | #define HCI_VENDOR_BLE_RPA_READ_IRK 0x05 44 | 45 | 46 | /***************************************************************************** 47 | ** Advertising data payload filter VSC 48 | ******************************************************************************/ 49 | 50 | /* VSC */ 51 | #define HCI_VENDOR_BLE_PCF_VSC (0x0157 | HCI_GRP_VENDOR_SPECIFIC) 52 | 53 | #endif 54 | 55 | -------------------------------------------------------------------------------- /vnd/include/vendor_api.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Name: vendor_api.h 4 | ** 5 | ** Description: Vendor specific BTE API function external definitions. 6 | ** 7 | ** Copyright (c) 2009-2011, BROADCOM Inc., All Rights Reserved. 8 | ** Broadcom Bluetooth Core. Proprietary and confidential. 9 | ** 10 | ******************************************************************************/ 11 | #ifndef VENDOR_API_H 12 | #define VENDOR_API_H 13 | 14 | #include "bt_types.h" 15 | #include "btm_api.h" 16 | 17 | /**************************************************************************** 18 | ** Resolvable private address offload VSC specific definitions 19 | ******************************************************************************/ 20 | 21 | enum 22 | { 23 | BTM_BLE_PRIVACY_ENABLE, 24 | BTM_BLE_PRIVACY_DISABLE 25 | }; 26 | 27 | 28 | /**************************************************************************** 29 | ** Advertising packet filter VSC specific definitions 30 | ******************************************************************************/ 31 | 32 | 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | /***************************************************************************** 39 | ** VENDOR SPECIFIC BLE FEATURE FUNCTIONS 40 | ******************************************************************************/ 41 | #if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE 42 | 43 | 44 | #endif 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /wipowerif/include/wipower_const.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * Neither the name of The Linux Foundation nor 12 | * the names of its contributors may be used to endorse or promote 13 | * products derived from this software without specific prior written 14 | * permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 20 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 23 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 25 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef _WIPOWER_CONSTANTS_H_ 30 | #define _WIPOWER_CONSTANTS_H_ 31 | 32 | #define WP_HCI_VS_CMD 0xFC1F 33 | 34 | #define WP_HCI_CMD_SET_CURRENT_LIMIT 0x16 35 | #define WP_HCI_CMD_SET_CHARGE_OUTPUT 0x17 36 | #define WP_HCI_CMD_ENABLE_ALERT 0x18 37 | #define WP_HCI_CMD_ENABLE_DATA 0x19 38 | #define WP_HCI_CMD_GET_CURRENT_LIMIT 0x1A 39 | #define WP_HCI_CMD_GET_CHARGE_OUTPUT 0x1B 40 | #define WP_HCI_CMD_ENABLE_POWER 0x1C 41 | 42 | #define WP_HCI_EVENT_ALERT 0x15 43 | #define WP_HCI_EVENT_DATA 0x16 44 | #define WP_HCI_EVENT_POWER_ON 0x17 45 | 46 | /* 47 | * enable: 0x00 disabled, 0x01 enabled: enable/disable detection command 48 | * on: 0x00 power down [event on PRU placed on to PTU] 49 | * 0x01 power up [event on PRU taken out of PTU] 50 | * time_flag: if true then host advertises on 600ms and if false its for 30ms 51 | * i.e. for PTU to short beacon on long beacon detection on charge complete or 52 | * charge required. 53 | */ 54 | int enable_power_apply(bool enable, bool on, bool time_flag); 55 | 56 | #endif /*_WIPOWER_CONSTANTS_H_*/ 57 | --------------------------------------------------------------------------------