Browse Source

update

master
zhaohe 1 year ago
parent
commit
0ea0526c17
  1. 97
      examples/ble_central/ble_app_uart_c/main.c
  2. 15127
      examples/ble_central/ble_app_uart_c/pca10100/s122/arm5_no_packs/JLinkLog.txt
  3. 4
      examples/ble_central/ble_app_uart_c/pca10100/s122/arm5_no_packs/ble_app_uart_c_pca10100_s122.uvoptx
  4. 93
      examples/ble_central/ble_app_uart_c/settings/ble_app_uart_c.wsdt

97
examples/ble_central/ble_app_uart_c/main.c

@ -223,46 +223,65 @@ static void db_disc_handler(ble_db_discovery_evt_t * p_evt)
* @details This function takes a list of characters of length data_len and prints the characters out on UART.
* If @ref ECHOBACK_BLE_UART_DATA is set, the data is sent back to sender.
*/
static void ble_nus_chars_received_uart_print(uint8_t * p_data, uint16_t data_len)
{
ret_code_t ret_val;
NRF_LOG_DEBUG("Receiving data.");
NRF_LOG_HEXDUMP_DEBUG(p_data, data_len);
app_uart_put(0x5A);
app_uart_put(0xA5);
for (uint32_t i = 0; i < data_len; i++)
{
do
{
ret_val = app_uart_put(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_put(0x5A);
app_uart_put(0xA5);
// if (p_data[data_len-1] == '\r')
// {
// while (app_uart_put('\n') == NRF_ERROR_BUSY);
// }
if (ECHOBACK_BLE_UART_DATA)
{
// Send data back to the peripheral.
do
{
ret_val = ble_nus_c_string_send(&m_ble_nus_c, p_data, data_len);
if ((ret_val != NRF_SUCCESS) && (ret_val != NRF_ERROR_BUSY))
{
NRF_LOG_ERROR("Failed sending NUS message. Error 0x%x. ", ret_val);
APP_ERROR_CHECK(ret_val);
}
} while (ret_val == NRF_ERROR_BUSY);
}
static void ble_nus_chars_received_uart_print(uint8_t* p_data, uint16_t data_len) {
ret_code_t ret_val;
NRF_LOG_DEBUG("Receiving data.");
NRF_LOG_HEXDUMP_DEBUG(p_data, data_len);
app_uart_put(0x5A);
app_uart_put(0xA5);
for (uint32_t i = 0; i < data_len; i++) {
do {
ret_val = app_uart_put(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_put(0x5B);
app_uart_put(0xB5);
}
// static void ble_nus_chars_received_uart_print(uint8_t * p_data, uint16_t data_len)
// {
// ret_code_t ret_val;
// NRF_LOG_DEBUG("Receiving data.");
// NRF_LOG_HEXDUMP_DEBUG(p_data, data_len);
// app_uart_put(0x5A);
// app_uart_put(0xA5);
// for (uint32_t i = 0; i < data_len; i++)
// {
// do
// {
// ret_val = app_uart_put(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_put(0x5A);
// app_uart_put(0xA5);
// // if (p_data[data_len-1] == '\r')
// // {
// // while (app_uart_put('\n') == NRF_ERROR_BUSY);
// // }
// if (ECHOBACK_BLE_UART_DATA)
// {
// // Send data back to the peripheral.
// do
// {
// ret_val = ble_nus_c_string_send(&m_ble_nus_c, p_data, data_len);
// if ((ret_val != NRF_SUCCESS) && (ret_val != NRF_ERROR_BUSY))
// {
// NRF_LOG_ERROR("Failed sending NUS message. Error 0x%x. ", ret_val);
// APP_ERROR_CHECK(ret_val);
// }
// } while (ret_val == NRF_ERROR_BUSY);
// }
// }
/**@brief Function for handling app_uart events.

15127
examples/ble_central/ble_app_uart_c/pca10100/s122/arm5_no_packs/JLinkLog.txt
File diff suppressed because it is too large
View File

4
examples/ble_central/ble_app_uart_c/pca10100/s122/arm5_no_packs/ble_app_uart_c_pca10100_s122.uvoptx

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

93
examples/ble_central/ble_app_uart_c/settings/ble_app_uart_c.wsdt

@ -0,0 +1,93 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<Workspace>
<ConfigDictionary>
<CurrentConfigs/>
</ConfigDictionary>
<Desktop>
<Static>
<Workspace>
<ColumnWidths>
<Column0>124</Column0>
<Column1>27</Column1>
<Column2>27</Column2>
<Column3>27</Column3>
</ColumnWidths>
</Workspace>
</Static>
<Windows>
<Wnd0>
<Tabs>
<Tab>
<Identity>TabID-7862-6113</Identity>
<TabName>Workspace</TabName>
<Factory>Workspace</Factory>
<Session>
<NodeDict/>
</Session>
</Tab>
</Tabs>
<SelectedTab>0</SelectedTab>
</Wnd0>
</Windows>
<Editor>
<Pane/>
<ActivePane>0</ActivePane>
<Sizes>
<Pane>
<X>1000000</X>
<Y>1000000</Y>
</Pane>
</Sizes>
<SplitMode>1</SplitMode>
</Editor>
<Positions>
<Top>
<Row0>
<Sizes>
<Toolbar-074e5a50>
<key>iaridepm.enu1</key>
</Toolbar-074e5a50>
</Sizes>
</Row0>
</Top>
<Left>
<Row0>
<Sizes>
<Wnd0>
<Rect>
<Top>-2</Top>
<Left>-2</Left>
<Bottom>676</Bottom>
<Right>198</Right>
<x>-2</x>
<y>-2</y>
<xscreen>200</xscreen>
<yscreen>200</yscreen>
<sizeHorzCX>160772</sizeHorzCX>
<sizeHorzCY>277393</sizeHorzCY>
<sizeVertCX>160772</sizeVertCX>
<sizeVertCY>940361</sizeVertCY>
</Rect>
</Wnd0>
</Sizes>
</Row0>
</Left>
<Right>
<Row0>
<Sizes/>
</Row0>
</Right>
<Bottom>
<Row0>
<Sizes/>
</Row0>
</Bottom>
<Float>
<Sizes/>
</Float>
</Positions>
</Desktop>
</Workspace>
Loading…
Cancel
Save