mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-08-25 11:19:57 +00:00
nimble/transport: Move BLE_MONITOR to transport
This allows to use monitor feature without host present.
This commit is contained in:
@@ -1968,13 +1968,13 @@ ble_ll_init(void)
|
||||
/* Transport APIs for LL side */
|
||||
|
||||
int
|
||||
ble_transport_to_ll_cmd(void *buf)
|
||||
ble_transport_to_ll_cmd_impl(void *buf)
|
||||
{
|
||||
return ble_ll_hci_cmd_rx(buf, NULL);
|
||||
}
|
||||
|
||||
int
|
||||
ble_transport_to_ll_acl(struct os_mbuf *om)
|
||||
ble_transport_to_ll_acl_impl(struct os_mbuf *om)
|
||||
{
|
||||
return ble_ll_hci_acl_rx(om, NULL);
|
||||
}
|
||||
|
||||
@@ -38,9 +38,6 @@ pkg.deps.BLE_SM_LEGACY:
|
||||
pkg.deps.BLE_SM_SC:
|
||||
- "@apache-mynewt-core/crypto/tinycrypt"
|
||||
|
||||
pkg.deps.BLE_MONITOR_RTT:
|
||||
- "@apache-mynewt-core/hw/drivers/rtt"
|
||||
|
||||
pkg.deps.BLE_MESH:
|
||||
- nimble/host/mesh
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include "stats/stats.h"
|
||||
#include "host/ble_hs.h"
|
||||
#include "ble_hs_priv.h"
|
||||
#include "ble_monitor_priv.h"
|
||||
#include "nimble/nimble_npl.h"
|
||||
#ifndef MYNEWT
|
||||
#include "nimble/nimble_port.h"
|
||||
@@ -220,10 +219,6 @@ ble_hs_process_rx_data_queue(void)
|
||||
struct os_mbuf *om;
|
||||
|
||||
while ((om = ble_mqueue_get(&ble_hs_rx_q)) != NULL) {
|
||||
#if BLE_MONITOR
|
||||
ble_monitor_send_om(BLE_MONITOR_OPCODE_ACL_RX_PKT, om);
|
||||
#endif
|
||||
|
||||
ble_hs_hci_evt_acl_process(om);
|
||||
}
|
||||
}
|
||||
@@ -498,11 +493,6 @@ ble_hs_event_rx_hci_ev(struct ble_npl_event *ev)
|
||||
rc = os_memblock_put(&ble_hs_hci_ev_pool, ev);
|
||||
BLE_HS_DBG_ASSERT_EVAL(rc == 0);
|
||||
|
||||
#if BLE_MONITOR
|
||||
ble_monitor_send(BLE_MONITOR_OPCODE_EVENT_PKT, hci_ev,
|
||||
hci_ev->length + sizeof(*hci_ev));
|
||||
#endif
|
||||
|
||||
ble_hs_hci_evt_process(hci_ev);
|
||||
}
|
||||
|
||||
@@ -696,10 +686,6 @@ ble_hs_rx_data(struct os_mbuf *om, void *arg)
|
||||
int
|
||||
ble_hs_tx_data(struct os_mbuf *om)
|
||||
{
|
||||
#if BLE_MONITOR
|
||||
ble_monitor_send_om(BLE_MONITOR_OPCODE_ACL_TX_PKT, om);
|
||||
#endif
|
||||
|
||||
return ble_transport_to_ll_acl(om);
|
||||
}
|
||||
|
||||
@@ -784,11 +770,6 @@ ble_hs_init(void)
|
||||
ble_hs_evq_set(nimble_port_get_dflt_eventq());
|
||||
#endif
|
||||
|
||||
#if BLE_MONITOR
|
||||
rc = ble_monitor_init();
|
||||
SYSINIT_PANIC_ASSERT(rc == 0);
|
||||
#endif
|
||||
|
||||
/* 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.
|
||||
@@ -801,22 +782,18 @@ ble_hs_init(void)
|
||||
ble_npl_eventq_put(nimble_port_get_dflt_eventq(), &ble_hs_ev_start_stage1);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if BLE_MONITOR
|
||||
ble_monitor_new_index(0, (uint8_t[6]){ }, "nimble0");
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Transport APIs for HS side */
|
||||
|
||||
int
|
||||
ble_transport_to_hs_evt(void *buf)
|
||||
ble_transport_to_hs_evt_impl(void *buf)
|
||||
{
|
||||
return ble_hs_hci_rx_evt(buf, NULL);
|
||||
}
|
||||
|
||||
int
|
||||
ble_transport_to_hs_acl(struct os_mbuf *om)
|
||||
ble_transport_to_hs_acl_impl(struct os_mbuf *om)
|
||||
{
|
||||
return ble_hs_rx_data(om, NULL);
|
||||
}
|
||||
|
||||
@@ -22,9 +22,7 @@
|
||||
#include <stdio.h>
|
||||
#include "os/os.h"
|
||||
#include "mem/mem.h"
|
||||
#include "host/ble_monitor.h"
|
||||
#include "ble_hs_priv.h"
|
||||
#include "ble_monitor_priv.h"
|
||||
|
||||
#define BLE_HCI_CMD_TIMEOUT_MS 2000
|
||||
|
||||
@@ -278,12 +276,6 @@ ble_hs_hci_wait_for_ack(void)
|
||||
switch (rc) {
|
||||
case 0:
|
||||
BLE_HS_DBG_ASSERT(ble_hs_hci_ack != NULL);
|
||||
|
||||
#if BLE_MONITOR
|
||||
ble_monitor_send(BLE_MONITOR_OPCODE_EVENT_PKT, (void *) ble_hs_hci_ack,
|
||||
sizeof(*ble_hs_hci_ack) + ble_hs_hci_ack->length);
|
||||
#endif
|
||||
|
||||
break;
|
||||
case OS_TIMEOUT:
|
||||
rc = BLE_HS_ETIMEOUT_HCI;
|
||||
|
||||
@@ -23,20 +23,13 @@
|
||||
#include <stdio.h>
|
||||
#include "os/os.h"
|
||||
#include "nimble/hci_common.h"
|
||||
#include "host/ble_monitor.h"
|
||||
#include "ble_hs_priv.h"
|
||||
#include "ble_monitor_priv.h"
|
||||
|
||||
static int
|
||||
ble_hs_hci_cmd_transport(struct ble_hci_cmd *cmd)
|
||||
{
|
||||
int rc;
|
||||
|
||||
#if BLE_MONITOR
|
||||
ble_monitor_send(BLE_MONITOR_OPCODE_COMMAND_PKT, cmd,
|
||||
cmd->length + sizeof(*cmd));
|
||||
#endif
|
||||
|
||||
rc = ble_transport_to_ll_cmd(cmd);
|
||||
switch (rc) {
|
||||
case 0:
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "os/os.h"
|
||||
#include "nimble/hci_common.h"
|
||||
#include "host/ble_gap.h"
|
||||
#include "host/ble_monitor.h"
|
||||
#include "ble_hs_priv.h"
|
||||
|
||||
_Static_assert(sizeof (struct hci_data_hdr) == BLE_HCI_DATA_HDR_SZ,
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
#include "ble_hs_periodic_sync_priv.h"
|
||||
#include "ble_uuid_priv.h"
|
||||
#include "host/ble_hs.h"
|
||||
#include "host/ble_monitor.h"
|
||||
#include "nimble/nimble_opt.h"
|
||||
#include "stats/stats.h"
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -45,7 +45,6 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include "nimble/ble.h"
|
||||
#include "host/ble_monitor.h"
|
||||
#include "ble_hs_priv.h"
|
||||
|
||||
#if NIMBLE_BLE_CONNECT
|
||||
|
||||
@@ -44,44 +44,6 @@ syscfg.defs:
|
||||
simulator.
|
||||
value: 1
|
||||
|
||||
# Monitor interface settings
|
||||
BLE_MONITOR_UART:
|
||||
description: Enables monitor interface over UART
|
||||
value: 0
|
||||
BLE_MONITOR_UART_DEV:
|
||||
description: Monitor interface UART device
|
||||
value: '"uart0"'
|
||||
BLE_MONITOR_UART_BAUDRATE:
|
||||
description: Baudrate for monitor interface UART
|
||||
value: 1000000
|
||||
BLE_MONITOR_UART_BUFFER_SIZE:
|
||||
description: >
|
||||
Monitor interface ringbuffer size for UART.
|
||||
This value should be a power of 2.
|
||||
value: 64
|
||||
BLE_MONITOR_RTT:
|
||||
description: Enables monitor interface over RTT
|
||||
value: 0
|
||||
BLE_MONITOR_RTT_BUFFER_NAME:
|
||||
description: Monitor interface upstream buffer name
|
||||
value: '"btmonitor"'
|
||||
BLE_MONITOR_RTT_BUFFER_SIZE:
|
||||
description: Monitor interface upstream buffer size
|
||||
value: 256
|
||||
BLE_MONITOR_RTT_BUFFERED:
|
||||
description: >
|
||||
Enables buffering when using monitor interface over RTT. The data
|
||||
are written to RTT once complete packet is created in intermediate
|
||||
buffer. This allows to skip complete packet if there is not enough
|
||||
space in RTT buffer (e.g. there is no reader connected). If disabled,
|
||||
monitor will simply block waiting for RTT to free space in buffer.
|
||||
value: 1
|
||||
BLE_MONITOR_CONSOLE_BUFFER_SIZE:
|
||||
description: >
|
||||
Size of internal buffer for console output. Any line exceeding this
|
||||
length value will be split.
|
||||
value: 128
|
||||
|
||||
# L2CAP settings.
|
||||
BLE_L2CAP_MAX_CHANS:
|
||||
description: >
|
||||
|
||||
@@ -165,7 +165,7 @@ ble_transport_hs_init(void)
|
||||
|
||||
#if !MYNEWT_VAL(BLE_CONTROLLER)
|
||||
int
|
||||
ble_transport_to_ll_cmd(void *buf)
|
||||
ble_transport_to_ll_cmd_impl(void *buf)
|
||||
{
|
||||
uint8_t pkt_type = HCI_H4_CMD;
|
||||
uint8_t *cmd = buf;
|
||||
@@ -179,7 +179,7 @@ ble_transport_to_ll_cmd(void *buf)
|
||||
}
|
||||
|
||||
int
|
||||
ble_transport_to_ll_acl(struct os_mbuf *om)
|
||||
ble_transport_to_ll_acl_impl(struct os_mbuf *om)
|
||||
{
|
||||
return hci_cmac_acl_tx(om);
|
||||
}
|
||||
@@ -187,13 +187,13 @@ ble_transport_to_ll_acl(struct os_mbuf *om)
|
||||
|
||||
#if MYNEWT_VAL(BLE_CONTROLLER)
|
||||
int
|
||||
ble_transport_to_hs_acl(struct os_mbuf *om)
|
||||
ble_transport_to_hs_acl_impl(struct os_mbuf *om)
|
||||
{
|
||||
return hci_cmac_acl_tx(om);
|
||||
}
|
||||
|
||||
int
|
||||
ble_transport_to_hs_evt(void *buf)
|
||||
ble_transport_to_hs_evt_impl(void *buf)
|
||||
{
|
||||
uint8_t pkt_type = HCI_H4_EVT;
|
||||
uint8_t *evt = buf;
|
||||
|
||||
@@ -686,13 +686,13 @@ ble_transport_ll_init(void)
|
||||
}
|
||||
|
||||
int
|
||||
ble_transport_to_ll_cmd(void *buf)
|
||||
ble_transport_to_ll_cmd_impl(void *buf)
|
||||
{
|
||||
return ble_hci_emspi_cmdevt_tx(buf, BLE_HCI_EMSPI_PKT_CMD);
|
||||
}
|
||||
|
||||
int
|
||||
ble_transport_to_ll_acl(struct os_mbuf *om)
|
||||
ble_transport_to_ll_acl_impl(struct os_mbuf *om)
|
||||
{
|
||||
return ble_hci_emspi_acl_tx(om);
|
||||
}
|
||||
@@ -24,18 +24,11 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <nimble/transport_impl.h>
|
||||
#include <nimble/transport/monitor.h>
|
||||
|
||||
struct os_mbuf;
|
||||
|
||||
/* Init functions to be implemented for transport acting as HS/LL side */
|
||||
extern void ble_transport_ll_init(void);
|
||||
extern void ble_transport_hs_init(void);
|
||||
|
||||
/* APIs to be implemented by HS/LL side of transports */
|
||||
extern int ble_transport_to_ll_cmd(void *buf);
|
||||
extern int ble_transport_to_ll_acl(struct os_mbuf *om);
|
||||
extern int ble_transport_to_hs_evt(void *buf);
|
||||
extern int ble_transport_to_hs_acl(struct os_mbuf *om);
|
||||
|
||||
/* Allocators for supported data types */
|
||||
void *ble_transport_alloc_cmd(void);
|
||||
void *ble_transport_alloc_evt(int discardable);
|
||||
@@ -48,11 +41,11 @@ void ble_transport_free(void *buf);
|
||||
/* Register put callback on acl_from_ll mbufs (for ll-hs flow control) */
|
||||
int ble_transport_register_put_acl_from_ll_cb(os_mempool_put_fn *cb);
|
||||
|
||||
#if MYNEWT_VAL(BLE_TRANSPORT_INT_FLOW_CTL)
|
||||
/* To be implemented if transport supports internal flow control between cores */
|
||||
extern int ble_transport_int_flow_ctl_get(void);
|
||||
extern void ble_transport_int_flow_ctl_put(void);
|
||||
#endif
|
||||
/* Send data to hs/ll side */
|
||||
int ble_transport_to_ll_cmd(void *buf);
|
||||
int ble_transport_to_ll_acl(struct os_mbuf *om);
|
||||
int ble_transport_to_hs_evt(void *buf);
|
||||
int ble_transport_to_hs_acl(struct os_mbuf *om);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
+35
-5
@@ -22,16 +22,46 @@
|
||||
|
||||
#include <syscfg/syscfg.h>
|
||||
|
||||
#undef BLE_MONITOR
|
||||
#define BLE_MONITOR (MYNEWT_VAL(BLE_MONITOR_UART) || MYNEWT_VAL(BLE_MONITOR_RTT))
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int ble_monitor_log(int level, const char *fmt, ...);
|
||||
#define BLE_MONITOR (MYNEWT_VAL(BLE_MONITOR_RTT) || \
|
||||
MYNEWT_VAL(BLE_MONITOR_UART))
|
||||
|
||||
int ble_monitor_out(int c);
|
||||
#if BLE_MONITOR
|
||||
int ble_monitor_log(int level, const char *fmt, ...);
|
||||
#else
|
||||
static inline int
|
||||
ble_monitor_log(int level, const char *fmt, ...)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
ble_transport_to_ll_cmd(void *buf)
|
||||
{
|
||||
return ble_transport_to_ll_cmd_impl(buf);
|
||||
}
|
||||
|
||||
static inline int
|
||||
ble_transport_to_ll_acl(struct os_mbuf *om)
|
||||
{
|
||||
return ble_transport_to_ll_acl_impl(om);
|
||||
}
|
||||
|
||||
static inline int
|
||||
ble_transport_to_hs_evt(void *buf)
|
||||
{
|
||||
return ble_transport_to_hs_evt_impl(buf);
|
||||
}
|
||||
|
||||
static inline int
|
||||
ble_transport_to_hs_acl(struct os_mbuf *om)
|
||||
{
|
||||
return ble_transport_to_hs_acl_impl(om);
|
||||
}
|
||||
#endif /* BLE_MONITOR */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
#ifndef H_NIMBLE_TRANSPORT_IMPL_
|
||||
#define H_NIMBLE_TRANSPORT_IMPL_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Init functions to be implemented for transport acting as HS/LL side */
|
||||
extern void ble_transport_ll_init(void);
|
||||
extern void ble_transport_hs_init(void);
|
||||
|
||||
/* APIs to be implemented by HS/LL side of transports */
|
||||
extern int ble_transport_to_ll_cmd_impl(void *buf);
|
||||
extern int ble_transport_to_ll_acl_impl(struct os_mbuf *om);
|
||||
extern int ble_transport_to_hs_evt_impl(void *buf);
|
||||
extern int ble_transport_to_hs_acl_impl(struct os_mbuf *om);
|
||||
|
||||
#if MYNEWT_VAL(BLE_TRANSPORT_INT_FLOW_CTL)
|
||||
/* To be implemented if transport supports internal flow control between cores */
|
||||
extern int ble_transport_int_flow_ctl_get(void);
|
||||
extern void ble_transport_int_flow_ctl_put(void);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* H_NIMBLE_TRANSPORT_IMPL_ */
|
||||
@@ -115,7 +115,7 @@ nrf5340_ble_hci_init(void)
|
||||
|
||||
#if MYNEWT_VAL(BLE_CONTROLLER)
|
||||
int
|
||||
ble_transport_to_hs_evt(void *buf)
|
||||
ble_transport_to_hs_evt_impl(void *buf)
|
||||
{
|
||||
uint8_t ind = HCI_H4_EVT;
|
||||
uint8_t* hci_ev = buf;
|
||||
@@ -133,7 +133,7 @@ ble_transport_to_hs_evt(void *buf)
|
||||
}
|
||||
|
||||
int
|
||||
ble_transport_to_hs_acl(struct os_mbuf *om)
|
||||
ble_transport_to_hs_acl_impl(struct os_mbuf *om)
|
||||
{
|
||||
return nrf5340_ble_hci_acl_tx(om);
|
||||
}
|
||||
@@ -149,7 +149,7 @@ ble_transport_hs_init(void)
|
||||
|
||||
#if !MYNEWT_VAL(BLE_CONTROLLER)
|
||||
int
|
||||
ble_transport_to_ll_cmd(void *buf)
|
||||
ble_transport_to_ll_cmd_impl(void *buf)
|
||||
{
|
||||
uint8_t ind = HCI_H4_CMD;
|
||||
uint8_t *cmd = buf;
|
||||
@@ -167,7 +167,7 @@ ble_transport_to_ll_cmd(void *buf)
|
||||
}
|
||||
|
||||
int
|
||||
ble_transport_to_ll_acl(struct os_mbuf *om)
|
||||
ble_transport_to_ll_acl_impl(struct os_mbuf *om)
|
||||
{
|
||||
return nrf5340_ble_hci_acl_tx(om);
|
||||
}
|
||||
|
||||
@@ -45,6 +45,9 @@ pkg.deps.'BLE_TRANSPORT_HS == "uart"':
|
||||
pkg.deps.'BLE_TRANSPORT_HS == "usb"':
|
||||
- nimble/transport/usb
|
||||
|
||||
pkg.deps.BLE_MONITOR_RTT:
|
||||
- "@apache-mynewt-core/hw/drivers/rtt"
|
||||
|
||||
pkg.init:
|
||||
ble_transport_init: 250
|
||||
ble_transport_hs_init:
|
||||
@@ -52,3 +55,6 @@ pkg.init:
|
||||
- $before:ble_transport_ll_init
|
||||
ble_transport_ll_init:
|
||||
- $after:ble_transport_hs_init
|
||||
|
||||
pkg.init.'BLE_MONITOR_RTT || BLE_MONITOR_UART':
|
||||
ble_monitor_init: $before:ble_transport_init
|
||||
|
||||
@@ -839,13 +839,13 @@ ble_transport_ll_init(void)
|
||||
}
|
||||
|
||||
int
|
||||
ble_transport_to_ll_acl(struct os_mbuf *om)
|
||||
ble_transport_to_ll_acl_impl(struct os_mbuf *om)
|
||||
{
|
||||
return ble_hci_trans_hs_acl_tx(om);
|
||||
}
|
||||
|
||||
int
|
||||
ble_transport_to_ll_cmd(void *buf)
|
||||
ble_transport_to_ll_cmd_impl(void *buf)
|
||||
{
|
||||
return ble_hci_trans_hs_cmd_tx(buf);
|
||||
}
|
||||
|
||||
@@ -17,13 +17,9 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
#include "host/ble_monitor.h"
|
||||
#include <syscfg/syscfg.h>
|
||||
|
||||
#if BLE_MONITOR
|
||||
|
||||
#if MYNEWT_VAL(BLE_MONITOR_UART) && MYNEWT_VAL(BLE_MONITOR_RTT)
|
||||
#error "Cannot enable monitor over UART and RTT at the same time!"
|
||||
#endif
|
||||
#if MYNEWT_VAL(BLE_MONITOR_RTT) || MYNEWT_VAL(BLE_MONITOR_UART)
|
||||
|
||||
#ifdef BABBLESIM
|
||||
#define _GNU_SOURCE
|
||||
@@ -41,8 +37,10 @@
|
||||
#if MYNEWT_VAL(BLE_MONITOR_RTT)
|
||||
#include "rtt/SEGGER_RTT.h"
|
||||
#endif
|
||||
#include "ble_hs_priv.h"
|
||||
#include "ble_monitor_priv.h"
|
||||
#include <nimble/hci_common.h>
|
||||
#include <nimble/transport.h>
|
||||
#include <nimble/nimble_npl.h>
|
||||
#include "monitor_priv.h"
|
||||
|
||||
struct ble_npl_mutex lock;
|
||||
|
||||
@@ -297,9 +295,11 @@ drops_tmp_cb(struct ble_npl_event *ev)
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
void
|
||||
ble_monitor_init(void)
|
||||
{
|
||||
SYSINIT_ASSERT_ACTIVE();
|
||||
|
||||
#if MYNEWT_VAL(BLE_MONITOR_UART)
|
||||
struct uart_conf uc = {
|
||||
.uc_speed = MYNEWT_VAL(BLE_MONITOR_UART_BAUDRATE),
|
||||
@@ -314,14 +314,12 @@ ble_monitor_init(void)
|
||||
|
||||
uart = (struct uart_dev *)os_dev_open(MYNEWT_VAL(BLE_MONITOR_UART_DEV),
|
||||
OS_TIMEOUT_NEVER, &uc);
|
||||
if (!uart) {
|
||||
return -1;
|
||||
}
|
||||
SYSINIT_PANIC_ASSERT(uart);
|
||||
#endif
|
||||
|
||||
#if MYNEWT_VAL(BLE_MONITOR_RTT)
|
||||
#if MYNEWT_VAL(BLE_MONITOR_RTT_BUFFERED)
|
||||
ble_npl_callout_init(&rtt_drops.tmo, ble_hs_evq_get(), drops_tmp_cb, NULL);
|
||||
ble_npl_callout_init(&rtt_drops.tmo, ble_npl_eventq_dflt_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;
|
||||
@@ -339,14 +337,14 @@ ble_monitor_init(void)
|
||||
SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL);
|
||||
#endif
|
||||
|
||||
if (rtt_index < 0) {
|
||||
return -1;
|
||||
}
|
||||
SYSINIT_PANIC_ASSERT(rtt_index >= 0);
|
||||
#endif
|
||||
|
||||
ble_npl_mutex_init(&lock);
|
||||
|
||||
return 0;
|
||||
#if BLE_MONITOR
|
||||
ble_monitor_new_index(0, (uint8_t[6]){ }, "nimble0");
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
@@ -492,4 +490,42 @@ ble_monitor_out(int c)
|
||||
return c;
|
||||
}
|
||||
|
||||
#endif
|
||||
int
|
||||
ble_transport_to_ll_cmd(void *buf)
|
||||
{
|
||||
struct ble_hci_cmd *cmd = buf;
|
||||
|
||||
ble_monitor_send(BLE_MONITOR_OPCODE_COMMAND_PKT, buf, cmd->length +
|
||||
sizeof(*cmd));
|
||||
|
||||
return ble_transport_to_ll_cmd_impl(buf);
|
||||
}
|
||||
|
||||
int
|
||||
ble_transport_to_ll_acl(struct os_mbuf *om)
|
||||
{
|
||||
ble_monitor_send_om(BLE_MONITOR_OPCODE_ACL_TX_PKT, om);
|
||||
|
||||
return ble_transport_to_ll_acl_impl(om);
|
||||
}
|
||||
|
||||
int
|
||||
ble_transport_to_hs_acl(struct os_mbuf *om)
|
||||
{
|
||||
ble_monitor_send_om(BLE_MONITOR_OPCODE_ACL_RX_PKT, om);
|
||||
|
||||
return ble_transport_to_hs_acl_impl(om);
|
||||
}
|
||||
|
||||
int
|
||||
ble_transport_to_hs_evt(void *buf)
|
||||
{
|
||||
struct ble_hci_ev *ev = buf;
|
||||
|
||||
ble_monitor_send(BLE_MONITOR_OPCODE_EVENT_PKT, buf, ev->length +
|
||||
sizeof(*ev));
|
||||
|
||||
return ble_transport_to_hs_evt_impl(buf);
|
||||
}
|
||||
|
||||
#endif /* MYNEWT_VAL(BLE_MONITOR_RTT) || MYNEWT_VAL(BLE_MONITOR_UART) */
|
||||
@@ -85,8 +85,6 @@ struct ble_monitor_user_logging {
|
||||
uint8_t ident_len;
|
||||
} __attribute__((packed));
|
||||
|
||||
int ble_monitor_init(void);
|
||||
|
||||
int ble_monitor_send(uint16_t opcode, const void *data, size_t len);
|
||||
|
||||
int ble_monitor_send_om(uint16_t opcode, const struct os_mbuf *om);
|
||||
@@ -0,0 +1,58 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
|
||||
syscfg.defs:
|
||||
BLE_MONITOR_UART:
|
||||
description: Enables monitor interface over UART
|
||||
value: 0
|
||||
BLE_MONITOR_UART_DEV:
|
||||
description: Monitor interface UART device
|
||||
value: '"uart0"'
|
||||
BLE_MONITOR_UART_BAUDRATE:
|
||||
description: Baudrate for monitor interface UART
|
||||
value: 1000000
|
||||
BLE_MONITOR_UART_BUFFER_SIZE:
|
||||
description: >
|
||||
Monitor interface ringbuffer size for UART.
|
||||
This value should be a power of 2.
|
||||
value: 64
|
||||
BLE_MONITOR_RTT:
|
||||
description: Enables monitor interface over RTT
|
||||
value: 0
|
||||
BLE_MONITOR_RTT_BUFFER_NAME:
|
||||
description: Monitor interface upstream buffer name
|
||||
value: '"btmonitor"'
|
||||
BLE_MONITOR_RTT_BUFFER_SIZE:
|
||||
description: Monitor interface upstream buffer size
|
||||
value: 256
|
||||
BLE_MONITOR_RTT_BUFFERED:
|
||||
description: >
|
||||
Enables buffering when using monitor interface over RTT. The data
|
||||
are written to RTT once complete packet is created in intermediate
|
||||
buffer. This allows to skip complete packet if there is not enough
|
||||
space in RTT buffer (e.g. there is no reader connected). If disabled,
|
||||
monitor will simply block waiting for RTT to free space in buffer.
|
||||
value: 1
|
||||
BLE_MONITOR_CONSOLE_BUFFER_SIZE:
|
||||
description: >
|
||||
Size of internal buffer for console output. Any line exceeding this
|
||||
length value will be split.
|
||||
value: 128
|
||||
|
||||
syscfg.restrictions:
|
||||
- '!(BLE_MONITOR_UART && BLE_MONITOR_RTT)'
|
||||
@@ -86,8 +86,9 @@ syscfg.defs:
|
||||
of ACL buffers available for controller.
|
||||
value: MYNEWT_VAL(BLE_TRANSPORT_ACL_COUNT)
|
||||
|
||||
# import defunct settings from separate file to reduce clutter in main file
|
||||
# import monitor and defunct settings from separate file to reduce clutter in main file
|
||||
$import:
|
||||
- "@apache-mynewt-nimble/nimble/transport/syscfg.monitor.yml"
|
||||
- "@apache-mynewt-nimble/nimble/transport/syscfg.defunct.yml"
|
||||
|
||||
syscfg.vals."BLE_EXT_ADV || BLE_LL_CFG_FEAT_LL_EXT_ADV":
|
||||
|
||||
@@ -172,7 +172,7 @@ hci_uart_configure(void)
|
||||
}
|
||||
|
||||
int
|
||||
ble_transport_to_hs_evt(void *buf)
|
||||
ble_transport_to_hs_evt_impl(void *buf)
|
||||
{
|
||||
struct hci_uart_tx *txe;
|
||||
os_sr_t sr;
|
||||
@@ -200,7 +200,7 @@ ble_transport_to_hs_evt(void *buf)
|
||||
}
|
||||
|
||||
int
|
||||
ble_transport_to_hs_acl(struct os_mbuf *om)
|
||||
ble_transport_to_hs_acl_impl(struct os_mbuf *om)
|
||||
{
|
||||
struct hci_uart_tx *txe;
|
||||
os_sr_t sr;
|
||||
|
||||
@@ -242,13 +242,13 @@ ble_hci_trans_ll_evt_tx(void *buf)
|
||||
}
|
||||
|
||||
int
|
||||
ble_transport_to_hs_acl(struct os_mbuf *om)
|
||||
ble_transport_to_hs_acl_impl(struct os_mbuf *om)
|
||||
{
|
||||
return ble_hci_trans_ll_tx(&ble_hci_tx_acl_queue, om);
|
||||
}
|
||||
|
||||
int
|
||||
ble_transport_to_hs_evt(void *buf)
|
||||
ble_transport_to_hs_evt_impl(void *buf)
|
||||
{
|
||||
return ble_hci_trans_ll_evt_tx(buf);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user