Skip to content

Commit 80f45a0

Browse files
committed
Add test for probe_device changes
1 parent c94a30c commit 80f45a0

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

firmware/libsi/test/test_gc_controller.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,35 @@ static void test_set_wireless_origin(void)
329329
TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_info_response_3, response_buf, 3);
330330
}
331331

332+
// Test that the probe device response is correct, and ignored after setting the wireless ID
333+
static void test_wavebird_probe_response()
334+
{
335+
int rc;
336+
337+
// Initialize as a WaveBird receiver
338+
struct si_device_gc_controller device;
339+
si_device_gc_init(&device, SI_TYPE_GC | SI_GC_WIRELESS | SI_GC_NOMOTOR);
340+
341+
// Send a probe command
342+
uint8_t probe_command[] = {SI_CMD_GC_PROBE_DEVICE, 0x00, 0x00};
343+
rc = simulate_command(&device, probe_command);
344+
345+
// Test probe response is as expected
346+
uint8_t expected_probe_response[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
347+
TEST_ASSERT_EQUAL(8, rc);
348+
TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_probe_response, response_buf, 8);
349+
350+
// Set a 10-bit wireless ID
351+
si_device_gc_set_wireless_id(&device, 0x2B1);
352+
TEST_ASSERT_EQUAL(0x2B1, si_device_gc_get_wireless_id(&device));
353+
354+
// Send another probe command
355+
rc = simulate_command(&device, probe_command);
356+
357+
// Test probe response is ignored after setting wireless ID
358+
TEST_ASSERT_EQUAL(0, rc);
359+
}
360+
332361
void test_gc_controller(void)
333362
{
334363
Unity.TestFile = __FILE_NAME__;
@@ -343,4 +372,5 @@ void test_gc_controller(void)
343372
RUN_TEST(test_set_wireless_id_when_fixed);
344373
RUN_TEST(test_wavebird_fix_device_without_wireless_id);
345374
RUN_TEST(test_set_wireless_origin);
375+
RUN_TEST(test_wavebird_probe_response);
346376
}

0 commit comments

Comments
 (0)