mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-09-22 00:47:23 +00:00
nimble: Make NimBLE use NPL
This replaces calls to Mynewt kernel APIs with corresponding calls to NPL APIs everywhere in Mynewt's code.
This commit is contained in:
@@ -21,10 +21,9 @@
|
||||
#define H_BLE_LL_
|
||||
|
||||
#include "stats/stats.h"
|
||||
#include "os/os_eventq.h"
|
||||
#include "os/os_callout.h"
|
||||
#include "os/os_cputime.h"
|
||||
#include "nimble/nimble_opt.h"
|
||||
#include "nimble/nimble_npl.h"
|
||||
#include "controller/ble_phy.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -103,27 +102,27 @@ struct ble_ll_obj
|
||||
#endif
|
||||
|
||||
/* Task event queue */
|
||||
struct os_eventq ll_evq;
|
||||
struct ble_npl_eventq ll_evq;
|
||||
|
||||
/* Wait for response timer */
|
||||
struct hal_timer ll_wfr_timer;
|
||||
|
||||
/* Packet receive queue (and event). Holds received packets from PHY */
|
||||
struct os_event ll_rx_pkt_ev;
|
||||
struct ble_npl_event ll_rx_pkt_ev;
|
||||
struct ble_ll_pkt_q ll_rx_pkt_q;
|
||||
|
||||
/* Packet transmit queue */
|
||||
struct os_event ll_tx_pkt_ev;
|
||||
struct ble_npl_event ll_tx_pkt_ev;
|
||||
struct ble_ll_pkt_q ll_tx_pkt_q;
|
||||
|
||||
/* Data buffer overflow event */
|
||||
struct os_event ll_dbuf_overflow_ev;
|
||||
struct ble_npl_event ll_dbuf_overflow_ev;
|
||||
|
||||
/* Number of completed packets event */
|
||||
struct os_event ll_comp_pkt_ev;
|
||||
struct ble_npl_event ll_comp_pkt_ev;
|
||||
|
||||
/* HW error callout */
|
||||
struct os_callout ll_hw_err_timer;
|
||||
struct ble_npl_callout ll_hw_err_timer;
|
||||
};
|
||||
extern struct ble_ll_obj g_ble_ll_data;
|
||||
|
||||
@@ -441,7 +440,7 @@ void ble_ll_state_set(uint8_t ll_state);
|
||||
uint8_t ble_ll_state_get(void);
|
||||
|
||||
/* Send an event to LL task */
|
||||
void ble_ll_event_send(struct os_event *ev);
|
||||
void ble_ll_event_send(struct ble_npl_event *ev);
|
||||
|
||||
/* Hand received pdu's to LL task */
|
||||
void ble_ll_rx_pdu_in(struct os_mbuf *rxpdu);
|
||||
|
||||
@@ -274,7 +274,7 @@ struct ble_ll_conn_sm
|
||||
* on a singly linked list. Only would need list pointer here.
|
||||
*/
|
||||
/* Connection end event */
|
||||
struct os_event conn_ev_end;
|
||||
struct ble_npl_event conn_ev_end;
|
||||
|
||||
/* Packet transmit queue */
|
||||
struct os_mbuf *cur_tx_pdu;
|
||||
@@ -287,13 +287,13 @@ struct ble_ll_conn_sm
|
||||
};
|
||||
|
||||
/* LL control procedure response timer */
|
||||
struct os_callout ctrl_proc_rsp_timer;
|
||||
struct ble_npl_callout ctrl_proc_rsp_timer;
|
||||
|
||||
/* For scheduling connections */
|
||||
struct ble_ll_sched_item conn_sch;
|
||||
|
||||
#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_PING) == 1)
|
||||
struct os_callout auth_pyld_timer;
|
||||
struct ble_npl_callout auth_pyld_timer;
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "controller/ble_ll_sched.h"
|
||||
#include "hal/hal_timer.h"
|
||||
#include "syscfg/syscfg.h"
|
||||
#include "nimble/nimble_npl.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -120,7 +121,7 @@ struct ble_ll_scan_sm
|
||||
int8_t scan_rpa_index;
|
||||
uint8_t scan_peer_rpa[BLE_DEV_ADDR_LEN];
|
||||
#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
|
||||
uint32_t scan_nrpa_timer;
|
||||
ble_npl_time_t scan_nrpa_timer;
|
||||
uint8_t scan_nrpa[BLE_DEV_ADDR_LEN];
|
||||
#endif
|
||||
|
||||
@@ -129,7 +130,7 @@ struct ble_ll_scan_sm
|
||||
uint16_t backoff_count;
|
||||
uint32_t scan_win_start_time;
|
||||
struct os_mbuf *scan_req_pdu;
|
||||
struct os_event scan_sched_ev;
|
||||
struct ble_npl_event scan_sched_ev;
|
||||
struct hal_timer scan_timer;
|
||||
|
||||
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
|
||||
|
||||
@@ -204,9 +204,9 @@ STATS_NAME_START(ble_ll_stats)
|
||||
STATS_NAME(ble_ll_stats, scan_timer_restarted)
|
||||
STATS_NAME_END(ble_ll_stats)
|
||||
|
||||
static void ble_ll_event_rx_pkt(struct os_event *ev);
|
||||
static void ble_ll_event_tx_pkt(struct os_event *ev);
|
||||
static void ble_ll_event_dbuf_overflow(struct os_event *ev);
|
||||
static void ble_ll_event_rx_pkt(struct ble_npl_event *ev);
|
||||
static void ble_ll_event_tx_pkt(struct ble_npl_event *ev);
|
||||
static void ble_ll_event_dbuf_overflow(struct ble_npl_event *ev);
|
||||
|
||||
#if MYNEWT
|
||||
|
||||
@@ -797,7 +797,7 @@ ble_ll_rx_pdu_in(struct os_mbuf *rxpdu)
|
||||
|
||||
pkthdr = OS_MBUF_PKTHDR(rxpdu);
|
||||
STAILQ_INSERT_TAIL(&g_ble_ll_data.ll_rx_pkt_q, pkthdr, omp_next);
|
||||
os_eventq_put(&g_ble_ll_data.ll_evq, &g_ble_ll_data.ll_rx_pkt_ev);
|
||||
ble_npl_eventq_put(&g_ble_ll_data.ll_evq, &g_ble_ll_data.ll_rx_pkt_ev);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -815,7 +815,7 @@ ble_ll_acl_data_in(struct os_mbuf *txpkt)
|
||||
OS_ENTER_CRITICAL(sr);
|
||||
STAILQ_INSERT_TAIL(&g_ble_ll_data.ll_tx_pkt_q, pkthdr, omp_next);
|
||||
OS_EXIT_CRITICAL(sr);
|
||||
os_eventq_put(&g_ble_ll_data.ll_evq, &g_ble_ll_data.ll_tx_pkt_ev);
|
||||
ble_npl_eventq_put(&g_ble_ll_data.ll_evq, &g_ble_ll_data.ll_tx_pkt_ev);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -828,7 +828,7 @@ ble_ll_acl_data_in(struct os_mbuf *txpkt)
|
||||
void
|
||||
ble_ll_data_buffer_overflow(void)
|
||||
{
|
||||
os_eventq_put(&g_ble_ll_data.ll_evq, &g_ble_ll_data.ll_dbuf_overflow_ev);
|
||||
ble_npl_eventq_put(&g_ble_ll_data.ll_evq, &g_ble_ll_data.ll_dbuf_overflow_ev);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -839,7 +839,7 @@ ble_ll_data_buffer_overflow(void)
|
||||
void
|
||||
ble_ll_hw_error(void)
|
||||
{
|
||||
os_callout_reset(&g_ble_ll_data.ll_hw_err_timer, 0);
|
||||
ble_npl_callout_reset(&g_ble_ll_data.ll_hw_err_timer, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -848,7 +848,7 @@ ble_ll_hw_error(void)
|
||||
* @param arg
|
||||
*/
|
||||
static void
|
||||
ble_ll_hw_err_timer_cb(struct os_event *ev)
|
||||
ble_ll_hw_err_timer_cb(struct ble_npl_event *ev)
|
||||
{
|
||||
if (ble_ll_hci_ev_hw_err(BLE_HW_ERR_HCI_SYNC_LOSS)) {
|
||||
/*
|
||||
@@ -856,8 +856,8 @@ ble_ll_hw_err_timer_cb(struct os_event *ev)
|
||||
* event every 50 milliseconds (or each OS tick if a tick is longer
|
||||
* than 100 msecs).
|
||||
*/
|
||||
os_callout_reset(&g_ble_ll_data.ll_hw_err_timer,
|
||||
os_time_ms_to_ticks32(50));
|
||||
ble_npl_callout_reset(&g_ble_ll_data.ll_hw_err_timer,
|
||||
ble_npl_time_ms_to_ticks32(50));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1055,25 +1055,25 @@ ble_ll_tx_mbuf_pducb(uint8_t *dptr, void *pducb_arg, uint8_t *hdr_byte)
|
||||
}
|
||||
|
||||
static void
|
||||
ble_ll_event_rx_pkt(struct os_event *ev)
|
||||
ble_ll_event_rx_pkt(struct ble_npl_event *ev)
|
||||
{
|
||||
ble_ll_rx_pkt_in();
|
||||
}
|
||||
|
||||
static void
|
||||
ble_ll_event_tx_pkt(struct os_event *ev)
|
||||
ble_ll_event_tx_pkt(struct ble_npl_event *ev)
|
||||
{
|
||||
ble_ll_tx_pkt_in();
|
||||
}
|
||||
|
||||
static void
|
||||
ble_ll_event_dbuf_overflow(struct os_event *ev)
|
||||
ble_ll_event_dbuf_overflow(struct ble_npl_event *ev)
|
||||
{
|
||||
ble_ll_hci_ev_databuf_overflow();
|
||||
}
|
||||
|
||||
static void
|
||||
ble_ll_event_comp_pkts(struct os_event *ev)
|
||||
ble_ll_event_comp_pkts(struct ble_npl_event *ev)
|
||||
{
|
||||
ble_ll_conn_num_comp_pkts_event_send(NULL);
|
||||
}
|
||||
@@ -1100,7 +1100,7 @@ ble_ll_task(void *arg)
|
||||
ble_ll_rand_start();
|
||||
|
||||
while (1) {
|
||||
os_eventq_run(&g_ble_ll_data.ll_evq);
|
||||
ble_npl_eventq_run(&g_ble_ll_data.ll_evq);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1142,9 +1142,9 @@ ble_ll_state_get(void)
|
||||
* @param ev Event to add to the Link Layer event queue.
|
||||
*/
|
||||
void
|
||||
ble_ll_event_send(struct os_event *ev)
|
||||
ble_ll_event_send(struct ble_npl_event *ev)
|
||||
{
|
||||
os_eventq_put(&g_ble_ll_data.ll_evq, ev);
|
||||
ble_npl_eventq_put(&g_ble_ll_data.ll_evq, ev);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1453,25 +1453,25 @@ ble_ll_init(void)
|
||||
lldata->ll_acl_pkt_size = MYNEWT_VAL(BLE_ACL_BUF_SIZE);
|
||||
|
||||
/* Initialize eventq */
|
||||
os_eventq_init(&lldata->ll_evq);
|
||||
ble_npl_eventq_init(&lldata->ll_evq);
|
||||
|
||||
/* Initialize the transmit (from host) and receive (from phy) queues */
|
||||
STAILQ_INIT(&lldata->ll_tx_pkt_q);
|
||||
STAILQ_INIT(&lldata->ll_rx_pkt_q);
|
||||
|
||||
/* Initialize transmit (from host) and receive packet (from phy) event */
|
||||
lldata->ll_rx_pkt_ev.ev_cb = ble_ll_event_rx_pkt;
|
||||
lldata->ll_tx_pkt_ev.ev_cb = ble_ll_event_tx_pkt;
|
||||
ble_npl_event_init(&lldata->ll_rx_pkt_ev, ble_ll_event_rx_pkt, NULL);
|
||||
ble_npl_event_init(&lldata->ll_tx_pkt_ev, ble_ll_event_tx_pkt, NULL);
|
||||
|
||||
/* Initialize data buffer overflow event and completed packets */
|
||||
lldata->ll_dbuf_overflow_ev.ev_cb = ble_ll_event_dbuf_overflow;
|
||||
lldata->ll_comp_pkt_ev.ev_cb = ble_ll_event_comp_pkts;
|
||||
ble_npl_event_init(&lldata->ll_dbuf_overflow_ev, ble_ll_event_dbuf_overflow, NULL);
|
||||
ble_npl_event_init(&lldata->ll_comp_pkt_ev, ble_ll_event_comp_pkts, NULL);
|
||||
|
||||
/* Initialize the HW error timer */
|
||||
os_callout_init(&g_ble_ll_data.ll_hw_err_timer,
|
||||
&g_ble_ll_data.ll_evq,
|
||||
ble_ll_hw_err_timer_cb,
|
||||
NULL);
|
||||
ble_npl_callout_init(&g_ble_ll_data.ll_hw_err_timer,
|
||||
&g_ble_ll_data.ll_evq,
|
||||
ble_ll_hw_err_timer_cb,
|
||||
NULL);
|
||||
|
||||
/* Initialize LL HCI */
|
||||
ble_ll_hci_init();
|
||||
|
||||
@@ -104,7 +104,7 @@ struct ble_ll_adv_sm
|
||||
struct os_mbuf *adv_data;
|
||||
struct os_mbuf *scan_rsp_data;
|
||||
uint8_t *conn_comp_ev;
|
||||
struct os_event adv_txdone_ev;
|
||||
struct ble_npl_event adv_txdone_ev;
|
||||
struct ble_ll_sched_item adv_sch;
|
||||
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
|
||||
uint8_t aux_active : 1;
|
||||
@@ -114,7 +114,7 @@ struct ble_ll_adv_sm
|
||||
struct ble_mbuf_hdr *rx_ble_hdr;
|
||||
struct os_mbuf **aux_data;
|
||||
struct ble_ll_adv_aux aux[2];
|
||||
struct os_event adv_sec_txdone_ev;
|
||||
struct ble_npl_event adv_sec_txdone_ev;
|
||||
uint16_t duration;
|
||||
uint16_t adi;
|
||||
uint8_t adv_secondary_chan;
|
||||
@@ -245,7 +245,7 @@ ble_ll_adv_chk_rpa_timeout(struct ble_ll_adv_sm *advsm)
|
||||
return;
|
||||
}
|
||||
|
||||
now = os_time_get();
|
||||
now = ble_npl_time_get();
|
||||
if ((int32_t)(now - advsm->adv_rpa_timer) >= 0) {
|
||||
ble_ll_adv_rpa_update(advsm);
|
||||
advsm->adv_rpa_timer = now + ble_ll_resolv_get_rpa_tmo();
|
||||
@@ -778,15 +778,15 @@ ble_ll_adv_tx_done(void *arg)
|
||||
|
||||
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
|
||||
if (ble_ll_adv_active_chanset_is_pri(advsm)) {
|
||||
os_eventq_put(&g_ble_ll_data.ll_evq, &advsm->adv_txdone_ev);
|
||||
ble_npl_eventq_put(&g_ble_ll_data.ll_evq, &advsm->adv_txdone_ev);
|
||||
} else if (ble_ll_adv_active_chanset_is_sec(advsm)) {
|
||||
os_eventq_put(&g_ble_ll_data.ll_evq, &advsm->adv_sec_txdone_ev);
|
||||
ble_npl_eventq_put(&g_ble_ll_data.ll_evq, &advsm->adv_sec_txdone_ev);
|
||||
} else {
|
||||
assert(0);
|
||||
}
|
||||
#else
|
||||
assert(ble_ll_adv_active_chanset_is_pri(advsm));
|
||||
os_eventq_put(&g_ble_ll_data.ll_evq, &advsm->adv_txdone_ev);
|
||||
ble_npl_eventq_put(&g_ble_ll_data.ll_evq, &advsm->adv_txdone_ev);
|
||||
#endif
|
||||
|
||||
ble_ll_log(BLE_LL_LOG_ID_ADV_TXDONE, ble_ll_state_get(),
|
||||
@@ -812,7 +812,7 @@ ble_ll_adv_event_rmvd_from_sched(struct ble_ll_adv_sm *advsm)
|
||||
* scheduled.
|
||||
*/
|
||||
advsm->adv_chan = ble_ll_adv_final_chan(advsm);
|
||||
os_eventq_put(&g_ble_ll_data.ll_evq, &advsm->adv_txdone_ev);
|
||||
ble_npl_eventq_put(&g_ble_ll_data.ll_evq, &advsm->adv_txdone_ev);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1359,10 +1359,10 @@ ble_ll_adv_halt(void)
|
||||
|
||||
ble_phy_txpwr_set(MYNEWT_VAL(BLE_LL_TX_PWR_DBM));
|
||||
|
||||
os_eventq_put(&g_ble_ll_data.ll_evq, &advsm->adv_txdone_ev);
|
||||
ble_npl_eventq_put(&g_ble_ll_data.ll_evq, &advsm->adv_txdone_ev);
|
||||
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
|
||||
if (!(advsm->props & BLE_HCI_LE_SET_EXT_ADV_PROP_LEGACY)) {
|
||||
os_eventq_put(&g_ble_ll_data.ll_evq, &advsm->adv_sec_txdone_ev);
|
||||
ble_npl_eventq_put(&g_ble_ll_data.ll_evq, &advsm->adv_sec_txdone_ev);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1473,7 +1473,7 @@ ble_ll_adv_set_adv_params(uint8_t *cmd)
|
||||
memcpy(advsm->peer_addr, cmd + 7, BLE_DEV_ADDR_LEN);
|
||||
|
||||
/* Reset RPA timer so we generate a new RPA */
|
||||
advsm->adv_rpa_timer = os_time_get();
|
||||
advsm->adv_rpa_timer = ble_npl_time_get();
|
||||
}
|
||||
#else
|
||||
/* If we dont support privacy some address types wont work */
|
||||
@@ -1550,9 +1550,9 @@ ble_ll_adv_sm_stop(struct ble_ll_adv_sm *advsm)
|
||||
#endif
|
||||
OS_EXIT_CRITICAL(sr);
|
||||
|
||||
os_eventq_remove(&g_ble_ll_data.ll_evq, &advsm->adv_txdone_ev);
|
||||
ble_npl_eventq_remove(&g_ble_ll_data.ll_evq, &advsm->adv_txdone_ev);
|
||||
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
|
||||
os_eventq_remove(&g_ble_ll_data.ll_evq, &advsm->adv_sec_txdone_ev);
|
||||
ble_npl_eventq_remove(&g_ble_ll_data.ll_evq, &advsm->adv_sec_txdone_ev);
|
||||
#endif
|
||||
|
||||
/* If there is an event buf we need to free it */
|
||||
@@ -2217,7 +2217,7 @@ ble_ll_adv_ext_set_param(uint8_t *cmdbuf, uint8_t *rspbuf, uint8_t *rsplen)
|
||||
#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
|
||||
if (own_addr_type > BLE_HCI_ADV_OWN_ADDR_RANDOM) {
|
||||
/* Reset RPA timer so we generate a new RPA */
|
||||
advsm->adv_rpa_timer = os_time_get();
|
||||
advsm->adv_rpa_timer = ble_npl_time_get();
|
||||
}
|
||||
#else
|
||||
/* If we dont support privacy some address types wont work */
|
||||
@@ -2947,12 +2947,12 @@ ble_ll_adv_drop_event(struct ble_ll_adv_sm *advsm)
|
||||
ble_ll_sched_rmv_elem(&advsm->aux[0].sch);
|
||||
ble_ll_sched_rmv_elem(&advsm->aux[1].sch);
|
||||
|
||||
os_eventq_remove(&g_ble_ll_data.ll_evq, &advsm->adv_sec_txdone_ev);
|
||||
ble_npl_eventq_remove(&g_ble_ll_data.ll_evq, &advsm->adv_sec_txdone_ev);
|
||||
advsm->aux_active = 0;
|
||||
#endif
|
||||
|
||||
advsm->adv_chan = ble_ll_adv_final_chan(advsm);
|
||||
os_eventq_put(&g_ble_ll_data.ll_evq, &advsm->adv_txdone_ev);
|
||||
ble_npl_eventq_put(&g_ble_ll_data.ll_evq, &advsm->adv_txdone_ev);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -3027,7 +3027,7 @@ ble_ll_adv_done(struct ble_ll_adv_sm *advsm)
|
||||
/* Remove the element from the schedule if it is still there. */
|
||||
ble_ll_sched_rmv_elem(&advsm->adv_sch);
|
||||
|
||||
os_eventq_remove(&g_ble_ll_data.ll_evq, &advsm->adv_txdone_ev);
|
||||
ble_npl_eventq_remove(&g_ble_ll_data.ll_evq, &advsm->adv_txdone_ev);
|
||||
|
||||
/*
|
||||
* Check if we have ended our advertising event. If our last advertising
|
||||
@@ -3173,9 +3173,9 @@ ble_ll_adv_done(struct ble_ll_adv_sm *advsm)
|
||||
}
|
||||
|
||||
static void
|
||||
ble_ll_adv_event_done(struct os_event *ev)
|
||||
ble_ll_adv_event_done(struct ble_npl_event *ev)
|
||||
{
|
||||
ble_ll_adv_done(ev->ev_arg);
|
||||
ble_ll_adv_done(ble_npl_event_get_arg(ev));
|
||||
}
|
||||
|
||||
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
|
||||
@@ -3204,7 +3204,7 @@ ble_ll_adv_sec_done(struct ble_ll_adv_sm *advsm)
|
||||
|
||||
/* Remove anything else scheduled for secondary channel */
|
||||
ble_ll_sched_rmv_elem(&aux->sch);
|
||||
os_eventq_remove(&g_ble_ll_data.ll_evq, &advsm->adv_sec_txdone_ev);
|
||||
ble_npl_eventq_remove(&g_ble_ll_data.ll_evq, &advsm->adv_sec_txdone_ev);
|
||||
|
||||
/* Stop advertising due to transmitting connection response */
|
||||
if (advsm->flags & BLE_LL_ADV_SM_FLAG_CONN_RSP_TXD) {
|
||||
@@ -3239,9 +3239,9 @@ ble_ll_adv_sec_done(struct ble_ll_adv_sm *advsm)
|
||||
}
|
||||
|
||||
static void
|
||||
ble_ll_adv_sec_event_done(struct os_event *ev)
|
||||
ble_ll_adv_sec_event_done(struct ble_npl_event *ev)
|
||||
{
|
||||
ble_ll_adv_sec_done(ev->ev_arg);
|
||||
ble_ll_adv_sec_done(ble_npl_event_get_arg(ev));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -3432,11 +3432,9 @@ ble_ll_adv_sm_init(struct ble_ll_adv_sm *advsm)
|
||||
advsm->adv_chanmask = BLE_HCI_ADV_CHANMASK_DEF;
|
||||
|
||||
/* Initialize advertising tx done event */
|
||||
advsm->adv_txdone_ev.ev_cb = ble_ll_adv_event_done;
|
||||
advsm->adv_txdone_ev.ev_arg = advsm;
|
||||
ble_npl_event_init(&advsm->adv_txdone_ev, ble_ll_adv_event_done, advsm);
|
||||
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
|
||||
advsm->adv_sec_txdone_ev.ev_cb = ble_ll_adv_sec_event_done;
|
||||
advsm->adv_sec_txdone_ev.ev_arg = advsm;
|
||||
ble_npl_event_init(&advsm->adv_sec_txdone_ev, ble_ll_adv_sec_event_done, advsm);
|
||||
#endif
|
||||
|
||||
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
|
||||
|
||||
@@ -215,7 +215,7 @@ STATS_NAME_START(ble_ll_conn_stats)
|
||||
STATS_NAME(ble_ll_conn_stats, mic_failures)
|
||||
STATS_NAME_END(ble_ll_conn_stats)
|
||||
|
||||
static void ble_ll_conn_event_end(struct os_event *ev);
|
||||
static void ble_ll_conn_event_end(struct ble_npl_event *ev);
|
||||
|
||||
#if (BLE_LL_BT5_PHY_SUPPORTED == 1)
|
||||
/**
|
||||
@@ -1638,22 +1638,22 @@ ble_ll_conn_can_send_next_pdu(struct ble_ll_conn_sm *connsm, uint32_t begtime,
|
||||
* @param arg
|
||||
*/
|
||||
void
|
||||
ble_ll_conn_auth_pyld_timer_cb(struct os_event *ev)
|
||||
ble_ll_conn_auth_pyld_timer_cb(struct ble_npl_event *ev)
|
||||
{
|
||||
struct ble_ll_conn_sm *connsm;
|
||||
|
||||
connsm = (struct ble_ll_conn_sm *)ev->ev_arg;
|
||||
connsm = (struct ble_ll_conn_sm *)ble_npl_event_get_arg(ev);
|
||||
ble_ll_auth_pyld_tmo_event_send(connsm);
|
||||
ble_ll_ctrl_proc_start(connsm, BLE_LL_CTRL_PROC_LE_PING);
|
||||
ble_ll_conn_auth_pyld_timer_start(connsm);
|
||||
}
|
||||
|
||||
void
|
||||
ble_ll_conn_rd_features_timer_cb(struct os_event *ev)
|
||||
ble_ll_conn_rd_features_timer_cb(struct ble_npl_event *ev)
|
||||
{
|
||||
struct ble_ll_conn_sm *connsm;
|
||||
|
||||
connsm = (struct ble_ll_conn_sm *)ev->ev_arg;
|
||||
connsm = (struct ble_ll_conn_sm *)ble_npl_event_get_arg(ev);
|
||||
|
||||
if (!connsm->csmflags.cfbit.pending_hci_rd_features ||
|
||||
!connsm->csmflags.cfbit.rxd_features) {
|
||||
@@ -1676,7 +1676,7 @@ ble_ll_conn_auth_pyld_timer_start(struct ble_ll_conn_sm *connsm)
|
||||
|
||||
/* Timeout in is in 10 msec units */
|
||||
tmo = (int32_t)BLE_LL_CONN_AUTH_PYLD_OS_TMO(connsm->auth_pyld_tmo);
|
||||
os_callout_reset(&connsm->auth_pyld_timer, tmo);
|
||||
ble_npl_callout_reset(&connsm->auth_pyld_timer, tmo);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1980,9 +1980,7 @@ ble_ll_conn_sm_new(struct ble_ll_conn_sm *connsm)
|
||||
connsm->conn_param_req.handle = 0;
|
||||
|
||||
/* Connection end event */
|
||||
connsm->conn_ev_end.ev_arg = connsm;
|
||||
connsm->conn_ev_end.ev_queued = 0;
|
||||
connsm->conn_ev_end.ev_cb = ble_ll_conn_event_end;
|
||||
ble_npl_event_init(&connsm->conn_ev_end, ble_ll_conn_event_end, connsm);
|
||||
|
||||
/* Initialize transmit queue and ack/flow control elements */
|
||||
STAILQ_INIT(&connsm->conn_txq);
|
||||
@@ -2019,7 +2017,7 @@ ble_ll_conn_sm_new(struct ble_ll_conn_sm *connsm)
|
||||
#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_init(&connsm->auth_pyld_timer,
|
||||
ble_npl_callout_init(&connsm->auth_pyld_timer,
|
||||
&g_ble_ll_data.ll_evq,
|
||||
ble_ll_conn_auth_pyld_timer_cb,
|
||||
connsm);
|
||||
@@ -2106,10 +2104,10 @@ ble_ll_conn_end(struct ble_ll_conn_sm *connsm, uint8_t ble_err)
|
||||
ble_ll_sched_rmv_elem(&connsm->conn_sch);
|
||||
|
||||
/* Stop any control procedures that might be running */
|
||||
os_callout_stop(&connsm->ctrl_proc_rsp_timer);
|
||||
ble_npl_callout_stop(&connsm->ctrl_proc_rsp_timer);
|
||||
|
||||
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_PING)
|
||||
os_callout_stop(&connsm->auth_pyld_timer);
|
||||
ble_npl_callout_stop(&connsm->auth_pyld_timer);
|
||||
#endif
|
||||
|
||||
/* Remove from the active connection list */
|
||||
@@ -2135,7 +2133,7 @@ ble_ll_conn_end(struct ble_ll_conn_sm *connsm, uint8_t ble_err)
|
||||
}
|
||||
|
||||
/* Make sure events off queue */
|
||||
os_eventq_remove(&g_ble_ll_data.ll_evq, &connsm->conn_ev_end);
|
||||
ble_npl_eventq_remove(&g_ble_ll_data.ll_evq, &connsm->conn_ev_end);
|
||||
|
||||
#if MYNEWT_VAL(BLE_LL_STRICT_CONN_SCHEDULING)
|
||||
/* Remove from occupied periods */
|
||||
@@ -2557,14 +2555,14 @@ ble_ll_conn_created(struct ble_ll_conn_sm *connsm, struct ble_mbuf_hdr *rxhdr)
|
||||
*
|
||||
*/
|
||||
static void
|
||||
ble_ll_conn_event_end(struct os_event *ev)
|
||||
ble_ll_conn_event_end(struct ble_npl_event *ev)
|
||||
{
|
||||
uint8_t ble_err;
|
||||
uint32_t tmo;
|
||||
struct ble_ll_conn_sm *connsm;
|
||||
|
||||
/* Better be a connection state machine! */
|
||||
connsm = (struct ble_ll_conn_sm *)ev->ev_arg;
|
||||
connsm = (struct ble_ll_conn_sm *)ble_npl_event_get_arg(ev);
|
||||
assert(connsm);
|
||||
|
||||
/* Check if we need to resume scanning */
|
||||
@@ -2591,7 +2589,7 @@ ble_ll_conn_event_end(struct os_event *ev)
|
||||
}
|
||||
|
||||
/* Remove any connection end events that might be enqueued */
|
||||
os_eventq_remove(&g_ble_ll_data.ll_evq, &connsm->conn_ev_end);
|
||||
ble_npl_eventq_remove(&g_ble_ll_data.ll_evq, &connsm->conn_ev_end);
|
||||
|
||||
/*
|
||||
* If we have received a packet, we can set the current transmit window
|
||||
@@ -3813,8 +3811,8 @@ ble_ll_conn_rx_isr_end(uint8_t *rxbuf, struct ble_mbuf_hdr *rxhdr)
|
||||
#endif
|
||||
++connsm->completed_pkts;
|
||||
if (connsm->completed_pkts > 2) {
|
||||
os_eventq_put(&g_ble_ll_data.ll_evq,
|
||||
&g_ble_ll_data.ll_comp_pkt_ev);
|
||||
ble_npl_eventq_put(&g_ble_ll_data.ll_evq,
|
||||
&g_ble_ll_data.ll_comp_pkt_ev);
|
||||
}
|
||||
}
|
||||
os_mbuf_free_chain(txpdu);
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
* Used to limit the rate at which we send the number of completed packets
|
||||
* event to the host. This is the os time at which we can send an event.
|
||||
*/
|
||||
static uint32_t g_ble_ll_last_num_comp_pkt_evt;
|
||||
static ble_npl_time_t g_ble_ll_last_num_comp_pkt_evt;
|
||||
extern uint8_t *g_ble_ll_conn_comp_ev;
|
||||
|
||||
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
|
||||
@@ -283,7 +283,7 @@ ble_ll_conn_num_comp_pkts_event_send(struct ble_ll_conn_sm *connsm)
|
||||
* have completed but there are data packets in the controller buffers
|
||||
* (i.e. enqueued in a connection state machine).
|
||||
*/
|
||||
if ((int32_t)(os_time_get() - g_ble_ll_last_num_comp_pkt_evt) <
|
||||
if ((ble_npl_stime_t)(ble_npl_time_get() - g_ble_ll_last_num_comp_pkt_evt) <
|
||||
MYNEWT_VAL(BLE_NUM_COMP_PKT_RATE)) {
|
||||
/*
|
||||
* If this connection has completed packets, send an event right away.
|
||||
@@ -358,7 +358,7 @@ skip_conn:
|
||||
}
|
||||
|
||||
if (event_sent) {
|
||||
g_ble_ll_last_num_comp_pkt_evt = os_time_get();
|
||||
g_ble_ll_last_num_comp_pkt_evt = ble_npl_time_get();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1464,7 +1464,7 @@ ble_ll_conn_hci_wr_auth_pyld_tmo(uint8_t *cmdbuf, uint8_t *rsp, uint8_t *rsplen)
|
||||
rc = BLE_ERR_INV_HCI_CMD_PARMS;
|
||||
} else {
|
||||
connsm->auth_pyld_tmo = tmo;
|
||||
if (os_callout_queued(&connsm->auth_pyld_timer)) {
|
||||
if (ble_npl_callout_queued(&connsm->auth_pyld_timer)) {
|
||||
ble_ll_conn_auth_pyld_timer_start(connsm);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ extern "C" {
|
||||
|
||||
/* Default authenticated payload timeout (30 seconds; in 10 msecs increments) */
|
||||
#define BLE_LL_CONN_DEF_AUTH_PYLD_TMO (3000)
|
||||
#define BLE_LL_CONN_AUTH_PYLD_OS_TMO(x) os_time_ms_to_ticks32((x) * 10)
|
||||
#define BLE_LL_CONN_AUTH_PYLD_OS_TMO(x) ble_npl_time_ms_to_ticks32((x) * 10)
|
||||
|
||||
|
||||
typedef void (*ble_ll_hci_post_cmd_complete_cb)(void);
|
||||
|
||||
@@ -681,7 +681,7 @@ ble_ll_ctrl_rx_phy_req(struct ble_ll_conn_sm *connsm, uint8_t *req,
|
||||
/* XXX: deal with other control procedures that we need to stop */
|
||||
if (err) {
|
||||
if (connsm->cur_ctrl_proc == BLE_LL_CTRL_PROC_PHY_UPDATE) {
|
||||
os_callout_stop(&connsm->ctrl_proc_rsp_timer);
|
||||
ble_npl_callout_stop(&connsm->ctrl_proc_rsp_timer);
|
||||
connsm->cur_ctrl_proc = BLE_LL_CTRL_PROC_IDLE;
|
||||
}
|
||||
|
||||
@@ -722,7 +722,7 @@ ble_ll_ctrl_rx_phy_rsp(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
|
||||
if (connsm->conn_role == BLE_LL_CONN_ROLE_MASTER) {
|
||||
if (connsm->cur_ctrl_proc == BLE_LL_CTRL_PROC_PHY_UPDATE) {
|
||||
ble_ll_ctrl_phy_update_ind_make(connsm, dptr, rsp, 0);
|
||||
os_callout_stop(&connsm->ctrl_proc_rsp_timer);
|
||||
ble_npl_callout_stop(&connsm->ctrl_proc_rsp_timer);
|
||||
rsp_opcode = BLE_LL_CTRL_PHY_UPDATE_IND;
|
||||
}
|
||||
|
||||
@@ -764,7 +764,7 @@ ble_ll_ctrl_rx_phy_update_ind(struct ble_ll_conn_sm *connsm, uint8_t *dptr)
|
||||
* complete the procedure
|
||||
*/
|
||||
if (connsm->cur_ctrl_proc == BLE_LL_CTRL_PROC_PHY_UPDATE) {
|
||||
os_callout_stop(&connsm->ctrl_proc_rsp_timer);
|
||||
ble_npl_callout_stop(&connsm->ctrl_proc_rsp_timer);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1773,10 +1773,10 @@ ble_ll_ctrl_rx_chanmap_req(struct ble_ll_conn_sm *connsm, uint8_t *dptr)
|
||||
* @param arg Pointer to connection state machine.
|
||||
*/
|
||||
void
|
||||
ble_ll_ctrl_proc_rsp_timer_cb(struct os_event *ev)
|
||||
ble_ll_ctrl_proc_rsp_timer_cb(struct ble_npl_event *ev)
|
||||
{
|
||||
/* Control procedure has timed out. Kill the connection */
|
||||
ble_ll_conn_timeout((struct ble_ll_conn_sm *)ev->ev_arg,
|
||||
ble_ll_conn_timeout((struct ble_ll_conn_sm *)ble_npl_event_get_arg(ev),
|
||||
BLE_ERR_LMP_LL_RSP_TMO);
|
||||
}
|
||||
|
||||
@@ -1914,7 +1914,7 @@ void
|
||||
ble_ll_ctrl_proc_stop(struct ble_ll_conn_sm *connsm, int ctrl_proc)
|
||||
{
|
||||
if (connsm->cur_ctrl_proc == ctrl_proc) {
|
||||
os_callout_stop(&connsm->ctrl_proc_rsp_timer);
|
||||
ble_npl_callout_stop(&connsm->ctrl_proc_rsp_timer);
|
||||
connsm->cur_ctrl_proc = BLE_LL_CTRL_PROC_IDLE;
|
||||
}
|
||||
CLR_PENDING_CTRL_PROC(connsm, ctrl_proc);
|
||||
@@ -1977,14 +1977,14 @@ ble_ll_ctrl_proc_start(struct ble_ll_conn_sm *connsm, int ctrl_proc)
|
||||
|
||||
/* Initialize the procedure response timeout */
|
||||
if (ctrl_proc != BLE_LL_CTRL_PROC_CHAN_MAP_UPD) {
|
||||
os_callout_init(&connsm->ctrl_proc_rsp_timer,
|
||||
ble_npl_callout_init(&connsm->ctrl_proc_rsp_timer,
|
||||
&g_ble_ll_data.ll_evq,
|
||||
ble_ll_ctrl_proc_rsp_timer_cb,
|
||||
connsm);
|
||||
|
||||
/* Re-start timer. Control procedure timeout is 40 seconds */
|
||||
os_callout_reset(&connsm->ctrl_proc_rsp_timer,
|
||||
os_time_ms_to_ticks32(BLE_LL_CTRL_PROC_TIMEOUT_MS));
|
||||
ble_npl_callout_reset(&connsm->ctrl_proc_rsp_timer,
|
||||
ble_npl_time_ms_to_ticks32(BLE_LL_CTRL_PROC_TIMEOUT_MS));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,10 +38,10 @@
|
||||
#include <ble_ll_dtm_priv.h>
|
||||
#endif
|
||||
|
||||
static void ble_ll_hci_cmd_proc(struct os_event *ev);
|
||||
static void ble_ll_hci_cmd_proc(struct ble_npl_event *ev);
|
||||
|
||||
/* OS event to enqueue command */
|
||||
static struct os_event g_ble_ll_hci_cmd_ev;
|
||||
static struct ble_npl_event g_ble_ll_hci_cmd_ev;
|
||||
|
||||
/* LE event mask */
|
||||
static uint8_t g_ble_ll_hci_le_event_mask[BLE_HCI_SET_LE_EVENT_MASK_LEN];
|
||||
@@ -1159,7 +1159,7 @@ ble_ll_hci_status_params_cmd_proc(uint8_t *cmdbuf, uint16_t ocf, uint8_t *rsplen
|
||||
* @param ev Pointer to os event containing a pointer to command buffer
|
||||
*/
|
||||
static void
|
||||
ble_ll_hci_cmd_proc(struct os_event *ev)
|
||||
ble_ll_hci_cmd_proc(struct ble_npl_event *ev)
|
||||
{
|
||||
int rc;
|
||||
uint8_t ogf;
|
||||
@@ -1170,7 +1170,7 @@ ble_ll_hci_cmd_proc(struct os_event *ev)
|
||||
ble_ll_hci_post_cmd_complete_cb post_cb = NULL;
|
||||
|
||||
/* The command buffer is the event argument */
|
||||
cmdbuf = (uint8_t *)ev->ev_arg;
|
||||
cmdbuf = (uint8_t *)ble_npl_event_get_arg(ev);
|
||||
assert(cmdbuf != NULL);
|
||||
|
||||
/* Get the opcode from the command buffer */
|
||||
@@ -1252,18 +1252,17 @@ ble_ll_hci_cmd_proc(struct os_event *ev)
|
||||
int
|
||||
ble_ll_hci_cmd_rx(uint8_t *cmd, void *arg)
|
||||
{
|
||||
struct os_event *ev;
|
||||
struct ble_npl_event *ev;
|
||||
|
||||
/* Get an event structure off the queue */
|
||||
ev = &g_ble_ll_hci_cmd_ev;
|
||||
if (ev->ev_queued) {
|
||||
if (ble_npl_event_is_queued(ev)) {
|
||||
return BLE_ERR_MEM_CAPACITY;
|
||||
}
|
||||
|
||||
/* Fill out the event and post to Link Layer */
|
||||
ev->ev_queued = 0;
|
||||
ev->ev_arg = cmd;
|
||||
os_eventq_put(&g_ble_ll_data.ll_evq, ev);
|
||||
ble_npl_event_set_arg(ev, cmd);
|
||||
ble_npl_eventq_put(&g_ble_ll_data.ll_evq, ev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1286,7 +1285,7 @@ void
|
||||
ble_ll_hci_init(void)
|
||||
{
|
||||
/* Set event callback for command processing */
|
||||
g_ble_ll_hci_cmd_ev.ev_cb = ble_ll_hci_cmd_proc;
|
||||
ble_npl_event_init(&g_ble_ll_hci_cmd_ev, ble_ll_hci_cmd_proc, NULL);
|
||||
|
||||
/* Set defaults for LE events: Vol 2 Part E 7.8.1 */
|
||||
g_ble_ll_hci_le_event_mask[0] = 0x1f;
|
||||
|
||||
@@ -38,7 +38,7 @@ struct ble_ll_resolv_data
|
||||
uint8_t rl_size;
|
||||
uint8_t rl_cnt;
|
||||
uint32_t rpa_tmo;
|
||||
struct os_callout rpa_timer;
|
||||
struct ble_npl_callout rpa_timer;
|
||||
};
|
||||
struct ble_ll_resolv_data g_ble_ll_resolv_data;
|
||||
|
||||
@@ -77,7 +77,7 @@ ble_ll_resolv_list_chg_allowed(void)
|
||||
* is used to regenerate local RPA's in the resolving list.
|
||||
*/
|
||||
void
|
||||
ble_ll_resolv_rpa_timer_cb(struct os_event *ev)
|
||||
ble_ll_resolv_rpa_timer_cb(struct ble_npl_event *ev)
|
||||
{
|
||||
int i;
|
||||
os_sr_t sr;
|
||||
@@ -92,7 +92,7 @@ ble_ll_resolv_rpa_timer_cb(struct os_event *ev)
|
||||
OS_EXIT_CRITICAL(sr);
|
||||
++rl;
|
||||
}
|
||||
os_callout_reset(&g_ble_ll_resolv_data.rpa_timer,
|
||||
ble_npl_callout_reset(&g_ble_ll_resolv_data.rpa_timer,
|
||||
(int32_t)g_ble_ll_resolv_data.rpa_tmo);
|
||||
}
|
||||
|
||||
@@ -324,9 +324,9 @@ ble_ll_resolv_enable_cmd(uint8_t *cmdbuf)
|
||||
if ((enabled ^ g_ble_ll_resolv_data.addr_res_enabled) != 0) {
|
||||
if (enabled) {
|
||||
tmo = (int32_t)g_ble_ll_resolv_data.rpa_tmo;
|
||||
os_callout_reset(&g_ble_ll_resolv_data.rpa_timer, tmo);
|
||||
ble_npl_callout_reset(&g_ble_ll_resolv_data.rpa_timer, tmo);
|
||||
} else {
|
||||
os_callout_stop(&g_ble_ll_resolv_data.rpa_timer);
|
||||
ble_npl_callout_stop(&g_ble_ll_resolv_data.rpa_timer);
|
||||
}
|
||||
g_ble_ll_resolv_data.addr_res_enabled = enabled;
|
||||
}
|
||||
@@ -368,7 +368,7 @@ ble_ll_resolv_set_rpa_tmo(uint8_t *cmdbuf)
|
||||
return BLE_ERR_INV_HCI_CMD_PARMS;
|
||||
}
|
||||
|
||||
g_ble_ll_resolv_data.rpa_tmo = os_time_ms_to_ticks32(tmo_secs * 1000);
|
||||
g_ble_ll_resolv_data.rpa_tmo = ble_npl_time_ms_to_ticks32(tmo_secs * 1000);
|
||||
|
||||
/* If resolving is not enabled, we are done here. */
|
||||
if (!ble_ll_resolv_enabled()) {
|
||||
@@ -376,7 +376,7 @@ ble_ll_resolv_set_rpa_tmo(uint8_t *cmdbuf)
|
||||
}
|
||||
|
||||
/* Reset timeout if resolving is enabled */
|
||||
os_callout_reset(&g_ble_ll_resolv_data.rpa_timer,
|
||||
ble_npl_callout_reset(&g_ble_ll_resolv_data.rpa_timer,
|
||||
(int32_t)g_ble_ll_resolv_data.rpa_tmo);
|
||||
|
||||
return BLE_ERR_SUCCESS;
|
||||
@@ -579,7 +579,7 @@ void
|
||||
ble_ll_resolv_list_reset(void)
|
||||
{
|
||||
g_ble_ll_resolv_data.addr_res_enabled = 0;
|
||||
os_callout_stop(&g_ble_ll_resolv_data.rpa_timer);
|
||||
ble_npl_callout_stop(&g_ble_ll_resolv_data.rpa_timer);
|
||||
ble_ll_resolv_list_clr();
|
||||
ble_ll_resolv_init();
|
||||
}
|
||||
@@ -590,7 +590,7 @@ ble_ll_resolv_init(void)
|
||||
uint8_t hw_size;
|
||||
|
||||
/* Default is 15 minutes */
|
||||
g_ble_ll_resolv_data.rpa_tmo = os_time_ms_to_ticks32(15 * 60 * 1000);
|
||||
g_ble_ll_resolv_data.rpa_tmo = ble_npl_time_ms_to_ticks32(15 * 60 * 1000);
|
||||
|
||||
hw_size = ble_hw_resolv_list_size();
|
||||
if (hw_size > MYNEWT_VAL(BLE_LL_RESOLV_LIST_SIZE)) {
|
||||
@@ -598,10 +598,10 @@ ble_ll_resolv_init(void)
|
||||
}
|
||||
g_ble_ll_resolv_data.rl_size = hw_size;
|
||||
|
||||
os_callout_init(&g_ble_ll_resolv_data.rpa_timer,
|
||||
&g_ble_ll_data.ll_evq,
|
||||
ble_ll_resolv_rpa_timer_cb,
|
||||
NULL);
|
||||
ble_npl_callout_init(&g_ble_ll_resolv_data.rpa_timer,
|
||||
&g_ble_ll_data.ll_evq,
|
||||
ble_ll_resolv_rpa_timer_cb,
|
||||
NULL);
|
||||
}
|
||||
|
||||
#endif /* if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1 */
|
||||
|
||||
@@ -267,10 +267,10 @@ ble_ll_scan_req_backoff(struct ble_ll_scan_sm *scansm, int success)
|
||||
static void
|
||||
ble_ll_scan_refresh_nrpa(struct ble_ll_scan_sm *scansm)
|
||||
{
|
||||
uint32_t now;
|
||||
ble_npl_time_t now;
|
||||
|
||||
now = os_time_get();
|
||||
if ((int32_t)(now - scansm->scan_nrpa_timer) >= 0) {
|
||||
now = ble_npl_time_get();
|
||||
if ((ble_npl_stime_t)(now - scansm->scan_nrpa_timer) >= 0) {
|
||||
/* Generate new NRPA */
|
||||
ble_ll_rand_data_get(scansm->scan_nrpa, BLE_DEV_ADDR_LEN);
|
||||
scansm->scan_nrpa[5] &= ~0xc0;
|
||||
@@ -1308,7 +1308,7 @@ ble_ll_aux_scan_rsp_failed(void)
|
||||
* @param arg
|
||||
*/
|
||||
static void
|
||||
ble_ll_scan_event_proc(struct os_event *ev)
|
||||
ble_ll_scan_event_proc(struct ble_npl_event *ev)
|
||||
{
|
||||
os_sr_t sr;
|
||||
int inside_window;
|
||||
@@ -1330,7 +1330,7 @@ ble_ll_scan_event_proc(struct os_event *ev)
|
||||
* Get the scanning state machine. If not enabled (this is possible), just
|
||||
* leave and do nothing (just make sure timer is stopped).
|
||||
*/
|
||||
scansm = (struct ble_ll_scan_sm *)ev->ev_arg;
|
||||
scansm = (struct ble_ll_scan_sm *)ble_npl_event_get_arg(ev);
|
||||
scanphy = &scansm->phy_data[scansm->cur_phy];
|
||||
|
||||
OS_ENTER_CRITICAL(sr);
|
||||
@@ -3157,8 +3157,7 @@ ble_ll_scan_common_init(void)
|
||||
memset(g_ble_ll_scan_params, 0, sizeof(g_ble_ll_scan_params));
|
||||
|
||||
/* Initialize scanning window end event */
|
||||
scansm->scan_sched_ev.ev_cb = ble_ll_scan_event_proc;
|
||||
scansm->scan_sched_ev.ev_arg = scansm;
|
||||
ble_npl_event_init(&scansm->scan_sched_ev, ble_ll_scan_event_proc, scansm);
|
||||
|
||||
for (i = 0; i < BLE_LL_SCAN_PHY_NUMBER; i++) {
|
||||
/* Set all non-zero default parameters */
|
||||
@@ -3174,7 +3173,7 @@ ble_ll_scan_common_init(void)
|
||||
|
||||
#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
|
||||
/* Make sure we'll generate new NRPA if necessary */
|
||||
scansm->scan_nrpa_timer = os_time_get();
|
||||
scansm->scan_nrpa_timer = ble_npl_time_get();
|
||||
#endif
|
||||
|
||||
/* Initialize scanning timer */
|
||||
|
||||
@@ -27,7 +27,12 @@
|
||||
#include "nimble/nimble_opt.h"
|
||||
#include "nrfx.h"
|
||||
#include "controller/ble_hw.h"
|
||||
#if MYNEWT
|
||||
#include "mcu/cmsis_nvic.h"
|
||||
#else
|
||||
#include "core_cm4.h"
|
||||
#include <nimble/nimble_npl_os.h>
|
||||
#endif
|
||||
#include "os/os_trace_api.h"
|
||||
|
||||
/* Total number of resolving list elements */
|
||||
@@ -324,7 +329,11 @@ ble_hw_rng_init(ble_rng_isr_cb_t cb, int bias)
|
||||
/* If we were passed a function pointer we need to enable the interrupt */
|
||||
if (cb != NULL) {
|
||||
NVIC_SetPriority(RNG_IRQn, (1 << __NVIC_PRIO_BITS) - 1);
|
||||
#if MYNEWT
|
||||
NVIC_SetVector(RNG_IRQn, (uint32_t)ble_rng_isr);
|
||||
#else
|
||||
ble_npl_hw_set_isr(RNG_IRQn, (uint32_t)ble_rng_isr);
|
||||
#endif
|
||||
NVIC_EnableIRQ(RNG_IRQn);
|
||||
g_ble_rng_isr_cb = cb;
|
||||
}
|
||||
|
||||
@@ -23,13 +23,18 @@
|
||||
#include "syscfg/syscfg.h"
|
||||
#include "os/os.h"
|
||||
#include "ble/xcvr.h"
|
||||
#include "mcu/cmsis_nvic.h"
|
||||
#include "hal/hal_gpio.h"
|
||||
#include "nimble/ble.h"
|
||||
#include "nimble/nimble_opt.h"
|
||||
#include "nimble/nimble_npl.h"
|
||||
#include "controller/ble_phy.h"
|
||||
#include "controller/ble_ll.h"
|
||||
#include "nrf.h"
|
||||
#include "nrfx.h"
|
||||
#if MYNEWT
|
||||
#include "mcu/cmsis_nvic.h"
|
||||
#include "hal/hal_gpio.h"
|
||||
#else
|
||||
#include "core_cm4.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* NOTE: This code uses a couple of PPI channels so care should be taken when
|
||||
@@ -1401,7 +1406,11 @@ ble_phy_init(void)
|
||||
|
||||
/* Set isr in vector table and enable interrupt */
|
||||
NVIC_SetPriority(RADIO_IRQn, 0);
|
||||
#if MYNEWT
|
||||
NVIC_SetVector(RADIO_IRQn, (uint32_t)ble_phy_isr);
|
||||
#else
|
||||
ble_npl_hw_set_isr(RADIO_IRQn, (uint32_t)ble_phy_isr);
|
||||
#endif
|
||||
NVIC_EnableIRQ(RADIO_IRQn);
|
||||
|
||||
/* Register phy statistics */
|
||||
|
||||
@@ -37,13 +37,12 @@
|
||||
#include "host/ble_sm.h"
|
||||
#include "host/ble_store.h"
|
||||
#include "host/ble_uuid.h"
|
||||
#include "nimble/nimble_npl.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct os_eventq;
|
||||
struct os_event;
|
||||
|
||||
#define BLE_HS_FOREVER INT32_MAX
|
||||
|
||||
#define BLE_HS_CONN_HANDLE_NONE 0xffff
|
||||
@@ -174,7 +173,7 @@ extern struct ble_hs_cfg ble_hs_cfg;
|
||||
int ble_hs_synced(void);
|
||||
int ble_hs_start(void);
|
||||
void ble_hs_sched_reset(int reason);
|
||||
void ble_hs_evq_set(struct os_eventq *evq);
|
||||
void ble_hs_evq_set(struct ble_npl_eventq *evq);
|
||||
void ble_hs_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -22,10 +22,10 @@
|
||||
|
||||
#include <inttypes.h>
|
||||
#include "stats/stats.h"
|
||||
#include "os/os_time.h"
|
||||
#include "os/queue.h"
|
||||
#include "host/ble_att.h"
|
||||
#include "host/ble_uuid.h"
|
||||
#include "nimble/nimble_npl.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -122,7 +122,7 @@ SLIST_HEAD(ble_att_prep_entry_list, ble_att_prep_entry);
|
||||
struct ble_att_svr_conn {
|
||||
/** This list is sorted by attribute handle ID. */
|
||||
struct ble_att_prep_entry_list basc_prep_list;
|
||||
os_time_t basc_prep_timeout_at;
|
||||
ble_npl_time_t basc_prep_timeout_at;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -188,7 +188,7 @@ uint16_t ble_att_svr_prev_handle(void);
|
||||
int ble_att_svr_rx_mtu(uint16_t conn_handle, struct os_mbuf **rxom);
|
||||
struct ble_att_svr_entry *ble_att_svr_find_by_handle(uint16_t handle_id);
|
||||
int32_t ble_att_svr_ticks_until_tmo(const struct ble_att_svr_conn *svr,
|
||||
os_time_t now);
|
||||
ble_npl_time_t now);
|
||||
int ble_att_svr_rx_find_info(uint16_t conn_handle, struct os_mbuf **rxom);
|
||||
int ble_att_svr_rx_find_type_value(uint16_t conn_handle,
|
||||
struct os_mbuf **rxom);
|
||||
|
||||
@@ -333,7 +333,7 @@ ble_att_svr_check_perms(uint16_t conn_handle, int is_read,
|
||||
* write times out.
|
||||
*/
|
||||
int32_t
|
||||
ble_att_svr_ticks_until_tmo(const struct ble_att_svr_conn *svr, os_time_t now)
|
||||
ble_att_svr_ticks_until_tmo(const struct ble_att_svr_conn *svr, ble_npl_time_t now)
|
||||
{
|
||||
#if BLE_HS_ATT_SVR_QUEUED_WRITE_TMO == 0
|
||||
return BLE_HS_FOREVER;
|
||||
@@ -2358,7 +2358,7 @@ ble_att_svr_insert_prep_entry(uint16_t conn_handle,
|
||||
|
||||
#if BLE_HS_ATT_SVR_QUEUED_WRITE_TMO != 0
|
||||
conn->bhc_att_svr.basc_prep_timeout_at =
|
||||
os_time_get() + BLE_HS_ATT_SVR_QUEUED_WRITE_TMO;
|
||||
ble_npl_time_get() + BLE_HS_ATT_SVR_QUEUED_WRITE_TMO;
|
||||
|
||||
ble_hs_timer_resched();
|
||||
#endif
|
||||
|
||||
+22
-23
@@ -20,7 +20,6 @@
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include "os/os.h"
|
||||
#include "nimble/nimble_opt.h"
|
||||
#include "host/ble_hs_adv.h"
|
||||
#include "host/ble_hs_hci.h"
|
||||
@@ -109,7 +108,7 @@ struct ble_gap_master_state {
|
||||
uint8_t op;
|
||||
|
||||
uint8_t exp_set:1;
|
||||
os_time_t exp_os_ticks;
|
||||
ble_npl_time_t exp_os_ticks;
|
||||
|
||||
ble_gap_event_fn *cb;
|
||||
void *cb_arg;
|
||||
@@ -162,7 +161,7 @@ struct ble_gap_slave_state {
|
||||
/* timer is used only with legacy advertising */
|
||||
#if !MYNEWT_VAL(BLE_EXT_ADV)
|
||||
unsigned int exp_set:1;
|
||||
os_time_t exp_os_ticks;
|
||||
ble_npl_time_t exp_os_ticks;
|
||||
#endif
|
||||
|
||||
ble_gap_event_fn *cb;
|
||||
@@ -174,7 +173,7 @@ static bssnz_t struct ble_gap_slave_state ble_gap_slave[BLE_ADV_INSTANCES];
|
||||
struct ble_gap_update_entry {
|
||||
SLIST_ENTRY(ble_gap_update_entry) next;
|
||||
struct ble_gap_upd_params params;
|
||||
os_time_t exp_os_ticks;
|
||||
ble_npl_time_t exp_os_ticks;
|
||||
uint16_t conn_handle;
|
||||
};
|
||||
SLIST_HEAD(ble_gap_update_entry_list, ble_gap_update_entry);
|
||||
@@ -853,14 +852,14 @@ ble_gap_update_notify(uint16_t conn_handle, int status)
|
||||
static uint32_t
|
||||
ble_gap_master_ticks_until_exp(void)
|
||||
{
|
||||
int32_t ticks;
|
||||
ble_npl_stime_t ticks;
|
||||
|
||||
if (ble_gap_master.op == BLE_GAP_OP_NULL || !ble_gap_master.exp_set) {
|
||||
/* Timer not set; infinity ticks until next event. */
|
||||
return BLE_HS_FOREVER;
|
||||
}
|
||||
|
||||
ticks = ble_gap_master.exp_os_ticks - os_time_get();
|
||||
ticks = ble_gap_master.exp_os_ticks - ble_npl_time_get();
|
||||
if (ticks > 0) {
|
||||
/* Timer not expired yet. */
|
||||
return ticks;
|
||||
@@ -874,14 +873,14 @@ ble_gap_master_ticks_until_exp(void)
|
||||
static uint32_t
|
||||
ble_gap_slave_ticks_until_exp(void)
|
||||
{
|
||||
int32_t ticks;
|
||||
ble_npl_stime_t ticks;
|
||||
|
||||
if (ble_gap_slave[0].op == BLE_GAP_OP_NULL || !ble_gap_slave[0].exp_set) {
|
||||
/* Timer not set; infinity ticks until next event. */
|
||||
return BLE_HS_FOREVER;
|
||||
}
|
||||
|
||||
ticks = ble_gap_slave[0].exp_os_ticks - os_time_get();
|
||||
ticks = ble_gap_slave[0].exp_os_ticks - ble_npl_time_get();
|
||||
if (ticks > 0) {
|
||||
/* Timer not expired yet. */
|
||||
return ticks;
|
||||
@@ -907,7 +906,7 @@ static uint16_t
|
||||
ble_gap_update_next_exp(int32_t *out_ticks_from_now)
|
||||
{
|
||||
struct ble_gap_update_entry *entry;
|
||||
os_time_t now;
|
||||
ble_npl_time_t now;
|
||||
uint16_t conn_handle;
|
||||
int32_t best_ticks;
|
||||
int32_t ticks;
|
||||
@@ -916,7 +915,7 @@ ble_gap_update_next_exp(int32_t *out_ticks_from_now)
|
||||
|
||||
conn_handle = BLE_HS_CONN_HANDLE_NONE;
|
||||
best_ticks = BLE_HS_FOREVER;
|
||||
now = os_time_get();
|
||||
now = ble_npl_time_get();
|
||||
|
||||
SLIST_FOREACH(entry, &ble_gap_update_entries, next) {
|
||||
ticks = entry->exp_os_ticks - now;
|
||||
@@ -941,7 +940,7 @@ ble_gap_update_next_exp(int32_t *out_ticks_from_now)
|
||||
static void
|
||||
ble_gap_master_set_timer(uint32_t ticks_from_now)
|
||||
{
|
||||
ble_gap_master.exp_os_ticks = os_time_get() + ticks_from_now;
|
||||
ble_gap_master.exp_os_ticks = ble_npl_time_get() + ticks_from_now;
|
||||
ble_gap_master.exp_set = 1;
|
||||
|
||||
ble_hs_timer_resched();
|
||||
@@ -951,7 +950,7 @@ ble_gap_master_set_timer(uint32_t ticks_from_now)
|
||||
static void
|
||||
ble_gap_slave_set_timer(uint32_t ticks_from_now)
|
||||
{
|
||||
ble_gap_slave[0].exp_os_ticks = os_time_get() + ticks_from_now;
|
||||
ble_gap_slave[0].exp_os_ticks = ble_npl_time_get() + ticks_from_now;
|
||||
ble_gap_slave[0].exp_set = 1;
|
||||
|
||||
ble_hs_timer_resched();
|
||||
@@ -1530,7 +1529,7 @@ ble_gap_master_timer(void)
|
||||
rc = ble_gap_conn_cancel_tx();
|
||||
if (rc != 0) {
|
||||
/* Failed to stop connecting; try again in 100 ms. */
|
||||
return os_time_ms_to_ticks32(BLE_GAP_CANCEL_RETRY_TIMEOUT_MS);
|
||||
return ble_npl_time_ms_to_ticks32(BLE_GAP_CANCEL_RETRY_TIMEOUT_MS);
|
||||
} else {
|
||||
/* Stop the timer now that the cancel command has been acked. */
|
||||
ble_gap_master.exp_set = 0;
|
||||
@@ -1550,7 +1549,7 @@ ble_gap_master_timer(void)
|
||||
rc = ble_gap_disc_enable_tx(0, 0);
|
||||
if (rc != 0) {
|
||||
/* Failed to stop discovery; try again in 100 ms. */
|
||||
return os_time_ms_to_ticks32(BLE_GAP_CANCEL_RETRY_TIMEOUT_MS);
|
||||
return ble_npl_time_ms_to_ticks32(BLE_GAP_CANCEL_RETRY_TIMEOUT_MS);
|
||||
}
|
||||
|
||||
ble_gap_disc_complete();
|
||||
@@ -2132,7 +2131,7 @@ ble_gap_adv_start(uint8_t own_addr_type, const ble_addr_t *direct_addr,
|
||||
}
|
||||
|
||||
if (duration_ms != BLE_HS_FOREVER) {
|
||||
rc = os_time_ms_to_ticks(duration_ms, &duration_ticks);
|
||||
rc = ble_npl_time_ms_to_ticks(duration_ms, &duration_ticks);
|
||||
if (rc != 0) {
|
||||
/* Duration too great. */
|
||||
rc = BLE_HS_EINVAL;
|
||||
@@ -3426,7 +3425,7 @@ ble_gap_disc(uint8_t own_addr_type, int32_t duration_ms,
|
||||
}
|
||||
|
||||
if (duration_ms != BLE_HS_FOREVER) {
|
||||
rc = os_time_ms_to_ticks(duration_ms, &duration_ticks);
|
||||
rc = ble_npl_time_ms_to_ticks(duration_ms, &duration_ticks);
|
||||
if (rc != 0) {
|
||||
/* Duration too great. */
|
||||
rc = BLE_HS_EINVAL;
|
||||
@@ -3882,7 +3881,7 @@ ble_gap_connect(uint8_t own_addr_type, const ble_addr_t *peer_addr,
|
||||
}
|
||||
|
||||
if (duration_ms != BLE_HS_FOREVER) {
|
||||
rc = os_time_ms_to_ticks(duration_ms, &duration_ticks);
|
||||
rc = ble_npl_time_ms_to_ticks(duration_ms, &duration_ticks);
|
||||
if (rc != 0) {
|
||||
/* Duration too great. */
|
||||
rc = BLE_HS_EINVAL;
|
||||
@@ -4412,8 +4411,8 @@ ble_gap_update_params(uint16_t conn_handle,
|
||||
entry->conn_handle = conn_handle;
|
||||
entry->params = *params;
|
||||
|
||||
entry->exp_os_ticks = os_time_get() +
|
||||
os_time_ms_to_ticks32(BLE_GAP_UPDATE_TIMEOUT_MS);
|
||||
entry->exp_os_ticks = ble_npl_time_get() +
|
||||
ble_npl_time_ms_to_ticks32(BLE_GAP_UPDATE_TIMEOUT_MS);
|
||||
|
||||
BLE_HS_LOG(INFO, "GAP procedure initiated: ");
|
||||
ble_gap_log_update(conn_handle, params);
|
||||
@@ -4840,7 +4839,7 @@ ble_gap_preempt(void)
|
||||
* `ble_gap_preempt()`.
|
||||
*/
|
||||
|
||||
static struct os_mutex preempt_done_mutex;
|
||||
static struct ble_npl_mutex preempt_done_mutex;
|
||||
|
||||
void
|
||||
ble_gap_preempt_done(void)
|
||||
@@ -4858,7 +4857,7 @@ ble_gap_preempt_done(void)
|
||||
disc_preempted = 0;
|
||||
|
||||
/* protects slaves from accessing by multiple threads */
|
||||
os_mutex_pend(&preempt_done_mutex, 0xFFFFFFFF);
|
||||
ble_npl_mutex_pend(&preempt_done_mutex, 0xFFFFFFFF);
|
||||
memset(slaves, 0, sizeof(slaves));
|
||||
|
||||
ble_hs_lock();
|
||||
@@ -4892,7 +4891,7 @@ ble_gap_preempt_done(void)
|
||||
ble_gap_call_event_cb(&event, slaves[i].cb, slaves[i].arg);
|
||||
}
|
||||
}
|
||||
os_mutex_release(&preempt_done_mutex);
|
||||
ble_npl_mutex_release(&preempt_done_mutex);
|
||||
|
||||
if (disc_preempted) {
|
||||
event.type = BLE_GAP_EVENT_DISC_COMPLETE;
|
||||
@@ -4913,7 +4912,7 @@ ble_gap_init(void)
|
||||
memset(&ble_gap_master, 0, sizeof ble_gap_master);
|
||||
memset(ble_gap_slave, 0, sizeof ble_gap_slave);
|
||||
|
||||
os_mutex_init(&preempt_done_mutex);
|
||||
ble_npl_mutex_init(&preempt_done_mutex);
|
||||
|
||||
SLIST_INIT(&ble_gap_update_entries);
|
||||
|
||||
|
||||
@@ -418,7 +418,7 @@ static struct ble_gattc_proc_list ble_gattc_procs;
|
||||
/* The time when we should attempt to resume stalled procedures, in OS ticks.
|
||||
* A value of 0 indicates no stalled procedures.
|
||||
*/
|
||||
static os_time_t ble_gattc_resume_at;
|
||||
static ble_npl_time_t ble_gattc_resume_at;
|
||||
|
||||
/* Statistics. */
|
||||
STATS_SECT_DECL(ble_gattc_stats) ble_gattc_stats;
|
||||
@@ -731,8 +731,8 @@ ble_gattc_proc_insert(struct ble_gattc_proc *proc)
|
||||
static void
|
||||
ble_gattc_proc_set_exp_timer(struct ble_gattc_proc *proc)
|
||||
{
|
||||
proc->exp_os_ticks = os_time_get() +
|
||||
os_time_ms_to_ticks32(BLE_GATTC_UNRESPONSIVE_TIMEOUT_MS);
|
||||
proc->exp_os_ticks = ble_npl_time_get() +
|
||||
ble_npl_time_ms_to_ticks32(BLE_GATTC_UNRESPONSIVE_TIMEOUT_MS);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -744,8 +744,8 @@ ble_gattc_proc_set_resume_timer(struct ble_gattc_proc *proc)
|
||||
* instead.
|
||||
*/
|
||||
if (ble_gattc_resume_at == 0) {
|
||||
ble_gattc_resume_at = os_time_get() +
|
||||
os_time_ms_to_ticks32(MYNEWT_VAL(BLE_GATT_RESUME_RATE));
|
||||
ble_gattc_resume_at = ble_npl_time_get() +
|
||||
ble_npl_time_ms_to_ticks32(MYNEWT_VAL(BLE_GATT_RESUME_RATE));
|
||||
|
||||
/* A value of 0 indicates the timer is unset. Disambiguate this. */
|
||||
if (ble_gattc_resume_at == 0) {
|
||||
@@ -862,7 +862,7 @@ ble_gattc_proc_matches_conn_op(struct ble_gattc_proc *proc, void *arg)
|
||||
}
|
||||
|
||||
struct ble_gattc_criteria_exp {
|
||||
os_time_t now;
|
||||
ble_npl_time_t now;
|
||||
int32_t next_exp_in;
|
||||
};
|
||||
|
||||
@@ -1012,7 +1012,7 @@ ble_gattc_extract_expired(struct ble_gattc_proc_list *dst_list)
|
||||
{
|
||||
struct ble_gattc_criteria_exp criteria;
|
||||
|
||||
criteria.now = os_time_get();
|
||||
criteria.now = ble_npl_time_get();
|
||||
criteria.next_exp_in = BLE_HS_FOREVER;
|
||||
|
||||
STAILQ_INIT(dst_list);
|
||||
@@ -1116,7 +1116,7 @@ ble_gattc_resume_procs(void)
|
||||
static int32_t
|
||||
ble_gattc_ticks_until_resume(void)
|
||||
{
|
||||
os_time_t now;
|
||||
ble_npl_time_t now;
|
||||
int32_t diff;
|
||||
|
||||
/* Resume timer not set. */
|
||||
@@ -1124,7 +1124,7 @@ ble_gattc_ticks_until_resume(void)
|
||||
return BLE_HS_FOREVER;
|
||||
}
|
||||
|
||||
now = os_time_get();
|
||||
now = ble_npl_time_get();
|
||||
diff = ble_gattc_resume_at - now;
|
||||
if (diff <= 0) {
|
||||
/* Timer already expired; resume immediately. */
|
||||
|
||||
+50
-62
@@ -23,59 +23,53 @@
|
||||
#include "sysinit/sysinit.h"
|
||||
#include "syscfg/syscfg.h"
|
||||
#include "stats/stats.h"
|
||||
#include "os/os.h"
|
||||
#include "nimble/ble_hci_trans.h"
|
||||
#include "ble_hs_priv.h"
|
||||
#include "ble_monitor_priv.h"
|
||||
#include "nimble/nimble_npl.h"
|
||||
|
||||
#define BLE_HS_HCI_EVT_COUNT \
|
||||
(MYNEWT_VAL(BLE_HCI_EVT_HI_BUF_COUNT) + \
|
||||
MYNEWT_VAL(BLE_HCI_EVT_LO_BUF_COUNT))
|
||||
|
||||
static void ble_hs_event_rx_hci_ev(struct os_event *ev);
|
||||
static void ble_hs_event_tx_notify(struct os_event *ev);
|
||||
static void ble_hs_event_reset(struct os_event *ev);
|
||||
static void ble_hs_event_start(struct os_event *ev);
|
||||
static void ble_hs_event_rx_hci_ev(struct ble_npl_event *ev);
|
||||
static void ble_hs_event_tx_notify(struct ble_npl_event *ev);
|
||||
static void ble_hs_event_reset(struct ble_npl_event *ev);
|
||||
static void ble_hs_event_start(struct ble_npl_event *ev);
|
||||
static void ble_hs_timer_sched(int32_t ticks_from_now);
|
||||
|
||||
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))
|
||||
OS_MEMPOOL_SIZE(BLE_HS_HCI_EVT_COUNT, sizeof (struct ble_npl_event))
|
||||
];
|
||||
|
||||
/** OS event - triggers tx of pending notifications and indications. */
|
||||
static struct os_event ble_hs_ev_tx_notifications = {
|
||||
.ev_cb = ble_hs_event_tx_notify,
|
||||
};
|
||||
static struct ble_npl_event ble_hs_ev_tx_notifications;
|
||||
|
||||
/** OS event - triggers a full reset. */
|
||||
static struct os_event ble_hs_ev_reset = {
|
||||
.ev_cb = ble_hs_event_reset,
|
||||
};
|
||||
static struct ble_npl_event ble_hs_ev_reset;
|
||||
|
||||
static struct os_event ble_hs_ev_start = {
|
||||
.ev_cb = ble_hs_event_start,
|
||||
};
|
||||
static struct ble_npl_event ble_hs_ev_start;
|
||||
|
||||
uint8_t ble_hs_sync_state;
|
||||
static int ble_hs_reset_reason;
|
||||
|
||||
#define BLE_HS_SYNC_RETRY_TIMEOUT_MS 100 /* ms */
|
||||
|
||||
static struct os_task *ble_hs_parent_task;
|
||||
static void *ble_hs_parent_task;
|
||||
|
||||
/**
|
||||
* Handles unresponsive timeouts and periodic retries in case of resource
|
||||
* shortage.
|
||||
*/
|
||||
static struct os_callout ble_hs_timer_timer;
|
||||
static struct ble_npl_callout ble_hs_timer_timer;
|
||||
|
||||
/* Shared queue that the host uses for work items. */
|
||||
static struct os_eventq *ble_hs_evq;
|
||||
static struct ble_npl_eventq *ble_hs_evq;
|
||||
|
||||
static struct ble_mqueue ble_hs_rx_q;
|
||||
|
||||
static struct os_mutex ble_hs_mutex;
|
||||
static struct ble_npl_mutex ble_hs_mutex;
|
||||
|
||||
/** These values keep track of required ATT and GATT resources counts. They
|
||||
* increase as services are added, and are read when the ATT server and GATT
|
||||
@@ -104,7 +98,7 @@ STATS_NAME_START(ble_hs_stats)
|
||||
STATS_NAME(ble_hs_stats, pvcy_add_entry_fail)
|
||||
STATS_NAME_END(ble_hs_stats)
|
||||
|
||||
struct os_eventq *
|
||||
struct ble_npl_eventq *
|
||||
ble_hs_evq_get(void)
|
||||
{
|
||||
return ble_hs_evq;
|
||||
@@ -118,7 +112,7 @@ ble_hs_evq_get(void)
|
||||
* @param evq The event queue to use for host work.
|
||||
*/
|
||||
void
|
||||
ble_hs_evq_set(struct os_eventq *evq)
|
||||
ble_hs_evq_set(struct ble_npl_eventq *evq)
|
||||
{
|
||||
ble_hs_evq = evq;
|
||||
}
|
||||
@@ -144,8 +138,8 @@ ble_hs_locked_by_cur_task(void)
|
||||
int
|
||||
ble_hs_is_parent_task(void)
|
||||
{
|
||||
return !os_started() ||
|
||||
os_sched_get_current_task() == ble_hs_parent_task;
|
||||
return !ble_npl_os_started() ||
|
||||
ble_npl_get_current_task_id() == ble_hs_parent_task;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -163,7 +157,7 @@ ble_hs_lock_nested(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
rc = os_mutex_pend(&ble_hs_mutex, 0xffffffff);
|
||||
rc = ble_npl_mutex_pend(&ble_hs_mutex, 0xffffffff);
|
||||
BLE_HS_DBG_ASSERT_EVAL(rc == 0 || rc == OS_NOT_STARTED);
|
||||
}
|
||||
|
||||
@@ -182,7 +176,7 @@ ble_hs_unlock_nested(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
rc = os_mutex_release(&ble_hs_mutex);
|
||||
rc = ble_npl_mutex_release(&ble_hs_mutex);
|
||||
BLE_HS_DBG_ASSERT_EVAL(rc == 0 || rc == OS_NOT_STARTED);
|
||||
}
|
||||
|
||||
@@ -326,7 +320,7 @@ ble_hs_synced(void)
|
||||
static int
|
||||
ble_hs_sync(void)
|
||||
{
|
||||
uint32_t retry_tmo_ticks;
|
||||
ble_npl_time_t retry_tmo_ticks;
|
||||
int rc;
|
||||
|
||||
/* Set the sync state to "bringup." This allows the parent task to send
|
||||
@@ -342,7 +336,7 @@ ble_hs_sync(void)
|
||||
ble_hs_sync_state = BLE_HS_SYNC_STATE_BAD;
|
||||
}
|
||||
|
||||
retry_tmo_ticks = os_time_ms_to_ticks32(BLE_HS_SYNC_RETRY_TIMEOUT_MS);
|
||||
retry_tmo_ticks = ble_npl_time_ms_to_ticks32(BLE_HS_SYNC_RETRY_TIMEOUT_MS);
|
||||
ble_hs_timer_sched(retry_tmo_ticks);
|
||||
|
||||
if (rc == 0) {
|
||||
@@ -403,7 +397,7 @@ ble_hs_reset(void)
|
||||
* periodic retries in case of resource shortage.
|
||||
*/
|
||||
static void
|
||||
ble_hs_timer_exp(struct os_event *ev)
|
||||
ble_hs_timer_exp(struct ble_npl_event *ev)
|
||||
{
|
||||
int32_t ticks_until_next;
|
||||
|
||||
@@ -433,14 +427,14 @@ ble_hs_timer_reset(uint32_t ticks)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = os_callout_reset(&ble_hs_timer_timer, ticks);
|
||||
rc = ble_npl_callout_reset(&ble_hs_timer_timer, ticks);
|
||||
BLE_HS_DBG_ASSERT_EVAL(rc == 0);
|
||||
}
|
||||
|
||||
static void
|
||||
ble_hs_timer_sched(int32_t ticks_from_now)
|
||||
{
|
||||
os_time_t abs_time;
|
||||
ble_npl_time_t abs_time;
|
||||
|
||||
if (ticks_from_now == BLE_HS_FOREVER) {
|
||||
return;
|
||||
@@ -449,10 +443,10 @@ ble_hs_timer_sched(int32_t ticks_from_now)
|
||||
/* Reset timer if it is not currently scheduled or if the specified time is
|
||||
* sooner than the previous expiration time.
|
||||
*/
|
||||
abs_time = os_time_get() + ticks_from_now;
|
||||
if (!os_callout_queued(&ble_hs_timer_timer) ||
|
||||
OS_TIME_TICK_LT(abs_time, ble_hs_timer_timer.c_ticks)) {
|
||||
|
||||
abs_time = ble_npl_time_get() + ticks_from_now;
|
||||
if (!ble_npl_callout_queued(&ble_hs_timer_timer) ||
|
||||
((ble_npl_stime_t)(abs_time -
|
||||
ble_npl_callout_get_ticks(&ble_hs_timer_timer))) < 0) {
|
||||
ble_hs_timer_reset(ticks_from_now);
|
||||
}
|
||||
}
|
||||
@@ -467,12 +461,13 @@ ble_hs_timer_resched(void)
|
||||
}
|
||||
|
||||
static void
|
||||
ble_hs_event_rx_hci_ev(struct os_event *ev)
|
||||
ble_hs_event_rx_hci_ev(struct ble_npl_event *ev)
|
||||
{
|
||||
uint8_t *hci_evt;
|
||||
int rc;
|
||||
|
||||
hci_evt = ev->ev_arg;
|
||||
hci_evt = ble_npl_event_get_arg(ev);
|
||||
|
||||
rc = os_memblock_put(&ble_hs_hci_ev_pool, ev);
|
||||
BLE_HS_DBG_ASSERT_EVAL(rc == 0);
|
||||
|
||||
@@ -485,25 +480,25 @@ ble_hs_event_rx_hci_ev(struct os_event *ev)
|
||||
}
|
||||
|
||||
static void
|
||||
ble_hs_event_tx_notify(struct os_event *ev)
|
||||
ble_hs_event_tx_notify(struct ble_npl_event *ev)
|
||||
{
|
||||
ble_gatts_tx_notifications();
|
||||
}
|
||||
|
||||
static void
|
||||
ble_hs_event_rx_data(struct os_event *ev)
|
||||
ble_hs_event_rx_data(struct ble_npl_event *ev)
|
||||
{
|
||||
ble_hs_process_rx_data_queue();
|
||||
}
|
||||
|
||||
static void
|
||||
ble_hs_event_reset(struct os_event *ev)
|
||||
ble_hs_event_reset(struct ble_npl_event *ev)
|
||||
{
|
||||
ble_hs_reset();
|
||||
}
|
||||
|
||||
static void
|
||||
ble_hs_event_start(struct os_event *ev)
|
||||
ble_hs_event_start(struct ble_npl_event *ev)
|
||||
{
|
||||
int rc;
|
||||
|
||||
@@ -514,16 +509,14 @@ ble_hs_event_start(struct os_event *ev)
|
||||
void
|
||||
ble_hs_enqueue_hci_event(uint8_t *hci_evt)
|
||||
{
|
||||
struct os_event *ev;
|
||||
struct ble_npl_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;
|
||||
ev->ev_cb = ble_hs_event_rx_hci_ev;
|
||||
ev->ev_arg = hci_evt;
|
||||
os_eventq_put(ble_hs_evq, ev);
|
||||
ble_npl_event_init(ev, ble_hs_event_rx_hci_ev, hci_evt);
|
||||
ble_npl_eventq_put(ble_hs_evq, ev);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -541,7 +534,7 @@ ble_hs_notifications_sched(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
os_eventq_put(ble_hs_evq, &ble_hs_ev_tx_notifications);
|
||||
ble_npl_eventq_put(ble_hs_evq, &ble_hs_ev_tx_notifications);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -557,7 +550,7 @@ ble_hs_sched_reset(int reason)
|
||||
BLE_HS_DBG_ASSERT(ble_hs_reset_reason == 0);
|
||||
|
||||
ble_hs_reset_reason = reason;
|
||||
os_eventq_put(ble_hs_evq, &ble_hs_ev_reset);
|
||||
ble_npl_eventq_put(ble_hs_evq, &ble_hs_ev_reset);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -584,9 +577,9 @@ ble_hs_start(void)
|
||||
{
|
||||
int rc;
|
||||
|
||||
ble_hs_parent_task = os_sched_get_current_task();
|
||||
ble_hs_parent_task = ble_npl_get_current_task_id();
|
||||
|
||||
os_callout_init(&ble_hs_timer_timer, ble_hs_evq,
|
||||
ble_npl_callout_init(&ble_hs_timer_timer, ble_hs_evq,
|
||||
ble_hs_timer_exp, NULL);
|
||||
|
||||
rc = ble_gatts_start();
|
||||
@@ -664,7 +657,7 @@ ble_hs_init(void)
|
||||
|
||||
/* Create memory pool of OS events */
|
||||
rc = os_mempool_init(&ble_hs_hci_ev_pool, BLE_HS_HCI_EVT_COUNT,
|
||||
sizeof (struct os_event), ble_hs_hci_os_event_buf,
|
||||
sizeof (struct ble_npl_event), ble_hs_hci_os_event_buf,
|
||||
"ble_hs_hci_ev_pool");
|
||||
SYSINIT_PANIC_ASSERT(rc == 0);
|
||||
|
||||
@@ -672,15 +665,10 @@ ble_hs_init(void)
|
||||
* bss.
|
||||
*/
|
||||
ble_hs_reset_reason = 0;
|
||||
ble_hs_ev_tx_notifications = (struct os_event) {
|
||||
.ev_cb = ble_hs_event_tx_notify,
|
||||
};
|
||||
ble_hs_ev_reset = (struct os_event) {
|
||||
.ev_cb = ble_hs_event_reset,
|
||||
};
|
||||
ble_hs_ev_start = (struct os_event) {
|
||||
.ev_cb = ble_hs_event_start,
|
||||
};
|
||||
|
||||
ble_npl_event_init(&ble_hs_ev_tx_notifications, ble_hs_event_tx_notify, NULL);
|
||||
ble_npl_event_init(&ble_hs_ev_reset, ble_hs_event_reset, NULL);
|
||||
ble_npl_event_init(&ble_hs_ev_start, ble_hs_event_start, NULL);
|
||||
|
||||
#if BLE_MONITOR
|
||||
rc = ble_monitor_init();
|
||||
@@ -717,7 +705,7 @@ ble_hs_init(void)
|
||||
STATS_SIZE_32), STATS_NAME_INIT_PARMS(ble_hs_stats), "ble_hs");
|
||||
SYSINIT_PANIC_ASSERT(rc == 0);
|
||||
|
||||
rc = os_mutex_init(&ble_hs_mutex);
|
||||
rc = ble_npl_mutex_init(&ble_hs_mutex);
|
||||
SYSINIT_PANIC_ASSERT(rc == 0);
|
||||
|
||||
#if MYNEWT_VAL(BLE_HS_DEBUG)
|
||||
@@ -727,13 +715,13 @@ 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);
|
||||
|
||||
ble_hs_evq_set(os_eventq_dflt_get());
|
||||
ble_hs_evq_set(ble_npl_eventq_dflt_get());
|
||||
|
||||
/* Enqueue the start event to the default event queue. Using the default
|
||||
* queue ensures the event won't run until the end of main(). This allows
|
||||
* the application to configure this package in the meantime.
|
||||
*/
|
||||
os_eventq_put(os_eventq_dflt_get(), &ble_hs_ev_start);
|
||||
ble_npl_eventq_put(ble_npl_eventq_dflt_get(), &ble_hs_ev_start);
|
||||
|
||||
#if BLE_MONITOR
|
||||
ble_monitor_new_index(0, (uint8_t[6]){ }, "nimble0");
|
||||
|
||||
@@ -411,14 +411,14 @@ ble_hs_conn_timer(void)
|
||||
#endif
|
||||
|
||||
struct ble_hs_conn *conn;
|
||||
os_time_t now;
|
||||
ble_npl_time_t now;
|
||||
int32_t next_exp_in;
|
||||
int32_t time_diff;
|
||||
uint16_t conn_handle;
|
||||
|
||||
conn_handle = BLE_HS_CONN_HANDLE_NONE;
|
||||
next_exp_in = BLE_HS_FOREVER;
|
||||
now = os_time_get();
|
||||
now = ble_npl_time_get();
|
||||
|
||||
ble_hs_lock();
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ struct ble_hs_conn {
|
||||
|
||||
struct ble_l2cap_chan_list bhc_channels;
|
||||
struct ble_l2cap_chan *bhc_rx_chan; /* Channel rxing current packet. */
|
||||
uint32_t bhc_rx_timeout;
|
||||
ble_npl_time_t bhc_rx_timeout;
|
||||
|
||||
/**
|
||||
* Count of packets sent over this connection that the controller has not
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
|
||||
#define BLE_HCI_CMD_TIMEOUT_MS 2000
|
||||
|
||||
static struct os_mutex ble_hs_hci_mutex;
|
||||
static struct os_sem ble_hs_hci_sem;
|
||||
static struct ble_npl_mutex ble_hs_hci_mutex;
|
||||
static struct ble_npl_sem ble_hs_hci_sem;
|
||||
|
||||
static uint8_t *ble_hs_hci_ack;
|
||||
static uint16_t ble_hs_hci_buf_sz;
|
||||
@@ -62,7 +62,7 @@ ble_hs_hci_lock(void)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = os_mutex_pend(&ble_hs_hci_mutex, 0xffffffff);
|
||||
rc = ble_npl_mutex_pend(&ble_hs_hci_mutex, BLE_NPL_TIME_FOREVER);
|
||||
BLE_HS_DBG_ASSERT_EVAL(rc == 0 || rc == OS_NOT_STARTED);
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ ble_hs_hci_unlock(void)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = os_mutex_release(&ble_hs_hci_mutex);
|
||||
rc = ble_npl_mutex_release(&ble_hs_hci_mutex);
|
||||
BLE_HS_DBG_ASSERT_EVAL(rc == 0 || rc == OS_NOT_STARTED);
|
||||
}
|
||||
|
||||
@@ -255,8 +255,8 @@ ble_hs_hci_wait_for_ack(void)
|
||||
rc = ble_hs_hci_phony_ack_cb(ble_hs_hci_ack, 260);
|
||||
}
|
||||
#else
|
||||
rc = os_sem_pend(&ble_hs_hci_sem,
|
||||
os_time_ms_to_ticks32(BLE_HCI_CMD_TIMEOUT_MS));
|
||||
rc = ble_npl_sem_pend(&ble_hs_hci_sem,
|
||||
ble_npl_time_ms_to_ticks32(BLE_HCI_CMD_TIMEOUT_MS));
|
||||
switch (rc) {
|
||||
case 0:
|
||||
BLE_HS_DBG_ASSERT(ble_hs_hci_ack != NULL);
|
||||
@@ -340,7 +340,7 @@ ble_hs_hci_cmd_tx_empty_ack(uint16_t opcode, void *cmd, uint8_t cmd_len)
|
||||
void
|
||||
ble_hs_hci_rx_ack(uint8_t *ack_ev)
|
||||
{
|
||||
if (os_sem_get_count(&ble_hs_hci_sem) > 0) {
|
||||
if (ble_npl_sem_get_count(&ble_hs_hci_sem) > 0) {
|
||||
/* This ack is unexpected; ignore it. */
|
||||
ble_hci_trans_buf_free(ack_ev);
|
||||
return;
|
||||
@@ -351,7 +351,7 @@ ble_hs_hci_rx_ack(uint8_t *ack_ev)
|
||||
* with the acknowledgement.
|
||||
*/
|
||||
ble_hs_hci_ack = ack_ev;
|
||||
os_sem_release(&ble_hs_hci_sem);
|
||||
ble_npl_sem_release(&ble_hs_hci_sem);
|
||||
}
|
||||
|
||||
int
|
||||
@@ -565,9 +565,9 @@ ble_hs_hci_init(void)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = os_sem_init(&ble_hs_hci_sem, 0);
|
||||
rc = ble_npl_sem_init(&ble_hs_hci_sem, 0);
|
||||
BLE_HS_DBG_ASSERT_EVAL(rc == 0);
|
||||
|
||||
rc = os_mutex_init(&ble_hs_hci_mutex);
|
||||
rc = ble_npl_mutex_init(&ble_hs_hci_mutex);
|
||||
BLE_HS_DBG_ASSERT_EVAL(rc == 0);
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ void ble_hs_unlock(void);
|
||||
void ble_hs_hw_error(uint8_t hw_code);
|
||||
void ble_hs_timer_resched(void);
|
||||
void ble_hs_notifications_sched(void);
|
||||
struct os_eventq *ble_hs_evq_get(void);
|
||||
struct ble_npl_eventq *ble_hs_evq_get(void);
|
||||
|
||||
struct ble_mqueue {
|
||||
STAILQ_HEAD(, os_mbuf_pkthdr) head;
|
||||
|
||||
@@ -237,7 +237,7 @@ ble_l2cap_rx_payload(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
|
||||
/* More fragments remain. */
|
||||
#if MYNEWT_VAL(BLE_L2CAP_RX_FRAG_TIMEOUT) != 0
|
||||
conn->bhc_rx_timeout =
|
||||
os_time_get() + MYNEWT_VAL(BLE_L2CAP_RX_FRAG_TIMEOUT);
|
||||
ble_npl_time_get() + MYNEWT_VAL(BLE_L2CAP_RX_FRAG_TIMEOUT);
|
||||
|
||||
ble_hs_timer_resched();
|
||||
#endif
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
struct ble_l2cap_sig_proc {
|
||||
STAILQ_ENTRY(ble_l2cap_sig_proc) next;
|
||||
|
||||
uint32_t exp_os_ticks;
|
||||
ble_npl_time_t exp_os_ticks;
|
||||
uint16_t conn_handle;
|
||||
uint8_t op;
|
||||
uint8_t id;
|
||||
@@ -304,7 +304,8 @@ ble_l2cap_sig_rx_noop(uint16_t conn_handle,
|
||||
static void
|
||||
ble_l2cap_sig_proc_set_timer(struct ble_l2cap_sig_proc *proc)
|
||||
{
|
||||
proc->exp_os_ticks = os_time_get() + BLE_L2CAP_SIG_UNRESPONSIVE_TIMEOUT;
|
||||
proc->exp_os_ticks = ble_npl_time_get() +
|
||||
ble_npl_time_ms_to_ticks32(BLE_L2CAP_SIG_UNRESPONSIVE_TIMEOUT);
|
||||
ble_hs_timer_resched();
|
||||
}
|
||||
|
||||
@@ -1176,11 +1177,11 @@ ble_l2cap_sig_extract_expired(struct ble_l2cap_sig_proc_list *dst_list)
|
||||
struct ble_l2cap_sig_proc *proc;
|
||||
struct ble_l2cap_sig_proc *prev;
|
||||
struct ble_l2cap_sig_proc *next;
|
||||
uint32_t now;
|
||||
int32_t next_exp_in;
|
||||
int32_t time_diff;
|
||||
ble_npl_time_t now;
|
||||
ble_npl_stime_t next_exp_in;
|
||||
ble_npl_stime_t time_diff;
|
||||
|
||||
now = os_time_get();
|
||||
now = ble_npl_time_get();
|
||||
STAILQ_INIT(dst_list);
|
||||
|
||||
/* Assume each event is either expired or has infinite duration. */
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#include "ble_hs_priv.h"
|
||||
#include "ble_monitor_priv.h"
|
||||
|
||||
struct os_mutex lock;
|
||||
struct ble_npl_mutex lock;
|
||||
|
||||
#if MYNEWT_VAL(BLE_MONITOR_UART)
|
||||
struct uart_dev *uart;
|
||||
@@ -57,7 +57,7 @@ static uint8_t rtt_pktbuf[MYNEWT_VAL(BLE_MONITOR_RTT_BUFFER_SIZE)];
|
||||
static size_t rtt_pktbuf_pos;
|
||||
static struct {
|
||||
bool dropped;
|
||||
struct os_callout tmo;
|
||||
struct ble_npl_callout tmo;
|
||||
struct ble_monitor_drops_hdr drops_hdr;
|
||||
} rtt_drops;
|
||||
|
||||
@@ -154,7 +154,7 @@ update_drop_counters(struct ble_monitor_hdr *failed_hdr)
|
||||
|
||||
if (*cnt < UINT8_MAX) {
|
||||
(*cnt)++;
|
||||
os_callout_reset(&rtt_drops.tmo, OS_TICKS_PER_SEC);
|
||||
ble_npl_callout_reset(&rtt_drops.tmo, OS_TICKS_PER_SEC);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ reset_drop_counters(void)
|
||||
rtt_drops.drops_hdr.acl_rx = 0;
|
||||
rtt_drops.drops_hdr.other = 0;
|
||||
|
||||
os_callout_stop(&rtt_drops.tmo);
|
||||
ble_npl_callout_stop(&rtt_drops.tmo);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -268,9 +268,9 @@ static FILE *btmon = (FILE *) &(struct File) {
|
||||
|
||||
#if MYNEWT_VAL(BLE_MONITOR_RTT) && MYNEWT_VAL(BLE_MONITOR_RTT_BUFFERED)
|
||||
static void
|
||||
drops_tmp_cb(struct os_event *ev)
|
||||
drops_tmp_cb(struct ble_npl_event *ev)
|
||||
{
|
||||
os_mutex_pend(&lock, OS_TIMEOUT_NEVER);
|
||||
ble_npl_mutex_pend(&lock, OS_TIMEOUT_NEVER);
|
||||
|
||||
/*
|
||||
* There's no "nop" in btsnoop protocol so we just send empty system note
|
||||
@@ -280,7 +280,7 @@ drops_tmp_cb(struct os_event *ev)
|
||||
monitor_write_header(BLE_MONITOR_OPCODE_SYSTEM_NOTE, 1);
|
||||
monitor_write("", 1);
|
||||
|
||||
os_mutex_release(&lock);
|
||||
ble_npl_mutex_release(&lock);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -308,7 +308,7 @@ ble_monitor_init(void)
|
||||
|
||||
#if MYNEWT_VAL(BLE_MONITOR_RTT)
|
||||
#if MYNEWT_VAL(BLE_MONITOR_RTT_BUFFERED)
|
||||
os_callout_init(&rtt_drops.tmo, ble_hs_evq_get(), drops_tmp_cb, NULL);
|
||||
ble_npl_callout_init(&rtt_drops.tmo, ble_hs_evq_get(), drops_tmp_cb, NULL);
|
||||
|
||||
/* Initialize types in header (we won't touch them later) */
|
||||
rtt_drops.drops_hdr.type_cmd = BLE_MONITOR_EXTHDR_COMMAND_DROPS;
|
||||
@@ -331,7 +331,7 @@ ble_monitor_init(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
os_mutex_init(&lock);
|
||||
ble_npl_mutex_init(&lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -339,12 +339,12 @@ ble_monitor_init(void)
|
||||
int
|
||||
ble_monitor_send(uint16_t opcode, const void *data, size_t len)
|
||||
{
|
||||
os_mutex_pend(&lock, OS_TIMEOUT_NEVER);
|
||||
ble_npl_mutex_pend(&lock, OS_TIMEOUT_NEVER);
|
||||
|
||||
monitor_write_header(opcode, len);
|
||||
monitor_write(data, len);
|
||||
|
||||
os_mutex_release(&lock);
|
||||
ble_npl_mutex_release(&lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -361,7 +361,7 @@ ble_monitor_send_om(uint16_t opcode, const struct os_mbuf *om)
|
||||
om_tmp = SLIST_NEXT(om_tmp, om_next);
|
||||
}
|
||||
|
||||
os_mutex_pend(&lock, OS_TIMEOUT_NEVER);
|
||||
ble_npl_mutex_pend(&lock, OS_TIMEOUT_NEVER);
|
||||
|
||||
monitor_write_header(opcode, length);
|
||||
|
||||
@@ -370,7 +370,7 @@ ble_monitor_send_om(uint16_t opcode, const struct os_mbuf *om)
|
||||
om = SLIST_NEXT(om, om_next);
|
||||
}
|
||||
|
||||
os_mutex_release(&lock);
|
||||
ble_npl_mutex_release(&lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -423,7 +423,7 @@ ble_monitor_log(int level, const char *fmt, ...)
|
||||
|
||||
ulog.ident_len = sizeof(id);
|
||||
|
||||
os_mutex_pend(&lock, OS_TIMEOUT_NEVER);
|
||||
ble_npl_mutex_pend(&lock, OS_TIMEOUT_NEVER);
|
||||
|
||||
monitor_write_header(BLE_MONITOR_OPCODE_USER_LOGGING,
|
||||
sizeof(ulog) + sizeof(id) + len + 1);
|
||||
@@ -437,7 +437,7 @@ ble_monitor_log(int level, const char *fmt, ...)
|
||||
/* null-terminate string */
|
||||
monitor_write("", 1);
|
||||
|
||||
os_mutex_release(&lock);
|
||||
ble_npl_mutex_release(&lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -352,8 +352,8 @@ ble_sm_gen_csrk(struct ble_sm_proc *proc, uint8_t *csrk)
|
||||
static void
|
||||
ble_sm_proc_set_timer(struct ble_sm_proc *proc)
|
||||
{
|
||||
proc->exp_os_ticks = os_time_get() +
|
||||
os_time_ms_to_ticks32(BLE_SM_TIMEOUT_MS);
|
||||
proc->exp_os_ticks = ble_npl_time_get() +
|
||||
ble_npl_time_ms_to_ticks32(BLE_SM_TIMEOUT_MS);
|
||||
ble_hs_timer_resched();
|
||||
}
|
||||
|
||||
@@ -652,11 +652,11 @@ ble_sm_extract_expired(struct ble_sm_proc_list *dst_list)
|
||||
struct ble_sm_proc *proc;
|
||||
struct ble_sm_proc *prev;
|
||||
struct ble_sm_proc *next;
|
||||
uint32_t now;
|
||||
int32_t next_exp_in;
|
||||
int32_t time_diff;
|
||||
ble_npl_time_t now;
|
||||
ble_npl_stime_t next_exp_in;
|
||||
ble_npl_stime_t time_diff;
|
||||
|
||||
now = os_time_get();
|
||||
now = ble_npl_time_get();
|
||||
STAILQ_INIT(dst_list);
|
||||
|
||||
/* Assume each event is either expired or has infinite duration. */
|
||||
|
||||
@@ -244,7 +244,7 @@ struct ble_sm_keys {
|
||||
struct ble_sm_proc {
|
||||
STAILQ_ENTRY(ble_sm_proc) next;
|
||||
|
||||
uint32_t exp_os_ticks;
|
||||
ble_npl_time_t exp_os_ticks;
|
||||
ble_sm_proc_flags flags;
|
||||
uint16_t conn_handle;
|
||||
uint8_t pair_alg;
|
||||
|
||||
@@ -22,15 +22,13 @@
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <string.h>
|
||||
#include "syscfg/syscfg.h"
|
||||
#include "os/os.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* XXX: some or all of these should not be here */
|
||||
#include "os/os.h"
|
||||
#include "syscfg/syscfg.h"
|
||||
|
||||
/* The number of advertising instances */
|
||||
#define BLE_ADV_INSTANCES (MYNEWT_VAL(BLE_MULTI_ADV_INSTANCES) + 1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user