MakerLabs ACM
firmware/

Documentation

See firmware/ Documentation

Classes

class  HIDGlobalReader
 
struct  HIDGlobalTagID
 
struct  TagRead
 
class  WiegandReader
 
struct  AppActorState
 
struct  AuthActorState
 
struct  DisplayActorState
 
struct  MachineActorState
 
struct  RFIDReaderActorState
 

Typedefs

typedef void(* TimerCallbackFunction) (void *)
 
using TagBits = std::bitset< 26 >
 
using string_view = std::experimental::string_view
 
using DisplayIntentFlatbuffer = flatbuffers::DetachedBuffer
 
using ActivityFlatbuffer = flatbuffers::DetachedBuffer
 
using LogFlatbuffer = flatbuffers::DetachedBuffer
 
using UserFlatbuffer = flatbuffers::DetachedBuffer
 
using string = std::string
 
using string_view = std::experimental::string_view
 
using RequestPayloadFlatbuffer = flatbuffers::DetachedBuffer
 
using UserFlatbuffer = flatbuffers::DetachedBuffer
 
using MutableUserFlatbuffer = std::vector< uint8_t >
 
using MutableActivityFlatbuffer = std::vector< uint8_t >
 
using MutableRequestPayloadFlatbuffer = std::vector< uint8_t >
 
using string = std::string
 
using string_view = std::experimental::string_view
 
using string = std::string
 
using string_view = std::experimental::string_view
 
using string_view = std::experimental::string_view
 
using string = std::string
 
using Timestamp = std::chrono::time_point< std::chrono::system_clock >
 

Global Functions

void beep_timer_isr (void *userdata)
 
void hold_timer_isr (void *userdata)
 
bool operator== (const HIDGlobalTagID &lhs, const HIDGlobalTagID &rhs)
 
static void wiegand_gpio_isr_handler (void *arg)
 
auto generate_activity (const string_view machine_id_str, const ActivityType activity_type, const string_view tag_id_str, const int usage_seconds) -> ActivityFlatbuffer
 
auto generate_log (const string_view machine_id_str, const LogSeverity severity, const string_view message_str) -> LogFlatbuffer
 
auto generate_show_user_details_from_user (const ACM::User *user) -> DisplayIntentFlatbuffer
 
auto generate_progress_bar (const std::experimental::string_view message, const uint32_t progress, const TimeDuration duration, const Icon icon) -> DisplayIntentFlatbuffer
 
auto generate_show_user_details (const std::experimental::string_view message, const std::experimental::string_view email, const std::experimental::string_view makerlabs_id, const std::experimental::string_view tag_id) -> DisplayIntentFlatbuffer
 
auto generate_activity (const std::experimental::string_view machine_id_str, const ACM::ActivityType activity_type, const std::experimental::string_view tag_id_str, const int usage_seconds=0) -> ActivityFlatbuffer
 
auto generate_log (const std::experimental::string_view machine_id_str, const ACM::LogSeverity severity, const std::experimental::string_view message_str) -> LogFlatbuffer
 
auto generate_progress_bar (const std::experimental::string_view message, const uint32_t progress, const TimeDuration duration, const Display::Icon icon=Display::Icon::None) -> DisplayIntentFlatbuffer
 
auto send_progress_bar (const DisplayIntentFlatbuffer &display_intent_flatbuf) -> bool
 
auto send_activity (const ActivityFlatbuffer &activity_mutable_buf) -> bool
 
auto app_actor_behaviour (const Pid &self, StatePtr &_state, const Message &message) -> ResultUnion
 
auto auth_actor_behaviour (const Pid &self, StatePtr &_state, const Message &message) -> ResultUnion
 
static void motors_gpio_isr_handler (void *arg)
 
auto machine_actor_behaviour (const Pid &self, StatePtr &_state, const Message &message) -> ResultUnion
 
void app_main ()
 
auto rfid_reader_actor_behaviour (const Pid &self, StatePtr &_state, const Message &message) -> ResultUnion
 
auto start_app () -> bool
 
auto start_request_manager (const Pid &sup_pid, const Message &message) -> ResultUnion
 
auto start_request_manager (const ActorModel::Pid &sup_pid, const ActorModel::Message &message) -> ActorModel::ResultUnion
 
 HIDGlobalReader::HIDGlobalReader (const WiegandReader::Config &config) noexcept
 
auto HIDGlobalReader::scanning_fsm () -> void
 
auto HIDGlobalReader::scan_tag () -> MaybeTagId
 
auto HIDGlobalReader::beep (TimeDuration duration) -> void
 
 HIDGlobalTagID::HIDGlobalTagID () noexcept
 
 HIDGlobalTagID::HIDGlobalTagID (const std::bitset< 26 > &bits) noexcept
 Parse a 26-bit HID Global iClass tag: validate parity, then decode facility_code and card_number More...
 
 WiegandReader::WiegandReader (const Config &config={})
 
bool WiegandReader::set_hold (bool enabled)
 
bool WiegandReader::set_red_led (bool enabled)
 
bool WiegandReader::set_green_led (bool enabled)
 
bool WiegandReader::set_beeper (bool enabled)
 
TagReadEvent WiegandReader::get_current_tag ()
 

Global Variables

static constexpr auto TIMER_DIVIDER = 16
 
static constexpr timer_idx_t BEEP_TIMER_IDX = static_cast<timer_idx_t>(0)
 
static constexpr timer_idx_t HOLD_TIMER_IDX = static_cast<timer_idx_t>(1)
 
static constexpr auto max_bit_interval = 100ms
 
static constexpr auto max_tag_active_interval = 2s
 
constexpr char TAG [] = "app_actor"
 
constexpr char TAG [] = "auth_actor"
 
constexpr char TAG [] = "display_actor"
 
constexpr char TAG [] = "machine_actor"
 
EventGroupHandle_t network_event_group
 
static int boot_count = 0
 
static wl_handle_t s_wl_handle = WL_INVALID_HANDLE
 
constexpr char TAG [] = "main"
 
constexpr char TAG [] = "rfid_reader_actor"
 
constexpr char TAG [] = "start_app"
 

Main ACM Actors

auto display_behaviour (const ActorModel::Pid &self, ActorModel::Mailbox &mailbox) -> ActorModel::ResultUnion
 
auto app_actor_behaviour (const ActorModel::Pid &self, ActorModel::StatePtr &_state, const ActorModel::Message &message) -> ActorModel::ResultUnion
 
auto auth_actor_behaviour (const ActorModel::Pid &self, ActorModel::StatePtr &_state, const ActorModel::Message &message) -> ActorModel::ResultUnion
 
auto rfid_reader_actor_behaviour (const ActorModel::Pid &self, ActorModel::StatePtr &_state, const ActorModel::Message &message) -> ActorModel::ResultUnion
 
auto machine_actor_behaviour (const ActorModel::Pid &self, ActorModel::StatePtr &_state, const ActorModel::Message &message) -> ActorModel::ResultUnion
 

Files

file  hid_global_reader.cpp
 Implementation of HIDGlobalReader.
 
file  hid_global_reader.h
 Header for HIDGlobalReader: scanning state-machine, tag bits parsing, and control of LEDs and beep function.
 
file  hid_global_tag_id.cpp
 Implementation of HIDGlobalTagID.
 
file  hid_global_tag_id.h
 
file  wiegand_reader.cpp
 Implementation of WiegandReader.
 
file  wiegand_reader.h
 
file  acm_helpers.cpp
 Implementation of acm_helpers.h.
 
file  acm_helpers.h
 
file  actors.h
 
file  app_actor.cpp
 Implementation of actor app.
 
file  auth_actor.cpp
 Implementation of actor auth.
 
file  display_actor.cpp
 Implementation of custom-loop actor display.
 
file  machine_actor.cpp
 Implementation of actor machine.
 
file  main.cpp
 
file  rfid_reader_actor.cpp
 Implementation of actor rfid_reader.
 
file  start_app.cpp
 
file  start_request_manager.cpp
 
file  start_request_manager.h
 Header for start_request_manager, ActorModel Module init function.
 

Typedef Documentation

◆ ActivityFlatbuffer

using ActivityFlatbuffer = flatbuffers::DetachedBuffer

◆ DisplayIntentFlatbuffer

using DisplayIntentFlatbuffer = flatbuffers::DetachedBuffer

◆ LogFlatbuffer

using LogFlatbuffer = flatbuffers::DetachedBuffer

◆ MutableActivityFlatbuffer

using MutableActivityFlatbuffer = std::vector<uint8_t>

◆ MutableRequestPayloadFlatbuffer

using MutableRequestPayloadFlatbuffer = std::vector<uint8_t>

◆ MutableUserFlatbuffer

using MutableUserFlatbuffer = std::vector<uint8_t>

◆ RequestPayloadFlatbuffer

using RequestPayloadFlatbuffer = flatbuffers::DetachedBuffer

◆ string [1/4]

using string = std::string

◆ string [2/4]

using string = std::string

◆ string [3/4]

using string = std::string

◆ string [4/4]

using string = std::string

◆ string_view [1/5]

using string_view = std::experimental::string_view

◆ string_view [2/5]

using string_view = std::experimental::string_view

◆ string_view [3/5]

using string_view = std::experimental::string_view

◆ string_view [4/5]

using string_view = std::experimental::string_view

◆ string_view [5/5]

using string_view = std::experimental::string_view

◆ TagBits

using TagBits = std::bitset<26>

◆ TimerCallbackFunction

typedef void(* TimerCallbackFunction) (void *)

◆ Timestamp

using Timestamp = std::chrono::time_point<std::chrono::system_clock>

◆ UserFlatbuffer [1/2]

using UserFlatbuffer = flatbuffers::DetachedBuffer

◆ UserFlatbuffer [2/2]

using UserFlatbuffer = flatbuffers::DetachedBuffer

Global Functions

◆ app_actor_behaviour() [1/2]

auto app_actor_behaviour ( const ActorModel::Pid &  self,
ActorModel::StatePtr &  _state,
const ActorModel::Message &  message 
) -> ActorModel::ResultUnion

◆ app_actor_behaviour() [2/2]

auto app_actor_behaviour ( const Pid &  self,
StatePtr &  _state,
const Message &  message 
) -> ResultUnion
Here is the call graph for this function:

◆ app_main()

void app_main ( )
Here is the call graph for this function:

◆ auth_actor_behaviour() [1/2]

auto auth_actor_behaviour ( const ActorModel::Pid &  self,
ActorModel::StatePtr &  _state,
const ActorModel::Message &  message 
) -> ActorModel::ResultUnion

◆ auth_actor_behaviour() [2/2]

auto auth_actor_behaviour ( const Pid &  self,
StatePtr &  _state,
const Message &  message 
) -> ResultUnion
Here is the call graph for this function:

◆ beep()

auto HIDGlobalReader::beep ( TimeDuration  duration) -> void

◆ beep_timer_isr()

void beep_timer_isr ( void *  userdata)

◆ display_behaviour()

auto display_behaviour ( const ActorModel::Pid &  self,
ActorModel::Mailbox &  mailbox 
) -> ActorModel::ResultUnion
Here is the call graph for this function:

◆ generate_activity() [1/2]

auto generate_activity ( const string_view  machine_id_str,
const ActivityType  activity_type,
const string_view  tag_id_str,
const int  usage_seconds 
) -> ActivityFlatbuffer

◆ generate_activity() [2/2]

auto generate_activity ( const std::experimental::string_view  machine_id_str,
const ACM::ActivityType  activity_type,
const std::experimental::string_view  tag_id_str,
const int  usage_seconds = 0 
) -> ActivityFlatbuffer

◆ generate_log() [1/2]

auto generate_log ( const std::experimental::string_view  machine_id_str,
const ACM::LogSeverity  severity,
const std::experimental::string_view  message_str 
) -> LogFlatbuffer

◆ generate_log() [2/2]

auto generate_log ( const string_view  machine_id_str,
const LogSeverity  severity,
const string_view  message_str 
) -> LogFlatbuffer

◆ generate_progress_bar() [1/2]

auto generate_progress_bar ( const std::experimental::string_view  message,
const uint32_t  progress,
const TimeDuration  duration,
const Display::Icon  icon = Display::Icon::None 
) -> DisplayIntentFlatbuffer

◆ generate_progress_bar() [2/2]

auto generate_progress_bar ( const std::experimental::string_view  message,
const uint32_t  progress,
const TimeDuration  duration,
const Icon  icon 
) -> DisplayIntentFlatbuffer

◆ generate_show_user_details()

◆ generate_show_user_details_from_user()

auto generate_show_user_details_from_user ( const ACM::User *  user) -> DisplayIntentFlatbuffer

◆ get_current_tag()

WiegandReader::TagReadEvent WiegandReader::get_current_tag ( )
Here is the call graph for this function:

◆ HIDGlobalReader()

HIDGlobalReader::HIDGlobalReader ( const WiegandReader::Config &  config)
explicitnoexcept
Here is the call graph for this function:

◆ HIDGlobalTagID() [1/2]

HIDGlobalTagID::HIDGlobalTagID ( )
noexcept

◆ HIDGlobalTagID() [2/2]

HIDGlobalTagID::HIDGlobalTagID ( const std::bitset< 26 > &  bits)
explicitnoexcept

Parse a 26-bit HID Global iClass tag: validate parity, then decode facility_code and card_number

Parameters
bitsBitset representation of 26-bit tag read
Note
Parsed according to "Standard" 26-Bit Wiegand Format as defined in: https://www.hidglobal.com/sites/default/files/hid-understanding_card_data_formats-wp-en.pdf

◆ hold_timer_isr()

void hold_timer_isr ( void *  userdata)

◆ machine_actor_behaviour() [1/2]

auto machine_actor_behaviour ( const ActorModel::Pid &  self,
ActorModel::StatePtr &  _state,
const ActorModel::Message &  message 
) -> ActorModel::ResultUnion

◆ machine_actor_behaviour() [2/2]

auto machine_actor_behaviour ( const Pid &  self,
StatePtr &  _state,
const Message &  message 
) -> ResultUnion
Here is the call graph for this function:

◆ motors_gpio_isr_handler()

static void motors_gpio_isr_handler ( void *  arg)
static
Here is the call graph for this function:

◆ operator==()

bool operator== ( const HIDGlobalTagID &  lhs,
const HIDGlobalTagID &  rhs 
)
inline

◆ rfid_reader_actor_behaviour() [1/2]

auto rfid_reader_actor_behaviour ( const ActorModel::Pid &  self,
ActorModel::StatePtr &  _state,
const ActorModel::Message &  message 
) -> ActorModel::ResultUnion

◆ rfid_reader_actor_behaviour() [2/2]

auto rfid_reader_actor_behaviour ( const Pid &  self,
StatePtr &  _state,
const Message &  message 
) -> ResultUnion
Here is the call graph for this function:

◆ scan_tag()

auto HIDGlobalReader::scan_tag ( ) -> MaybeTagId

◆ scanning_fsm()

auto HIDGlobalReader::scanning_fsm ( ) -> void

◆ send_activity()

auto send_activity ( const ActivityFlatbuffer &  activity_mutable_buf) -> bool

◆ send_progress_bar()

auto send_progress_bar ( const DisplayIntentFlatbuffer &  display_intent_flatbuf) -> bool
Here is the call graph for this function:

◆ set_beeper()

bool WiegandReader::set_beeper ( bool  enabled)

◆ set_green_led()

bool WiegandReader::set_green_led ( bool  enabled)

◆ set_hold()

bool WiegandReader::set_hold ( bool  enabled)

◆ set_red_led()

bool WiegandReader::set_red_led ( bool  enabled)

◆ start_app()

auto start_app ( ) -> bool

Actor behaviour mapping, name registration

Single actor with multiple behaviours combined sharing the same task:

  • actor_model features: {oom_killer}
  • app features: {auth, rfid_reader, machine, app}
  • requests features: {permission_check_endpoint}
  • network_manager features: {network_manager, ntp, wifi, network_check}

DisplayActor using its own run-loop

Dynamic Module holding start_request_manager init function.

Supervisor actor which calls start_request_manager module defined above.

FirmwareUpdateActor

Initialization Messages

  • Send periodic uptime status message to app (1min)
  • Start Wifi in STA mode

(Wait for valid network connection before starting services)

  • Send periodic network_check ping message (10min)
  • Fetch time via NTP

(Wait for valid network connection and NTP time before continuing)

  • Update progress bar for startup (arbitrary estimate, 30s)
  • Send endpoint request_intent template
  • Send periodic auth message (20min)
  • Send periodic firmware_update check message (configurable)

Ready to start RFID scanning! (500ms check interval)

Here is the call graph for this function:

◆ start_request_manager() [1/2]

auto start_request_manager ( const ActorModel::Pid &  sup_pid,
const ActorModel::Message &  message 
) -> ActorModel::ResultUnion

◆ start_request_manager() [2/2]

auto start_request_manager ( const Pid &  sup_pid,
const Message &  message 
) -> ResultUnion
Here is the call graph for this function:

◆ wiegand_gpio_isr_handler()

static void wiegand_gpio_isr_handler ( void *  arg)
static
Here is the call graph for this function:

◆ WiegandReader()

WiegandReader::WiegandReader ( const Config &  config = {})
explicit

Global Variables

◆ BEEP_TIMER_IDX

constexpr timer_idx_t BEEP_TIMER_IDX = static_cast<timer_idx_t>(0)
static

◆ boot_count

int boot_count = 0
static

◆ HOLD_TIMER_IDX

constexpr timer_idx_t HOLD_TIMER_IDX = static_cast<timer_idx_t>(1)
static

◆ max_bit_interval

constexpr auto max_bit_interval = 100ms
static

◆ max_tag_active_interval

constexpr auto max_tag_active_interval = 2s
static

◆ network_event_group

EventGroupHandle_t network_event_group

◆ s_wl_handle

wl_handle_t s_wl_handle = WL_INVALID_HANDLE
static

◆ TAG [1/7]

constexpr char TAG[] = "rfid_reader_actor"

◆ TAG [2/7]

constexpr char TAG[] = "auth_actor"

◆ TAG [3/7]

constexpr char TAG[] = "display_actor"

◆ TAG [4/7]

constexpr char TAG[] = "machine_actor"

◆ TAG [5/7]

constexpr char TAG[] = "main"

◆ TAG [6/7]

constexpr char TAG[] = "app_actor"

◆ TAG [7/7]

constexpr char TAG[] = "start_app"

◆ TIMER_DIVIDER

constexpr auto TIMER_DIVIDER = 16
static