From a1cff30cf7bc44f0f12fd0a9623603a6a0060ae5 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Sat, 17 Feb 2024 12:24:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=B0=E7=9A=84=E5=90=8D?= =?UTF-8?q?=E5=AD=97=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ble_app_uart_c_pca10100_s122.uvoptx | 4 ++-- main.c | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ble_app_uart_c_pca10100_s122.uvoptx b/ble_app_uart_c_pca10100_s122.uvoptx index ef68672..f4cc9b4 100644 --- a/ble_app_uart_c_pca10100_s122.uvoptx +++ b/ble_app_uart_c_pca10100_s122.uvoptx @@ -75,7 +75,7 @@ 1 0 - 1 + 0 5 @@ -272,7 +272,7 @@ 0 0 - 0 + 1 5 diff --git a/main.c b/main.c index 0bbddac..00d7d90 100644 --- a/main.c +++ b/main.c @@ -146,6 +146,7 @@ static void scan_evt_handler(scan_evt_t const* p_scan_evt) { static char m_target_periph_name0[20] = "M1002"; /**< Name of the device we try to connect to. This name is searched in the scan report data*/ static char m_target_periph_name1[20] = "M1001"; /**< Name of the device we try to connect to. This name is searched in the scan report data*/ static char m_target_periph_name2[20] = "iflytop"; /**< Name of the device we try to connect to. This name is searched in the scan report data*/ +static char m_target_periph_name3[20] = "ADS1293"; /**< Name of the device we try to connect to. This name is searched in the scan report data*/ static void scan_init(void) { ret_code_t err_code; nrf_ble_scan_init_t init_scan; @@ -164,6 +165,7 @@ static void scan_init(void) { APP_ERROR_CHECK(nrf_ble_scan_filter_set(&m_scan, SCAN_NAME_FILTER, m_target_periph_name0)); APP_ERROR_CHECK(nrf_ble_scan_filter_set(&m_scan, SCAN_NAME_FILTER, m_target_periph_name1)); APP_ERROR_CHECK(nrf_ble_scan_filter_set(&m_scan, SCAN_NAME_FILTER, m_target_periph_name2)); + APP_ERROR_CHECK(nrf_ble_scan_filter_set(&m_scan, SCAN_NAME_FILTER, m_target_periph_name3)); // err_code = nrf_ble_scan_filters_enable(&m_scan, NRF_BLE_SCAN_NAME_FILTER, false); // APP_ERROR_CHECK(err_code); @@ -206,15 +208,18 @@ static void ble_nus_chars_received_uart_print(uint8_t* p_data, uint16_t data_len NRF_LOG_HEXDUMP_DEBUG(p_data, data_len); app_uart_force_put(0x5A); app_uart_force_put(0xA5); + uint8_t sumcheck = 0; for (uint32_t i = 0; i < data_len; i++) { do { ret_val = app_uart_put(p_data[i]); + sumcheck += p_data[i]; if ((ret_val != NRF_SUCCESS) && (ret_val != NRF_ERROR_BUSY)) { NRF_LOG_ERROR("app_uart_put failed for index 0x%04x.", i); APP_ERROR_CHECK(ret_val); } } while (ret_val == NRF_ERROR_BUSY); } + app_uart_force_put(sumcheck); app_uart_force_put(0x5B); app_uart_force_put(0xB5); }