From 4268edbc1f6fa662537d45b55f76069d777149fc Mon Sep 17 00:00:00 2001 From: Michal Pawluk Date: Mon, 21 Dec 2015 14:38:05 +0100 Subject: [PATCH] [SAMPLE APP][Bluetooth LE Service] Advertiser creation section added Change-Id: If1ed526722480666ecaf4bb0ec30edd8cee132c0 Signed-off-by: Michal Pawluk --- .../html/wearable_n/bluetooth_le_service_sd_wn.htm | 59 ++++++++++++++++++++-- 1 file changed, 54 insertions(+), 5 deletions(-) diff --git a/org.tizen.sampledescriptions/html/wearable_n/bluetooth_le_service_sd_wn.htm b/org.tizen.sampledescriptions/html/wearable_n/bluetooth_le_service_sd_wn.htm index 037fe68..4d52b36 100644 --- a/org.tizen.sampledescriptions/html/wearable_n/bluetooth_le_service_sd_wn.htm +++ b/org.tizen.sampledescriptions/html/wearable_n/bluetooth_le_service_sd_wn.htm @@ -117,11 +117,13 @@ See the References section for the details of all the undescr

Advertiser creation

-

Data advertising

-

Once the Bluetooth adapter state is changed to BT_ADAPTER_ENABLED and the -__bt_device_state_changed_cb() callback function is invoked, the advertiser is created and the service starts its normal operation. +__bt_device_state_changed_cb() callback function is invoked, the advertiser creation procedure takes place. +
+In case the __bt_device_state_changed_cb() callback function is invoked with the +adapter_state argument set to BT_ADAPTER_DISABLED, +the currently running advertiser is deleted (bt_advertiser_delete()).

@@ -141,10 +143,57 @@ static void __bt_device_state_changed_cb(int result, bt_adapter_state_e adapter_
 

-In the advertiser creation procedure (bt_advertiser_create()) its initial configuration takes place and the advertising is started -(see the Advertiser creation section). +The bt_advertiser_create() function creates the advertiser handle, performs its initial configuration and starts advertising. +

+ +
+bool bt_advertiser_create(bt_advertiser_h *adv_h, int appearance)
+{
+   if (!__create_advertizer(adv_h, appearance))
+      return false;
+
+   if (!bt_common_start_advertising(*adv_h, NULL)) {
+      __delete_advertizer(adv_h);
+      return false;
+   }
+
+   __advertizer_appearance = appearance;
+
+   return true;
+}
+
+ +

+The advertiser's handle's creation and initial configuration is performed by the __create_advertizer() function listed below. +Once the function succeeds, the advertising starts (bt_common_start_advertising()).

+
+static bool __create_advertizer(bt_advertiser_h *adv_h, int appearance)
+{
+   *adv_h = NULL;
+
+   if (!bt_common_create_advertizer(adv_h))
+      return false;
+
+   if (!bt_common_set_advertising_mode(*adv_h, BT_ADAPTER_LE_ADVERTISING_MODE_LOW_LATENCY))
+      return false;
+
+   if (!bt_common_set_connectable(*adv_h))
+      return false;
+
+   if (!__set_advertizing_properties(*adv_h))
+      return false;
+
+   if (!__set_scan_response_properties(*adv_h, appearance))
+      return false;
+
+   return true;
+}
+
+ +

Data advertising

+

Each time data is received from the Heart Rate sensor, the __sensor_data_read_cb() callback function is invoked. Within this function, the Heart Rate measurement value is packed into the advertiser buffer and broadcasted over the Bluetooth network with the relevant UUID value. Together with the obtained measurement, -- 2.7.4