Tuesday, October 13, 2015

Inquiry in Bluetooth after turn on BT

BT inquiry:

We are going to start form the scanning or inquiring the device, once the BT is turned ON.


/packages/apps/Settings/src/com/android/settings/bluetooth/BluetoothSettings.java:
This function is get called from the top right cornor where we are doing the refresh.
public boolean onOptionsItemSelected(MenuItem item) --> startScanning();

// this will get called when BT is totaly turned ON.
 public void onBluetoothStateChanged(int bluetoothState)--> startScanning();

// This function will get called when any device is getting bonded once the bonding complete then below content will
get updated.
public void onDeviceBondStateChanged(CachedBluetoothDevice cachedDevice, int bondState) --> startScanning();

 /packages/apps/Settings/src/com/android/settings/bluetooth/LocalBluetoothAdapter.java
startScanning()--> mAdapter.startDiscovery()

/frameworks/base/core/java/android/bluetooth/BluetoothAdapter.java
 : Start the remote device discovery process. The discovery process usually involves an inquiry scan of about 12 seconds, followed by a page
scan of each new device to retrieve its Bluetooth name.
It is asynchronous call, it will return immediately. Register for #ACTION_DISCOVERY_STARTED and ACTION_DISCOVERY_FINISHED intents to determin exactly when the disocvery starts and completes.
Register for BluetoothDevice#ACTION_FOUND to be notified as remote bluetooth devices are found.

NOTE: Discovery is not managed by th eActivity, but is run as a system service, so an application should always call BluetoothAdapter#cancelDiscovery().
Device discovery will only find remote device that are currently discoverable.
 mService.startDiscovery();

/packages/apps/Bluetooth/src/com/android/bluetooth/btservice/AdapterService.java

startDiscovery() --> startDiscoveryNative();

 /packages/apps/Bluetooth/jni/com_android_bluetooth_btservice_AdapterService.cpp

startDiscoveryNative(JNIEnv* env, jobject obj) --> start_discovery();

/hardware/libhardware/include/hardware/bluetooth.h[HAL LAYER]

int (*start_discovery)(void);

/external/bluetooth/bluedroid/btif/src/bluetooth.c [STACK LAYER NOW ONWARDS]

static int start_discovery(void)--> btif_dm_start_discovery();

/external/bluetooth/bluedroid/btif/src/btif_dm.c

btif_dm_start_discovery-->   BTA_DmSearch(&inq_params, services, bte_search_devices_evt);

/external/bluetooth/bluedroid/bta/dm/bta_dm_api.c
// This function searches for peer bluetooth devices.It performs an inquiry and gets the rremote name for devices.

BTA_DmSearch()


/external/bluetooth/bluedroid/bta/dm/bta_dm_act.c
//Start an inquiry
bta_dm_search_start() --> BTM_StartInquiry()

/external/bluetooth/bluedroid/stack/btm/btm_inq.c
// for start the inquiry:
BTM_StartInquiry(), p_results_cb  -- is the pointer to callback with inquiry result.

NOTE: Inquiry having 3 second timeout waiting for response.

------------------- after inquiry complete sending data to application side------------------
/external/bluetooth/bluedroid/btif/src/btif_dm.c
//Switches context from BTE to BTIF for DM search events
bte_search_devices_evt()---> btif_dm_search_devices_evt()

/external/bluetooth/bluedroid/btif/src/btif_dm.c
btif_dm_search_devices_evt()-->
  HAL_CBACK(bt_hal_cbacks, device_found_cb,num_properties, properties);

  /hardware/libhardware/include/hardware/bluetooth.h[HAL layer]
device_found_callback device_found_cb;

/packages/apps/Bluetooth/jni/com_android_bluetooth_btservice_AdapterService.cpp
device_found_callback () -->devicePropertyChangedCallback()

/packages/apps/Bluetooth/src/com/android/bluetooth/btservice/JniCallbacks.java

devicePropertyChangedCallback () -->  mRemoteDevices.devicePropertyChangedCallback(address, types, val);


/packages/apps/Bluetooth/src/com/android/bluetooth/btservice/RemoteDevices.java

devicePropertyChangedCallback() -->

No comments:

Post a Comment

Qualcomm Short Term

  113 is the SL. 1st Target by mid July.

Total Pageviews