Add extracted tools: CitrineOS, OpenOCPP, ShapeShifter
- CitrineOS core extracted (CSMS OCPP 2.0.1) - OpenOCPP extracted (firmware OCPP 1.6J/2.0.1) - ShapeShifter library installed (pip install -e) - ShapeShifter specification extracted - EVerest extracted TODO updated with progress
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2020 - 2025 Pionix GmbH and Contributors to EVerest
|
||||
|
||||
#include "auth_token_providerImpl.hpp"
|
||||
|
||||
#include <everest/helpers/helpers.hpp>
|
||||
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
||||
namespace module {
|
||||
namespace main {
|
||||
|
||||
static std::string nfcidToString(const std::vector<std::uint8_t>& nfcid) {
|
||||
std::ostringstream oss;
|
||||
|
||||
for (std::uint16_t byte : nfcid) {
|
||||
oss << std::setfill('0') << std::setw(2) << std::uppercase << std::hex << byte;
|
||||
}
|
||||
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
void auth_token_providerImpl::detected_rfid_token_callback(
|
||||
const std::pair<std::string, std::vector<std::uint8_t>>& reply) {
|
||||
auto& [protocol, nfcid] = reply;
|
||||
|
||||
const auto now = std::chrono::steady_clock::now();
|
||||
const auto debounce_interval = std::chrono::milliseconds(config.token_debounce_interval_ms);
|
||||
|
||||
types::authorization::ProvidedIdToken provided_token;
|
||||
|
||||
try {
|
||||
provided_token.id_token = {nfcidToString(nfcid), types::authorization::string_to_id_token_type(protocol)};
|
||||
} catch (const std::out_of_range& e) {
|
||||
return;
|
||||
}
|
||||
|
||||
provided_token.authorization_type = types::authorization::AuthorizationType::RFID;
|
||||
|
||||
if (now < last_rfid_submit + debounce_interval) {
|
||||
EVLOG_debug << "Ignoring rfid/nfc token (debouncing): " << protocol << ": "
|
||||
<< everest::helpers::redact(provided_token);
|
||||
return;
|
||||
}
|
||||
|
||||
EVLOG_debug << "Publishing new rfid/nfc token: " << protocol << ": " << everest::helpers::redact(provided_token);
|
||||
|
||||
publish_provided_token(provided_token);
|
||||
last_rfid_submit = now;
|
||||
}
|
||||
|
||||
void auth_token_providerImpl::error_log_callback(const std::string& message) {
|
||||
EVLOG_warning << "NxpNfcFrontend: " << message;
|
||||
}
|
||||
|
||||
void auth_token_providerImpl::init() {
|
||||
try {
|
||||
nxpNfcFrontend = std::make_unique<NxpNfcFrontendDataSource>();
|
||||
} catch (const std::exception& e) {
|
||||
EVLOG_error << "Failed to initialize NxpNfcFrontend: " << e.what();
|
||||
}
|
||||
nxpNfcFrontend->setDetectionCallback(
|
||||
[this](auto&&... args) { this->detected_rfid_token_callback(std::forward<decltype(args)>(args)...); });
|
||||
nxpNfcFrontend->setErrorLogCallback(
|
||||
[this](auto&&... args) { this->error_log_callback(std::forward<decltype(args)>(args)...); });
|
||||
}
|
||||
|
||||
void auth_token_providerImpl::ready() {
|
||||
if (nxpNfcFrontend) {
|
||||
nxpNfcFrontend->run();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace main
|
||||
} // namespace module
|
||||
@@ -0,0 +1,81 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2020 - 2025 Pionix GmbH and Contributors to EVerest
|
||||
#ifndef MAIN_AUTH_TOKEN_PROVIDER_IMPL_HPP
|
||||
#define MAIN_AUTH_TOKEN_PROVIDER_IMPL_HPP
|
||||
|
||||
//
|
||||
// AUTO GENERATED - MARKED REGIONS WILL BE KEPT
|
||||
// template version 3
|
||||
//
|
||||
|
||||
#include <generated/interfaces/auth_token_provider/Implementation.hpp>
|
||||
|
||||
#include "../NxpNfcFrontendTokenProvider.hpp"
|
||||
|
||||
// ev@75ac1216-19eb-4182-a85c-820f1fc2c091:v1
|
||||
// insert your custom include headers here
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <memory>
|
||||
|
||||
#ifndef BUILD_WITH_NAMED_PIPE_DATASOURCE
|
||||
#include <nxpnfcfrontend.hpp>
|
||||
using NxpNfcFrontendDataSource = NxpNfcFrontendWrapper::NxpNfcFrontend;
|
||||
#endif // BUILD_WITH_NAMED_PIPE_DATASOURCE
|
||||
|
||||
#ifdef BUILD_WITH_NAMED_PIPE_DATASOURCE
|
||||
#include <namedPipeDataSource.hpp>
|
||||
using NxpNfcFrontendDataSource = NamedPipeDataSource;
|
||||
#endif // BUILD_WITH_NAMED_PIPE_DATASOURCE
|
||||
// ev@75ac1216-19eb-4182-a85c-820f1fc2c091:v1
|
||||
|
||||
namespace module {
|
||||
namespace main {
|
||||
|
||||
struct Conf {
|
||||
int token_debounce_interval_ms;
|
||||
};
|
||||
|
||||
class auth_token_providerImpl : public auth_token_providerImplBase {
|
||||
public:
|
||||
auth_token_providerImpl() = delete;
|
||||
auth_token_providerImpl(Everest::ModuleAdapter* ev, const Everest::PtrContainer<NxpNfcFrontendTokenProvider>& mod,
|
||||
Conf& config) :
|
||||
auth_token_providerImplBase(ev, "main"), mod(mod), config(config){};
|
||||
|
||||
// ev@8ea32d28-373f-4c90-ae5e-b4fcc74e2a61:v1
|
||||
// insert your public definitions here
|
||||
// ev@8ea32d28-373f-4c90-ae5e-b4fcc74e2a61:v1
|
||||
|
||||
protected:
|
||||
// no commands defined for this interface
|
||||
|
||||
// ev@d2d1847a-7b88-41dd-ad07-92785f06f5c4:v1
|
||||
// insert your protected definitions here
|
||||
// ev@d2d1847a-7b88-41dd-ad07-92785f06f5c4:v1
|
||||
|
||||
private:
|
||||
const Everest::PtrContainer<NxpNfcFrontendTokenProvider>& mod;
|
||||
const Conf& config;
|
||||
|
||||
virtual void init() override;
|
||||
virtual void ready() override;
|
||||
|
||||
// ev@3370e4dd-95f4-47a9-aaec-ea76f34a66c9:v1
|
||||
// insert your private definitions here
|
||||
void detected_rfid_token_callback(const std::pair<std::string, std::vector<std::uint8_t>>&);
|
||||
void error_log_callback(const std::string&);
|
||||
|
||||
std::unique_ptr<NxpNfcFrontendDataSource> nxpNfcFrontend;
|
||||
std::chrono::steady_clock::time_point last_rfid_submit{};
|
||||
// ev@3370e4dd-95f4-47a9-aaec-ea76f34a66c9:v1
|
||||
};
|
||||
|
||||
// ev@3d7da0ad-02c2-493d-9920-0bbbd56b9876:v1
|
||||
// insert other definitions here
|
||||
// ev@3d7da0ad-02c2-493d-9920-0bbbd56b9876:v1
|
||||
|
||||
} // namespace main
|
||||
} // namespace module
|
||||
|
||||
#endif // MAIN_AUTH_TOKEN_PROVIDER_IMPL_HPP
|
||||
Reference in New Issue
Block a user