</li>
<li>Bluetooth LE
<ul class="toc">
- <li><a href="#le_adapter">Enabling the Bluetooth LE Adapter and Checking its State</a></li>
<li><a href="#le_scan">Managing Bluetooth LE Scans</a></li>
<li><a href="#add_adv_data">Adding Advertising Data to the LE Advertisement</a></li>
<li><a href="#set_adv_conn">Setting the Advertising Connectable Mode</a></li>
<li>Bluetooth LE
<ul>
- <li><a href="#le_adapter">Enabling the Bluetooth LE Adapter and Checking its State</a>
- <p>Ensure that the Bluetooth LE (BLE) adapter is enabled.</p></li>
<li><a href="#le_scan">Managing Bluetooth LE Scans</a>
<p>Start the scan, handle the scanning results, and stop the scan.</p></li>
<li><a href="#add_adv_data">Adding Advertising Data to the LE Advertisement</a>
int test_id = (int)data;
int ret;
char *uuid = NULL;
- char *str = NULL;
bt_gatt_get_uuid(svc_handle, &uuid);
- bt_gatt_get_uuid_specification_name(uuid, &str);
+ dlog_print(DLOG_INFO, LOG_TAG, "[%d / %d] uuid : (%s)", index, total, uuid);
- dlog_print(DLOG_INFO, LOG_TAG, "[%d / %d] %s (%s)", index, total, str ? str : "Unknown", uuid);
-
- g_free(str);
g_free(uuid);
if (test_id == BT_UNIT_TEST_FUNCTION_GATT_CLIENT_PRINT_ALL)
{
int ret;
char *uuid = NULL;
- char *str = NULL;
bt_gatt_get_uuid(chr_handle, &uuid);
- bt_gatt_get_uuid_specification_name(uuid, &str);
- dlog_print(DLOG_INFO, LOG_TAG, "\t[%d / %d] %s (%s)", index, total, str ? str : "Unknown", uuid);
+ dlog_print(DLOG_INFO, LOG_TAG, "\t[%d / %d] uuid : (%s)", index, total, uuid);
__bt_gatt_client_print_value(chr_handle);
- g_free(str);
g_free(uuid);
ret = bt_gatt_characteristic_foreach_descriptors(chr_handle,
bool __bt_gatt_client_foreach_desc_cb(int total, int index, bt_gatt_h desc_handle, void *data)
{
char *uuid = NULL;
- char *str = NULL;
bt_gatt_get_uuid(desc_handle, &uuid);
- bt_gatt_get_uuid_specification_name(uuid, &str);
- dlog_print(DLOG_INFO, LOG_TAG, "\t\t[%d / %d] %s (%s)", index, total, str ? str : "Unknown", uuid);
+ dlog_print(DLOG_INFO, LOG_TAG, "\t\t[%d / %d] uuid : (%s)", index, total, uuid);
__bt_gatt_client_print_value(desc_handle);
g_free(str);
void __bt_gatt_client_read_complete_cb(int result, bt_gatt_h gatt_handle, void *data)
{
char *uuid = NULL;
- char *str = NULL;
bt_gatt_get_uuid(gatt_handle, &uuid);
- bt_gatt_get_uuid_specification_name(uuid, &str);
- dlog_print(DLOG_INFO, LOG_TAG, "Read %s for %s (%s)",
- result == BT_ERROR_NONE ? "Success" : "Fail", str ? str : "Unknown", uuid);
+ dlog_print(DLOG_INFO, LOG_TAG, "Read %s for uuid : (%s)",
+ result == BT_ERROR_NONE ? "Success" : "Fail", uuid);
g_free(str);
g_free(uuid);
void __bt_gatt_client_write_complete_cb(int result, bt_gatt_h gatt_handle, void *data)
{
char *uuid = NULL;
- char *str = NULL;
bt_gatt_get_uuid(gatt_handle, &uuid);
- bt_gatt_get_uuid_specification_name(uuid, &str);
- dlog_print(DLOG_INFO, LOG_TAG, "Write %s for %s (%s)",
- result == BT_ERROR_NONE ? "Success" : "Fail", str ? str : "Unknown", uuid);
+ dlog_print(DLOG_INFO, LOG_TAG, "Write %s for uuid : (%s)",
+ result == BT_ERROR_NONE ? "Success" : "Fail", uuid);
g_free(str);
g_free(uuid);
- <h2 id="le_adapter" name="le_adapter">Enabling the Bluetooth LE Adapter and Checking its State</h2>
-
- <p>In order to communicate with the remote device or to perform BLE (Bluetooth LE) operations on the local device, the LE adapter must be enabled. The device user can enable or disable BLE in the device with an ON/OFF button. The procedure applies to both basic rate and enhanced data rate (BR/EDR).</p>
-
- <p class="figure">Figure: Bluetooth ON/OFF button</p>
- <p align="center"><img alt="Bluetooth ON/OFF button" src="../../images/bluetooth_onoff.png" /></p>
-
- <p>To check whether the BLE adapter is enabled, retrieve the adapter state:</p>
-
-<pre class="prettyprint">
-bt_adapter_le_state_e le_adapter_state;
-// Check whether BLE is enabled
-ret = bt_adapter_get_le_state(&le_adapter_state);
-
-if (ret != BT_ERROR_NONE)
-{
- dlog_print(DLOG_ERROR, LOG_TAG, "[bt_adapter_le_get_state] Failed");
-
- return;
-}
-
-// If the Bluetooth service is disabled
-if (le_adapter_state == BT_ADAPTER_DISABLED)
-{
- dlog_print(DLOG_ERROR, LOG_TAG, "Bluetooth LE adapter is not enabled. You should enable Bluetooth!!");
-}
-</pre>
-<p>To monitor the changes in the LE adapter and BLE states, define and register the appropriate callback functions.</p>
-
-
<h2 id="le_scan" name="le_scan">Managing Bluetooth LE Scans</h2>
<p>To discover nearby LE devices, perform a scan:</p>
</script>
</body>
-</html>
\ No newline at end of file
+</html>