Skip to content

HID Prox examples

Maxime C edited this page Apr 4, 2023 · 2 revisions

Found bellow some code examples on how to use HID Prox chip functionality with this sdk.\ All examples assume you already have a valid chip object. Please see How to Use Liblogicalaccess first.

Configure your project

Normally, using specific chip functionality means you cannot use the generic abstraction layer / plug-in architecture provided by the core library to achieve your goal.\ But HID Prox doesn't have any specific features except Access Control which is available through the abstraction layer, it is highly recommended to use the abstraction layer. If anyway you still want strong dependency, your project has to include HID Prox plug-in headers and link with it directly.

Add the following include to your code file:

#include <prox/proxchip.hpp>

On Windows, link with ''ProxCards.lib''.\ On Linux, link with ''libProxCards.so''.

Examples

std::shared_ptr<logicalaccess::ProxChip> proxChip = std::dynamic_pointer_cast<logicalaccess::ProxChip>(chip);

if (proxChip)
{
    std::shared_ptr<logicalaccess::ProxCardProvider> proxcp = mifareChip->getProxCardProvider();
    if (proxcp)
    {        
        // DO PROX STUFF HERE
        // DO PROX STUFF HERE
        // DO PROX STUFF HERE
    }
    else
    {
        std::cout << "The HID Prox chip doesn't have any card provider associated. Does the reader support it?" << std::endl;
    }
}
else
{
    std::cout << "Not a HID Prox chip." << std::endl;
}

Read the access control identifier

See read access control format for an example with Wiegand 26 (H10301) format.

Write an access control identifier

Only HID Global and there internal solutions are allowed to encode HID Prox chips.\ Even if it is technically possible, patents and legal risk discourage reader manufacturers to offer this kind of functionality.

Get the full PACS bits

To do so you have to link directly with the HID Prox plug-in as describe on the top of this page.

#include <prox/proxaccesscontrolcardservice.hpp>
std::shared_ptr<logicalaccess::ProxAccessControlCardService> proxacService = std::dynamic_pointer_cast<logicalaccess::ProxAccessControlCardService>(acService);

if (proxacService)
{
    std::vector<unsigned char> pacsBits = proxacService->getPACSBits();
    std::cout << "PACS Bits is " << pacsBits.size() << " bytes long." << std::endl;
}