You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/11/10 22:39:29 UTC
[22/50] [abbrv] incubator-mynewt-core git commit: BLE IAS svc -
Update to use sysinit.
BLE IAS svc - Update to use sysinit.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/bbe1c78a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/bbe1c78a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/bbe1c78a
Branch: refs/heads/master
Commit: bbe1c78a1896c1a5f12839514aecba0add6610f4
Parents: 44fffd4
Author: Christopher Collins <cc...@apache.org>
Authored: Tue Nov 8 14:15:09 2016 -0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Nov 8 14:15:09 2016 -0800
----------------------------------------------------------------------
.../ias/include/services/ias/ble_svc_ias.h | 6 ++--
net/nimble/host/services/ias/pkg.yml | 2 ++
net/nimble/host/services/ias/src/ble_svc_ias.c | 38 ++++++++++----------
3 files changed, 22 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/bbe1c78a/net/nimble/host/services/ias/include/services/ias/ble_svc_ias.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/ias/include/services/ias/ble_svc_ias.h b/net/nimble/host/services/ias/include/services/ias/ble_svc_ias.h
index da173cf..b63b458 100644
--- a/net/nimble/host/services/ias/include/services/ias/ble_svc_ias.h
+++ b/net/nimble/host/services/ias/include/services/ias/ble_svc_ias.h
@@ -20,8 +20,6 @@
#ifndef H_BLE_IAS_TPS_
#define H_BLE_IAS_TPS_
-struct ble_hs_cfg;
-
#define BLE_SVC_IAS_UUID16 0x1802
#define BLE_SVC_IAS_CHR_UUID16_ALERT_LEVEL 0x2a06
@@ -32,8 +30,8 @@ struct ble_hs_cfg;
typedef int ble_svc_ias_event_fn(uint8_t alert_level);
-int ble_svc_ias_init(struct ble_hs_cfg *cfg,
- ble_svc_ias_event_fn *cb);
+void ble_svc_ias_set_cb(ble_svc_ias_event_fn *cb);
+void ble_svc_ias_init(void);
#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/bbe1c78a/net/nimble/host/services/ias/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/ias/pkg.yml b/net/nimble/host/services/ias/pkg.yml
index 39242f4..3879906 100644
--- a/net/nimble/host/services/ias/pkg.yml
+++ b/net/nimble/host/services/ias/pkg.yml
@@ -30,3 +30,5 @@ pkg.keywords:
pkg.deps:
- net/nimble/host
+pkg.init_function: ble_svc_ias_init
+pkg.init_stage: 3
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/bbe1c78a/net/nimble/host/services/ias/src/ble_svc_ias.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/ias/src/ble_svc_ias.c b/net/nimble/host/services/ias/src/ble_svc_ias.c
index 07b98f1..4af6936 100644
--- a/net/nimble/host/services/ias/src/ble_svc_ias.c
+++ b/net/nimble/host/services/ias/src/ble_svc_ias.c
@@ -19,11 +19,13 @@
#include <assert.h>
#include <string.h>
+#include "sysinit/sysinit.h"
#include "host/ble_hs.h"
#include "services/ias/ble_svc_ias.h"
/* Callback function */
static ble_svc_ias_event_fn *ble_svc_ias_cb_fn;
+
/* Alert level */
static uint8_t ble_svc_ias_alert_level;
@@ -114,33 +116,29 @@ ble_svc_ias_access(uint16_t conn_handle, uint16_t attr_handle,
}
/**
- * Initialize the IAS. The developer must specify the event function
- * callback for the IAS to function properly.
+ * Designates the specified function as the IAS callback. This callback is
+ * necessary for this service to function properly.
*
* @param cb The callback function to call when
* the client signals an alert.
*/
-int
-ble_svc_ias_init(struct ble_hs_cfg *cfg, ble_svc_ias_event_fn *cb)
+void
+ble_svc_ias_set_cb(ble_svc_ias_event_fn *cb)
{
- int rc;
-
- if (!cb) {
- return BLE_HS_EINVAL;
- }
-
ble_svc_ias_cb_fn = cb;
+}
- rc = ble_gatts_count_cfg(ble_svc_ias_defs, cfg);
- if (rc != 0) {
- return rc;
- }
+/**
+ * Initialize the IAS package.
+ */
+void
+ble_svc_ias_init(void)
+{
+ int rc;
+
+ rc = ble_gatts_count_cfg(ble_svc_ias_defs);
+ SYSINIT_PANIC_ASSERT(rc == 0);
rc = ble_gatts_add_svcs(ble_svc_ias_defs);
- if (rc != 0) {
- return rc;
- }
-
- return 0;
+ SYSINIT_PANIC_ASSERT(rc == 0);
}
-