Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id D0F55200BBD for ; Tue, 8 Nov 2016 23:57:26 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id CFC78160AD0; Tue, 8 Nov 2016 22:57:26 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 01BB4160B0C for ; Tue, 8 Nov 2016 23:57:25 +0100 (CET) Received: (qmail 47115 invoked by uid 500); 8 Nov 2016 22:57:25 -0000 Mailing-List: contact commits-help@mynewt.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@mynewt.incubator.apache.org Delivered-To: mailing list commits@mynewt.incubator.apache.org Received: (qmail 47022 invoked by uid 99); 8 Nov 2016 22:57:24 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Nov 2016 22:57:24 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 9358B1A9B42 for ; Tue, 8 Nov 2016 22:57:24 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -6.219 X-Spam-Level: X-Spam-Status: No, score=-6.219 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id AdzdlK-HAtn4 for ; Tue, 8 Nov 2016 22:57:23 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with SMTP id 2F1B95FC5F for ; Tue, 8 Nov 2016 22:57:22 +0000 (UTC) Received: (qmail 36808 invoked by uid 99); 8 Nov 2016 22:54:52 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Nov 2016 22:54:52 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 48728E0BB1; Tue, 8 Nov 2016 22:54:52 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ccollins@apache.org To: commits@mynewt.incubator.apache.org Date: Tue, 08 Nov 2016 22:55:09 -0000 Message-Id: <10ec80bbea6044378a6fe7d8de779f96@git.apache.org> In-Reply-To: <21043bec7898403eb0c9d008284b6b67@git.apache.org> References: <21043bec7898403eb0c9d008284b6b67@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [19/22] incubator-mynewt-core git commit: BLE ANS service - Use sysinit. archived-at: Tue, 08 Nov 2016 22:57:27 -0000 BLE ANS service - 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/32b0d33a Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/32b0d33a Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/32b0d33a Branch: refs/heads/develop Commit: 32b0d33a3a409668e9199c9bb6c28a8f5db3d374 Parents: ff4ce46 Author: Christopher Collins Authored: Tue Nov 8 14:40:56 2016 -0800 Committer: Christopher Collins Committed: Tue Nov 8 14:40:56 2016 -0800 ---------------------------------------------------------------------- .../ans/include/services/ans/ble_svc_ans.h | 4 +- net/nimble/host/services/ans/pkg.yml | 3 + net/nimble/host/services/ans/src/ble_svc_ans.c | 65 ++++++++------------ net/nimble/host/services/ans/syscfg.yml | 25 ++++++++ 4 files changed, 56 insertions(+), 41 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/32b0d33a/net/nimble/host/services/ans/include/services/ans/ble_svc_ans.h ---------------------------------------------------------------------- diff --git a/net/nimble/host/services/ans/include/services/ans/ble_svc_ans.h b/net/nimble/host/services/ans/include/services/ans/ble_svc_ans.h index eaf102a..8d3e3cf 100644 --- a/net/nimble/host/services/ans/include/services/ans/ble_svc_ans.h +++ b/net/nimble/host/services/ans/include/services/ans/ble_svc_ans.h @@ -79,9 +79,7 @@ int ble_svc_ans_new_alert_add(uint8_t cat_id, const char * info_str); int ble_svc_ans_unr_alert_add(uint8_t cat_id); -int ble_svc_ans_init(struct ble_hs_cfg *cfg, - uint8_t initial_new_alert_cat, - uint8_t initial_unr_alert_cat); +void ble_svc_ans_init(void); #endif http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/32b0d33a/net/nimble/host/services/ans/pkg.yml ---------------------------------------------------------------------- diff --git a/net/nimble/host/services/ans/pkg.yml b/net/nimble/host/services/ans/pkg.yml index 91a92c6..41a738c 100644 --- a/net/nimble/host/services/ans/pkg.yml +++ b/net/nimble/host/services/ans/pkg.yml @@ -29,3 +29,6 @@ pkg.keywords: pkg.deps: - net/nimble/host + +pkg.init_function: ble_svc_ans_init +pkg.init_stage: 3 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/32b0d33a/net/nimble/host/services/ans/src/ble_svc_ans.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/services/ans/src/ble_svc_ans.c b/net/nimble/host/services/ans/src/ble_svc_ans.c index eae4598..249e2f5 100644 --- a/net/nimble/host/services/ans/src/ble_svc_ans.c +++ b/net/nimble/host/services/ans/src/ble_svc_ans.c @@ -20,6 +20,8 @@ #include #include #include +#include "sysinit/sysinit.h" +#include "syscfg/syscfg.h" #include "host/ble_hs.h" #include "host/ble_gap.h" #include "services/ans/ble_svc_ans.h" @@ -348,44 +350,6 @@ ble_svc_ans_unr_alert_add(uint8_t cat_id) } /** - * Initialize the ANS with initial values for enabled categories - * for new and unread alert characteristics. Bitwise or the - * catagory bitmasks to enable multiple catagories. - * - * XXX: We should technically be able to change the new alert and - * unread alert catagories when we have no active connections. - * - * @param cfg The host configuration - * @param initial_new_alert_cat Initial supported new alert category - * bitmask. - * @param initial_unr_alert_cat Initial supported unread alert category - * bitmask. - * - * @return 0 on success, non-zero error code otherwise. - */ -int -ble_svc_ans_init(struct ble_hs_cfg *cfg, uint8_t initial_new_alert_cat, - uint8_t initial_unr_alert_cat) -{ - int rc; - - ble_svc_ans_new_alert_cat = initial_new_alert_cat; - ble_svc_ans_unr_alert_cat = initial_unr_alert_cat; - - rc = ble_gatts_count_cfg(ble_svc_ans_defs, cfg); - if (rc != 0) { - return rc; - } - - rc = ble_gatts_add_svcs(ble_svc_ans_defs); - if (rc != 0) { - return rc; - } - - return 0; -} - -/** * Send a new alert notification to the given category with the * given info string. * @@ -465,3 +429,28 @@ ble_svc_ans_chr_write(struct os_mbuf *om, uint16_t min_len, return 0; } + +/** + * Initialize the ANS with initial values for enabled categories + * for new and unread alert characteristics. Bitwise or the + * catagory bitmasks to enable multiple catagories. + * + * XXX: We should technically be able to change the new alert and + * unread alert catagories when we have no active connections. + * + * @return 0 on success, non-zero error code otherwise. + */ +void +ble_svc_ans_init(void) +{ + int rc; + + rc = ble_gatts_count_cfg(ble_svc_ans_defs); + SYSINIT_PANIC_ASSERT(rc == 0); + + rc = ble_gatts_add_svcs(ble_svc_ans_defs); + SYSINIT_PANIC_ASSERT(rc == 0); + + ble_svc_ans_new_alert_cat = MYNEWT_VAL(BLE_SVC_ANS_NEW_ALERT_CAT); + ble_svc_ans_unr_alert_cat = MYNEWT_VAL(BLE_SVC_ANS_UNR_ALERT_CAT); +} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/32b0d33a/net/nimble/host/services/ans/syscfg.yml ---------------------------------------------------------------------- diff --git a/net/nimble/host/services/ans/syscfg.yml b/net/nimble/host/services/ans/syscfg.yml new file mode 100644 index 0000000..a77f23d --- /dev/null +++ b/net/nimble/host/services/ans/syscfg.yml @@ -0,0 +1,25 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +syscfg.defs: + BLE_SVC_ANS_NEW_ALERT_CAT: + description: "Initial supported new alert category bitmask." + value: 0 + + BLE_SVC_ANS_UNR_ALERT_CAT: + description: "Initial supported unread alert category bitmask." + value: 0