- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个在 Nordic SDK 上运行的 Arduino 设备(它是 Red Bear Lab BLE nano)。我希望能够在 GTKTerm 中进行串行打印,以便能够调试代码中发生的情况。为此,我有以下代码:
/*
* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved.
*
* The information contained herein is confidential property of Nordic Semiconductor. The use,
* copying, transfer or disclosure of such information is prohibited except by express written
* agreement with Nordic Semiconductor.
*
*/
/**
* @brief BLE Heart Rate Collector application main file.
*
* This file contains the source code for a sample heart rate collector.
*/
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "nordic_common.h"
#include "nrf_sdm.h"
#include "ble.h"
#include "ble_hci.h"
#include "ble_db_discovery.h"
#include "softdevice_handler.h"
#include "app_util.h"
#include "app_error.h"
#include "boards.h"
#include "nrf_gpio.h"
#include "pstorage.h"
#include "device_manager.h"
#include "app_trace.h"
#include "ble_hrs_c.h"
#include "ble_bas_c.h"
#include "app_util.h"
#include "app_timer.h"
#include "bsp.h"
#include "bsp_btn_ble.h"
#define UART_TX_BUF_SIZE 256 /**< UART TX buffer size. */
#define UART_RX_BUF_SIZE 1 /**< UART RX buffer size. */
#define STRING_BUFFER_LEN 50
#define BOND_DELETE_ALL_BUTTON_ID 0 /**< Button used for deleting all bonded centrals during startup. */
#define APP_TIMER_PRESCALER 0 /**< Value of the RTC1 PRESCALER register. */
#define APP_TIMER_MAX_TIMERS (2+BSP_APP_TIMERS_NUMBER) /**< Maximum number of simultaneously created timers. */
#define APP_TIMER_OP_QUEUE_SIZE 2 /**< Size of timer operation queues. */
#define APPL_LOG app_trace_log /**< Debug logger macro that will be used in this file to do logging of debug information over UART. */
#define SEC_PARAM_BOND 1 /**< Perform bonding. */
#define SEC_PARAM_MITM 1 /**< Man In The Middle protection not required. */
#define SEC_PARAM_IO_CAPABILITIES BLE_GAP_IO_CAPS_NONE /**< No I/O capabilities. */
#define SEC_PARAM_OOB 0 /**< Out Of Band data not available. */
#define SEC_PARAM_MIN_KEY_SIZE 7 /**< Minimum encryption key size. */
#define SEC_PARAM_MAX_KEY_SIZE 16 /**< Maximum encryption key size. */
#define SCAN_INTERVAL 0x00A0 /**< Determines scan interval in units of 0.625 millisecond. */
#define SCAN_WINDOW 0x0050 /**< Determines scan window in units of 0.625 millisecond. */
#define MIN_CONNECTION_INTERVAL MSEC_TO_UNITS(7.5, UNIT_1_25_MS) /**< Determines minimum connection interval in millisecond. */
#define MAX_CONNECTION_INTERVAL MSEC_TO_UNITS(30, UNIT_1_25_MS) /**< Determines maximum connection interval in millisecond. */
#define SLAVE_LATENCY 0 /**< Determines slave latency in counts of connection events. */
#define SUPERVISION_TIMEOUT MSEC_TO_UNITS(4000, UNIT_10_MS) /**< Determines supervision time-out in units of 10 millisecond. */
#define TARGET_UUID 0x180D /**< Target device name that application is looking for. */
#define MAX_PEER_COUNT DEVICE_MANAGER_MAX_CONNECTIONS /**< Maximum number of peer's application intends to manage. */
#define UUID16_SIZE 2 /**< Size of 16 bit UUID */
/**@breif Macro to unpack 16bit unsigned UUID from octet stream. */
#define UUID16_EXTRACT(DST, SRC) \
do \
{ \
(*(DST)) = (SRC)[1]; \
(*(DST)) <<= 8; \
(*(DST)) |= (SRC)[0]; \
} while (0)
/**@brief Variable length data encapsulation in terms of length and pointer to data */
typedef struct
{
uint8_t * p_data; /**< Pointer to data. */
uint16_t data_len; /**< Length of data. */
}data_t;
typedef enum
{
BLE_NO_SCAN, /**< No advertising running. */
BLE_WHITELIST_SCAN, /**< Advertising with whitelist. */
BLE_FAST_SCAN, /**< Fast advertising running. */
} ble_scan_mode_t;
static ble_db_discovery_t m_ble_db_discovery; /**< Structure used to identify the DB Discovery module. */
static ble_hrs_c_t m_ble_hrs_c; /**< Structure used to identify the heart rate client module. */
static ble_bas_c_t m_ble_bas_c; /**< Structure used to identify the Battery Service client module. */
static ble_gap_scan_params_t m_scan_param; /**< Scan parameters requested for scanning and connection. */
static dm_application_instance_t m_dm_app_id; /**< Application identifier. */
static dm_handle_t m_dm_device_handle; /**< Device Identifier identifier. */
static uint8_t m_peer_count = 0; /**< Number of peer's connected. */
static ble_scan_mode_t m_scan_mode = BLE_FAST_SCAN; /**< Scan mode used by application. */
static uint16_t m_conn_handle; /**< Current connection handle. */
static volatile bool m_whitelist_temporarily_disabled = false; /**< True if whitelist has been temporarily disabled. */
static bool m_memory_access_in_progress = false; /**< Flag to keep track of ongoing operations on persistent memory. */
/**
* @brief Connection parameters requested for connection.
*/
static const ble_gap_conn_params_t m_connection_param =
{
(uint16_t)MIN_CONNECTION_INTERVAL, // Minimum connection
(uint16_t)MAX_CONNECTION_INTERVAL, // Maximum connection
0, // Slave latency
(uint16_t)SUPERVISION_TIMEOUT // Supervision time-out
};
static void scan_start(void);
#define APPL_LOG app_trace_log /**< Debug logger macro that will be used in this file to do logging of debug information over UART. */
/**@brief Function for initializing the UART.
*/
static void uart_init(void)
{
uint32_t err_code;
const app_uart_comm_params_t comm_params =
{
RX_PIN_NUMBER,
TX_PIN_NUMBER,
RTS_PIN_NUMBER,
CTS_PIN_NUMBER,
APP_UART_FLOW_CONTROL_ENABLED,
false,
UART_BAUDRATE_BAUDRATE_Baud38400
};
APP_UART_FIFO_INIT(&comm_params,
UART_RX_BUF_SIZE,
UART_TX_BUF_SIZE,
uart_error_handle,
APP_IRQ_PRIORITY_LOW,
err_code);
APP_ERROR_CHECK(err_code);
app_trace_init();
}
/** @brief Function for the Power manager.
*/
static void power_manage(void)
{
uint32_t err_code = sd_app_evt_wait();
APP_ERROR_CHECK(err_code);
}
int main(void)
{
bool erase_bonds;
// Initialize.
uart_init();
printf("Heart rate collector example (this is a custom log)\r\n");
for (;; )
{
power_manage();
}
}
我遇到的问题是,只有有时我才会在 GTKterm 中看到输出。我无法找到何时有效、何时无效的模式。我该如何调试这个?
最佳答案
How would I go about debugging this?
给初学者的一些建议:
确保您的终端软件正在声明 DTR 信号。这就是找到的解决方案here .
暂时删除对 power_manage()
的调用,以确保这不是问题的一部分。
将 APP_UART_FLOW_CONTROL_ENABLED
更改为 APP_UART_FLOW_CONTROL_DISABLED
判断是否是流量控制问题。在任何情况下,您都不需要对输出到 PC 进行流量控制。如果您要向设备输入(尤其是缓冲区长度为 1)或者要将数据发送到缓冲有限的慢速设备,则可能需要它。
调用 APP_UART_FIFO_INIT
后验证 ERR_CODE
以确保该阶段不会出现任何问题。可能的错误代码定义为 here .
关于c - Nordic SDK 打印到串口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40252073/
Nordic 发布了一个 IoT SDK对于某些平台(包括 nordic nRF51822 BLE SoC),允许开发人员使用支持 BLE 的计算机或路由器作为网关(推荐使用带有 BlueZ 堆栈的
简介:本案例测试了long range,注意nrf52系列芯片中,部分硬件是不支持CADED的,因此也就是不支持long range,如nrf52832就不支持long range。同时协议栈也是部分
1、简介 在 NCS 中有多种的 DFU 选择,强烈推荐使用 MCUboot ,当然如果你需要选择传统的 nrf_DFU 也是可以的,但是要用到官方
我在 XSL 样式表中有这段 JavaScript: function outputUrl() { var currentScripts = document.getElementsB
我有一个在 Nordic SDK 上运行的 Arduino 设备(它是 Red Bear Lab BLE nano)。我希望能够在 GTKTerm 中进行串行打印,以便能够调试代码中发生的情况。为此,
我想设置一个 Docker 容器并与我的同事共享,这样我们就不必单独设置开发环境。 最佳答案 请注意,这不包括将容器保存为镜像并上传到 DockerHub(搜索该部分)。还值得注意的是,这组指令将是创
我通过 Android 的 Nordic 库 thingylib ( github ) 连接到 thingy52 并在回调监听器 ThingyListener 中接收有关设备的信息 (例如 onGra
我想使用 Nordic 芯片 (nRF52) 从客户端建立安全的蓝牙连接。我还运行了 WolfSSL 库。因此,我收到来自 Nordic Softdevice 的“BLE_GAP_EVT_LESC_D
我是一名优秀的程序员,十分优秀!