Main class for the Rpleth module.  
 More...
#include <RplethModule.hpp>
 | 
| static std::vector< uint8_t >  | card_convert_from_text (const std::pair< std::string, int > &card_info) | 
|   | Convert a card number from textual hexadecimal representation to a 8 bytes byte-vector in Network Byte Order.  More...
  | 
|   | 
 | 
| virtual void  | handle_pipe () | 
|   | The base class register the pipe_ socket to its reactor_ so that this function is called when the pipe_ is available from reading.  More...
  | 
|   | 
| virtual void  | handle_control () | 
|   | Handle called when a message on the module's control socket arrives.  More...
  | 
|   | 
| virtual void  | dump_additional_config (zmqpp::message *out) const | 
|   | Dump additional configuration (for example module specific config file).  More...
  | 
|   | 
| void  | dump_config (ConfigManager::ConfigFormat fmt, zmqpp::message *out_msg) const | 
|   | Fills a message with the module's configuration information.  More...
  | 
|   | 
| void  | config_check (const std::string &obj_name, ConfigChecker::ObjectType type) | 
|   | An helper that checks configuration the existence of some objects.  More...
  | 
|   | 
| void  | config_check (const std::string &obj_name) | 
|   | An helper that checks configuration the existence of some objects.  More...
  | 
|   | 
| zmqpp::context &  | ctx_ | 
|   | A reference to the ZeroMQ context in case you need it to create additional socket.  More...
  | 
|   | 
| zmqpp::socket &  | pipe_ | 
|   | A reference to the pair socket that link back to the module manager.  More...
  | 
|   | 
| boost::property_tree::ptree  | config_ | 
|   | The configuration tree passed to the start_module function.  More...
  | 
|   | 
| CoreUtilsPtr  | utils_ | 
|   | Pointer to the core utils, which gives access to scheduler and others.  More...
  | 
|   | 
| bool  | is_running_ | 
|   | Boolean indicating whether the main loop should run or not.  More...
  | 
|   | 
| zmqpp::socket  | control_ | 
|   | Control REP socket.  More...
  | 
|   | 
| zmqpp::reactor  | reactor_ | 
|   | The reactor object we poll() on in the main loop.  More...
  | 
|   | 
| std::string  | name_ | 
|   | 
Main class for the Rpleth module. 
For configuration information, see Configuration Options . 
Definition at line 43 of file RplethModule.hpp.
 
◆ RplethModule() [1/2]
      
        
          | RplethModule::RplethModule  | 
          ( | 
          zmqpp::context &  | 
          ctx,  | 
        
        
           | 
           | 
          zmqpp::socket *  | 
          pipe,  | 
        
        
           | 
           | 
          const boost::property_tree::ptree &  | 
          cfg,  | 
        
        
           | 
           | 
          CoreUtilsPtr  | 
          utils  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
 
◆ ~RplethModule()
      
        
          | RplethModule::~RplethModule  | 
          ( | 
           | ) | 
           | 
        
      
 
 
◆ RplethModule() [2/2]
  
  
      
        
          | Leosac::Module::Rpleth::RplethModule::RplethModule  | 
          ( | 
          const RplethModule &  | 
           | ) | 
           | 
         
       
   | 
  
delete   | 
  
 
 
◆ card_convert_from_text()
  
  
      
        
          | std::vector< uint8_t > RplethModule::card_convert_from_text  | 
          ( | 
          const std::pair< std::string, int > &  | 
          card_info | ) | 
           | 
         
       
   | 
  
static   | 
  
 
Convert a card number from textual hexadecimal representation to a 8 bytes byte-vector in Network Byte Order. 
The format (Wiegand 26, 32, ...) is ingored. The whole frame will be used to compute the card serial number returned in the vector.
- Parameters
 - 
  
    | card_info | pair (string, int) with hex representation and number of bit.  | 
  
   
Definition at line 386 of file RplethModule.cpp.
 
 
◆ client_connected()
  
  
      
        
          | bool RplethModule::client_connected  | 
          ( | 
          const std::string &  | 
          identity | ) | 
           const | 
         
       
   | 
  
private   | 
  
 
 
◆ client_failed()
  
  
      
        
          | bool RplethModule::client_failed  | 
          ( | 
          const std::string &  | 
          identity | ) | 
           const | 
         
       
   | 
  
private   | 
  
 
Is the client in an invalid state ? 
- Returns
 - true if the client is in the 
clients_failed_ list.  
Definition at line 337 of file RplethModule.cpp.
 
 
◆ get_dhcp_state()
◆ get_network_config()
  
  
      
        
          | boost::property_tree::ptree RplethModule::get_network_config  | 
          ( | 
           | ) | 
           | 
         
       
   | 
  
private   | 
  
 
Retrieve the network configuration from the core. 
Definition at line 565 of file RplethModule.cpp.
 
 
◆ handle_client_msg()
  
  
      
        
          | bool RplethModule::handle_client_msg  | 
          ( | 
          const std::string &  | 
          client_identity,  | 
         
        
           | 
           | 
          CircularBuffer &  | 
          buf  | 
         
        
           | 
          ) | 
           |  | 
         
       
   | 
  
private   | 
  
 
Try to handle a client message. 
This is called when we received any amount of data, for any client. If there isn't enough data to handle a rpleth message, this does nothing.
It returns true unless sending a packing would have blocked.
- Note
 - There is a possible race between client disconnection and notification, so it sometime happens that we attempt to send data to an already disconnected client. This would block forever so we use 
dont_wait flag and report a failed client by returning false. Message from failed client are ignored until reception of disconnection notification.  
Definition at line 110 of file RplethModule.cpp.
 
 
◆ handle_client_packet()
If we successfully built a packet, lets handle it. 
Definition at line 140 of file RplethModule.cpp.
 
 
◆ handle_socket()
  
  
      
        
          | void RplethModule::handle_socket  | 
          ( | 
           | ) | 
           | 
         
       
   | 
  
private   | 
  
 
 
◆ handle_wiegand_event()
  
  
      
        
          | void RplethModule::handle_wiegand_event  | 
          ( | 
           | ) | 
           | 
         
       
   | 
  
private   | 
  
 
We received a message (on the BUS, from the wiegand reader we watch), that means a card was inserted. 
We store all cards until we receive a RECEIVE_CARDS command. 
Definition at line 196 of file RplethModule.cpp.
 
 
◆ operator=()
◆ process_config()
  
  
      
        
          | void RplethModule::process_config  | 
          ( | 
           | ) | 
           | 
         
       
   | 
  
private   | 
  
 
 
◆ push_network_config()
  
  
      
        
          | bool RplethModule::push_network_config  | 
          ( | 
          const boost::property_tree::ptree &  | 
          tree | ) | 
           | 
         
       
   | 
  
private   | 
  
 
Push a configuration to the core as the new network config. 
Definition at line 553 of file RplethModule.cpp.
 
 
◆ restart_reader()
  
  
      
        
          | void RplethModule::restart_reader  | 
          ( | 
           | ) | 
           | 
         
       
   | 
  
private   | 
  
 
 
◆ rpleth_beep()
◆ rpleth_greenled()
  
  
      
        
          | void RplethModule::rpleth_greenled  | 
          ( | 
          const RplethPacket &  | 
          p | ) | 
           | 
         
       
   | 
  
private   | 
  
 
 
◆ rpleth_publish_card()
  
  
      
        
          | void RplethModule::rpleth_publish_card  | 
          ( | 
           | ) | 
           | 
         
       
   | 
  
private   | 
  
 
Flush the cards_read_stream_ list to clients. 
This will notify client of all card that we read. 
Definition at line 343 of file RplethModule.cpp.
 
 
◆ rpleth_receive_cards()
Handle Rpleth ReceiveUnpresentedCards command. 
This sends cards that were read to the Rpleth client. 
- Returns
 - a response packet with the cards, ascii format, separated by a pipe. 
 
Definition at line 254 of file RplethModule.cpp.
 
 
◆ rpleth_send_cards()
  
  
      
        
          | void RplethModule::rpleth_send_cards  | 
          ( | 
          const RplethPacket &  | 
          packet | ) | 
           | 
         
       
   | 
  
private   | 
  
 
Handle Rpleth SendCards command: we will store the list of received card somewhere safe. 
Cards are text data, separated by a pipe. 
Definition at line 225 of file RplethModule.cpp.
 
 
◆ set_dhcp_state()
◆ set_reader_gw()
◆ set_reader_ip()
◆ set_reader_netmask()
◆ buffer_size
  
  
      
        
          | constexpr int Leosac::Module::Rpleth::RplethModule::buffer_size = 8192 | 
         
       
   | 
  
staticprivate   | 
  
 
 
◆ bus_sub_
  
  
      
        
          | zmqpp::socket Leosac::Module::Rpleth::RplethModule::bus_sub_ | 
         
       
   | 
  
private   | 
  
 
Subscribe to the message bus and listen for event sent by the wiegand reader we watch. 
Definition at line 214 of file RplethModule.hpp.
 
 
◆ cards_pushed_
  
  
      
        
          | std::list<std::string> Leosac::Module::Rpleth::RplethModule::cards_pushed_ | 
         
       
   | 
  
private   | 
  
 
 
◆ cards_read_
  
  
      
        
          | std::list<std::string> Leosac::Module::Rpleth::RplethModule::cards_read_ | 
         
       
   | 
  
private   | 
  
 
Valid cards our Wiegand reader read: cards that were not pushed are not stored here. 
Definition at line 193 of file RplethModule.hpp.
 
 
◆ cards_read_stream_
  
  
      
        
          | std::list<std::pair<std::string, int> > Leosac::Module::Rpleth::RplethModule::cards_read_stream_ | 
         
       
   | 
  
private   | 
  
 
If stream mode is on, all cards read are stored here. 
String data of card and number of bit read. 
Definition at line 199 of file RplethModule.hpp.
 
 
◆ clients_
  
  
      
        
          | std::map<std::string, CircularBuffer> Leosac::Module::Rpleth::RplethModule::clients_ | 
         
       
   | 
  
private   | 
  
 
 
◆ core_
  
  
      
        
          | zmqpp::socket Leosac::Module::Rpleth::RplethModule::core_ | 
         
       
   | 
  
private   | 
  
 
 
◆ ctx_
  
  
      
        
          | zmqpp::context& Leosac::Module::Rpleth::RplethModule::ctx_ | 
         
       
   | 
  
private   | 
  
 
 
◆ failed_clients_
  
  
      
        
          | std::vector<std::string> Leosac::Module::Rpleth::RplethModule::failed_clients_ | 
         
       
   | 
  
private   | 
  
 
Client that are "failed". 
A client is considered fail if a send() to them would have block. It's likely they are disconnected but we dont know it yet. Message from those client are ignored. 
Definition at line 232 of file RplethModule.hpp.
 
 
◆ reader_
◆ server_
  
  
      
        
          | zmqpp::socket Leosac::Module::Rpleth::RplethModule::server_ | 
         
       
   | 
  
private   | 
  
 
 
◆ stream_mode_
  
  
      
        
          | bool Leosac::Module::Rpleth::RplethModule::stream_mode_ | 
         
       
   | 
  
private   | 
  
 
 
The documentation for this class was generated from the following files: