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,38 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2020 - 2025 Pionix GmbH and Contributors to EVerest
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
namespace charge_bridge::filesystem_utils {
|
||||
|
||||
bool read_from_file_partial(const fs::path& file_path, const std::size_t byte_count, std::string& out_data);
|
||||
|
||||
bool read_from_file(const fs::path& file_path, std::string& out_data);
|
||||
|
||||
/// @brief Process the file in chunks with the provided function. If the process function
|
||||
/// returns false, this function will also immediately return
|
||||
/// @return True if the file was properly opened false otherwise
|
||||
bool process_file(const fs::path& file_path, std::size_t buffer_size,
|
||||
std::function<bool(const std::vector<std::uint8_t>&, bool last_chunk)>&& func);
|
||||
|
||||
bool process_file(std::ifstream& file, std::size_t buffer_size,
|
||||
std::function<bool(const std::vector<std::uint8_t>&, bool last_chunk)>&& func);
|
||||
|
||||
struct CryptSignedHeader {
|
||||
std::string firmware_version; // max 32 bytes long string describing the fw version
|
||||
std::uint8_t sig_len = 0;
|
||||
std::vector<std::uint8_t> signature; // length = sig_len
|
||||
std::uint8_t num_sectors = 0; // global one-byte value
|
||||
std::array<std::uint8_t, 16> iv{}; // 16-byte IV from file #2
|
||||
};
|
||||
|
||||
bool read_crypt_signed_header(const fs::path& path, CryptSignedHeader& hdr, std::uint32_t& image_offset);
|
||||
|
||||
} // namespace charge_bridge::filesystem_utils
|
||||
@@ -0,0 +1,10 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2020 - 2025 Pionix GmbH and Contributors to EVerest
|
||||
#pragma once
|
||||
#include <iostream>
|
||||
|
||||
namespace charge_bridge::utilities {
|
||||
|
||||
std::ostream& print_error(std::string const& device, std::string const& unit, int status);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2020 - 2025 Pionix GmbH and Contributors to EVerest
|
||||
#pragma once
|
||||
|
||||
#include <charge_bridge/charge_bridge.hpp>
|
||||
|
||||
namespace charge_bridge::utilities {
|
||||
|
||||
std::vector<charge_bridge_config> parse_config_multi(std::string const& config_file);
|
||||
} // namespace charge_bridge::utilities
|
||||
@@ -0,0 +1,18 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2020 - 2025 Pionix GmbH and Contributors to EVerest
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
|
||||
namespace charge_bridge::utilities {
|
||||
|
||||
// Converts a struct to raw bytes
|
||||
template <typename T> static inline void struct_to_vector(const T& data_struct, std::vector<std::uint8_t>& buffer) {
|
||||
static constexpr auto struct_size = sizeof(T);
|
||||
|
||||
buffer.resize(struct_size);
|
||||
std::memcpy(buffer.data(), &data_struct, struct_size);
|
||||
}
|
||||
} // namespace charge_bridge::utilities
|
||||
@@ -0,0 +1,16 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2020 - 2025 Pionix GmbH and Contributors to EVerest
|
||||
#pragma once
|
||||
|
||||
#include <protocol/cb_config.h>
|
||||
#include <string>
|
||||
|
||||
namespace charge_bridge::utilities {
|
||||
|
||||
std::string to_string(CbCanBaudrate value);
|
||||
std::string to_string(CbUartBaudrate value);
|
||||
std::string to_string(CbUartParity value);
|
||||
std::string to_string(CbUartStopbits value);
|
||||
std::string to_string(CbUartConfig const& value);
|
||||
|
||||
} // namespace charge_bridge::utilities
|
||||
@@ -0,0 +1,18 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2020 - 2026 Pionix GmbH and Contributors to EVerest
|
||||
#pragma once
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
namespace charge_bridge::utilities {
|
||||
bool string_starts_with(std::string_view const& str, std::string_view const& pattern);
|
||||
bool string_ends_with(std::string const& str, std::string const& pattern);
|
||||
|
||||
std::string string_after_pattern(std::string_view const& str, std::string_view const& pattern);
|
||||
std::string& replace_all_in_place(std::string& source, std::string const& placeholder, std::string const& substitute);
|
||||
std::string replace_all(std::string const& source, std::string const& placeholder, std::string const& substitute);
|
||||
|
||||
std::set<std::string> csv_to_set(std::string const& str);
|
||||
|
||||
} // namespace charge_bridge::utilities
|
||||
@@ -0,0 +1,19 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2020 - 2025 Pionix GmbH and Contributors to EVerest
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace charge_bridge::utilities {
|
||||
class symlink {
|
||||
public:
|
||||
symlink(std::string const& src, std::string const& tar);
|
||||
symlink();
|
||||
bool set_link(std::string const& src, std::string const& tar);
|
||||
bool del_link();
|
||||
~symlink();
|
||||
|
||||
private:
|
||||
std::string m_tar;
|
||||
};
|
||||
} // namespace charge_bridge::utilities
|
||||
@@ -0,0 +1,35 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2020 - 2025 Pionix GmbH and Contributors to EVerest
|
||||
#pragma once
|
||||
|
||||
#include "everest/io/udp/udp_payload.hpp"
|
||||
#include <everest/io/event/fd_event_handler.hpp>
|
||||
#include <everest/io/udp/udp_socket.hpp>
|
||||
#include <optional>
|
||||
|
||||
namespace charge_bridge::utilities {
|
||||
|
||||
class sync_udp_client {
|
||||
public:
|
||||
using udp_payload = everest::lib::io::udp::udp_payload;
|
||||
using reply = std::optional<udp_payload>;
|
||||
sync_udp_client(std::string const& remote, std::uint16_t port);
|
||||
sync_udp_client(std::string const& remote, std::uint16_t port, std::uint16_t retries, std::uint16_t timeout_ms);
|
||||
reply request_reply(udp_payload const& payload);
|
||||
reply request_reply(udp_payload const& payload, std::uint16_t timeout_ms, std::uint16_t retries);
|
||||
bool tx(udp_payload const& payload);
|
||||
reply rx();
|
||||
reply rx(std::uint16_t timeout_ms);
|
||||
bool is_open();
|
||||
|
||||
private:
|
||||
void init(std::string const& remote, std::uint16_t port);
|
||||
void clear_socket();
|
||||
|
||||
std::uint16_t m_retries;
|
||||
std::uint16_t m_timeout_ms;
|
||||
everest::lib::io::udp::udp_client_socket m_udp;
|
||||
everest::lib::io::event::fd_event_handler m_handler;
|
||||
};
|
||||
|
||||
} // namespace charge_bridge::utilities
|
||||
@@ -0,0 +1,58 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2020 - 2025 Pionix GmbH and Contributors to EVerest
|
||||
#pragma once
|
||||
#include <everest_api_types/evse_board_support/API.hpp>
|
||||
#include <protocol/cb_config.h>
|
||||
#include <protocol/cb_management.h>
|
||||
#include <ryml.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace charge_bridge::utilities {
|
||||
|
||||
class yml_node_error {
|
||||
public:
|
||||
yml_node_error(c4::yml::ConstNodeRef node);
|
||||
yml_node_error(c4::yml::ConstNodeRef node, std::string const& msg);
|
||||
|
||||
c4::yml::ConstNodeRef m_node;
|
||||
std::string m_msg;
|
||||
};
|
||||
|
||||
namespace EXT_API = everest::lib::API;
|
||||
namespace EXT_API_BSP = EXT_API::V1_0::types::evse_board_support;
|
||||
|
||||
bool decode_CbGpioMode(c4::yml::ConstNodeRef const& node, CbGpioMode& rhs);
|
||||
bool decode_CbGpioPulls(c4::yml::ConstNodeRef const& node, CbGpioPulls& rhs);
|
||||
bool decode_CbUartBaudrate(c4::yml::ConstNodeRef const& node, CbUartBaudrate& rhs);
|
||||
bool decode_CbUartStopbits(c4::yml::ConstNodeRef const& node, CbUartStopbits& rhs);
|
||||
bool decode_CbUartParity(c4::yml::ConstNodeRef const& node, CbUartParity& rhs);
|
||||
bool decode_CbCanBaudrate(c4::yml::ConstNodeRef const& node, CbCanBaudrate& rhs);
|
||||
bool decode_CbRelayMode(c4::yml::ConstNodeRef const& node, CbRelayMode& rhs);
|
||||
bool decode_CbSafetyMode(c4::yml::ConstNodeRef const& node, CbSafetyMode& rhs);
|
||||
bool decode_RelayConfig(c4::yml::ConstNodeRef const& node, RelayConfig& rhs);
|
||||
bool decode_SafetyConfig(c4::yml::ConstNodeRef const& node, SafetyConfig& rhs);
|
||||
bool decode_CbGpioConfig(c4::yml::ConstNodeRef const& node, CbGpioConfig& rhs);
|
||||
bool decode_CbUartConfig(c4::yml::ConstNodeRef const& node, CbUartConfig& rhs);
|
||||
bool decode_CbCanConfig(c4::yml::ConstNodeRef const& node, CbCanConfig& rhs);
|
||||
bool decode_CbNetworkConfig(c4::yml::ConstNodeRef const& node, CbNetworkConfig& rhs);
|
||||
bool decode_Connector_type(c4::yml::ConstNodeRef const& node, EXT_API_BSP::Connector_type& rhs);
|
||||
bool decode_HardwareCapabilities(c4::yml::ConstNodeRef const& node, EXT_API_BSP::HardwareCapabilities& rhs);
|
||||
|
||||
c4::yml::ConstNodeRef const& operator>>(c4::yml::ConstNodeRef const& node, CbGpioMode& rhs);
|
||||
c4::yml::ConstNodeRef const& operator>>(c4::yml::ConstNodeRef const& node, CbGpioPulls& rhs);
|
||||
c4::yml::ConstNodeRef const& operator>>(c4::yml::ConstNodeRef const& node, CbUartBaudrate& rhs);
|
||||
c4::yml::ConstNodeRef const& operator>>(c4::yml::ConstNodeRef const& node, CbUartStopbits& rhs);
|
||||
c4::yml::ConstNodeRef const& operator>>(c4::yml::ConstNodeRef const& node, CbUartParity& rhs);
|
||||
c4::yml::ConstNodeRef const& operator>>(c4::yml::ConstNodeRef const& node, CbCanBaudrate& rhs);
|
||||
c4::yml::ConstNodeRef const& operator>>(c4::yml::ConstNodeRef const& node, CbRelayMode& rhs);
|
||||
c4::yml::ConstNodeRef const& operator>>(c4::yml::ConstNodeRef const& node, CbSafetyMode& rhs);
|
||||
c4::yml::ConstNodeRef const& operator>>(c4::yml::ConstNodeRef const& node, RelayConfig& rhs);
|
||||
c4::yml::ConstNodeRef const& operator>>(c4::yml::ConstNodeRef const& node, SafetyConfig& rhs);
|
||||
c4::yml::ConstNodeRef const& operator>>(c4::yml::ConstNodeRef const& node, CbGpioConfig& rhs);
|
||||
c4::yml::ConstNodeRef const& operator>>(c4::yml::ConstNodeRef const& node, CbUartConfig& rhs);
|
||||
c4::yml::ConstNodeRef const& operator>>(c4::yml::ConstNodeRef const& node, CbCanConfig& rhs);
|
||||
c4::yml::ConstNodeRef const& operator>>(c4::yml::ConstNodeRef const& node, CbNetworkConfig& rhs);
|
||||
c4::yml::ConstNodeRef const& operator>>(c4::yml::ConstNodeRef const& node, EXT_API_BSP::Connector_type& rhs);
|
||||
c4::yml::ConstNodeRef const& operator>>(c4::yml::ConstNodeRef const& node, EXT_API_BSP::HardwareCapabilities& rhs);
|
||||
|
||||
} // namespace charge_bridge::utilities
|
||||
Reference in New Issue
Block a user