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;

}

  • Hi SHMoon, 

    Could you describe how the test is performed ? 
    The data output on UART were simply noise or it was some data ? 

    If you turn off the line that output on UART: app_uart_put() 

    Do you still see the same problem ? 

  • -nRF5_SDK_17.1.0

    -NUS (Peripheral-Central)

    .

    We conducted an experiment dividing it into two cases.

    .

    Case 1) Peripheral power is turned off and central is scanning.

    => UART data above does not occur

    .

    Case 2) Peripheral is turned on and paired with central.

    => UART data above above occurs

    .

    .

    Could you describe how the test is performed ? 
    The data output on UART were simply noise or it was some data ? 

    There is absolutely nothing transmitted on the UART line that is simply noise.

    .

    The orange line below is the tx line of the nRF52832, and the white line is the rx line.

    With tx data transmission, data is loaded on the rx line. In other words, the receiving side of communication is sending data through the rx line because the tx is normal.

    .

    In the waveform below, I haven't done any manipulation, but data is being generated when the button is pressed.

    .

    If you zoom in, it looks like that...

    This statistic is actually how we use it.

    (The transfer was made via static void ble_nus_chars_received_uart_print(uint8_t * p_data, uint16_t data_len)

    Covers the basic format of the case. )

    - start byte : 0x02

    - mode : 0xA0 ( button )

    - length : 0x02

    - data : 0x1F (button )

    -reserved : 0x00

    - end byte : 0x03

    .

    .

    Sometimes, tx is generated as shown below.

    Occasionally, data that cannot be generated as shown below may be generated.

    .

    .

    .

    I didn't press any buttons,

    I don't understand that the data of the communication protocol when the button is operated is transmitted through tx...

    I checked the debugging messages with printf.

    .

    However, surprisingly, data was being sent to the tx line using the ble_nus_chars_received_uart_print function.

    So the protocol was adjusted.

    .

    However, the only condition that enters this function is when the peripheral button is pressed, but no button is pressed at all.

    I don't understand why it was implemented.

    .

  • Suggestion: turn on the internal pull-up on the Rx pin for both Central and Peripheral. With either Rx pin disconnected, without a pull-up the Rx inputs are both susceptible to generate noise such as this which will be forwarded to the Central via BLE and output on the UART.

    Edit: Note you may have ECHOBACK_BLE_UART_DATA enabled, which further complicates testing

  • I am using 4.7k pullups for tx/rx on nRF52832.

    During the test, I added a pull-up to the other MCU, but it had no effect.

    ECHOBACK_BLE_UART_DATA is disabled.

  • Does the peripheral button have a pull-up enabled or an external pull-up? (Required)

Related