~aleteoryx/muditaos

ref: sign_test muditaos/module-bluetooth/Bluetooth/doc/README.md -rw-r--r-- 1.5 KiB
a217eeb3 — Dawid Wojtas [BH-2024] Fix lack of alarm directory after updating software 1 year, 5 months ago

#How to add new command handling in bluetooth

remember Blutetooth Worker command handling uses double dispatch (if you are not familiar with the technique, see: double dispatch example)

#To add a new event:

  1. In event/Events.hpp
    • Add new event
    • remember to
      • inherit from base event
      • add override on dispatch function
    • Events may have const data inside, in such case please:
      • set const data in constructor
      • set data as const in structure
      • do not add needless getter/setter
  2. In AbstractController.hpp:
    • Add new event to forward declaration
    • Add new event handler in the class below
  3. In WorkerController.{hpp,cpp}
    • Add new event handler to worker controller implementation
    • Add event handling in the desired state
    • When adding new Handler or Event in the sml state machine please:
      • define structure per each event handler
      • this way we have it's name in the logs wich is super helpful
  4. In test catalog
    • add unit tests regarding the state added
    • please add tests for both: success and failure scenarions, not only the green path

#Bluetooth command handling state diagram

#To generate state machine diagram

make bluetooth_uml then ./bluetooth_uml > bluetooth_uml.puml and generate diagram via plantuml from that