15static const uint8_t
kMe = 7;
51 TEST_ASSERT_EQUAL_UINT32(0,
lk.frames_ok());
52 TEST_ASSERT_EQUAL_UINT32(0,
lk.frames_dropped());
60 TEST_ASSERT_EQUAL_UINT32(2,
lk.frames_ok());
61 TEST_ASSERT_EQUAL_UINT32(0,
lk.frames_dropped());
67 TEST_ASSERT_EQUAL_UINT32(0,
lk.frames_ok());
68 TEST_ASSERT_EQUAL_UINT32(1,
lk.frames_dropped());
72 uint8_t noise[12] = {0xDE, 0xAD, 0xBE, 0xEF, 1, 2, 3, 4, 5, 6, 7, 8};
79 TEST_ASSERT_EQUAL_UINT32(1,
lk.frames_dropped());
85 for (
int i = 0; i < 200; i++) {
87 x = x * 1664525u + 1013904223u;
88 const uint8_t len =
static_cast<uint8_t
>(1 + (x >> 24) % 200);
89 for (
unsigned k = 0; k < len; k++) {
90 x = x * 1664525u + 1013904223u;
91 buf[k] =
static_cast<uint8_t
>(x >> 24);
100 uint8_t
payload[7] = {1, 0x10, 0x1C, 0, 0, 0, 0};
106 TEST_ASSERT_TRUE(
fake::inject(out,
static_cast<uint8_t
>(
n)));
108 TEST_ASSERT_EQUAL_UINT32(1,
lk.frames_ok());
111 TEST_ASSERT_EQUAL_UINT16(9,
lk.last_frame().seq);
112 TEST_ASSERT_EQUAL_UINT8(7,
lk.last_frame().payload_len);
113 TEST_ASSERT_EQUAL_HEX8_ARRAY(
payload,
lk.last_frame().payload, 7);
117 uint8_t
payload[7] = {1, 0x10, 0x1C, 0, 0, 0, 0};
123 TEST_ASSERT_TRUE(
fake::inject(out,
static_cast<uint8_t
>(
n)));
129 TEST_ASSERT_TRUE(
fake::inject(out,
static_cast<uint8_t
>(
n)));
131 TEST_ASSERT_EQUAL_UINT32(1,
lk.frames_ok());
132 TEST_ASSERT_EQUAL_UINT16(41,
lk.last_frame().seq);
136 uint8_t
payload[4] = {0xFF, 0x01, 0xE8, 0x1C};
146 TEST_ASSERT_EQUAL_UINT8(
static_cast<uint8_t
>(
n), got);
158 TEST_ASSERT_EQUAL_UINT32(2,
lk.radio_errors());
159 TEST_ASSERT_EQUAL_UINT32(0,
lk.frames_dropped());
160 TEST_ASSERT_EQUAL_UINT32(0,
lk.frames_ok());
*brief create JSON pointer *sa reference_tokens const string_t & a
return reference_tokens back()
*brief user defined string literal for JSON values *sa std::size_t n
void fail_next_receive(RadioStatus result)
void reset(bool chip_present)
uint8_t last_sent(uint8_t *out, uint8_t out_cap)
bool inject(const uint8_t *bytes, uint8_t len)
FrameStatus encode_frame(FrameType type, uint16_t seq, const uint8_t *payload, uint8_t payload_len, uint8_t *out, size_t out_cap, size_t &out_len)
Build a frame into out[0..out_cap).
void put_u32(uint8_t *p, uint32_t v)
RadioStatus radio_probe()
FrameStatus decode_frame(const uint8_t *buf, size_t len, Frame &out)
Parse and validate a received packet.
constexpr size_t kLoraMaxPacket
RadioStatus radio_send(const uint8_t *bytes, uint8_t len)
constexpr size_t kFrameMaxLen
constexpr uint32_t kArmKey
PLACEHOLDER: lead to choose the real key before flight.
static void test_heartbeat_is_counted_but_not_acted_on(void)
static void test_pure_noise_never_arms(void)
static void test_two_good_arms_arm_the_rocket(void)
static void test_send_goes_through_the_seam(void)
static void test_nothing_waiting_does_nothing(void)
static void test_corrupted_frame_is_dropped_before_the_gate(void)
static void inject_arm(uint16_t seq, bool corrupt)
static void test_noise_between_good_arms_does_not_cancel_them(void)
static void test_bad_frame_does_not_replace_the_last_good_one(void)
static void test_radio_errors_are_counted_apart_from_bad_frames(void)
static void test_probe_reports_chip_presence(void)