Skip to content

Commit

Permalink
✨ (StateMachine): Transition DeepSleeping state to Terminate state on…
Browse files Browse the repository at this point in the history
… BLE events
  • Loading branch information
YannLocatelli authored and ladislas committed Jul 9, 2024
1 parent 9845606 commit b086532
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libs/RobotKit/include/StateMachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ struct StateMachine {
, sm::state::deep_sleeping + event<sm::event::charge_did_start> = X
, sm::state::deep_sleeping + event<sm::event::charge_did_stop> = X

, sm::state::deep_sleeping + event<sm::event::ble_connection> = X
, sm::state::deep_sleeping + event<sm::event::ble_disconnection> = X

, sm::state::charging + boost::sml::on_entry<_> / (sm::action::start_deep_sleep_timeout {}, sm::action::start_charging_behavior {} )
, sm::state::charging + boost::sml::on_exit<_> / (sm::action::stop_deep_sleep_timeout {}, sm::action::stop_charging_behavior {} )

Expand Down
22 changes: 22 additions & 0 deletions libs/RobotKit/tests/StateMachine_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,28 @@ TEST_F(StateMachineTest, stateDeepSleepingEventChargeDidStop)
EXPECT_TRUE(sm.is(X));
}

TEST_F(StateMachineTest, stateDeepSleepingEventBleConnection)
{
sm.set_current_states(lksm::state::deep_sleeping);

EXPECT_CALL(mock_rc, wakeUp);

sm.process_event(lksm::event::ble_connection {});

EXPECT_TRUE(sm.is(X));
}

TEST_F(StateMachineTest, stateDeepSleepingEventBleDisconnection)
{
sm.set_current_states(lksm::state::deep_sleeping);

EXPECT_CALL(mock_rc, wakeUp);

sm.process_event(lksm::event::ble_disconnection {});

EXPECT_TRUE(sm.is(X));
}

TEST_F(StateMachineTest, stateIdleEventChargeDidStart)
{
sm.set_current_states(lksm::state::idle);
Expand Down

0 comments on commit b086532

Please sign in to comment.