Skip to content

Commit f3e026c

Browse files
committed
Added S-Frame RR test
1 parent 69ad469 commit f3e026c

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

unittest/tiny_fd_tests.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,3 +385,32 @@ TEST(TINY_FD, ABM_CheckMtuAndSendSplit)
385385
result = tiny_fd_send_packet_to(handle, TINY_FD_PRIMARY_ADDR, (const void *)"\x01\x02\x03", 3, 1000);
386386
CHECK_EQUAL(TINY_ERR_DATA_TOO_LARGE, result); // Should return error for frame larger than MTU
387387
}
388+
389+
TEST(TINY_FD, ABM_CheckReceiveReadyWithCommandBitSet)
390+
{
391+
// On Receive Ready with command bit set, and if there is no data to send,
392+
// we should send RR frame with command bit cleared
393+
establishConnection(); // Establish connection first
394+
// Emulate receiving a Receive Ready frame with poll bit set
395+
auto read_result = tiny_fd_on_rx_data(handle, (uint8_t *)"\x7E\x03\x11\x7E", 4); // RR frame with poll bit set
396+
CHECK_EQUAL(TINY_SUCCESS, read_result);
397+
int len = tiny_fd_get_tx_data(handle, outBuffer.data(), outBuffer.size(), 100);
398+
CHECK_EQUAL(4, len); // We should have sent RR frame
399+
// Check RR frame
400+
CHECK_EQUAL(0x7E, outBuffer[0]); // Flag
401+
CHECK_EQUAL(0x01, outBuffer[1]); // Address field - CR bit must be cleared
402+
CHECK_EQUAL(0x11, outBuffer[2]); // RR packet with N(R) = 0
403+
CHECK_EQUAL(0x7E, outBuffer[3]); // Flag
404+
}
405+
406+
TEST(TINY_FD, ABM_CheckReceiveReadyWithCommandBitCleared)
407+
{
408+
// On Receive Ready with command bit set, and if there is no data to send,
409+
// we should send RR frame with command bit cleared
410+
establishConnection(); // Establish connection first
411+
// Emulate receiving a Receive Ready frame with poll bit set
412+
auto read_result = tiny_fd_on_rx_data(handle, (uint8_t *)"\x7E\x01\x11\x7E", 4); // RR frame with poll bit set
413+
CHECK_EQUAL(TINY_SUCCESS, read_result);
414+
int len = tiny_fd_get_tx_data(handle, outBuffer.data(), outBuffer.size(), 100);
415+
CHECK_EQUAL(0, len); // We should have sent RR frame
416+
}

0 commit comments

Comments
 (0)