You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/04/25 21:34:35 UTC

[GitHub] andrzej-kaczmarek closed pull request #58: call ble_gatts_chr_updated() on battery level change

andrzej-kaczmarek closed pull request #58: call ble_gatts_chr_updated() on battery level change
URL: https://github.com/apache/mynewt-nimble/pull/58
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/nimble/host/services/bas/include/services/bas/ble_svc_bas.h b/nimble/host/services/bas/include/services/bas/ble_svc_bas.h
index 690d0a7c..2706b5d3 100644
--- a/nimble/host/services/bas/include/services/bas/ble_svc_bas.h
+++ b/nimble/host/services/bas/include/services/bas/ble_svc_bas.h
@@ -26,11 +26,6 @@
 /* 16 Bit Battery Service Characteristic UUIDs */
 #define BLE_SVC_BAS_CHR_UUID16_BATTERY_LEVEL                 0x2A19
 
-void ble_svc_bas_on_gap_connect(uint16_t conn_handle);
-
-void ble_svc_bas_init(void);
-
 int ble_svc_bas_battery_level_set(uint8_t level);
 
 #endif
-
diff --git a/nimble/host/services/bas/src/ble_svc_bas.c b/nimble/host/services/bas/src/ble_svc_bas.c
index ac8d5b58..631519cf 100644
--- a/nimble/host/services/bas/src/ble_svc_bas.c
+++ b/nimble/host/services/bas/src/ble_svc_bas.c
@@ -31,14 +31,6 @@
 static uint16_t ble_svc_bas_battery_handle;
 #endif
 
-/* Connection handle 
- *
- * TODO: In order to support multiple connections we would need to save
- *       the handles for every connection, not just the most recent. Then
- *       we would need to notify each connection when needed.
- * */
-static uint16_t ble_svc_bas_conn_handle;
-
 /* Battery level */
 uint8_t ble_svc_bas_battery_level;
 
@@ -84,7 +76,7 @@ ble_svc_bas_access(uint16_t conn_handle, uint16_t attr_handle,
 {
     uint16_t uuid16 = ble_uuid_u16(ctxt->chr->uuid);
     int rc;
-    
+
     switch (uuid16) {
     case BLE_SVC_BAS_CHR_UUID16_BATTERY_LEVEL:
         assert(ctxt->op == BLE_GATT_ACCESS_OP_READ_CHR);
@@ -98,19 +90,6 @@ ble_svc_bas_access(uint16_t conn_handle, uint16_t attr_handle,
     }
 }
 
-/**
- * This function must be called with the connection handle when a gap 
- * connect event is received in order to send notifications to the
- * client.
- *
- * @params conn_handle          The connection handle for the current
- *                                  connection.
- */
-void 
-ble_svc_bas_on_gap_connect(uint16_t conn_handle) 
-{
-    ble_svc_bas_conn_handle = conn_handle;
-}
 
 /**
  * Set the battery level, must be between 0 and 100.
@@ -118,17 +97,15 @@ ble_svc_bas_on_gap_connect(uint16_t conn_handle)
  */
 int
 ble_svc_bas_battery_level_set(uint8_t level) {
-    int rc = 0;
     if (level > 100)
 	level = 100;
     if (ble_svc_bas_battery_level != level) {
 	ble_svc_bas_battery_level = level;
 #if MYNEWT_VAL(BLE_SVC_BAS_BATTERY_LEVEL_NOTIFY_ENABLE) > 0
-	rc = ble_gattc_notify(ble_svc_bas_conn_handle,
-			      ble_svc_bas_battery_handle);
+        ble_gatts_chr_updated(ble_svc_bas_battery_handle);
 #endif
     }
-    return rc;
+    return 0;
 }
 
 /**


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services