The CS (Susceptiblility) test is completed with UART output even if there is no response.

hello,

While conducting a CS (Susceptiblility) test, unexpected data was generated from the UART. When I checked the data, the data was output as follows.

Of course, I did not run any events that generate data.

Why did I not enter any key data... did BLE work?

void ble_nus_c_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context)
{
ble_nus_c_t * p_ble_nus_c = (ble_nus_c_t *)p_context;

if ((p_ble_nus_c == NULL) || (p_ble_evt == NULL))
{
return;
}

if ( (p_ble_nus_c->conn_handle == BLE_CONN_HANDLE_INVALID)
||(p_ble_nus_c->conn_handle != p_ble_evt->evt.gap_evt.conn_handle)
)
{
return;
}

switch (p_ble_evt->header.evt_id)
{
case BLE_GATTC_EVT_HVX:

#ifdef DEBUG
printf("> nus_c_on_ble_evt - BLE_GATTC_EVT_HVX\r\n");
#endif
on_hvx(p_ble_nus_c, p_ble_evt);
break;

case BLE_GAP_EVT_DISCONNECTED:
if (p_ble_evt->evt.gap_evt.conn_handle == p_ble_nus_c->conn_handle
&& p_ble_nus_c->evt_handler != NULL)
{

#ifdef DEBUG
printf("> nus_c_on_ble_evt - BLE_GAP_EVT_DISCONNECTED\r\n");
#endif

ble_nus_c_evt_t nus_c_evt;

nus_c_evt.evt_type = BLE_NUS_C_EVT_DISCONNECTED;

p_ble_nus_c->conn_handle = BLE_CONN_HANDLE_INVALID;
p_ble_nus_c->evt_handler(p_ble_nus_c, &nus_c_evt);
}
break;

default:
// No implementation needed.
break;
}
}

/**@brief Callback handling Nordic UART Service (NUS) client events.
*
* @details This function is called to notify the application of NUS client events.
*
* @param[in] p_ble_nus_c NUS client handle. This identifies the NUS client.
* @param[in] p_ble_nus_evt Pointer to the NUS client event.
*/

/**@snippet [Handling events from the ble_nus_c module] */
static void ble_nus_c_evt_handler(ble_nus_c_t * p_ble_nus_c, ble_nus_c_evt_t const * p_ble_nus_evt)
{
ret_code_t err_code;

#ifdef DEBUG
printf("> ble_nus_c_E_H");
#endif

switch (p_ble_nus_evt->evt_type)
{
case BLE_NUS_C_EVT_DISCOVERY_COMPLETE:

#ifdef DEBUG
printf(" Disco_complete\n\r");
//RF_LOG_INFO("Discovery complete.");
#endif
err_code = ble_nus_c_handles_assign(p_ble_nus_c, p_ble_nus_evt->conn_handle, &p_ble_nus_evt->handles);
APP_ERROR_CHECK(err_code);

err_code = ble_nus_c_tx_notif_enable(p_ble_nus_c);
APP_ERROR_CHECK(err_code);

#ifdef DEBUG
printf(" Connected to device with NUS\n\r");
#endif

gFlag_Connection = 1;
//NRF_LOG_INFO("Connected to device with Nordic UART Service.");
break;

case BLE_NUS_C_EVT_NUS_TX_EVT:
ble_nus_chars_received_uart_print(p_ble_nus_evt->p_data, p_ble_nus_evt->data_len);
break;

case BLE_NUS_C_EVT_DISCONNECTED:

#ifdef DEBUG
printf(" Disconn\n\r");
#endif
gFlag_Connection = 0;
//NRF_LOG_INFO("Disconnected.");

// TODO [2023-04-11] disconnect
scan_start();

break;
}
}

/**@brief Function for handling characters received by the Nordic UART Service (NUS).
*
* @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;
uint8_t mError = 0, mCheck_sum = 0, i;

#ifdef DEBUG
printf("> NUS rData L:%x D: ", data_len);
//NRF_LOG_DEBUG("Receiving data.");
//NRF_LOG_HEXDUMP_DEBUG(p_data, data_len);
#endif

mSTX_pointer = 0xFF;
for (uint32_t i = 0; i < data_len; i++)
{
do
{
// TODO [ 2023-050-10 / yk / PBA Ver.0.0 ]
//ret_val = app_uart_put(p_data[i]);

if ((ret_val != NRF_SUCCESS) && (ret_val != NRF_ERROR_BUSY))
{

#ifdef DEBUG
printf("> app_uart_put failed for index 0x%04x.", i);
// NRF_LOG_ERROR("app_uart_put failed for index 0x%04x.", i);
#endif
APP_ERROR_CHECK(ret_val);

mError = 1;
}
// TODO [ 2023-050-10 / yk / PBA Ver.0.0 ]
/*
if( ( UART_STX == p_data[i] ) && ( 0xFF == mSTX_pointer ) )
{
mSTX_pointer = i;
}
*/

} while (ret_val == NRF_ERROR_BUSY);
}

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))
{

#ifdef DEBUG
printf("> Failed sending NUS message. Error 0x%x. ", ret_val);
//NRF_LOG_ERROR("Failed sending NUS message. Error 0x%x. ", ret_val);
#endif
APP_ERROR_CHECK(ret_val);
}
} while (ret_val == NRF_ERROR_BUSY);
}

// TODO [ 2023-050-10 / yk / PBA Ver.0.0 ]
if( 0 == mError )
{

for ( i = 0; i < 2; i++ )
{
mData_RemoconKey[ 3 + i ] = p_data[i];
}
mData_SideKey[4] = gFlag_Connection;

for( i = 1; i <= ( UART_LENGTH + 2 ); i++ )
{
mCheck_sum ^= mData_RemoconKey[i] ;
}
mData_RemoconKey[ 5 ] = mCheck_sum;

// nrf_gpio_pin_write( NRF_GPIO_PIN_9, 1 );

for( i = 0; i < ( UART_LENGTH + 5 ); i++ )
{
app_uart_put( mData_RemoconKey[i] );
}

mData_RemoconKey[3] = 0;
mData_RemoconKey[4] = 0;
mData_RemoconKey[5] = 0;

}

Parents Reply Children
No Data
Related