AlexaStatusMessage: DeferredResponse, ChangeReport, ErrorResponse, scene and doorbell events, UUID-shaped messageId
A message has a kind, and the kind decides its topic: answers on <root>/<id>/alexaResponce, the answer after a DeferredResponse on <root>/<id>/deferredResponse (sendAsync()), a ChangeReport on <root>/changeReport with the changed properties apart from the others (context()), DoorbellPress on <root>/event. AlexaDirective gains deferred(), error(type, message), sceneStarted() and sceneStopped(); thermostat error types go out in the namespace of the thermostat. The helpers are add*Prop, the Add*Prop names stay; a temperature keeps its scale (69 FAHRENHEIT, was 20.56 CELSIUS). messageId is a version 4 UUID from the hardware random source, where rand() seeded per second gave two messages one id. basicLight: static RAM 30,540 B (-76), flash 334,981 B (+1,280); 112 host tests (bridge logic 52, messages 19, new). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
42af413a6e
commit
3215457f91
12 changed files with 1093 additions and 90 deletions
|
|
@ -882,6 +882,33 @@ void test_wait_is_counted_across_the_overflow_of_millis()
|
|||
TEST_ASSERT_TRUE(backoff.due(744, since));
|
||||
}
|
||||
|
||||
// --- message id ---
|
||||
|
||||
void test_message_id_is_a_uuid_of_version_4()
|
||||
{
|
||||
const uint32_t random[4] = {0x01234567u, 0x89abcdefu, 0xfedcba98u, 0x76543210u};
|
||||
char id[ALEXA_MESSAGE_ID_SIZE];
|
||||
|
||||
TEST_ASSERT_TRUE(AlexaBridgeLogic::formatMessageId(random, id, sizeof(id)));
|
||||
// The digits of the numbers in their order; the 13th is the version, the 17th has the variant in its two
|
||||
// highest bits (f, 1111, becomes b, 1011)
|
||||
TEST_ASSERT_EQUAL_STRING("01234567-89ab-4def-bedc-ba9876543210", id);
|
||||
|
||||
const uint32_t zeros[4] = {0, 0, 0, 0};
|
||||
TEST_ASSERT_TRUE(AlexaBridgeLogic::formatMessageId(zeros, id, sizeof(id)));
|
||||
TEST_ASSERT_EQUAL_STRING("00000000-0000-4000-8000-000000000000", id);
|
||||
}
|
||||
|
||||
void test_message_id_needs_a_buffer_of_its_size()
|
||||
{
|
||||
const uint32_t random[4] = {1, 2, 3, 4};
|
||||
char id[ALEXA_MESSAGE_ID_SIZE] = "untouched";
|
||||
|
||||
TEST_ASSERT_FALSE(AlexaBridgeLogic::formatMessageId(random, id, ALEXA_MESSAGE_ID_SIZE - 1));
|
||||
TEST_ASSERT_EQUAL_STRING("", id);
|
||||
TEST_ASSERT_FALSE(AlexaBridgeLogic::formatMessageId(random, nullptr, ALEXA_MESSAGE_ID_SIZE));
|
||||
}
|
||||
|
||||
// --- time ---
|
||||
|
||||
void test_timestamp_is_iso_8601_in_utc()
|
||||
|
|
@ -984,6 +1011,8 @@ int main(int, char **)
|
|||
RUN_TEST(test_wait_keeps_doubling_across_sessions_that_end_early);
|
||||
RUN_TEST(test_attempt_that_fails_after_a_long_session_does_not_start_the_wait_over);
|
||||
RUN_TEST(test_length_of_a_session_is_counted_across_the_overflow_of_millis);
|
||||
RUN_TEST(test_message_id_is_a_uuid_of_version_4);
|
||||
RUN_TEST(test_message_id_needs_a_buffer_of_its_size);
|
||||
RUN_TEST(test_attempt_is_due_when_the_wait_is_over);
|
||||
RUN_TEST(test_wait_is_counted_across_the_overflow_of_millis);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue