当前位置:网站首页>nus_ data_ Handler source code interprets data types such as structure
nus_ data_ Handler source code interprets data types such as structure
2022-06-12 05:46:00 【m0_ seven thousand seven hundred and eighty-eight】
c++ Object programming thinking is embodied in struct.
Structs are convenient for defining data types ,struct Describe data objects that require different types of data .
enumeration (Enum) type , Be able to list all possible values , And give them a name .
nodic Official website uart Introduce
## ***services_init register NUS,nus_init.data_handler = nus_data_handler;***
static void nus_data_handler(ble_nus_evt_t *p_evt)
{
if (p_evt->type == BLE_NUS_EVT_RX_DATA)
{
uint32_t err_code;
NRF_LOG_DEBUG("nus_data_handler:Received data from BLE NUS. Writing data on UART.");
NRF_LOG_HEXDUMP_DEBUG(p_evt->params.rx_data.p_data, p_evt->params.rx_data.length);
for (uint32_t i = 0; i < p_evt->params.rx_data.length; i++)
{
do
{
err_code = app_uart_put(p_evt->params.rx_data.p_data[i]);
if ((err_code != NRF_SUCCESS) && (err_code != NRF_ERROR_BUSY))
{
NRF_LOG_ERROR("Failed receiving NUS message. Error 0x%x. ", err_code);
APP_ERROR_CHECK(err_code);
}
} while (err_code == NRF_ERROR_BUSY);
}
if (p_evt->params.rx_data.p_data[p_evt->params.rx_data.length - 1] == '\r')
{
while (app_uart_put('\n') == NRF_ERROR_BUSY);
}
}
}
## ***ble_nus.h***
//p_evt->type(ble_nus_evt_type_t) == BLE_NUS_EVT_RX_DATA
//p_evt->params.rx_data.p_data
typedef struct
{
ble_nus_evt_type_t type; /**< Event type. */
ble_nus_t * p_nus; /**< A pointer to the instance. */
uint16_t conn_handle; /**< Connection handle. */
ble_nus_client_context_t * p_link_ctx; /**< A pointer to the link context. */
union
{
ble_nus_evt_rx_data_t rx_data; /**< @ref BLE_NUS_EVT_RX_DATA event data. */
ble_nus_evt_rx_data_t led_data;// preservation led data
} params;
} ble_nus_evt_t;
//evt_type
typedef enum
{
BLE_NUS_EVT_RX_DATA, /**< Data received. */
BLE_NUS_EVT_TX_RDY, /**< Service is ready to accept new data to be transmitted. */
BLE_NUS_EVT_LED_OPT, // add to led Event type
BLE_NUS_EVT_COMM_STARTED, /**< Notification has been enabled. */
BLE_NUS_EVT_COMM_STOPPED, /**< Notification has been disabled. */
} ble_nus_evt_type_t;
//the buffer with received data
typedef struct
{
uint8_t const * p_data; /**< A pointer to the buffer with received data. */
uint16_t length; /**< Length of received data. */
} ble_nus_evt_rx_data_t;
边栏推荐
- Go 接口实现原理【高阶篇】
- [go] Viper reads the configuration file in the go project
- [gpio] how to modify / display GPIO status through ADB shell
- Why can't NAND flash be used as RAM while nor flash can
- Review notes of naturallanguageprocessing based on deep learning
- yolov5
- 国企为什么要上市
- Nature | make an account of the new crown casualties in the world
- Golang idea configures the agent to improve the speed of packages downloaded by go get
- log4j 1. X upgrade to 2 Solution of X dependency incompatibility
猜你喜欢

16. sum of the nearest three numbers

分公司负责人需要承担的法律责任

Halcon 3D 深度图转换为3D图像

Identification of campus green plants based on tensorflow

GRP development: four communication modes of GRP

Filter的注解配置
![[gin] gin framework for golang web development](/img/15/68c4fd217555f940b3cd3d10fcd54f.jpg)
[gin] gin framework for golang web development

Introduction to redis cluster

Introduction to Internet Protocol

Conversion of Halcon 3D depth map to 3D image
随机推荐
CODIS stress test (PHP)
Laravel8 when search
C语言-数组的定义方式
Introduction to Internet Protocol
Mysql笔记
Introduction to thread pool: ThreadPoolExecutor
Performance test - GTI application service performance monitoring platform
16. 最接近的三数之和
[grpc development] go language builds simple server and client
Analysis of pointer
beginning一款非常优秀的emlog主题v3.1,支持Emlog Pro
16. sum of the nearest three numbers
Thesis reading_ Figure neural network gin
RTMP streaming +rtmp playback low delay solution in unity environment
Deep understanding of asynchronous programming
基于tensorflow的校园绿植识别
Redis transaction
March 22, 2021
Redis cluster cluster capacity expansion and data migration
Chapter 8 - structure