Browse Source

添加新的名字匹配

master
zhaohe 1 year ago
parent
commit
a1cff30cf7
  1. 4
      ble_app_uart_c_pca10100_s122.uvoptx
  2. 5
      main.c

4
ble_app_uart_c_pca10100_s122.uvoptx

@ -75,7 +75,7 @@
<OPTFL>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<IsCurrentTarget>1</IsCurrentTarget>
<IsCurrentTarget>0</IsCurrentTarget>
</OPTFL>
<CpuCode>5</CpuCode>
<DebugOpt>
@ -272,7 +272,7 @@
<OPTFL>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<IsCurrentTarget>0</IsCurrentTarget>
<IsCurrentTarget>1</IsCurrentTarget>
</OPTFL>
<CpuCode>5</CpuCode>
<DebugOpt>

5
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);
}

Loading…
Cancel
Save