Return-Path: X-Original-To: apmail-mynewt-commits-archive@minotaur.apache.org Delivered-To: apmail-mynewt-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DB83B19D19 for ; Tue, 15 Mar 2016 00:36:27 +0000 (UTC) Received: (qmail 42854 invoked by uid 500); 15 Mar 2016 00:36:27 -0000 Delivered-To: apmail-mynewt-commits-archive@mynewt.apache.org Received: (qmail 42784 invoked by uid 500); 15 Mar 2016 00:36:27 -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 42765 invoked by uid 99); 15 Mar 2016 00:36:27 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Mar 2016 00:36:27 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 389731804EA for ; Tue, 15 Mar 2016 00:36:27 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -3.299 X-Spam-Level: X-Spam-Status: No, score=-3.299 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, KAM_LOTSOFHASH=0.25, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.329] autolearn=disabled Received: from mx2-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id ZhjcJPgEYJ3E for ; Tue, 15 Mar 2016 00:36:13 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx2-lw-eu.apache.org (ASF Mail Server at mx2-lw-eu.apache.org) with SMTP id DA5B55F3F5 for ; Tue, 15 Mar 2016 00:36:09 +0000 (UTC) Received: (qmail 40628 invoked by uid 99); 15 Mar 2016 00:36:09 -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, 15 Mar 2016 00:36:09 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id DDE6EDFF8A; Tue, 15 Mar 2016 00:36:08 +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, 15 Mar 2016 00:36:10 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [03/42] incubator-mynewt-core git commit: Reflect repository name change in yml files. Types in packages. Move projects -> apps. http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/libs/console/stub/pkg.yml ---------------------------------------------------------------------- diff --git a/libs/console/stub/pkg.yml b/libs/console/stub/pkg.yml index 6a73d9c..cf9da84 100644 --- a/libs/console/stub/pkg.yml +++ b/libs/console/stub/pkg.yml @@ -22,8 +22,8 @@ pkg.vers: 0.8.0 pkg.description: Stub for text-based IO interface. pkg.author: Marko Kiiskila pkg.homepage: http://mynewt.apache.org/os/modules/console/console/ -pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva +pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core pkg.keywords: pkg.deps: -pkg.caps: console +pkg.apis: console http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/libs/elua/elua_base/pkg.yml ---------------------------------------------------------------------- diff --git a/libs/elua/elua_base/pkg.yml b/libs/elua/elua_base/pkg.yml index 6388961..ffb48a1 100644 --- a/libs/elua/elua_base/pkg.yml +++ b/libs/elua/elua_base/pkg.yml @@ -24,14 +24,14 @@ pkg.author: - Bogdan Marinescu - Dado Sutter pkg.homepage: http://www.eluaproject.net/ -pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva +pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core pkg.keywords: - lua - scripting - interpreter pkg.cflags: -DLUA_OPTIMIZE_MEMORY=2 -DLUA_CROSS_COMPILER -DLUA_USE_MKSTEMP -DLUA_NUMBER_INTEGRAL -DMYNEWT -pkg.req_caps: +pkg.req_apis: - console pkg.deps: - fs/fs http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/libs/flash_test/pkg.yml ---------------------------------------------------------------------- diff --git a/libs/flash_test/pkg.yml b/libs/flash_test/pkg.yml index c830455..569f72f 100644 --- a/libs/flash_test/pkg.yml +++ b/libs/flash_test/pkg.yml @@ -19,12 +19,17 @@ pkg.name: libs/flash_test pkg.vers: 0.8.0 +pkg.description: flash HAL tester +pkg.homepage: +pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core +pkg.keywords: + pkg.deps: - libs/os - libs/util - hw/hal - libs/baselibc -pkg.reqs: +pkg.req_apis: - console -pkg.identities: +pkg.features: - TEST http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/libs/imgmgr/pkg.yml ---------------------------------------------------------------------- diff --git a/libs/imgmgr/pkg.yml b/libs/imgmgr/pkg.yml index f1a3a8c..fd22888 100644 --- a/libs/imgmgr/pkg.yml +++ b/libs/imgmgr/pkg.yml @@ -22,7 +22,7 @@ pkg.vers: 0.8.0 pkg.description: Library for image uploading. pkg.author: Marko Kiiskila pkg.homepage: http://mynewt.apache.org/os/modules/imgmgr/imgmgr/ -pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva +pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core pkg.keywords: pkg.deps: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/libs/json/pkg.yml ---------------------------------------------------------------------- diff --git a/libs/json/pkg.yml b/libs/json/pkg.yml index cf2032a..a9e45a9 100644 --- a/libs/json/pkg.yml +++ b/libs/json/pkg.yml @@ -22,7 +22,7 @@ pkg.vers: 0.8.0 pkg.description: JSON encoding / decoding library. pkg.author: Sterling Hughes pkg.homepage: http://mynewt.apache.org/os/modules/json/json/ -pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva +pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core pkg.keywords: pkg.cflags.float_user: -DFLOAT_SUPPORT http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/libs/mbedtls/pkg.yml ---------------------------------------------------------------------- diff --git a/libs/mbedtls/pkg.yml b/libs/mbedtls/pkg.yml index d877198..a36d9af 100644 --- a/libs/mbedtls/pkg.yml +++ b/libs/mbedtls/pkg.yml @@ -22,7 +22,7 @@ pkg.vers: 0.8.0 pkg.description: SSL / TLS library for embedded systems. pkg.author: ARM pkg.homepage: https://tls.mbed.org/ -pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva +pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core pkg.keywords: - ssl - tls http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/libs/newtmgr/pkg.yml ---------------------------------------------------------------------- diff --git a/libs/newtmgr/pkg.yml b/libs/newtmgr/pkg.yml index 83c25e6..fc7c0db 100644 --- a/libs/newtmgr/pkg.yml +++ b/libs/newtmgr/pkg.yml @@ -22,7 +22,7 @@ pkg.vers: 0.8.0 pkg.description: Server-side newtmgr functionality. pkg.author: Sterling Hughes pkg.homepage: -pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva +pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core pkg.keywords: pkg.deps: @@ -32,5 +32,5 @@ pkg.deps: - libs/testutil - libs/shell -pkg.identities: +pkg.features: - NEWTMGR http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/libs/os/pkg.yml ---------------------------------------------------------------------- diff --git a/libs/os/pkg.yml b/libs/os/pkg.yml index 6cf0627..bf7fa7d 100644 --- a/libs/os/pkg.yml +++ b/libs/os/pkg.yml @@ -22,13 +22,13 @@ pkg.vers: 0.8.0 pkg.description: Mynewt operating system core. pkg.author: wes3 pkg.homepage: http://mynewt.apache.org/os/core_os/mynewt_os/ -pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva +pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core pkg.keywords: pkg.deps: - libs/testutil - libs/util -pkg.req_caps: +pkg.req_apis: - console pkg.deps.SHELL: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/libs/shell/pkg.yml ---------------------------------------------------------------------- diff --git a/libs/shell/pkg.yml b/libs/shell/pkg.yml index 389f162..8600f68 100644 --- a/libs/shell/pkg.yml +++ b/libs/shell/pkg.yml @@ -22,13 +22,13 @@ pkg.vers: 0.8.0 pkg.description: Command processor for console-based applications. pkg.author: Sterling Hughes pkg.homepage: http://mynewt.apache.org/os/modules/shell/shell/ -pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva +pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core pkg.keywords: pkg.deps: - libs/os - libs/util -pkg.reqs: +pkg.apis: - console -pkg.identities: +pkg.features: - SHELL http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/libs/testreport/pkg.yml ---------------------------------------------------------------------- diff --git a/libs/testreport/pkg.yml b/libs/testreport/pkg.yml index c0ca116..84b82ad 100644 --- a/libs/testreport/pkg.yml +++ b/libs/testreport/pkg.yml @@ -22,7 +22,7 @@ pkg.vers: 0.8.0 pkg.description: Library for recording unit test results to flash. pkg.author: Christopher Collins pkg.homepage: -pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva +pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core pkg.keywords: - unit - test http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/libs/testutil/pkg.yml ---------------------------------------------------------------------- diff --git a/libs/testutil/pkg.yml b/libs/testutil/pkg.yml index 1d899d5..070b149 100644 --- a/libs/testutil/pkg.yml +++ b/libs/testutil/pkg.yml @@ -22,7 +22,7 @@ pkg.vers: 0.8.0 pkg.description: Support library for implementing unit tests. pkg.author: Christopher Collins pkg.homepage: http://mynewt.apache.org/os/modules/testutil/testutil/ -pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva +pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core pkg.keywords: - unit - test http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/libs/util/pkg.yml ---------------------------------------------------------------------- diff --git a/libs/util/pkg.yml b/libs/util/pkg.yml index 3ef5276..f61c089 100644 --- a/libs/util/pkg.yml +++ b/libs/util/pkg.yml @@ -22,7 +22,7 @@ pkg.vers: 0.8.0 pkg.description: Library containing miscellaneous utilities. pkg.author: Sterling Hughes pkg.homepage: -pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva +pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core pkg.keywords: - base64 - circular buffer http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/net/nimble/controller/pkg.yml ---------------------------------------------------------------------- diff --git a/net/nimble/controller/pkg.yml b/net/nimble/controller/pkg.yml index 379a7ba..c521aec 100644 --- a/net/nimble/controller/pkg.yml +++ b/net/nimble/controller/pkg.yml @@ -22,7 +22,7 @@ pkg.vers: 0.8.0 pkg.description: Controller side of the nimble Bluetooth Smart stack. pkg.author: wes3 pkg.homepage: -pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva +pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core pkg.keywords: - ble - bluetooth @@ -31,5 +31,5 @@ pkg.deps: - libs/os - sys/stats - net/nimble -pkg.identities: +pkg.features: - BLE_DEVICE http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/net/nimble/drivers/native/pkg.yml ---------------------------------------------------------------------- diff --git a/net/nimble/drivers/native/pkg.yml b/net/nimble/drivers/native/pkg.yml index f0a6d3a..272d2dd 100644 --- a/net/nimble/drivers/native/pkg.yml +++ b/net/nimble/drivers/native/pkg.yml @@ -22,11 +22,11 @@ pkg.vers: 0.8.0 pkg.description: BLE driver for simulations. pkg.author: wes3 pkg.homepage: -pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva +pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core pkg.keywords: - ble - bluetooth -pkg.caps: ble_driver +pkg.apis: ble_driver pkg.deps: - net/nimble/controller http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/net/nimble/drivers/nrf51/pkg.yml ---------------------------------------------------------------------- diff --git a/net/nimble/drivers/nrf51/pkg.yml b/net/nimble/drivers/nrf51/pkg.yml index 78ad311..1ebfaec 100644 --- a/net/nimble/drivers/nrf51/pkg.yml +++ b/net/nimble/drivers/nrf51/pkg.yml @@ -22,12 +22,12 @@ pkg.vers: 0.8.0 pkg.description: BLE driver for nRF51 systems. pkg.author: wes3 pkg.homepage: -pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva +pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core pkg.keywords: - ble - bluetooth -pkg.caps: ble_driver +pkg.apis: ble_driver pkg.deps: - net/nimble - net/nimble/controller http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/net/nimble/drivers/nrf52/pkg.yml ---------------------------------------------------------------------- diff --git a/net/nimble/drivers/nrf52/pkg.yml b/net/nimble/drivers/nrf52/pkg.yml index f9f2a8b..e4255bb 100644 --- a/net/nimble/drivers/nrf52/pkg.yml +++ b/net/nimble/drivers/nrf52/pkg.yml @@ -22,12 +22,12 @@ pkg.vers: 0.8.0 pkg.description: BLE driver for nRF52 systems. pkg.author: wes3 pkg.homepage: -pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva +pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core pkg.keywords: - ble - bluetooth -pkg.caps: ble_driver +pkg.apis: ble_driver pkg.deps: - net/nimble - net/nimble/controller http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/net/nimble/host/pkg.yml ---------------------------------------------------------------------- diff --git a/net/nimble/host/pkg.yml b/net/nimble/host/pkg.yml index a4610be..5e07071 100644 --- a/net/nimble/host/pkg.yml +++ b/net/nimble/host/pkg.yml @@ -22,7 +22,7 @@ pkg.vers: 0.8.0 pkg.description: Host side of the nimble Bluetooth Smart stack. pkg.author: Christopher Collins pkg.homepage: -pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva +pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core pkg.keywords: - ble - bluetooth @@ -33,7 +33,7 @@ pkg.deps: - libs/os - libs/util - net/nimble -pkg.req_caps: +pkg.req_apis: - console # Satisfy capability dependencies for the self-contained test executable. http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/net/nimble/pkg.yml ---------------------------------------------------------------------- diff --git a/net/nimble/pkg.yml b/net/nimble/pkg.yml index e5e2b90..70c31b8 100644 --- a/net/nimble/pkg.yml +++ b/net/nimble/pkg.yml @@ -22,7 +22,7 @@ pkg.vers: 0.8.0 pkg.description: Generic functionality for the nimble Bluetooth Smart stack; used by both the controller and the host. pkg.author: wes3 pkg.homepage: -pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva +pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core pkg.keywords: - ble - bluetooth http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/pkg-list.yml ---------------------------------------------------------------------- diff --git a/pkg-list.yml b/pkg-list.yml index 3edb569..f3cae7e 100644 --- a/pkg-list.yml +++ b/pkg-list.yml @@ -38,14 +38,14 @@ pkgs: libs/console/stub: vers: 0.8.0 hash: d41aedc5941495ca9320cc013f68ee73d4e349ab - caps: + apis: - console@none#stable libs/os: vers: 0.8.0 hash: 999a3419d9959d3c39b11dcc67d79c7888b4b765 deps: - libs/testutil@none#stable - req_caps: + req_apis: - console@none#stable project/blinky: vers: 0.8.0 @@ -74,7 +74,7 @@ pkgs: hash: 513cc71e129320e3e2d80a9cdfc748db6c83fbb4 deps: - net/nimble/controller@none#stable - caps: + apis: - ble_driver@none#stable fs/fs: vers: 0.8.0 @@ -92,7 +92,7 @@ pkgs: hash: 0f4bff75e83236ad27c49ba9a161d50b76c648fb deps: - fs/fs@none#stable - req_caps: + req_apis: - console@none#stable libs/util: vers: 0.8.0 @@ -220,7 +220,7 @@ pkgs: deps: - net/nimble@none#stable - net/nimble/controller@none#stable - caps: + apis: - ble_driver@none#stable compiler/arm-none-eabi-m4: vers: 0.8.0 @@ -231,7 +231,7 @@ pkgs: deps: - hw/hal@none#stable - libs/os@none#stable - caps: + apis: - console@none#stable hw/mcu/stm/stm32f4xx: vers: 0.0.0 @@ -295,7 +295,7 @@ pkgs: - libs/os@none#stable - libs/util@none#stable - net/nimble@none#stable - req_caps: + req_apis: - console@none#stable libs/imgmgr: vers: 0.8.0 @@ -319,7 +319,7 @@ pkgs: libs/baselibc: vers: 0.8.0 hash: bb46b003c472b16309bd9fbed81f5c4c62bd4aa5 - req_caps: + req_apis: - console@none#stable net/nimble/drivers/nrf52: vers: 0.8.0 @@ -327,7 +327,7 @@ pkgs: deps: - net/nimble@none#stable - net/nimble/controller@none#stable - caps: + apis: - ble_driver@none#stable hw/mcu/nordic/nrf51xxx: vers: 0.0.0 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/project.yml ---------------------------------------------------------------------- diff --git a/project.yml b/project.yml new file mode 100644 index 0000000..5c30981 --- /dev/null +++ b/project.yml @@ -0,0 +1,26 @@ +# +# 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. +# + +project.name: "apache-mynewt-core" + +repository.apache-mynewt-core: + type: github + vers: 0-latest + user: sterlinghughes + repo: incubator-mynewt-core http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/project/bleprph/src/bleprph.h ---------------------------------------------------------------------- diff --git a/project/bleprph/src/bleprph.h b/project/bleprph/src/bleprph.h deleted file mode 100644 index e903fe0..0000000 --- a/project/bleprph/src/bleprph.h +++ /dev/null @@ -1,43 +0,0 @@ -/** - * 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. - */ - -#ifndef H_BLEPRPH_ -#define H_BLEPRPH_ - -#include "log/log.h" - -void gatt_svr_init(void); - -extern struct log bleprph_log; - -extern const char *bleprph_device_name; -extern const uint16_t bleprph_appearance; -extern const uint8_t bleprph_privacy_flag; -extern uint8_t bleprph_reconnect_addr[6]; -extern uint8_t bleprph_pref_conn_params[8]; -extern uint8_t bleprph_gatt_service_changed[4]; - -/* bleprph uses the first "peruser" log module. */ -#define BLEPRPH_LOG_MODULE (LOG_MODULE_PERUSER + 0) - -/* Convenience macro for logging to the bleprph module. */ -#define BLEPRPH_LOG(lvl, ...) \ - LOG_ ## lvl(&bleprph_log, BLEPRPH_LOG_MODULE, __VA_ARGS__) - -#endif http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/project/bleprph/src/gatt_svr.c ---------------------------------------------------------------------- diff --git a/project/bleprph/src/gatt_svr.c b/project/bleprph/src/gatt_svr.c deleted file mode 100644 index 27a1433..0000000 --- a/project/bleprph/src/gatt_svr.c +++ /dev/null @@ -1,342 +0,0 @@ -/** - * 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. - */ - -#include -#include -#include "bsp/bsp.h" -#include "console/console.h" -#include "host/ble_hs.h" -#include "bleprph.h" - -#define GATT_SVR_SVC_ALERT_UUID 0x1811 -#define GATT_SVR_CHR_SUP_NEW_ALERT_CAT_UUID 0x2A47 -#define GATT_SVR_CHR_NEW_ALERT 0x2A46 -#define GATT_SVR_CHR_SUP_UNR_ALERT_CAT_UUID 0x2A48 -#define GATT_SVR_CHR_UNR_ALERT_STAT_UUID 0x2A45 -#define GATT_SVR_CHR_ALERT_NOT_CTRL_PT 0x2A44 - -static int -gatt_svr_chr_access_gap(uint16_t conn_handle, uint16_t attr_handle, uint8_t op, - union ble_gatt_access_ctxt *ctxt, void *arg); -static int -gatt_svr_chr_access_gatt(uint16_t conn_handle, uint16_t attr_handle, uint8_t op, - union ble_gatt_access_ctxt *ctxt, void *arg); -static int -gatt_svr_chr_access_alert(uint16_t conn_handle, uint16_t attr_handle, - uint8_t op, union ble_gatt_access_ctxt *ctxt, - void *arg); - -static const struct ble_gatt_svc_def gatt_svr_svcs[] = { - { - /*** Service: GAP. */ - .type = BLE_GATT_SVC_TYPE_PRIMARY, - .uuid128 = BLE_UUID16(BLE_GAP_SVC_UUID16), - .characteristics = (struct ble_gatt_chr_def[]) { { - /*** Characteristic: Device Name. */ - .uuid128 = BLE_UUID16(BLE_GAP_CHR_UUID16_DEVICE_NAME), - .access_cb = gatt_svr_chr_access_gap, - .flags = BLE_GATT_CHR_F_READ, - }, { - /*** Characteristic: Appearance. */ - .uuid128 = BLE_UUID16(BLE_GAP_CHR_UUID16_APPEARANCE), - .access_cb = gatt_svr_chr_access_gap, - .flags = BLE_GATT_CHR_F_READ, - }, { - /*** Characteristic: Peripheral Privacy Flag. */ - .uuid128 = BLE_UUID16(BLE_GAP_CHR_UUID16_PERIPH_PRIV_FLAG), - .access_cb = gatt_svr_chr_access_gap, - .flags = BLE_GATT_CHR_F_READ, - }, { - /*** Characteristic: Reconnection Address. */ - .uuid128 = BLE_UUID16(BLE_GAP_CHR_UUID16_RECONNECT_ADDR), - .access_cb = gatt_svr_chr_access_gap, - .flags = BLE_GATT_CHR_F_WRITE, - }, { - /*** Characteristic: Peripheral Preferred Connection Parameters. */ - .uuid128 = BLE_UUID16(BLE_GAP_CHR_UUID16_PERIPH_PREF_CONN_PARAMS), - .access_cb = gatt_svr_chr_access_gap, - .flags = BLE_GATT_CHR_F_READ, - }, { - 0, /* No more characteristics in this service. */ - } }, - }, - - { - /*** Service: GATT */ - .type = BLE_GATT_SVC_TYPE_PRIMARY, - .uuid128 = BLE_UUID16(BLE_GATT_SVC_UUID16), - .characteristics = (struct ble_gatt_chr_def[]) { { - .uuid128 = BLE_UUID16(BLE_GATT_CHR_SERVICE_CHANGED_UUID16), - .access_cb = gatt_svr_chr_access_gatt, - .flags = BLE_GATT_CHR_F_INDICATE, - }, { - 0, /* No more characteristics in this service. */ - } }, - }, - - { - /*** Alert Notification Service. */ - .type = BLE_GATT_SVC_TYPE_PRIMARY, - .uuid128 = BLE_UUID16(GATT_SVR_SVC_ALERT_UUID), - .characteristics = (struct ble_gatt_chr_def[]) { { - .uuid128 = BLE_UUID16(GATT_SVR_CHR_SUP_NEW_ALERT_CAT_UUID), - .access_cb = gatt_svr_chr_access_alert, - .flags = BLE_GATT_CHR_F_READ, - }, { - .uuid128 = BLE_UUID16(GATT_SVR_CHR_NEW_ALERT), - .access_cb = gatt_svr_chr_access_alert, - .flags = BLE_GATT_CHR_F_NOTIFY, - }, { - .uuid128 = BLE_UUID16(GATT_SVR_CHR_SUP_UNR_ALERT_CAT_UUID), - .access_cb = gatt_svr_chr_access_alert, - .flags = BLE_GATT_CHR_F_READ, - }, { - .uuid128 = BLE_UUID16(GATT_SVR_CHR_UNR_ALERT_STAT_UUID), - .access_cb = gatt_svr_chr_access_alert, - .flags = BLE_GATT_CHR_F_NOTIFY, - }, { - .uuid128 = BLE_UUID16(GATT_SVR_CHR_ALERT_NOT_CTRL_PT), - .access_cb = gatt_svr_chr_access_alert, - .flags = BLE_GATT_CHR_F_WRITE, - }, { - 0, /* No more characteristics in this service. */ - } }, - }, - - { - 0, /* No more services. */ - }, -}; - -static int -gatt_svr_chr_write(uint8_t op, union ble_gatt_access_ctxt *ctxt, - uint16_t min_len, uint16_t max_len, void *dst, - uint16_t *len) -{ - assert(op == BLE_GATT_ACCESS_OP_WRITE_CHR); - if (ctxt->chr_access.len < min_len || - ctxt->chr_access.len > max_len) { - return BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN; - } - memcpy(dst, ctxt->chr_access.data, ctxt->chr_access.len); - if (len != NULL) { - *len = ctxt->chr_access.len; - } - - return 0; -} - -static int -gatt_svr_chr_access_gap(uint16_t conn_handle, uint16_t attr_handle, uint8_t op, - union ble_gatt_access_ctxt *ctxt, void *arg) -{ - uint16_t uuid16; - - uuid16 = ble_uuid_128_to_16(ctxt->chr_access.chr->uuid128); - assert(uuid16 != 0); - - switch (uuid16) { - case BLE_GAP_CHR_UUID16_DEVICE_NAME: - assert(op == BLE_GATT_ACCESS_OP_READ_CHR); - ctxt->chr_access.data = (void *)bleprph_device_name; - ctxt->chr_access.len = strlen(bleprph_device_name); - break; - - case BLE_GAP_CHR_UUID16_APPEARANCE: - assert(op == BLE_GATT_ACCESS_OP_READ_CHR); - ctxt->chr_access.data = (void *)&bleprph_appearance; - ctxt->chr_access.len = sizeof bleprph_appearance; - break; - - case BLE_GAP_CHR_UUID16_PERIPH_PRIV_FLAG: - assert(op == BLE_GATT_ACCESS_OP_READ_CHR); - ctxt->chr_access.data = (void *)&bleprph_privacy_flag; - ctxt->chr_access.len = sizeof bleprph_privacy_flag; - break; - - case BLE_GAP_CHR_UUID16_RECONNECT_ADDR: - assert(op == BLE_GATT_ACCESS_OP_WRITE_CHR); - if (ctxt->chr_access.len != sizeof bleprph_reconnect_addr) { - return BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN; - } - memcpy(bleprph_reconnect_addr, ctxt->chr_access.data, - sizeof bleprph_reconnect_addr); - break; - - case BLE_GAP_CHR_UUID16_PERIPH_PREF_CONN_PARAMS: - assert(op == BLE_GATT_ACCESS_OP_READ_CHR); - ctxt->chr_access.data = (void *)&bleprph_pref_conn_params; - ctxt->chr_access.len = sizeof bleprph_pref_conn_params; - break; - - default: - assert(0); - break; - } - - return 0; -} - -static int -gatt_svr_chr_access_gatt(uint16_t conn_handle, uint16_t attr_handle, uint8_t op, - union ble_gatt_access_ctxt *ctxt, void *arg) -{ - uint16_t uuid16; - - uuid16 = ble_uuid_128_to_16(ctxt->chr_access.chr->uuid128); - assert(uuid16 != 0); - - switch (uuid16) { - case BLE_GATT_CHR_SERVICE_CHANGED_UUID16: - if (op == BLE_GATT_ACCESS_OP_WRITE_CHR) { - if (ctxt->chr_access.len != sizeof bleprph_gatt_service_changed) { - return BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN; - } - memcpy(bleprph_gatt_service_changed, ctxt->chr_access.data, - sizeof bleprph_gatt_service_changed); - } else if (op == BLE_GATT_ACCESS_OP_READ_CHR) { - ctxt->chr_access.data = (void *)&bleprph_gatt_service_changed; - ctxt->chr_access.len = sizeof bleprph_gatt_service_changed; - } - break; - - default: - assert(0); - break; - } - - return 0; -} - -#define GATT_SVR_NEW_ALERT_VAL_MAX_LEN 64 - -static const uint8_t gatt_svr_new_alert_cat = 0x01; /* Simple alert. */ -static uint8_t gatt_svr_new_alert_val[GATT_SVR_NEW_ALERT_VAL_MAX_LEN]; -static uint16_t gatt_svr_new_alert_val_len; -static const uint8_t gatt_svr_unr_alert_cat = 0x01; /* Simple alert. */ -static uint16_t gatt_svr_unr_alert_stat; -static uint16_t gatt_svr_alert_not_ctrl_pt; - -static int -gatt_svr_chr_access_alert(uint16_t conn_handle, uint16_t attr_handle, - uint8_t op, union ble_gatt_access_ctxt *ctxt, - void *arg) -{ - uint16_t uuid16; - int rc; - - uuid16 = ble_uuid_128_to_16(ctxt->chr_access.chr->uuid128); - assert(uuid16 != 0); - - switch (uuid16) { - case GATT_SVR_CHR_SUP_NEW_ALERT_CAT_UUID: - assert(op == BLE_GATT_ACCESS_OP_READ_CHR); - ctxt->chr_access.data = (void *)&gatt_svr_new_alert_cat; - ctxt->chr_access.len = sizeof gatt_svr_new_alert_cat; - return 0; - - case GATT_SVR_CHR_NEW_ALERT: - if (op == BLE_GATT_ACCESS_OP_WRITE_CHR) { - rc = gatt_svr_chr_write(op, ctxt, 0, sizeof gatt_svr_new_alert_val, - gatt_svr_new_alert_val, - &gatt_svr_new_alert_val_len); - return rc; - } else if (op == BLE_GATT_ACCESS_OP_READ_CHR) { - ctxt->chr_access.data = (void *)&gatt_svr_new_alert_val; - ctxt->chr_access.len = sizeof gatt_svr_new_alert_val; - return 0; - } - - case GATT_SVR_CHR_SUP_UNR_ALERT_CAT_UUID: - assert(op == BLE_GATT_ACCESS_OP_READ_CHR); - ctxt->chr_access.data = (void *)&gatt_svr_unr_alert_cat; - ctxt->chr_access.len = sizeof gatt_svr_unr_alert_cat; - return 0; - - case GATT_SVR_CHR_UNR_ALERT_STAT_UUID: - if (op == BLE_GATT_ACCESS_OP_WRITE_CHR) { - rc = gatt_svr_chr_write(op, ctxt, 2, 2, &gatt_svr_unr_alert_stat, - NULL); - } else { - ctxt->chr_access.data = (void *)&gatt_svr_unr_alert_stat; - ctxt->chr_access.len = sizeof gatt_svr_unr_alert_stat; - rc = 0; - } - return rc; - - case GATT_SVR_CHR_ALERT_NOT_CTRL_PT: - if (op == BLE_GATT_ACCESS_OP_WRITE_CHR) { - rc = gatt_svr_chr_write(op, ctxt, 2, 2, - &gatt_svr_alert_not_ctrl_pt, NULL); - } else { - rc = BLE_ATT_ERR_UNLIKELY; - } - return rc; - - default: - assert(0); - return BLE_ATT_ERR_UNLIKELY; - } -} - -static void -gatt_svr_register_cb(uint8_t op, union ble_gatt_register_ctxt *ctxt, void *arg) -{ - uint16_t uuid16; - - switch (op) { - case BLE_GATT_REGISTER_OP_SVC: - uuid16 = ble_uuid_128_to_16(ctxt->svc_reg.svc->uuid128); - assert(uuid16 != 0); - BLEPRPH_LOG(DEBUG, "registered service 0x%04x with handle=%d\n", - uuid16, ctxt->svc_reg.handle); - break; - - case BLE_GATT_REGISTER_OP_CHR: - uuid16 = ble_uuid_128_to_16(ctxt->chr_reg.chr->uuid128); - assert(uuid16 != 0); - BLEPRPH_LOG(DEBUG, "registering characteristic 0x%04x with " - "def_handle=%d val_handle=%d\n", - uuid16, ctxt->chr_reg.def_handle, - ctxt->chr_reg.val_handle); - break; - - case BLE_GATT_REGISTER_OP_DSC: - uuid16 = ble_uuid_128_to_16(ctxt->dsc_reg.dsc->uuid128); - assert(uuid16 != 0); - BLEPRPH_LOG(DEBUG, "registering descriptor 0x%04x with handle=%d " - "chr_handle=%d\n", - uuid16, ctxt->dsc_reg.dsc_handle, - ctxt->dsc_reg.chr_def_handle); - break; - - default: - assert(0); - break; - } -} - -void -gatt_svr_init(void) -{ - int rc; - - rc = ble_gatts_register_svcs(gatt_svr_svcs, gatt_svr_register_cb, NULL); - assert(rc == 0); -} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/project/bleprph/src/main.c ---------------------------------------------------------------------- diff --git a/project/bleprph/src/main.c b/project/bleprph/src/main.c deleted file mode 100755 index 8824428..0000000 --- a/project/bleprph/src/main.c +++ /dev/null @@ -1,299 +0,0 @@ -/** - * 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. - */ -#include -#include -#include -#include -#include "bsp/bsp.h" -#include "os/os.h" -#include "bsp/bsp.h" -#include "hal/hal_gpio.h" -#include "hal/hal_cputime.h" -#include "console/console.h" - -/* BLE */ -#include "nimble/ble.h" -#include "host/host_hci.h" -#include "host/ble_hs.h" -#include "host/ble_hs_adv.h" -#include "host/ble_uuid.h" -#include "host/ble_att.h" -#include "host/ble_gap.h" -#include "host/ble_gatt.h" -#include "controller/ble_ll.h" - -#include "bleprph.h" - -#define BSWAP16(x) ((uint16_t)(((x) << 8) | (((x) & 0xff00) >> 8))) - -/** Mbuf settings. */ -#define MBUF_NUM_MBUFS (8) -#define MBUF_BUF_SIZE OS_ALIGN(BLE_MBUF_PAYLOAD_SIZE, 4) -#define MBUF_MEMBLOCK_SIZE (MBUF_BUF_SIZE + BLE_MBUF_MEMBLOCK_OVERHEAD) -#define MBUF_MEMPOOL_SIZE OS_MEMPOOL_SIZE(MBUF_NUM_MBUFS, MBUF_MEMBLOCK_SIZE) - -static os_membuf_t bleprph_mbuf_mpool_data[MBUF_MEMPOOL_SIZE]; -struct os_mbuf_pool bleprph_mbuf_pool; -struct os_mempool bleprph_mbuf_mpool; - -/** Log data. */ -static struct log_handler bleprph_log_console_handler; -struct log bleprph_log; - -/** Priority of the nimble host task. */ -#define BLEPRPH_BLE_HS_PRIO (1) - -/** bleprph task settings. */ -#define BLEPRPH_STACK_SIZE (OS_STACK_ALIGN(200)) -#define BLEPRPH_TASK_PRIO (BLEPRPH_BLE_HS_PRIO + 1) - -struct os_eventq bleprph_evq; -struct os_task bleprph_task; -bssnz_t os_stack_t bleprph_stack[BLEPRPH_STACK_SIZE]; - -/** Our global device address (public) */ -uint8_t g_dev_addr[BLE_DEV_ADDR_LEN] = {0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a}; - -/** Our random address (in case we need it) */ -uint8_t g_random_addr[BLE_DEV_ADDR_LEN]; - -/** Device name - included in advertisements and exposed by GAP service. */ -const char *bleprph_device_name = "nimble-bleprph"; - -/** Device properties - exposed by GAP service. */ -const uint16_t bleprph_appearance = BSWAP16(BLE_GAP_APPEARANCE_GEN_COMPUTER); -const uint8_t bleprph_privacy_flag = 0; -uint8_t bleprph_reconnect_addr[6]; -uint8_t bleprph_pref_conn_params[8]; -uint8_t bleprph_gatt_service_changed[4]; - -static int bleprph_on_connect(int event, int status, - struct ble_gap_conn_ctxt *ctxt, void *arg); - -/** - * Utility function to log an array of bytes. - */ -static void -bleprph_print_bytes(uint8_t *bytes, int len) -{ - int i; - - for (i = 0; i < len; i++) { - BLEPRPH_LOG(INFO, "%s0x%02x", i != 0 ? ":" : "", bytes[i]); - } -} - -/** - * Logs information about a connection to the console. - */ -static void -bleprph_print_conn_desc(struct ble_gap_conn_desc *desc) -{ - BLEPRPH_LOG(INFO, "handle=%d peer_addr_type=%d peer_addr=", - desc->conn_handle, desc->peer_addr_type); - bleprph_print_bytes(desc->peer_addr, 6); - BLEPRPH_LOG(INFO, " conn_itvl=%d conn_latency=%d supervision_timeout=%d", - desc->conn_itvl, desc->conn_latency, - desc->supervision_timeout); -} - -/** - * Enables advertising with the following parameters: - * o General discoverable mode. - * o Undirected connectable mode. - */ -static void -bleprph_advertise(void) -{ - struct ble_hs_adv_fields fields; - int rc; - - /* Set the advertisement data included in our advertisements. */ - memset(&fields, 0, sizeof fields); - fields.name = (uint8_t *)bleprph_device_name; - fields.name_len = strlen(bleprph_device_name); - fields.name_is_complete = 1; - rc = ble_gap_adv_set_fields(&fields); - if (rc != 0) { - BLEPRPH_LOG(ERROR, "error setting advertisement data; rc=%d\n", rc); - return; - } - - /* Begin advertising. */ - rc = ble_gap_adv_start(BLE_GAP_DISC_MODE_GEN, BLE_GAP_CONN_MODE_UND, - NULL, 0, NULL, bleprph_on_connect, NULL); - if (rc != 0) { - BLEPRPH_LOG(ERROR, "error enabling advertisement; rc=%d\n", rc); - return; - } -} - -static int -bleprph_on_connect(int event, int status, struct ble_gap_conn_ctxt *ctxt, - void *arg) -{ - switch (event) { - case BLE_GAP_EVENT_CONN: - BLEPRPH_LOG(INFO, "connection %s; status=%d ", - status == 0 ? "up" : "down", status); - bleprph_print_conn_desc(ctxt->desc); - BLEPRPH_LOG(INFO, "\n"); - - if (status != 0) { - /* Connection terminated; resume advertising. */ - bleprph_advertise(); - } - break; - - case BLE_GAP_EVENT_CONN_UPDATED: - BLEPRPH_LOG(INFO, "connection updated; status=%d ", status); - bleprph_print_conn_desc(ctxt->desc); - BLEPRPH_LOG(INFO, "\n"); - break; - - case BLE_GAP_EVENT_CONN_UPDATE_REQ: - BLEPRPH_LOG(INFO, "connection update request; status=%d ", status); - *ctxt->self_params = *ctxt->peer_params; - break; - } - - return 0; -} - -/** - * Event loop for the main bleprph task. - */ -static void -bleprph_task_handler(void *unused) -{ - struct os_event *ev; - struct os_callout_func *cf; - - /* Register GATT attributes (services, characteristics, and - * descriptors). - */ - gatt_svr_init(); - - /* Initialize eventq */ - os_eventq_init(&bleprph_evq); - - /* Begin advertising. */ - bleprph_advertise(); - - while (1) { - ev = os_eventq_get(&bleprph_evq); - switch (ev->ev_type) { - case OS_EVENT_T_TIMER: - cf = (struct os_callout_func *)ev; - assert(cf->cf_func); - cf->cf_func(cf->cf_arg); - break; - default: - assert(0); - break; - } - } -} - -/** - * main - * - * The main function for the project. This function initializes the os, calls - * init_tasks to initialize tasks (and possibly other objects), then starts the - * OS. We should not return from os start. - * - * @return int NOTE: this function should never return! - */ -int -main(void) -{ - struct ble_hs_cfg cfg; - uint32_t seed; - int rc; - int i; - - /* Initialize OS */ - os_init(); - - /* Set cputime to count at 1 usec increments */ - rc = cputime_init(1000000); - assert(rc == 0); - - /* Seed random number generator with least significant bytes of device - * address. - */ - seed = 0; - for (i = 0; i < 4; ++i) { - seed |= g_dev_addr[i]; - seed <<= 8; - } - srand(seed); - - /* Initialize msys mbufs. */ - rc = os_mempool_init(&bleprph_mbuf_mpool, MBUF_NUM_MBUFS, - MBUF_MEMBLOCK_SIZE, bleprph_mbuf_mpool_data, - "bleprph_mbuf_data"); - assert(rc == 0); - - rc = os_mbuf_pool_init(&bleprph_mbuf_pool, &bleprph_mbuf_mpool, - MBUF_MEMBLOCK_SIZE, MBUF_NUM_MBUFS); - assert(rc == 0); - - rc = os_msys_register(&bleprph_mbuf_pool); - assert(rc == 0); - - /* Initialize the logging system. */ - log_init(); - log_console_handler_init(&bleprph_log_console_handler); - log_register("bleprph", &bleprph_log, &bleprph_log_console_handler); - - os_task_init(&bleprph_task, "bleprph", bleprph_task_handler, - NULL, BLEPRPH_TASK_PRIO, OS_WAIT_FOREVER, - bleprph_stack, BLEPRPH_STACK_SIZE); - - /* Initialize the BLE LL */ - rc = ble_ll_init(); - assert(rc == 0); - - /* Initialize the BLE host. */ - cfg = ble_hs_cfg_dflt; - cfg.max_hci_bufs = 3; - cfg.max_connections = 1; - cfg.max_attrs = 32; - cfg.max_services = 4; - cfg.max_client_configs = 6; - cfg.max_gattc_procs = 2; - cfg.max_l2cap_chans = 3; - cfg.max_l2cap_sig_procs = 2; - - rc = ble_hs_init(BLEPRPH_BLE_HS_PRIO, &cfg); - assert(rc == 0); - - /* Initialize the console (for log output). */ - rc = console_init(NULL); - assert(rc == 0); - - /* Start the OS */ - os_start(); - - /* os start should never return. If it does, this should be an error */ - assert(0); - - return 0; -} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/project/bletest/pkg.yml ---------------------------------------------------------------------- diff --git a/project/bletest/pkg.yml b/project/bletest/pkg.yml deleted file mode 100644 index de3fdaa..0000000 --- a/project/bletest/pkg.yml +++ /dev/null @@ -1,40 +0,0 @@ -# -# 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. -# - -pkg.name: bletest -pkg.vers: 0.8.0 -pkg.description: Test project for the nimble BLE controller. -pkg.author: wes3 -pkg.homepage: -pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva -pkg.keywords: - -pkg.deps: - - net/nimble/controller - - net/nimble/host - - libs/os - - libs/console/full - - libs/baselibc - - libs/shell - - libs/imgmgr - - libs/newtmgr - - sys/config - - sys/log - - sys/stats -pkg.cflags: -DBLETEST http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/project/bletest/src/main.c ---------------------------------------------------------------------- diff --git a/project/bletest/src/main.c b/project/bletest/src/main.c deleted file mode 100755 index d004aa9..0000000 --- a/project/bletest/src/main.c +++ /dev/null @@ -1,969 +0,0 @@ -/** - * 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. - */ - -#include -#include -#include "os/os.h" -#include "bsp/bsp.h" -#include "hal/hal_gpio.h" -#include "hal/hal_cputime.h" -#include "hal/hal_flash.h" -#include "console/console.h" -#include "shell/shell.h" -#include "stats/stats.h" -#include "hal/flash_map.h" -#include "fs/fs.h" -#include "nffs/nffs.h" -#include "newtmgr/newtmgr.h" -#include "imgmgr/imgmgr.h" - -/* BLE */ -#include "nimble/ble.h" -#include "nimble/hci_transport.h" -#include "nimble/hci_common.h" -#include "host/host_hci.h" -#include "host/ble_hs.h" -#include "controller/ble_ll.h" -#include "controller/ble_ll_hci.h" -#include "controller/ble_ll_conn.h" -#include "controller/ble_ll_scan.h" -#include "controller/ble_ll_adv.h" - -/* Task priorities */ -/* NOTE: highest priority task (0) reserved for controller LL task */ -#define HOST_TASK_PRIO (OS_TASK_PRI_HIGHEST + 1) -#define BLETEST_TASK_PRIO (HOST_TASK_PRIO + 1) -#define SHELL_TASK_PRIO (BLETEST_TASK_PRIO + 1) -#define NEWTMGR_TASK_PRIO (SHELL_TASK_PRIO + 1) - -/* Shell task stack */ -#define SHELL_TASK_STACK_SIZE (OS_STACK_ALIGN(256)) -os_stack_t shell_stack[SHELL_TASK_STACK_SIZE]; - -/* Newt manager task stack */ -#define NEWTMGR_TASK_STACK_SIZE (OS_STACK_ALIGN(448)) -os_stack_t newtmgr_stack[NEWTMGR_TASK_STACK_SIZE]; - -/* Shell maximum input line length */ -#define SHELL_MAX_INPUT_LEN (256) - -/* For LED toggling */ -int g_led_pin; - -/* Our global device address (public) */ -uint8_t g_dev_addr[BLE_DEV_ADDR_LEN]; - -/* Our random address (in case we need it) */ -uint8_t g_random_addr[BLE_DEV_ADDR_LEN]; - -/* A buffer for host advertising data */ -uint8_t g_host_adv_data[BLE_HCI_MAX_ADV_DATA_LEN]; -uint8_t g_host_adv_len; - -/* Create a mbuf pool of BLE mbufs */ -#define MBUF_NUM_MBUFS (42) -#define MBUF_BUF_SIZE OS_ALIGN(BLE_MBUF_PAYLOAD_SIZE, 4) -#define MBUF_MEMBLOCK_SIZE (MBUF_BUF_SIZE + BLE_MBUF_MEMBLOCK_OVERHEAD) -#define MBUF_MEMPOOL_SIZE OS_MEMPOOL_SIZE(MBUF_NUM_MBUFS, MBUF_MEMBLOCK_SIZE) - -struct os_mbuf_pool g_mbuf_pool; -struct os_mempool g_mbuf_mempool; -os_membuf_t g_mbuf_buffer[MBUF_MEMPOOL_SIZE]; - -/* Some application configurations */ -#define BLETEST_ROLE_ADVERTISER (0) -#define BLETEST_ROLE_SCANNER (1) -#define BLETEST_ROLE_INITIATOR (2) -#define BLETEST_CFG_ROLE (BLETEST_ROLE_INITIATOR) -//#define BLETEST_CFG_ROLE (BLETEST_ROLE_ADVERTISER) -//#define BLETEST_CFG_ROLE (BLETEST_ROLE_SCANNER) -#define BLETEST_CFG_ADV_OWN_ADDR_TYPE (BLE_HCI_ADV_OWN_ADDR_PUBLIC) -#define BLETEST_CFG_ADV_PEER_ADDR_TYPE (BLE_HCI_ADV_PEER_ADDR_PUBLIC) -#define BLETEST_CFG_FILT_DUP_ADV (0) -#define BLETEST_CFG_ADV_ITVL (600000 / BLE_HCI_ADV_ITVL) -#define BLETEST_CFG_ADV_TYPE BLE_HCI_ADV_TYPE_ADV_IND -#define BLETEST_CFG_ADV_FILT_POLICY (BLE_HCI_ADV_FILT_NONE) -#define BLETEST_CFG_SCAN_ITVL (700000 / BLE_HCI_SCAN_ITVL) -#define BLETEST_CFG_SCAN_WINDOW (700000 / BLE_HCI_SCAN_ITVL) -#define BLETEST_CFG_SCAN_TYPE (BLE_HCI_SCAN_TYPE_ACTIVE) -#define BLETEST_CFG_SCAN_FILT_POLICY (BLE_HCI_SCAN_FILT_NO_WL) -#define BLETEST_CFG_CONN_ITVL (128) /* in 1.25 msec increments */ -#define BLETEST_CFG_SLAVE_LATENCY (0) -#define BLETEST_CFG_INIT_FILTER_POLICY (BLE_HCI_CONN_FILT_NO_WL) -#define BLETEST_CFG_CONN_SPVN_TMO (1000) /* 20 seconds */ -#define BLETEST_CFG_MIN_CE_LEN (6) -#define BLETEST_CFG_MAX_CE_LEN (BLETEST_CFG_CONN_ITVL) -#define BLETEST_CFG_CONN_PEER_ADDR_TYPE (BLE_HCI_CONN_PEER_ADDR_PUBLIC) -#define BLETEST_CFG_CONN_OWN_ADDR_TYPE (BLE_HCI_ADV_OWN_ADDR_RANDOM) -#define BLETEST_CFG_CONCURRENT_CONNS (1) - -/* BLETEST variables */ -#undef BLETEST_ADV_PKT_NUM -#define BLETEST_PKT_SIZE (251) -#define BLETEST_STACK_SIZE (256) -uint32_t g_next_os_time; -int g_bletest_state; -struct os_eventq g_bletest_evq; -struct os_callout_func g_bletest_timer; -struct os_task bletest_task; -bssnz_t os_stack_t bletest_stack[BLETEST_STACK_SIZE]; -uint32_t g_bletest_conn_end; -int g_bletest_start_update; -uint32_t g_bletest_conn_upd_time; -uint8_t g_bletest_current_conns; -uint8_t g_bletest_cur_peer_addr[BLE_DEV_ADDR_LEN]; -uint8_t g_last_handle_used; -uint8_t g_bletest_led_state; -uint32_t g_bletest_led_rate; -uint32_t g_bletest_next_led_time; - -#ifdef BLETEST_ADV_PKT_NUM -void -bletest_inc_adv_pkt_num(void) -{ - int rc; - uint8_t *dptr; - uint8_t digit; - - if (g_host_adv_len != 0) { - dptr = &g_host_adv_data[18]; - while (dptr >= &g_host_adv_data[13]) { - digit = *dptr; - ++digit; - if (digit == 58) { - digit = 48; - *dptr = digit; - --dptr; - } else { - *dptr = digit; - break; - } - } - - rc = host_hci_cmd_le_set_adv_data(g_host_adv_data, g_host_adv_len); - assert(rc == 0); - host_hci_outstanding_opcode = 0; - } -} -#endif - -void -bletest_send_conn_update(uint16_t handle) -{ - int rc; - struct hci_conn_update hcu; - - hcu.conn_latency = 4; - hcu.supervision_timeout = 2000; - hcu.conn_itvl_min = 1000; - hcu.conn_itvl_max = 1000; - hcu.handle = handle; - hcu.min_ce_len = 4; - hcu.max_ce_len = 4; - - rc = host_hci_cmd_le_conn_update(&hcu); - assert(rc == 0); - host_hci_outstanding_opcode = 0; -} - -/** - * Sets the advertising data to be sent in advertising pdu's which contain - * advertising data. - * - * @param dptr - * @return uint8_t - */ -uint8_t -bletest_set_adv_data(uint8_t *dptr) -{ - uint8_t len; - - /* Place flags in first */ - dptr[0] = 2; - dptr[1] = 0x01; /* Flags identifier */ - dptr[2] = 0x06; - dptr += 3; - len = 3; - - /* Add local name */ - dptr[0] = 15; /* Length of this data, not including the length */ - dptr[1] = 0x09; - dptr[2] = 'r'; - dptr[3] = 'u'; - dptr[4] = 'n'; - dptr[5] = 't'; - dptr[6] = 'i'; - dptr[7] = 'm'; - dptr[8] = 'e'; - dptr[9] = '-'; - dptr[10] = '0'; - dptr[11] = '0'; - dptr[12] = '0'; - dptr[13] = '0'; - dptr[14] = '0'; - dptr[15] = '0'; - dptr += 16; - len += 16; - - /* Add local device address */ - dptr[0] = 0x08; - dptr[1] = 0x1B; - dptr[2] = 0x00; - memcpy(dptr + 3, g_dev_addr, BLE_DEV_ADDR_LEN); - len += 9; - - g_host_adv_len = len; - - return len; -} - -#if (BLETEST_CFG_ROLE == BLETEST_ROLE_ADVERTISER) -void -bletest_init_advertising(void) -{ - int rc; - uint8_t adv_len; - uint8_t rand_addr[BLE_DEV_ADDR_LEN]; - struct hci_adv_params adv; - - /* Just zero out advertising */ - memset(&adv, 0, sizeof(struct hci_adv_params)); - - /* Set advertising parameters */ - adv.adv_type = BLETEST_CFG_ADV_TYPE; - adv.adv_channel_map = 0x07; - adv.adv_filter_policy = BLETEST_CFG_ADV_FILT_POLICY; - adv.own_addr_type = BLETEST_CFG_ADV_OWN_ADDR_TYPE; - adv.peer_addr_type = BLETEST_CFG_ADV_PEER_ADDR_TYPE; - if ((adv.adv_type == BLE_HCI_ADV_TYPE_ADV_DIRECT_IND_HD) || - (adv.adv_type == BLE_HCI_ADV_TYPE_ADV_DIRECT_IND_LD)) { - memcpy(adv.peer_addr, g_bletest_cur_peer_addr, BLE_DEV_ADDR_LEN); - if (adv.peer_addr_type == BLE_HCI_ADV_PEER_ADDR_RANDOM) { - adv.peer_addr[5] |= 0xc0; - } - adv_len = 0; - } else { - adv_len = bletest_set_adv_data(&g_host_adv_data[0]); - } - - console_printf("Trying to connect to %x.%x.%x.%x.%x.%x\n", - adv.peer_addr[0], adv.peer_addr[1], adv.peer_addr[2], - adv.peer_addr[3], adv.peer_addr[4], adv.peer_addr[5]); - - if (adv.adv_type == BLE_HCI_ADV_TYPE_ADV_DIRECT_IND_HD) { - adv.adv_itvl_min = 0; - adv.adv_itvl_max = 0; - } else { - adv.adv_itvl_min = BLETEST_CFG_ADV_ITVL; - adv.adv_itvl_max = BLETEST_CFG_ADV_ITVL; /* Advertising interval */ - } - - /* Set the advertising parameters */ - rc = host_hci_cmd_le_set_adv_params(&adv); - assert(rc == 0); - host_hci_outstanding_opcode = 0; - - /* If we are using a random address, we need to set it */ - if (adv.own_addr_type == BLE_HCI_ADV_OWN_ADDR_RANDOM) { - memcpy(rand_addr, g_dev_addr, BLE_DEV_ADDR_LEN); - rand_addr[5] |= 0xc0; - rc = host_hci_cmd_le_set_rand_addr(rand_addr); - assert(rc == 0); - host_hci_outstanding_opcode = 0; - } - - /* Set advertising data */ - if (adv_len != 0) { - rc = host_hci_cmd_le_set_adv_data(&g_host_adv_data[0], adv_len); - assert(rc == 0); - host_hci_outstanding_opcode = 0; - - /* Set scan response data */ - rc = host_hci_cmd_le_set_scan_rsp_data(&g_host_adv_data[0], adv_len); - assert(rc == 0); - host_hci_outstanding_opcode = 0; - } -} -#endif - -#if (BLETEST_CFG_ROLE == BLETEST_ROLE_SCANNER) -void -bletest_init_scanner(void) -{ - int rc; - uint8_t dev_addr[BLE_DEV_ADDR_LEN]; - uint8_t filter_policy; - - /* Set scanning parameters */ - rc = host_hci_cmd_le_set_scan_params(BLETEST_CFG_SCAN_TYPE, - BLETEST_CFG_SCAN_ITVL, - BLETEST_CFG_SCAN_WINDOW, - BLE_HCI_ADV_OWN_ADDR_PUBLIC, - BLETEST_CFG_SCAN_FILT_POLICY); - assert(rc == 0); - host_hci_outstanding_opcode = 0; - - filter_policy = BLETEST_CFG_SCAN_FILT_POLICY; - if (filter_policy & 1) { - /* Add some whitelist addresses */ - dev_addr[0] = 0x00; - dev_addr[1] = 0x00; - dev_addr[2] = 0x00; - dev_addr[3] = 0x88; - dev_addr[4] = 0x88; - dev_addr[5] = 0x08; - rc = host_hci_cmd_le_add_to_whitelist(dev_addr, BLE_ADDR_TYPE_PUBLIC); - assert(rc == 0); - host_hci_outstanding_opcode = 0; - } -} - -void -bletest_execute_scanner(void) -{ - int rc; - - /* Enable scanning */ - if ((int32_t)(os_time_get() - g_next_os_time) >= 0) { - if (g_bletest_state) { - rc = host_hci_cmd_le_set_scan_enable(0, BLETEST_CFG_FILT_DUP_ADV); - assert(rc == 0); - host_hci_outstanding_opcode = 0; - g_bletest_state = 0; - } else { - rc = host_hci_cmd_le_set_scan_enable(1, BLETEST_CFG_FILT_DUP_ADV); - assert(rc == 0); - host_hci_outstanding_opcode = 0; - g_bletest_state = 1; - } - g_next_os_time += (OS_TICKS_PER_SEC * 60); - } -} -#endif - -#if (BLETEST_CFG_ROLE == BLETEST_ROLE_INITIATOR) -void -bletest_init_initiator(void) -{ - int rc; - uint8_t rand_addr[BLE_DEV_ADDR_LEN]; - struct hci_create_conn cc; - struct hci_create_conn *hcc; - - /* Enable initiating */ - hcc = &cc; - hcc->conn_itvl_max = BLETEST_CFG_CONN_ITVL; - hcc->conn_itvl_min = BLETEST_CFG_CONN_ITVL; - hcc->conn_latency = BLETEST_CFG_SLAVE_LATENCY; - hcc->filter_policy = BLETEST_CFG_INIT_FILTER_POLICY; - hcc->supervision_timeout = BLETEST_CFG_CONN_SPVN_TMO; - hcc->scan_itvl = BLETEST_CFG_SCAN_ITVL; - hcc->scan_window = BLETEST_CFG_SCAN_WINDOW; - hcc->peer_addr_type = BLETEST_CFG_CONN_PEER_ADDR_TYPE; - memcpy(hcc->peer_addr, g_bletest_cur_peer_addr, BLE_DEV_ADDR_LEN); - if (hcc->peer_addr_type == BLE_HCI_CONN_PEER_ADDR_RANDOM) { - hcc->peer_addr[5] |= 0xc0; - } - hcc->own_addr_type = BLETEST_CFG_CONN_OWN_ADDR_TYPE; - hcc->min_ce_len = BLETEST_CFG_MIN_CE_LEN; - hcc->max_ce_len = BLETEST_CFG_MAX_CE_LEN; - - console_printf("Trying to connect to %x.%x.%x.%x.%x.%x\n", - hcc->peer_addr[0], hcc->peer_addr[1], hcc->peer_addr[2], - hcc->peer_addr[3], hcc->peer_addr[4], hcc->peer_addr[5]); - - /* If we are using a random address, we need to set it */ - if (hcc->own_addr_type == BLE_HCI_ADV_OWN_ADDR_RANDOM) { - memcpy(rand_addr, g_dev_addr, BLE_DEV_ADDR_LEN); - rand_addr[5] |= 0xc0; - rc = host_hci_cmd_le_set_rand_addr(rand_addr); - assert(rc == 0); - host_hci_outstanding_opcode = 0; - } - - rc = host_hci_cmd_le_create_connection(hcc); - assert(rc == 0); - host_hci_outstanding_opcode = 0; -} - -void -bletest_execute_initiator(void) -{ - int i; - int rc; - uint16_t handle; - uint8_t new_chan_map[5]; - - /* - * Determine if there is an active connection for the current handle - * we are trying to create. If so, start looking for the next one - */ - if (g_bletest_current_conns < BLETEST_CFG_CONCURRENT_CONNS) { - handle = g_bletest_current_conns + 1; - if (ble_ll_conn_find_active_conn(handle)) { - /* Set LED to slower blink rate */ - g_bletest_led_rate = OS_TICKS_PER_SEC; - - /* Ask for version information */ - rc = host_hci_cmd_rd_rem_version(handle); - host_hci_outstanding_opcode = 0; - - /* Scanning better be stopped! */ - assert(ble_ll_scan_enabled() == 0); - - /* Add to current connections */ - if (!rc) { - ++g_bletest_current_conns; - - /* Move to next connection */ - if (g_bletest_current_conns < BLETEST_CFG_CONCURRENT_CONNS) { - /* restart initiating */ - g_bletest_cur_peer_addr[5] += 1; - g_dev_addr[5] += 1; - bletest_init_initiator(); - } - } - } - } else { - if ((int32_t)(os_time_get() - g_next_os_time) >= 0) { - if ((g_bletest_state == 1) || (g_bletest_state == 3)) { - for (i = 0; i < g_bletest_current_conns; ++i) { - if (ble_ll_conn_find_active_conn(i + 1)) { - host_hci_cmd_le_rd_chanmap(i+1); - host_hci_outstanding_opcode = 0; - } - } - } else if (g_bletest_state == 2) { - new_chan_map[0] = 0; - new_chan_map[1] = 0x3; - new_chan_map[2] = 0; - new_chan_map[3] = 0; - new_chan_map[4] = 0; - host_hci_cmd_le_set_host_chan_class(new_chan_map); - host_hci_outstanding_opcode = 0; - } else { - for (i = 0; i < g_bletest_current_conns; ++i) { - if (ble_ll_conn_find_active_conn(i + 1)) { - host_hci_cmd_read_rssi(i+1); - host_hci_outstanding_opcode = 0; - } - } - } - ++g_bletest_state; - g_next_os_time = os_time_get() + OS_TICKS_PER_SEC * 5; - } - } -} -#endif - -#if (BLETEST_CFG_ROLE == BLETEST_ROLE_ADVERTISER) -/* - * Test wrapper to get packets. Only get a packet if we have more than half - * left - */ -static struct os_mbuf * -bletest_get_packet(void) -{ - struct os_mbuf *om; - - om = NULL; - if (g_mbuf_pool.omp_pool->mp_num_free >= 5) { - om = os_msys_get_pkthdr(BLE_MBUF_PAYLOAD_SIZE, - sizeof(struct ble_mbuf_hdr)); - } - return om; -} - -#if 0 -void -bletest_execute(void) -{ - int rc; - - int i; - uint16_t pktlen; - uint16_t handle; - struct os_mbuf *om; - struct ble_ll_conn_sm *connsm; - - handle = 1; - if ((int32_t)(os_time_get() - g_next_os_time) >= 0) { - if (g_bletest_state == 0) { - rc = host_hci_cmd_le_set_adv_enable(1); - host_hci_outstanding_opcode = 0; - assert(rc == 0); - g_bletest_state = 1; - } else if (g_bletest_state == 1) { - /* See if handle 1 has been created. If so, send packets */ - connsm = ble_ll_conn_find_active_conn(handle); - if (connsm) { - /* Set connection end time */ - g_bletest_conn_end = os_time_get() + - (OS_TICKS_PER_SEC * (60 * 15)); - g_bletest_state = 2; - } - } else if (g_bletest_state == 2) { - if ((int32_t)(os_time_get() - g_bletest_conn_end) >= 0) { - g_bletest_state = 3; - host_hci_cmd_disconnect(handle, BLE_ERR_REM_USER_CONN_TERM); - } else { - om = bletest_get_packet(); - if (om) { - /* set payload length */ - pktlen = BLETEST_PKT_SIZE; - om->om_len = BLETEST_PKT_SIZE + 4; - - /* Put the HCI header in the mbuf */ - htole16(om->om_data, handle); - htole16(om->om_data + 2, om->om_len); - - /* Place L2CAP header in packet */ - htole16(om->om_data + 4, pktlen); - om->om_data[6] = 0; - om->om_data[7] = 0; - - /* Fill with incrementing pattern (starting from 1) */ - for (i = 0; i < pktlen; ++i) { - om->om_data[8 + i] = (uint8_t)(i + 1); - } - - /* Add length */ - om->om_len += 4; - OS_MBUF_PKTHDR(om)->omp_len = om->om_len; - ble_hci_transport_host_acl_data_send(om); - } - g_next_os_time += OS_TICKS_PER_SEC / 10; - return; - } - } else if (g_bletest_state == 3) { - /* We should be waiting for disconnect */ - connsm = ble_ll_conn_find_active_conn(handle); - if (!connsm) { - /* Set to 0 if you want to restart advertising */ - //g_bletest_state = 0; - g_bletest_state = 4; - } - } - g_next_os_time += OS_TICKS_PER_SEC; - } -} -#else -static void -bletest_execute_advertiser(void) -{ - int i,j; - int rc; - uint16_t handle; - uint16_t pktlen; - struct os_mbuf *om; - - /* See if we should start advertising again */ - if (g_bletest_current_conns < BLETEST_CFG_CONCURRENT_CONNS) { - handle = g_bletest_current_conns + 1; - if (ble_ll_conn_find_active_conn(handle)) { - /* Set LED to slower blink rate */ - g_bletest_led_rate = OS_TICKS_PER_SEC; - - /* advertising better be stopped! */ - assert(ble_ll_adv_enabled() == 0); - - /* Send the remote used features command */ - rc = host_hci_cmd_le_read_rem_used_feat(handle); - host_hci_outstanding_opcode = 0; - if (rc) { - return; - } - - /* Send the remote read version command */ - rc = host_hci_cmd_rd_rem_version(handle); - host_hci_outstanding_opcode = 0; - if (rc) { - return; - } - - /* set conn update time */ - g_bletest_conn_upd_time = os_time_get() + (OS_TICKS_PER_SEC * 5); - g_bletest_start_update = 1; - - /* Add to current connections */ - ++g_bletest_current_conns; - - /* Move to next connection */ - if (g_bletest_current_conns < BLETEST_CFG_CONCURRENT_CONNS) { - /* restart initiating */ - g_bletest_cur_peer_addr[5] += 1; - g_dev_addr[5] += 1; - bletest_init_advertising(); - rc = host_hci_cmd_le_set_adv_enable(1); - host_hci_outstanding_opcode = 0; - } - } - } -#if 0 - if (g_bletest_start_update) { - if ((int32_t)(os_time_get() - g_bletest_conn_upd_time) >= 0) { - bletest_send_conn_update(1); - g_bletest_start_update = 0; - } - } -#endif - /* See if it is time to hand a data packet to the connection */ - if ((int32_t)(os_time_get() - g_next_os_time) >= 0) { - if (g_bletest_current_conns) { - for (i = 0; i < g_bletest_current_conns; ++i) { - if ((g_last_handle_used == 0) || - (g_last_handle_used > g_bletest_current_conns)) { - g_last_handle_used = 1; - } - handle = g_last_handle_used; - if (ble_ll_conn_find_active_conn(handle)) { - om = bletest_get_packet(); - if (om) { - /* set payload length */ - pktlen = BLETEST_PKT_SIZE; - om->om_len = BLETEST_PKT_SIZE + 4; - - /* Put the HCI header in the mbuf */ - htole16(om->om_data, handle); - htole16(om->om_data + 2, om->om_len); - - /* Place L2CAP header in packet */ - htole16(om->om_data + 4, pktlen); - om->om_data[6] = 0; - om->om_data[7] = 0; - om->om_len += 4; - - /* Fill with incrementing pattern (starting from 1) */ - for (j = 0; j < pktlen; ++j) { - om->om_data[8 + j] = (uint8_t)(j + 1); - } - - /* Add length */ - OS_MBUF_PKTHDR(om)->omp_len = om->om_len; - ble_hci_transport_host_acl_data_send(om); - - /* Increment last handle used */ - ++g_last_handle_used; - } - } else { - ++g_last_handle_used; - } - } - } - g_next_os_time = os_time_get() + OS_TICKS_PER_SEC; - } -} -#endif -#endif - -/** - * Main bletest function. Called by the task timer every 50 msecs. - * - */ -void -bletest_execute(void) -{ - /* Toggle LED at set rate */ - if ((int32_t)(os_time_get() - g_bletest_next_led_time) >= 0) { - hal_gpio_toggle(LED_BLINK_PIN); - g_bletest_next_led_time = os_time_get() + g_bletest_led_rate; - } -#if (BLETEST_CFG_ROLE == BLETEST_ROLE_ADVERTISER) - bletest_execute_advertiser(); -#endif -#if (BLETEST_CFG_ROLE == BLETEST_ROLE_SCANNER) - bletest_execute_scanner(); -#endif -#if (BLETEST_CFG_ROLE == BLETEST_ROLE_INITIATOR) - bletest_execute_initiator(); -#endif -} - -/** - * Callback when BLE test timer expires. - * - * @param arg - */ -void -bletest_timer_cb(void *arg) -{ - /* Call the bletest code */ - bletest_execute(); - - /* Re-start the timer (run every 50 msecs) */ - os_callout_reset(&g_bletest_timer.cf_c, OS_TICKS_PER_SEC / 20); -} - -/** - * BLE test task - * - * @param arg - */ -void -bletest_task_handler(void *arg) -{ - int rc; - uint64_t event_mask; - struct os_event *ev; - struct os_callout_func *cf; - - /* Set LED blink rate */ - g_bletest_led_rate = OS_TICKS_PER_SEC / 20; - - /* Wait one second before starting test task */ - os_time_delay(OS_TICKS_PER_SEC); - - /* Initialize eventq */ - os_eventq_init(&g_bletest_evq); - - /* Initialize the host timer */ - os_callout_func_init(&g_bletest_timer, &g_bletest_evq, bletest_timer_cb, - NULL); - - /* Send the reset command first */ - rc = host_hci_cmd_send(BLE_HCI_OGF_CTLR_BASEBAND, BLE_HCI_OCF_CB_RESET, - 0, NULL); - assert(rc == 0); - host_hci_outstanding_opcode = 0; - -#if (BLETEST_CFG_ROLE == BLETEST_ROLE_ADVERTISER) - /* Initialize the advertiser */ - console_printf("Starting BLE test task as advertiser\n"); - bletest_init_advertising(); -#endif - -#if (BLETEST_CFG_ROLE == BLETEST_ROLE_SCANNER) - /* Initialize the scanner */ - console_printf("Starting BLE test task as scanner\n"); - bletest_init_scanner(); -#endif - -#if (BLETEST_CFG_ROLE == BLETEST_ROLE_INITIATOR) - /* Initialize the scanner */ - console_printf("Starting BLE test task as initiator\n"); - bletest_init_initiator(); -#endif - - /* Set the event mask we want to display */ - event_mask = 0x7FF; - rc = host_hci_cmd_le_set_event_mask(event_mask); - assert(rc == 0); - host_hci_outstanding_opcode = 0; - - /* Turn on all events */ - event_mask = 0xffffffffffffffff; - rc = host_hci_cmd_set_event_mask(event_mask); - assert(rc == 0); - host_hci_outstanding_opcode = 0; - - /* Turn on all events */ - rc = host_hci_cmd_rd_local_version(); - assert(rc == 0); - host_hci_outstanding_opcode = 0; - - /* Wait some time before starting */ - os_time_delay(OS_TICKS_PER_SEC); - - /* Init bletest variables */ - g_bletest_state = 0; - g_next_os_time = os_time_get(); - - /* Begin advertising if we are an advertiser */ -#if (BLETEST_CFG_ROLE == BLETEST_ROLE_ADVERTISER) - rc = host_hci_cmd_le_set_adv_enable(1); - assert(rc == 0); - host_hci_outstanding_opcode = 0; -#endif - - bletest_timer_cb(NULL); - - while (1) { - ev = os_eventq_get(&g_bletest_evq); - switch (ev->ev_type) { - case OS_EVENT_T_TIMER: - cf = (struct os_callout_func *)ev; - assert(cf->cf_func); - cf->cf_func(cf->cf_arg); - break; - default: - assert(0); - break; - } - } -} - -/** - * init_tasks - * - * Called by main.c after os_init(). This function performs initializations - * that are required before tasks are running. - * - * @return int 0 success; error otherwise. - */ -static int -init_tasks(void) -{ - int rc; - - os_task_init(&bletest_task, "bletest", bletest_task_handler, NULL, - BLETEST_TASK_PRIO, OS_WAIT_FOREVER, bletest_stack, - BLETEST_STACK_SIZE); - - /* Initialize host HCI */ - rc = ble_hs_init(HOST_TASK_PRIO, NULL); - assert(rc == 0); - - /* Initialize the BLE LL */ - rc = ble_ll_init(); - assert(rc == 0); - - return 0; -} - -/** - * main - * - * The main function for the project. This function initializes the os, calls - * init_tasks to initialize tasks (and possibly other objects), then starts the - * OS. We should not return from os start. - * - * @return int NOTE: this function should never return! - */ -int -main(void) -{ - int i; - int rc; - uint32_t seed; -#if 0 - int cnt; - struct nffs_area_desc descs[NFFS_AREA_MAX]; -#endif - - /* Initialize OS */ - os_init(); - - /* Set cputime to count at 1 usec increments */ - rc = cputime_init(1000000); - assert(rc == 0); - - rc = os_mempool_init(&g_mbuf_mempool, MBUF_NUM_MBUFS, - MBUF_MEMBLOCK_SIZE, &g_mbuf_buffer[0], "mbuf_pool"); - assert(rc == 0); - - rc = os_mbuf_pool_init(&g_mbuf_pool, &g_mbuf_mempool, MBUF_MEMBLOCK_SIZE, - MBUF_NUM_MBUFS); - assert(rc == 0); - - rc = os_msys_register(&g_mbuf_pool); - assert(rc == 0); - - /* Dummy device address */ -#if BLETEST_CFG_ROLE == BLETEST_ROLE_ADVERTISER - g_dev_addr[0] = 0x00; - g_dev_addr[1] = 0x00; - g_dev_addr[2] = 0x00; - g_dev_addr[3] = 0x88; - g_dev_addr[4] = 0x88; - g_dev_addr[5] = 0x08; - - g_bletest_cur_peer_addr[0] = 0x00; - g_bletest_cur_peer_addr[1] = 0x00; - g_bletest_cur_peer_addr[2] = 0x00; - g_bletest_cur_peer_addr[3] = 0x99; - g_bletest_cur_peer_addr[4] = 0x99; - g_bletest_cur_peer_addr[5] = 0x09; -#else - g_dev_addr[0] = 0x00; - g_dev_addr[1] = 0x00; - g_dev_addr[2] = 0x00; - g_dev_addr[3] = 0x99; - g_dev_addr[4] = 0x99; - g_dev_addr[5] = 0x09; - - g_bletest_cur_peer_addr[0] = 0x00; - g_bletest_cur_peer_addr[1] = 0x00; - g_bletest_cur_peer_addr[2] = 0x00; - g_bletest_cur_peer_addr[3] = 0x88; - g_bletest_cur_peer_addr[4] = 0x88; - g_bletest_cur_peer_addr[5] = 0x08; -#endif - - /* - * Seed random number generator with least significant bytes of device - * address. - */ - seed = 0; - for (i = 0; i < 4; ++i) { - seed |= g_dev_addr[i]; - seed <<= 8; - } - srand(seed); - - /* Set the led pin as an output */ - g_led_pin = LED_BLINK_PIN; - hal_gpio_init_out(g_led_pin, 1); - - /* Init the console */ - rc = console_init(shell_console_rx_cb); - assert(rc == 0); - -#if 0 - rc = hal_flash_init(); - assert(rc == 0); - - nffs_config.nc_num_inodes = 32; - nffs_config.nc_num_blocks = 64; - nffs_config.nc_num_files = 2; - nffs_config.nc_num_dirs = 2; - rc = nffs_init(); - assert(rc == 0); - - cnt = NFFS_AREA_MAX; - rc = flash_area_to_nffs_desc(FLASH_AREA_NFFS, &cnt, descs); - assert(rc == 0); - if (nffs_detect(descs) == FS_ECORRUPT) { - rc = nffs_format(descs); - assert(rc == 0); - } -#endif - - shell_task_init(SHELL_TASK_PRIO, shell_stack, SHELL_TASK_STACK_SIZE, - SHELL_MAX_INPUT_LEN); - - nmgr_task_init(NEWTMGR_TASK_PRIO, newtmgr_stack, NEWTMGR_TASK_STACK_SIZE); -#if 0 - imgmgr_module_init(); -#endif - - /* Init statistics module */ - stats_module_init(); - - /* Init tasks */ - init_tasks(); - - /* Start the OS */ - os_start(); - - /* os start should never return. If it does, this should be an error */ - assert(0); - - return rc; -} - http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/project/bletiny/pkg.yml ---------------------------------------------------------------------- diff --git a/project/bletiny/pkg.yml b/project/bletiny/pkg.yml deleted file mode 100644 index 32d25f7..0000000 --- a/project/bletiny/pkg.yml +++ /dev/null @@ -1,33 +0,0 @@ -# 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. -# -pkg.name: bletiny -pkg.vers: 0.8.0 -pkg.description: Shell application exposing the nimble GAP and GATT. -pkg.author: Christopher Collins -pkg.homepage: -pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva -pkg.keywords: - -pkg.deps: - - libs/os - - sys/log - - net/nimble/controller - - net/nimble/host - - libs/console/full - - libs/shell - - libs/baselibc http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a601f78b/project/bletiny/src/bletiny_priv.h ---------------------------------------------------------------------- diff --git a/project/bletiny/src/bletiny_priv.h b/project/bletiny/src/bletiny_priv.h deleted file mode 100644 index e32251b..0000000 --- a/project/bletiny/src/bletiny_priv.h +++ /dev/null @@ -1,169 +0,0 @@ -/** - * 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. - */ - -#ifndef H_BLETINY_PRIV_ -#define H_BLETINY_PRIV_ - -#include -#include "nimble/nimble_opt.h" -#include "log/log.h" -#include "os/queue.h" - -#include "host/ble_gatt.h" -struct ble_gap_white_entry; -struct ble_hs_adv_fields; -struct ble_gap_upd_params; -struct ble_gap_crt_params; -struct hci_adv_params; -struct ble_l2cap_sig_update_req; -struct ble_l2cap_sig_update_params; - -typedef int cmd_fn(int argc, char **argv); -struct cmd_entry { - char *name; - cmd_fn *cb; -}; - -struct kv_pair { - char *key; - int val; -}; - -struct bletiny_dsc { - SLIST_ENTRY(bletiny_dsc) next; - struct ble_gatt_dsc dsc; -}; -SLIST_HEAD(bletiny_dsc_list, bletiny_dsc); - -struct bletiny_chr { - SLIST_ENTRY(bletiny_chr) next; - struct ble_gatt_chr chr; - - struct bletiny_dsc_list dscs; -}; -SLIST_HEAD(bletiny_chr_list, bletiny_chr); - -struct bletiny_svc { - SLIST_ENTRY(bletiny_svc) next; - struct ble_gatt_service svc; - - struct bletiny_chr_list chrs; -}; - -SLIST_HEAD(bletiny_svc_list, bletiny_svc); - -struct bletiny_conn { - uint16_t handle; - uint8_t addr_type; - uint8_t addr[6]; - - struct bletiny_svc_list svcs; -}; - -extern struct bletiny_conn bletiny_conns[NIMBLE_OPT_MAX_CONNECTIONS]; -extern int bletiny_num_conns; - -extern const char *bletiny_device_name; -extern const uint16_t bletiny_appearance; -extern const uint8_t bletiny_privacy_flag; -extern uint8_t bletiny_reconnect_addr[6]; -extern uint8_t bletiny_pref_conn_params[8]; -extern uint8_t bletiny_gatt_service_changed[4]; - -extern struct nmgr_transport nm_ble_transport; -extern uint16_t nm_attr_val_handle; - -extern struct log bletiny_log; - -void print_addr(void *addr); -void print_uuid(void *uuid128); -const struct cmd_entry *parse_cmd_find(const struct cmd_entry *cmds, - char *name); -struct kv_pair *parse_kv_find(struct kv_pair *kvs, char *name); -char *parse_arg_find(char *key); -long parse_arg_long_bounds(char *name, long min, long max, int *out_status); -long parse_arg_long(char *name, int *staus); -uint16_t parse_arg_uint16(char *name, int *status); -uint16_t parse_arg_uint16_dflt(char *name, uint16_t dflt, int *out_status); -uint32_t parse_arg_uint32(char *name, int *out_status); -int parse_arg_kv(char *name, struct kv_pair *kvs); -int parse_arg_byte_stream(char *name, int max_len, uint8_t *dst, int *out_len); -int parse_arg_byte_stream_exact_length(char *name, uint8_t *dst, int len); -int parse_arg_mac(char *name, uint8_t *dst); -int parse_arg_uuid(char *name, uint8_t *dst_uuid128); -int parse_err_too_few_args(char *cmd_name); -int parse_arg_all(int argc, char **argv); -int cmd_init(void); -void periph_init(void); -int nm_chr_access(uint16_t conn_handle, uint16_t attr_handle, - uint8_t op, union ble_gatt_access_ctxt *ctxt, - void *arg); -int nm_rx_rsp(uint8_t *attr_val, uint16_t attr_len); -void nm_init(void); -void bletiny_lock(void); -void bletiny_unlock(void); -int bletiny_exchange_mtu(uint16_t conn_handle); -int bletiny_disc_svcs(uint16_t conn_handle); -int bletiny_disc_svc_by_uuid(uint16_t conn_handle, uint8_t *uuid128); -int bletiny_disc_all_chrs(uint16_t conn_handle, uint16_t start_handle, - uint16_t end_handle); -int bletiny_disc_chrs_by_uuid(uint16_t conn_handle, uint16_t start_handle, - uint16_t end_handle, uint8_t *uuid128); -int bletiny_disc_all_dscs(uint16_t conn_handle, uint16_t chr_val_handle, - uint16_t chr_end_handle); -int bletiny_find_inc_svcs(uint16_t conn_handle, uint16_t start_handle, - uint16_t end_handle); -int bletiny_read(uint16_t conn_handle, uint16_t attr_handle); -int bletiny_read_long(uint16_t conn_handle, uint16_t attr_handle); -int bletiny_read_by_uuid(uint16_t conn_handle, uint16_t start_handle, - uint16_t end_handle, uint8_t *uuid128); -int bletiny_read_mult(uint16_t conn_handle, uint16_t *attr_handles, - int num_attr_handles); -int bletiny_write(uint16_t conn_handle, uint16_t attr_handle, void *value, - uint16_t value_len); -int bletiny_write_no_rsp(uint16_t conn_handle, uint16_t attr_handle, - void *value, uint16_t value_len); -int bletiny_write_long(uint16_t conn_handle, uint16_t attr_handle, - void *value, uint16_t value_len); -int bletiny_write_reliable(uint16_t conn_handle, struct ble_gatt_attr *attrs, - int num_attrs); -int bletiny_adv_start(int disc, int conn, uint8_t *peer_addr, int addr_type, - struct hci_adv_params *params); -int bletiny_adv_stop(void); -int bletiny_conn_initiate(int addr_type, uint8_t *peer_addr, - struct ble_gap_crt_params *params); -int bletiny_conn_cancel(void); -int bletiny_term_conn(uint16_t conn_handle); -int bletiny_wl_set(struct ble_gap_white_entry *white_list, - int white_list_count); -int bletiny_scan(uint32_t dur_ms, uint8_t disc_mode, uint8_t scan_type, - uint8_t filter_policy); -int bletiny_set_adv_data(struct ble_hs_adv_fields *adv_fields); -int bletiny_update_conn(uint16_t conn_handle, - struct ble_gap_upd_params *params); -void bletiny_chrup(uint16_t attr_handle); -int bletiny_l2cap_update(uint16_t conn_handle, - struct ble_l2cap_sig_update_params *params); -int bletiny_show_rssi(uint16_t conn_handle); - -#define BLETINY_LOG_MODULE (LOG_MODULE_PERUSER + 0) -#define BLETINY_LOG(lvl, ...) \ - LOG_ ## lvl(&bletiny_log, BLETINY_LOG_MODULE, __VA_ARGS__) - -#endif