http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/net/nimble/controller/src/ble_ll_conn.c ---------------------------------------------------------------------- diff --git a/net/nimble/controller/src/ble_ll_conn.c b/net/nimble/controller/src/ble_ll_conn.c index ba8fbc4..4a553d0 100644 --- a/net/nimble/controller/src/ble_ll_conn.c +++ b/net/nimble/controller/src/ble_ll_conn.c @@ -234,7 +234,7 @@ ble_ll_init_get_conn_comp_ev(void) return evbuf; } -#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1) +#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) /** * Called to determine if the received PDU is an empty PDU or not. */ @@ -625,7 +625,7 @@ ble_ll_conn_wait_txend(void *arg) ble_ll_conn_current_sm_over(connsm); } -#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1) +#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) static void ble_ll_conn_start_rx_encrypt(void *arg) { @@ -724,7 +724,7 @@ ble_ll_conn_chk_csm_flags(struct ble_ll_conn_sm *connsm) { uint8_t update_status; -#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1) +#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) if (connsm->csmflags.cfbit.send_ltk_req) { /* * Send Long term key request event to host. If masked, we need to @@ -814,7 +814,7 @@ ble_ll_conn_tx_data_pdu(struct ble_ll_conn_sm *connsm) m = OS_MBUF_PKTHDR_TO_MBUF(pkthdr); nextpkthdr = STAILQ_NEXT(pkthdr, omp_next); -#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1) +#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) /* * If we are encrypting, we are only allowed to send certain * kinds of LL control PDU's. If none is enqueued, send empty pdu! @@ -864,7 +864,7 @@ ble_ll_conn_tx_data_pdu(struct ble_ll_conn_sm *connsm) if (cur_offset == 0) { hdr_byte = ble_hdr->txinfo.hdr_byte & BLE_LL_DATA_HDR_LLID_MASK; } -#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1) +#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) if (connsm->enc_data.enc_state > CONN_ENC_S_ENCRYPTED) { /* We will allow a next packet if it itself is allowed */ pkthdr = OS_MBUF_PKTHDR(connsm->cur_tx_pdu); @@ -879,7 +879,7 @@ ble_ll_conn_tx_data_pdu(struct ble_ll_conn_sm *connsm) /* Empty PDU here. NOTE: header byte gets set later */ pktlen = 0; cur_txlen = 0; -#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1) +#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) if (connsm->enc_data.enc_state > CONN_ENC_S_ENCRYPTED) { /* We will allow a next packet if it itself is allowed */ if (nextpkthdr && !ble_ll_ctrl_enc_allowed_pdu(nextpkthdr)) { @@ -1002,7 +1002,7 @@ conn_tx_pdu: txend_func = NULL; } -#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1) +#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) int is_ctrl; uint8_t llid; uint8_t opcode; @@ -1143,7 +1143,7 @@ ble_ll_conn_event_start_cb(struct ble_ll_sched_item *sch) ble_phy_setchan(connsm->data_chan_index, connsm->access_addr, connsm->crcinit); -#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1) +#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) ble_phy_resolv_list_disable(); #endif @@ -1151,7 +1151,7 @@ ble_ll_conn_event_start_cb(struct ble_ll_sched_item *sch) /* Set start time of transmission */ rc = ble_phy_tx_set_start_time(sch->start_time + XCVR_PROC_DELAY_USECS); if (!rc) { -#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1) +#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) if (CONN_F_ENCRYPTED(connsm)) { ble_phy_encrypt_enable(connsm->enc_data.tx_pkt_cntr, connsm->enc_data.iv, @@ -1173,7 +1173,7 @@ ble_ll_conn_event_start_cb(struct ble_ll_sched_item *sch) rc = BLE_LL_SCHED_STATE_DONE; } } else { -#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1) +#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) if (CONN_F_ENCRYPTED(connsm)) { ble_phy_encrypt_enable(connsm->enc_data.rx_pkt_cntr, connsm->enc_data.iv, @@ -1288,7 +1288,7 @@ ble_ll_conn_can_send_next_pdu(struct ble_ll_conn_sm *connsm, uint32_t begtime) return rc; } -#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_PING) == 1) +#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_PING) /** * Callback for the Authenticated payload timer. This function is called * when the authenticated payload timer expires. When the authenticated @@ -1490,12 +1490,12 @@ ble_ll_conn_sm_new(struct ble_ll_conn_sm *connsm) connsm->eff_max_rx_octets = BLE_LL_CONN_SUPP_BYTES_MIN; /* Reset encryption data */ -#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1) +#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) memset(&connsm->enc_data, 0, sizeof(struct ble_ll_conn_enc_data)); connsm->enc_data.enc_state = CONN_ENC_S_UNENCRYPTED; #endif -#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_PING) == 1) +#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_PING) connsm->auth_pyld_tmo = BLE_LL_CONN_DEF_AUTH_PYLD_TMO; CONN_F_LE_PING_SUPP(connsm) = 1; os_callout_func_init(&connsm->auth_pyld_timer, @@ -1584,7 +1584,7 @@ ble_ll_conn_end(struct ble_ll_conn_sm *connsm, uint8_t ble_err) /* Stop any control procedures that might be running */ os_callout_stop(&connsm->ctrl_proc_rsp_timer.cf_c); -#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_PING) == 1) +#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_PING) os_callout_stop(&connsm->auth_pyld_timer.cf_c); #endif @@ -1926,7 +1926,7 @@ ble_ll_conn_event_end(void *arg) connsm->slave_cur_tx_win_usecs = 0; } -#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_PING) == 1) +#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_PING) /* * If we are encrypted and have passed the authenticated payload timeout * we need to send an event to tell the host. Unfortunately, I think we @@ -1990,7 +1990,7 @@ ble_ll_conn_req_pdu_update(struct os_mbuf *m, uint8_t *adva, uint8_t addr_type, struct ble_mbuf_hdr *ble_hdr; struct ble_ll_conn_sm *connsm; -#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1) +#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) int is_rpa; struct ble_ll_resolv_entry *rl; #endif @@ -2017,7 +2017,7 @@ ble_ll_conn_req_pdu_update(struct os_mbuf *m, uint8_t *adva, uint8_t addr_type, } /* XXX: do this ahead of time? Calculate the local rpa I mean */ -#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1) +#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) if (connsm->own_addr_type > BLE_HCI_ADV_OWN_ADDR_RANDOM) { rl = NULL; is_rpa = ble_ll_is_rpa(adva, addr_type); @@ -2166,7 +2166,7 @@ ble_ll_conn_event_halt(void) void ble_ll_init_rx_pkt_in(uint8_t *rxbuf, struct ble_mbuf_hdr *ble_hdr) { -#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1) +#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) int8_t rpa_index; #endif uint8_t addr_type; @@ -2189,7 +2189,7 @@ ble_ll_init_rx_pkt_in(uint8_t *rxbuf, struct ble_mbuf_hdr *ble_hdr) addr_type = BLE_HCI_CONN_PEER_ADDR_PUBLIC; } -#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1) +#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) /* * Did we resolve this address? If so, set correct peer address * and peer address type. @@ -2326,7 +2326,7 @@ ble_ll_init_rx_isr_end(uint8_t *rxbuf, uint8_t crcok, resolved = 0; chk_wl = ble_ll_scan_whitelist_enabled(); -#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1) +#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) if (ble_ll_is_rpa(adv_addr, addr_type) && ble_ll_resolv_enabled()) { index = ble_hw_resolv_list_match(); if (index >= 0) { @@ -2549,7 +2549,7 @@ ble_ll_conn_rx_data_pdu(struct os_mbuf *rxpdu, struct ble_mbuf_hdr *hdr) goto conn_rx_data_pdu_end; } -#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_PING) == 1) +#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_PING) /* * Reset authenticated payload timeout if valid MIC. NOTE: we dont * check the MIC failure bit as that would have terminated the @@ -2588,7 +2588,7 @@ ble_ll_conn_rx_data_pdu(struct os_mbuf *rxpdu, struct ble_mbuf_hdr *hdr) goto conn_rx_data_pdu_end; } -#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1) +#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) /* * XXX: should we check to see if we are in a state where we * might expect to get an encrypted PDU? @@ -2740,14 +2740,14 @@ ble_ll_conn_rx_isr_end(uint8_t *rxbuf, struct ble_mbuf_hdr *rxhdr) conn_nesn = connsm->next_exp_seqnum; if (rxpdu && ((hdr_sn && conn_nesn) || (!hdr_sn && !conn_nesn))) { connsm->next_exp_seqnum ^= 1; -#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1) - if (CONN_F_ENCRYPTED(connsm) && !ble_ll_conn_is_empty_pdu(rxpdu)) { +#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) + if (CONN_F_ENCRYPTED(connsm) && !ble_ll_conn_is_empty_pdu(rxbuf)) { ++connsm->enc_data.rx_pkt_cntr; } #endif } -#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1) +#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) ble_ll_log(BLE_LL_LOG_ID_CONN_RX, hdr_byte, (uint16_t)connsm->tx_seqnum << 8 | conn_nesn, @@ -2785,7 +2785,7 @@ ble_ll_conn_rx_isr_end(uint8_t *rxbuf, struct ble_mbuf_hdr *rxhdr) */ txpdu = connsm->cur_tx_pdu; if (txpdu) { -#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1) +#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) if (connsm->enc_data.tx_encrypted) { ++connsm->enc_data.tx_pkt_cntr; } @@ -2847,7 +2847,7 @@ chk_rx_terminate_ind: } else { /* A slave always replies */ reply = 1; -#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1) +#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) if (is_ctrl && (opcode == BLE_LL_CTRL_PAUSE_ENC_RSP)) { connsm->enc_data.enc_state = CONN_ENC_S_UNENCRYPTED; } @@ -2912,7 +2912,7 @@ ble_ll_conn_enqueue_pkt(struct ble_ll_conn_sm *connsm, struct os_mbuf *om, } lifo = 0; -#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1) +#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) if (connsm->enc_data.enc_state > CONN_ENC_S_ENCRYPTED) { uint8_t llid;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/net/nimble/controller/src/ble_ll_conn_hci.c ---------------------------------------------------------------------- diff --git a/net/nimble/controller/src/ble_ll_conn_hci.c b/net/nimble/controller/src/ble_ll_conn_hci.c index 18defc4..d8a58c3 100644 --- a/net/nimble/controller/src/ble_ll_conn_hci.c +++ b/net/nimble/controller/src/ble_ll_conn_hci.c @@ -260,7 +260,7 @@ ble_ll_conn_num_comp_pkts_event_send(struct ble_ll_conn_sm *connsm) * (i.e. enqueued in a connection state machine). */ if ((uint32_t)(g_ble_ll_last_num_comp_pkt_evt - os_time_get()) < - (NIMBLE_OPT_NUM_COMP_PKT_RATE * OS_TICKS_PER_SEC)) { + (MYNEWT_VAL(BLE_NUM_COMP_PKT_RATE) * OS_TICKS_PER_SEC)) { /* * If this connection has completed packets, send an event right away. * We do this to increase throughput but we dont want to search the @@ -341,7 +341,7 @@ ble_ll_conn_num_comp_pkts_event_send(struct ble_ll_conn_sm *connsm) if (event_sent) { g_ble_ll_last_num_comp_pkt_evt = os_time_get() + - (NIMBLE_OPT_NUM_COMP_PKT_RATE * OS_TICKS_PER_SEC); + (MYNEWT_VAL(BLE_NUM_COMP_PKT_RATE) * OS_TICKS_PER_SEC); } } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/net/nimble/controller/src/ble_ll_scan.c ---------------------------------------------------------------------- diff --git a/net/nimble/controller/src/ble_ll_scan.c b/net/nimble/controller/src/ble_ll_scan.c index 0ac7e80..2d58282 100644 --- a/net/nimble/controller/src/ble_ll_scan.c +++ b/net/nimble/controller/src/ble_ll_scan.c @@ -387,7 +387,7 @@ ble_ll_hci_send_adv_report(uint8_t pdu_type, uint8_t txadd, uint8_t *rxbuf, struct ble_ll_scan_sm *scansm) { int rc; -#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1) +#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) int index; #endif uint8_t evtype; @@ -443,7 +443,7 @@ ble_ll_hci_send_adv_report(uint8_t pdu_type, uint8_t txadd, uint8_t *rxbuf, } rxbuf += BLE_LL_PDU_HDR_LEN; -#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1) +#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) if (BLE_MBUF_HDR_RESOLVED(hdr)) { index = scansm->scan_rpa_index; adv_addr = g_ble_ll_resolv_list[index].rl_identity_addr; @@ -1105,7 +1105,7 @@ ble_ll_scan_wfr_timer_exp(void) void ble_ll_scan_rx_pkt_in(uint8_t ptype, uint8_t *rxbuf, struct ble_mbuf_hdr *hdr) { -#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1) +#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) int index; #endif uint8_t *adv_addr; http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/net/nimble/host/services/gap/include/services/gap/ble_svc_gap.h ---------------------------------------------------------------------- diff --git a/net/nimble/host/services/gap/include/services/gap/ble_svc_gap.h b/net/nimble/host/services/gap/include/services/gap/ble_svc_gap.h index dcc2712..070599d 100644 --- a/net/nimble/host/services/gap/include/services/gap/ble_svc_gap.h +++ b/net/nimble/host/services/gap/include/services/gap/ble_svc_gap.h @@ -34,6 +34,6 @@ struct ble_hs_cfg; const char *ble_svc_gap_device_name(void); int ble_svc_gap_device_name_set(const char *name); -int ble_svc_gap_init(void); +void ble_svc_gap_init(void); #endif http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/net/nimble/host/services/gap/pkg.yml ---------------------------------------------------------------------- diff --git a/net/nimble/host/services/gap/pkg.yml b/net/nimble/host/services/gap/pkg.yml index b84e816..376a555 100644 --- a/net/nimble/host/services/gap/pkg.yml +++ b/net/nimble/host/services/gap/pkg.yml @@ -29,3 +29,6 @@ pkg.keywords: pkg.deps: - net/nimble/host + +pkg.init_function: ble_svc_gap_init +pkg.init_stage: 3 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/net/nimble/host/services/gap/src/ble_svc_gap.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/services/gap/src/ble_svc_gap.c b/net/nimble/host/services/gap/src/ble_svc_gap.c index eb67b6c..98fd749 100644 --- a/net/nimble/host/services/gap/src/ble_svc_gap.c +++ b/net/nimble/host/services/gap/src/ble_svc_gap.c @@ -19,6 +19,8 @@ #include <assert.h> #include <string.h> + +#include "sysinit/sysinit.h" #include "host/ble_hs.h" #include "services/gap/ble_svc_gap.h" @@ -148,20 +150,14 @@ ble_svc_gap_device_name_set(const char *name) return 0; } -int +void ble_svc_gap_init(void) { int rc; rc = ble_gatts_count_cfg(ble_svc_gap_defs); - if (rc != 0) { - return rc; - } + SYSINIT_PANIC_ASSERT(rc == 0); rc = ble_gatts_add_svcs(ble_svc_gap_defs); - if (rc != 0) { - return rc; - } - - return 0; + SYSINIT_PANIC_ASSERT(rc == 0); } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/net/nimble/host/services/gatt/include/services/gatt/ble_svc_gatt.h ---------------------------------------------------------------------- diff --git a/net/nimble/host/services/gatt/include/services/gatt/ble_svc_gatt.h b/net/nimble/host/services/gatt/include/services/gatt/ble_svc_gatt.h index 320a3ff..adc4433 100644 --- a/net/nimble/host/services/gatt/include/services/gatt/ble_svc_gatt.h +++ b/net/nimble/host/services/gatt/include/services/gatt/ble_svc_gatt.h @@ -24,6 +24,6 @@ struct ble_hs_cfg; #define BLE_SVC_GATT_CHR_SERVICE_CHANGED_UUID16 0x2a05 -int ble_svc_gatt_init(struct ble_hs_cfg *cfg); +void ble_svc_gatt_init(void); #endif http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/net/nimble/host/services/gatt/pkg.yml ---------------------------------------------------------------------- diff --git a/net/nimble/host/services/gatt/pkg.yml b/net/nimble/host/services/gatt/pkg.yml index 54343bd..ec0eb1e 100644 --- a/net/nimble/host/services/gatt/pkg.yml +++ b/net/nimble/host/services/gatt/pkg.yml @@ -30,5 +30,5 @@ pkg.keywords: pkg.deps: - net/nimble/host -pkg.init_function: ble_svc_mandatory_pkg_init +pkg.init_function: ble_svc_gatt_init pkg.init_stage: 3 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/net/nimble/host/services/gatt/src/ble_svc_gatt.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/services/gatt/src/ble_svc_gatt.c b/net/nimble/host/services/gatt/src/ble_svc_gatt.c index c6426f0..e447e2a 100644 --- a/net/nimble/host/services/gatt/src/ble_svc_gatt.c +++ b/net/nimble/host/services/gatt/src/ble_svc_gatt.c @@ -19,6 +19,7 @@ #include <assert.h> +#include "sysinit/sysinit.h" #include "host/ble_hs.h" #include "services/gatt/ble_svc_gatt.h" @@ -71,20 +72,14 @@ ble_svc_gatt_access(uint16_t conn_handle, uint16_t attr_handle, return 0; } -int +void ble_svc_gatt_init(void) { int rc; rc = ble_gatts_count_cfg(ble_svc_gatt_defs); - if (rc != 0) { - return rc; - } + SYSINIT_PANIC_ASSERT(rc == 0); rc = ble_gatts_add_svcs(ble_svc_gatt_defs); - if (rc != 0) { - return rc; - } - - return 0; + SYSINIT_PANIC_ASSERT(rc == 0); } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/net/nimble/host/services/mandatory/src/ble_svc_mandatory.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/services/mandatory/src/ble_svc_mandatory.c b/net/nimble/host/services/mandatory/src/ble_svc_mandatory.c deleted file mode 100644 index 90fdb4b..0000000 --- a/net/nimble/host/services/mandatory/src/ble_svc_mandatory.c +++ /dev/null @@ -1,36 +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 <assert.h> - -#include "sysinit/sysinit.h" -#include "services/mandatory/ble_svc_gap.h" -#include "services/mandatory/ble_svc_gatt.h" - -void -ble_svc_mandatory_pkg_init(void) -{ - int rc; - - rc = ble_svc_gap_init(); - SYSINIT_PANIC_ASSERT(rc == 0); - - rc = ble_svc_gatt_init(); - SYSINIT_PANIC_ASSERT(rc == 0); -} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/net/nimble/host/src/ble_gap.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/src/ble_gap.c b/net/nimble/host/src/ble_gap.c index 5014a86..57a24da 100644 --- a/net/nimble/host/src/ble_gap.c +++ b/net/nimble/host/src/ble_gap.c @@ -216,7 +216,7 @@ STATS_NAME_END(ble_gap_stats) * $debug * *****************************************************************************/ -#if BLE_HS_DEBUG +#if MYNEWT_VAL(BLE_HS_DEBUG) int ble_gap_dbg_update_active(uint16_t conn_handle) { http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/net/nimble/host/src/ble_hs.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/src/ble_hs.c b/net/nimble/host/src/ble_hs.c index 85b524b..3b33341 100644 --- a/net/nimble/host/src/ble_hs.c +++ b/net/nimble/host/src/ble_hs.c @@ -38,8 +38,6 @@ */ #define BLE_HS_MAX_EVS_IN_A_ROW 2 -static struct log_handler ble_hs_log_console_handler; - struct os_mempool ble_hs_hci_ev_pool; static os_membuf_t ble_hs_hci_os_event_buf[ OS_MEMPOOL_SIZE(BLE_HS_HCI_EVT_COUNT, sizeof (struct os_event)) @@ -419,22 +417,6 @@ ble_hs_enqueue_hci_event(uint8_t *hci_evt) ev = os_memblock_get(&ble_hs_hci_ev_pool); if (ev == NULL) { - ble_hci_trans_buf_free(ev->ev_arg); - } else { - ev->ev_queued = 0; - ev->ev_type = BLE_HOST_HCI_EVENT_CTLR_EVENT; - ev->ev_arg = hci_evt; - ble_hs_event_enqueue(ev); - } -} - -void -ble_hs_enqueue_hci_event(uint8_t *hci_evt) -{ - struct os_event *ev; - - ev = os_memblock_get(&ble_hs_hci_ev_pool); - if (ev == NULL) { ble_hci_trans_buf_free(hci_evt); } else { ev->ev_queued = 0; @@ -636,6 +618,4 @@ ble_hs_init(void) /* Configure the HCI transport to communicate with a host. */ ble_hci_trans_cfg_hs(ble_hs_hci_rx_evt, NULL, ble_hs_rx_data, NULL); - - return 0; } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/net/nimble/host/src/test/ble_hs_hci_test.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/src/test/ble_hs_hci_test.c b/net/nimble/host/src/test/ble_hs_hci_test.c deleted file mode 100644 index 21184b8..0000000 --- a/net/nimble/host/src/test/ble_hs_hci_test.c +++ /dev/null @@ -1,99 +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 <stddef.h> -#include <errno.h> -#include <string.h> -#include "nimble/hci_common.h" -#include "nimble/ble_hci_trans.h" -#include "host/ble_hs_test.h" -#include "testutil/testutil.h" -#include "ble_hs_test_util.h" - -TEST_CASE(ble_hs_hci_test_event_bad) -{ - uint8_t *buf; - int rc; - - /*** Invalid event code. */ - buf = ble_hci_trans_buf_alloc(BLE_HCI_TRANS_BUF_EVT_HI); - TEST_ASSERT_FATAL(buf != NULL); - - buf[0] = 0xff; - buf[1] = 0; - rc = ble_hs_hci_evt_process(buf); - TEST_ASSERT(rc == BLE_HS_ENOTSUP); -} - -TEST_CASE(ble_hs_hci_test_rssi) -{ - uint8_t params[BLE_HCI_READ_RSSI_ACK_PARAM_LEN]; - uint16_t opcode; - int8_t rssi; - int rc; - - opcode = ble_hs_hci_util_opcode_join(BLE_HCI_OGF_STATUS_PARAMS, - BLE_HCI_OCF_RD_RSSI); - - /*** Success. */ - /* Connection handle. */ - htole16(params + 0, 1); - - /* RSSI. */ - params[2] = -8; - - ble_hs_test_util_set_ack_params(opcode, 0, params, sizeof params); - - rc = ble_hs_hci_util_read_rssi(1, &rssi); - TEST_ASSERT_FATAL(rc == 0); - TEST_ASSERT(rssi == -8); - - /*** Failure: incorrect connection handle. */ - htole16(params + 0, 99); - - ble_hs_test_util_set_ack_params(opcode, 0, params, sizeof params); - - rc = ble_hs_hci_util_read_rssi(1, &rssi); - TEST_ASSERT(rc == BLE_HS_ECONTROLLER); - - /*** Failure: params too short. */ - ble_hs_test_util_set_ack_params(opcode, 0, params, sizeof params - 1); - rc = ble_hs_hci_util_read_rssi(1, &rssi); - TEST_ASSERT(rc == BLE_HS_ECONTROLLER); - - /*** Failure: params too long. */ - ble_hs_test_util_set_ack_params(opcode, 0, params, sizeof params + 1); - rc = ble_hs_hci_util_read_rssi(1, &rssi); - TEST_ASSERT(rc == BLE_HS_ECONTROLLER); -} - -TEST_SUITE(ble_hs_hci_suite) -{ - tu_suite_set_post_test_cb(ble_hs_test_util_post_test, NULL); - - ble_hs_hci_test_event_bad(); - ble_hs_hci_test_rssi(); -} - -int -ble_hs_hci_test_all(void) -{ - ble_hs_hci_suite(); - return tu_any_failed; -} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/net/nimble/host/test/src/ble_gap_test.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/test/src/ble_gap_test.c b/net/nimble/host/test/src/ble_gap_test.c index 3fe398f..34a5cd9 100644 --- a/net/nimble/host/test/src/ble_gap_test.c +++ b/net/nimble/host/test/src/ble_gap_test.c @@ -2743,8 +2743,8 @@ TEST_CASE(ble_gap_test_case_conn_timeout_conn_forever) { ble_gap_test_util_init(); - /* 3 ms. */ - ble_gap_test_util_conn_timeout(3); + /* 30 ms. */ + ble_gap_test_util_conn_timeout(30); /* No timeout. */ ble_gap_test_util_conn_forever(); @@ -2758,8 +2758,8 @@ TEST_CASE(ble_gap_test_case_conn_timeout_conn_timeout) /* 30 ms. */ ble_gap_test_util_conn_timeout(30); - /* 5 ms. */ - ble_gap_test_util_conn_timeout(5); + /* 20 ms. */ + ble_gap_test_util_conn_timeout(20); } @@ -2776,16 +2776,16 @@ TEST_CASE(ble_gap_test_case_conn_forever_conn_timeout) /* Clear GAP event for remainder of test. */ ble_gap_test_util_reset_cb_info(); - /* 3 ms. */ - ble_gap_test_util_conn_timeout(3); + /* 30 ms. */ + ble_gap_test_util_conn_timeout(30); } TEST_CASE(ble_gap_test_case_disc_timeout_disc_forever) { ble_gap_test_util_init(); - /* 3 ms. */ - ble_gap_test_util_disc_timeout(3); + /* 30 ms. */ + ble_gap_test_util_disc_timeout(30); /* No timeout. */ ble_gap_test_util_disc_forever(); @@ -2799,8 +2799,8 @@ TEST_CASE(ble_gap_test_case_disc_timeout_disc_timeout) /* 30 ms. */ ble_gap_test_util_disc_timeout(30); - /* 5 ms. */ - ble_gap_test_util_disc_timeout(5); + /* 20 ms. */ + ble_gap_test_util_disc_timeout(20); } @@ -2814,8 +2814,8 @@ TEST_CASE(ble_gap_test_case_disc_forever_disc_timeout) /* Cancel discovery procedure manually. */ ble_hs_test_util_disc_cancel(0); - /* 3 ms. */ - ble_gap_test_util_disc_timeout(3); + /* 30 ms. */ + ble_gap_test_util_disc_timeout(30); } TEST_CASE(ble_gap_test_case_conn_timeout_disc_timeout) @@ -2825,8 +2825,8 @@ TEST_CASE(ble_gap_test_case_conn_timeout_disc_timeout) /* 15 seconds. */ ble_gap_test_util_conn_timeout(15000); - /* 1285 ms. */ - ble_gap_test_util_disc_timeout(1285); + /* 1280 ms. */ + ble_gap_test_util_disc_timeout(1280); } TEST_SUITE(ble_gap_test_suite_timeout) http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/net/nimble/host/test/src/ble_hs_test_util.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/test/src/ble_hs_test_util.c b/net/nimble/host/test/src/ble_hs_test_util.c index 81e059a..554b687 100644 --- a/net/nimble/host/test/src/ble_hs_test_util.c +++ b/net/nimble/host/test/src/ble_hs_test_util.c @@ -539,23 +539,6 @@ ble_hs_test_util_conn_cancel_full(void) TEST_ASSERT_FATAL(rc == 0); } -int -ble_hs_test_util_conn_terminate(uint16_t conn_handle, uint8_t hci_status) -{ - struct hci_le_conn_complete evt; - int rc; - - ble_hs_test_util_conn_cancel(0); - - memset(&evt, 0, sizeof evt); - evt.subevent_code = BLE_HCI_LE_SUBEV_CONN_COMPLETE; - evt.status = BLE_ERR_UNK_CONN_ID; - evt.role = BLE_HCI_LE_CONN_COMPLETE_ROLE_MASTER; - - rc = ble_gap_rx_conn_complete(&evt); - TEST_ASSERT_FATAL(rc == 0); -} - void ble_hs_test_util_set_ack_disconnect(uint8_t hci_status) { http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/net/nimble/transport/ram/src/ble_hci_ram.c ---------------------------------------------------------------------- diff --git a/net/nimble/transport/ram/src/ble_hci_ram.c b/net/nimble/transport/ram/src/ble_hci_ram.c index 458df5a..effe2c3 100644 --- a/net/nimble/transport/ram/src/ble_hci_ram.c +++ b/net/nimble/transport/ram/src/ble_hci_ram.c @@ -20,6 +20,8 @@ #include <assert.h> #include <errno.h> #include <stddef.h> +#include "syscfg/syscfg.h" +#include "sysinit/sysinit.h" #include "os/os.h" #include "util/mem.h" #include "nimble/ble.h" http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/net/nimble/transport/uart/src/ble_hci_uart.c ---------------------------------------------------------------------- diff --git a/net/nimble/transport/uart/src/ble_hci_uart.c b/net/nimble/transport/uart/src/ble_hci_uart.c index d660e4c..8ec1431 100755 --- a/net/nimble/transport/uart/src/ble_hci_uart.c +++ b/net/nimble/transport/uart/src/ble_hci_uart.c @@ -21,6 +21,7 @@ #include <string.h> #include <stdio.h> #include <errno.h> +#include "syscfg/syscfg.h" #include "bsp/bsp.h" #include "os/os.h" #include "util/mem.h" @@ -46,7 +47,7 @@ */ /* XXX: for now, define this here */ -#ifdef FEATURE_BLE_DEVICE +#if MYNEWT_VAL(BLE_DEVICE) extern void ble_ll_data_buffer_overflow(void); extern void ble_ll_hw_error(uint8_t err); @@ -298,7 +299,7 @@ ble_hci_uart_tx_char(void *arg) return rc; } -#ifdef FEATURE_BLE_DEVICE +#if MYNEWT_VAL(BLE_DEVICE) /** * HCI uart sync lost. * @@ -331,7 +332,7 @@ ble_hci_uart_rx_pkt_type(uint8_t data) switch (ble_hci_uart_state.rx_type) { /* Host should never receive a command! */ -#ifdef FEATURE_BLE_DEVICE +#if MYNEWT_VAL(BLE_DEVICE) case BLE_HCI_UART_H4_CMD: ble_hci_uart_state.rx_cmd.len = 0; ble_hci_uart_state.rx_cmd.cur = 0; @@ -344,7 +345,7 @@ ble_hci_uart_rx_pkt_type(uint8_t data) #endif /* Controller should never receive an event */ -#ifdef FEATURE_BLE_HOST +#if MYNEWT_VAL(BLE_HOST) case BLE_HCI_UART_H4_EVT: /* * XXX: we should not assert if host cannot allocate an event. Need @@ -372,7 +373,7 @@ ble_hci_uart_rx_pkt_type(uint8_t data) break; default: -#ifdef FEATURE_BLE_DEVICE +#if MYNEWT_VAL(BLE_DEVICE) /* * If we receive an unknown HCI packet type this is considered a loss * of sync. @@ -391,7 +392,7 @@ ble_hci_uart_rx_pkt_type(uint8_t data) return 0; } -#ifdef FEATURE_BLE_DEVICE +#if MYNEWT_VAL(BLE_DEVICE) /** * HCI uart sync loss. * @@ -501,7 +502,7 @@ ble_hci_uart_rx_skip_cmd(uint8_t data) } #endif -#ifdef FEATURE_BLE_HOST +#if MYNEWT_VAL(BLE_HOST) static void ble_hci_uart_rx_evt(uint8_t data) { @@ -594,7 +595,7 @@ ble_hci_uart_rx_skip_acl(uint8_t data) if (rxd_bytes == ble_hci_uart_state.rx_acl.len) { /* XXX: I dont like this but for now this denotes controller only */ -#ifdef FEATURE_BLE_DEVICE +#if MYNEWT_VAL(BLE_DEVICE) ble_ll_data_buffer_overflow(); #endif ble_hci_uart_state.rx_type = BLE_HCI_UART_H4_NONE; @@ -607,7 +608,7 @@ ble_hci_uart_rx_char(void *arg, uint8_t data) switch (ble_hci_uart_state.rx_type) { case BLE_HCI_UART_H4_NONE: return ble_hci_uart_rx_pkt_type(data); -#ifdef FEATURE_BLE_DEVICE +#if MYNEWT_VAL(BLE_DEVICE) case BLE_HCI_UART_H4_CMD: ble_hci_uart_rx_cmd(data); return 0; @@ -618,7 +619,7 @@ ble_hci_uart_rx_char(void *arg, uint8_t data) ble_hci_uart_rx_sync_loss(data); return 0; #endif -#ifdef FEATURE_BLE_HOST +#if MYNEWT_VAL(BLE_HOST) case BLE_HCI_UART_H4_EVT: ble_hci_uart_rx_evt(data); return 0; @@ -960,13 +961,6 @@ ble_hci_uart_init(void) ble_hci_uart_free_mem(); - /* Create memory pool of HCI command / event buffers */ - rc = mem_malloc_mempool(&ble_hci_uart_evt_pool, - BLE_HCI_UART_EVT_COUNT, - MYNEWT_VAL(BLE_HCI_UART_BUF_SIZE), - "ble_hci_uart_evt_pool", - &ble_hci_uart_evt_buf); - /* * XXX: For now, we will keep the ACL buffer size such that it can * accommodate BLE_MBUF_PAYLOAD_SIZE. It should be possible to make this http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/sys/config/pkg.yml ---------------------------------------------------------------------- diff --git a/sys/config/pkg.yml b/sys/config/pkg.yml index 2d7c83d..e005530 100644 --- a/sys/config/pkg.yml +++ b/sys/config/pkg.yml @@ -41,7 +41,7 @@ pkg.init_stage: 5 pkg.syscfg_defs: CONFIG_FCB: description: 'TBD' - value: 0 + value: 1 CONFIG_FCB_MAGIC: description: 'TBD' value: 0xc09f6e5e http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/sys/config/test/pkg.yml ---------------------------------------------------------------------- diff --git a/sys/config/test/pkg.yml b/sys/config/test/pkg.yml index 7b533a6..0a366db 100644 --- a/sys/config/test/pkg.yml +++ b/sys/config/test/pkg.yml @@ -30,3 +30,7 @@ pkg.deps.SELFTEST: - fs/nffs - sys/fcb - libs/console/stub + +pkg.syscfg_vals.SELFTEST: + CONFIG_NFFS: 1 + CONFIG_FCB: 1 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/sys/mn_socket/test/src/mn_sock_test.c ---------------------------------------------------------------------- diff --git a/sys/mn_socket/test/src/mn_sock_test.c b/sys/mn_socket/test/src/mn_sock_test.c index a1e7177..39acd2b 100644 --- a/sys/mn_socket/test/src/mn_sock_test.c +++ b/sys/mn_socket/test/src/mn_sock_test.c @@ -847,7 +847,7 @@ mn_socket_test_handler(void *arg) sock_udp_ll(); sock_udp_mcast_v4(); sock_udp_mcast_v6(); - os_test_restart(); + tu_restart(); } TEST_CASE(socket_tests) http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/sys/reboot/pkg.yml ---------------------------------------------------------------------- diff --git a/sys/reboot/pkg.yml b/sys/reboot/pkg.yml index f55397b..afa950b 100644 --- a/sys/reboot/pkg.yml +++ b/sys/reboot/pkg.yml @@ -40,7 +40,7 @@ pkg.init_stage: 2 pkg.syscfg_defs: REBOOT_LOG_0_TYPE: description: 'TBD' - value: LOG_TYPE_STORAGE + value: LOG_STORE_CONSOLE REBOOT_LOG_0_ENTRY_COUNT: description: 'TBD' value: 10 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/sys/stats/pkg.yml ---------------------------------------------------------------------- diff --git a/sys/stats/pkg.yml b/sys/stats/pkg.yml index c23bedc..9927ef3 100644 --- a/sys/stats/pkg.yml +++ b/sys/stats/pkg.yml @@ -38,7 +38,7 @@ pkg.init_stage: 0 pkg.syscfg_defs: STATS_NAMES: description: 'TBD' - value: 1 + value: 0 STATS_CLI: description: 'TBD' value: 'MYNEWT_PKG_LIBS_SHELL'