Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions aether/channels/ethernet_transport_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
// IWYU pragma: end_keeps

namespace ae {
namespace ethernet_transport_factory_internal {
static constexpr auto kTcpPacketQueueCapacity = AE_TCP_PACKET_QUEUE_SIZE;
static constexpr auto kUdpPacketQueueCapacity = AE_UDP_PACKET_QUEUE_SIZE;
} // namespace ethernet_transport_factory_internal

std::unique_ptr<ByteIStream> EthernetTransportFactory::Create(
AeContext const& ae_context, Ptr<IPoller> const& poller,
Endpoint address_port_protocol) {
Expand Down Expand Up @@ -70,8 +75,10 @@ std::unique_ptr<ByteIStream> EthernetTransportFactory::BuildTcp(
using SocketType = WinTcpSocket;
# endif

return std::make_unique<TcpTransport<SocketType, AE_TCP_PACKET_QUEUE_SIZE>>(
ae_context, poller, std::move(address_port_protocol));
using Transport = TcpTransport<
SocketType, ethernet_transport_factory_internal::kTcpPacketQueueCapacity>;
return std::make_unique<Transport>(ae_context, poller,
std::move(address_port_protocol));
# else
static_assert(false, "No transport enabled");
# endif
Expand Down Expand Up @@ -100,8 +107,10 @@ std::unique_ptr<ByteIStream> EthernetTransportFactory::BuildUdp(
# elif WIN_SOCKET_ENABLED
using SocketType = WinUdpSocket;
# endif
return std::make_unique<UdpTransport<SocketType, AE_UDP_PACKET_QUEUE_SIZE>>(
ae_context, poller, std::move(address_port_protocol));
using Transport = UdpTransport<
SocketType, ethernet_transport_factory_internal::kUdpPacketQueueCapacity>;
return std::make_unique<Transport>(ae_context, poller,
std::move(address_port_protocol));
# else
static_assert(false, "No transport enabled");
# endif
Expand Down
6 changes: 5 additions & 1 deletion aether/client_messages/p2p_message_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <optional>

#include "aether/common.h"
#include "aether/config.h"

#include "aether-objects/ptr/ptr_view.h"
#include "aether/ae_context.h"
Expand Down Expand Up @@ -60,6 +61,9 @@ class P2pStream final : public ByteIStream {
Uid const& destination() const;

private:
static constexpr auto kBufferCapacity = AE_P2P_MESSAGE_STREAM_BUFFER_CAPACITY;
using Buffer = BufferWrite<AeMessage, kBufferCapacity>;

void ConnectReceive();
void ConnectSend();

Expand All @@ -76,7 +80,7 @@ class P2pStream final : public ByteIStream {

// connection to destination cloud
std::unique_ptr<CloudServerConnections> dest_cloud_conn_;
BufferWrite<AeMessage, 100> buffer_write_;
Buffer buffer_write_;
std::unique_ptr<p2p_stream_internal::MessageSendStream> message_send_stream_;

OutDataEvent out_data_event_;
Expand Down
12 changes: 6 additions & 6 deletions aether/client_messages/p2p_safe_message_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,24 @@
#ifndef AETHER_CLIENT_MESSAGES_P2P_SAFE_MESSAGE_STREAM_H_
#define AETHER_CLIENT_MESSAGES_P2P_SAFE_MESSAGE_STREAM_H_

#include "aether/common.h"
#include "aether/ae_context.h"
#include "aether/memory.h"
#include "aether/common.h"
#include "aether/config.h"
#include "aether/actions/action_context.h"
#include "aether/memory.h"

#include "aether/safe_stream/safe_stream_config.h"
#include "aether/stream_api/istream.h"
#include "aether/stream_api/sized_packet_gate.h"
#include "aether/safe_stream/safe_stream_config.h"

namespace ae {
template <std::size_t Capacity>
class SafeStream;

static constexpr inline std::size_t kP2pSafeStreamCapacity =
AE_SAFE_STREAM_CAPACITY;
class P2pSafeStream final : public ByteIStream {
public:
using SafeStreamImpl = SafeStream<AE_SAFE_STREAM_CAPACITY>;
using SafeStreamImpl = SafeStream<kP2pSafeStreamCapacity>;

P2pSafeStream(AeContext const& ae_context, SafeStreamConfig const& config,
std::shared_ptr<ByteIStream> p2p_stream);
Expand All @@ -49,7 +50,6 @@ class P2pSafeStream final : public ByteIStream {

private:
SizedPacketGate sized_packet_gate_;
// TODO: add config
std::unique_ptr<SafeStreamImpl> safe_stream_;
std::shared_ptr<ByteIStream> p2p_stream_;
OutDataEvent out_data_event_;
Expand Down
49 changes: 49 additions & 0 deletions aether/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
#ifndef AETHER_CONFIG_H_
#define AETHER_CONFIG_H_

// Defines Aether's compile-time configuration defaults. USER_CONFIG, when
// defined, is included before these defaults so it can override them. Add new
// options to aether/tele_compile_options.h for telemetry reporting.

// IWYU pragma: begin_exports
#include <cstddef>
#include <cstdint>
Expand Down Expand Up @@ -87,6 +91,51 @@
# define AE_TCP_PACKET_QUEUE_SIZE 100
#endif // AE_TCP_PACKET_QUEUE_SIZE

// Buffered server connection write buffer entry count.
#ifndef AE_SERVER_CONNECTION_BUFFER_CAPACITY
# define AE_SERVER_CONNECTION_BUFFER_CAPACITY 10
#endif

// Root registration server selection stream write buffer entry count.
#ifndef AE_ROOT_REG_SERVER_BUFFER_CAPACITY
# define AE_ROOT_REG_SERVER_BUFFER_CAPACITY 2
#endif

// Peer-to-peer message stream write buffer entry count.
#ifndef AE_P2P_MESSAGE_STREAM_BUFFER_CAPACITY
# define AE_P2P_MESSAGE_STREAM_BUFFER_CAPACITY 10
#endif

// Cloud retrieval action pool entry count.
#ifndef AE_CLOUD_GET_CLOUD_ACTION_POOL_CAPACITY
# define AE_CLOUD_GET_CLOUD_ACTION_POOL_CAPACITY 5
#endif

// Cloud server retrieval action pool entry count.
#ifndef AE_CLOUD_GET_SERVERS_ACTION_POOL_CAPACITY
# define AE_CLOUD_GET_SERVERS_ACTION_POOL_CAPACITY 5
#endif

// Modem network operation action pool entry count.
#ifndef AE_MODEM_NETWORK_OP_ACTION_POOL_CAPACITY
# define AE_MODEM_NETWORK_OP_ACTION_POOL_CAPACITY 10
#endif

// Modem write action pool entry count.
#ifndef AE_MODEM_WRITE_ACTION_POOL_CAPACITY
# define AE_MODEM_WRITE_ACTION_POOL_CAPACITY 10
#endif

// Modem TCP packet queue entry count.
#ifndef AE_MODEM_TCP_PACKET_QUEUE_SIZE
# define AE_MODEM_TCP_PACKET_QUEUE_SIZE 10
#endif

// Modem UDP packet queue entry count.
#ifndef AE_MODEM_UDP_PACKET_QUEUE_SIZE
# define AE_MODEM_UDP_PACKET_QUEUE_SIZE 10
#endif

#ifndef AE_SUPPORT_WEBSOCKET
# define AE_SUPPORT_WEBSOCKET 1
#endif // AE_SUPPORT_WEBSOCKET
Expand Down
12 changes: 10 additions & 2 deletions aether/connection_manager/client_cloud_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include <map>
#include <optional>

#include "aether/config.h"

#include "aether-objects/obj/obj.h"
#include "aether-objects/ptr/ptr.h"
#include "aether/actions/action_pool.h"
Expand Down Expand Up @@ -72,15 +74,21 @@ class ClientCloudManager : public Obj {
ClientCloudManager() = default;

public:
static constexpr auto kGetCloudActionPoolCapacity =
AE_CLOUD_GET_CLOUD_ACTION_POOL_CAPACITY;
static constexpr auto kGetServersActionPoolCapacity =
AE_CLOUD_GET_SERVERS_ACTION_POOL_CAPACITY;

using CloudUpdateEvent =
Event<void(Uid const& uid, Result<Cloud::ptr const&, int>)>;

using GetCloudActionPool =
ActionPool<AeContext,
std::variant<client_cloud_manager_internal::GetCloudFromCache,
GetCloudFromAether>,
5>;
using GetServersPool = ActionPool<AeContext, GetServersAction, 5>;
kGetCloudActionPoolCapacity>;
using GetServersPool =
ActionPool<AeContext, GetServersAction, kGetServersActionPoolCapacity>;

explicit ClientCloudManager(ObjProp prop, ObjPtr<Aether> aether,
ObjPtr<Client> client);
Expand Down
52 changes: 31 additions & 21 deletions aether/modems/bg95_at_modem.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@

#include "aether/config.h"
#if AE_SUPPORT_MODEMS && AE_ENABLE_BG95
# include <set>
# include <memory>
# include <set>

# include "aether/ae_context.h"
# include "aether/poller/poller.h"
# include "aether/actions/action_pool.h"
# include "aether/actions/actions_queue.h"
# include "aether/actions/repeatable_task.h"
# include "aether/serial_ports/iserial_port.h"
# include "aether/ae_context.h"
# include "aether/poller/poller.h"
# include "aether/serial_ports/at_support/at_support.h"
# include "aether/serial_ports/iserial_port.h"

# include "aether/modems/imodem_driver.h"

Expand Down Expand Up @@ -95,8 +95,7 @@ class ModemStartedAlreadyOperation final : public ModemOperation {

class ModemStartOperation final : public ModemOperation {
public:
explicit ModemStartOperation(AeContext const& ae_context,
Bg95AtModem& self);
explicit ModemStartOperation(AeContext const& ae_context, Bg95AtModem& self);

private:
auto SetBaudRate(kBaudRate const rate);
Expand Down Expand Up @@ -125,8 +124,7 @@ class ModemStoppedAlreadyOperation final : public ModemOperation {

class ModemStopOperation final : public ModemOperation {
public:
explicit ModemStopOperation(AeContext const& ae_context,
Bg95AtModem& self);
explicit ModemStopOperation(AeContext const& ae_context, Bg95AtModem& self);

private:
auto Pipeline();
Expand All @@ -141,16 +139,16 @@ class ModemStopOperation final : public ModemOperation {
class ModemSetPowerSaveParamOperation final : public ModemOperation {
public:
explicit ModemSetPowerSaveParamOperation(AeContext const& /*ae_context*/,
Bg95AtModem& /*self*/,
ModemPowerSaveParam /*psp*/) {
Bg95AtModem& /*self*/,
ModemPowerSaveParam /*psp*/) {
SetResult(Ok{kIgnore});
}
};

class ModemPowerOffOperation final : public ModemOperation {
public:
explicit ModemPowerOffOperation(AeContext const& ae_context,
Bg95AtModem& self);
Bg95AtModem& self);

private:
auto Pipeline();
Expand All @@ -174,13 +172,13 @@ class Bg95AtModem final : public IModemDriver {
static constexpr std::uint16_t kModemMTU{1520};

public:
explicit Bg95AtModem(AeContext const& ae_context,
IPoller::ptr const& poller, ModemInit modem_init);
explicit Bg95AtModem(AeContext const& ae_context, IPoller::ptr const& poller,
ModemInit modem_init);

ModemOperation* Start() override;
ModemOperation* Stop() override;
OpenNetworkOperation* OpenNetwork(Protocol protocol, std::string const& host,
std::uint16_t port) override;
std::uint16_t port) override;
ModemOperation* CloseNetwork(ConnectionIndex connect_index) override;
WriteOperation* WritePacket(ConnectionIndex connect_index,
std::span<std::uint8_t const> data) override;
Expand All @@ -190,6 +188,21 @@ class Bg95AtModem final : public IModemDriver {
ModemOperation* PowerOff() override;

private:
static constexpr auto kNetworkOpActionPoolCapacity =
AE_MODEM_NETWORK_OP_ACTION_POOL_CAPACITY;
static constexpr auto kWriteActionPoolCapacity =
AE_MODEM_WRITE_ACTION_POOL_CAPACITY;

using OpenNetworkActionPool =
ActionPool<AeContext, bg95_modem_internal::OpenNetworkOperationImpl,
kNetworkOpActionPoolCapacity>;
using CloseNetworkActionPool =
ActionPool<AeContext, bg95_modem_internal::CloseNetworkOperationImpl,
kNetworkOpActionPoolCapacity>;
using WriteActionPool =
ActionPool<AeContext, bg95_modem_internal::WriteOperationImpl,
kWriteActionPoolCapacity>;

void Init();
void SetupPoll();
void PollEvent(std::int32_t handle);
Expand All @@ -208,12 +221,9 @@ class Bg95AtModem final : public IModemDriver {
std::unique_ptr<ModemOperation> modem_stop_operation_;
std::unique_ptr<ModemOperation> modem_set_psp_operation_;
std::unique_ptr<ModemOperation> modem_poweroff_operation_;
ActionPool<AeContext, bg95_modem_internal::OpenNetworkOperationImpl, 10>
open_network_pool_;
ActionPool<AeContext, bg95_modem_internal::CloseNetworkOperationImpl, 10>
close_network_pool_;
ActionPool<AeContext, bg95_modem_internal::WriteOperationImpl, 10>
write_pool_;
OpenNetworkActionPool open_network_pool_;
CloseNetworkActionPool close_network_pool_;
WriteActionPool write_pool_;

bool initiated_;
bool started_;
Expand All @@ -222,4 +232,4 @@ class Bg95AtModem final : public IModemDriver {

} /* namespace ae */
#endif
#endif // AETHER_MODEMS_BG95_AT_MODEM_H_
#endif // AETHER_MODEMS_BG95_AT_MODEM_H_
32 changes: 22 additions & 10 deletions aether/modems/sim7070_at_modem.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@
#include "aether/config.h"

#if AE_SUPPORT_MODEMS && AE_ENABLE_SIM7070
# include <set>
# include <memory>
# include <set>

# include "aether/ae_context.h"
# include "aether/poller/poller.h"
# include "aether/actions/action_pool.h"
# include "aether/actions/actions_queue.h"
# include "aether/actions/repeatable_task.h"
# include "aether/serial_ports/iserial_port.h"
# include "aether/ae_context.h"
# include "aether/poller/poller.h"
# include "aether/serial_ports/at_support/at_support.h"
# include "aether/serial_ports/iserial_port.h"

# include "aether/modems/imodem_driver.h"

Expand Down Expand Up @@ -196,6 +196,21 @@ class Sim7070AtModem final : public IModemDriver {
ModemOperation* PowerOff() override;

private:
static constexpr auto kNetworkOpActionPoolCapacity =
AE_MODEM_NETWORK_OP_ACTION_POOL_CAPACITY;
static constexpr auto kWriteActionPoolCapacity =
AE_MODEM_WRITE_ACTION_POOL_CAPACITY;

using OpenNetworkActionPool =
ActionPool<AeContext, sim7070_modem_internal::OpenNetworkOperationImpl,
kNetworkOpActionPoolCapacity>;
using CloseNetworkActionPool =
ActionPool<AeContext, sim7070_modem_internal::CloseNetworkOperationImpl,
kNetworkOpActionPoolCapacity>;
using WriteActionPool =
ActionPool<AeContext, sim7070_modem_internal::WriteOperationImpl,
kWriteActionPoolCapacity>;

void Init();
void SetupPoll();
void PollEvent(std::int32_t handle);
Expand All @@ -214,12 +229,9 @@ class Sim7070AtModem final : public IModemDriver {
std::unique_ptr<ModemOperation> modem_stop_operation_;
std::unique_ptr<ModemOperation> modem_set_psp_operation_;
std::unique_ptr<ModemOperation> modem_poweroff_operation_;
ActionPool<AeContext, sim7070_modem_internal::OpenNetworkOperationImpl, 10>
open_network_pool_;
ActionPool<AeContext, sim7070_modem_internal::CloseNetworkOperationImpl, 10>
close_network_pool_;
ActionPool<AeContext, sim7070_modem_internal::WriteOperationImpl, 10>
write_pool_;
OpenNetworkActionPool open_network_pool_;
CloseNetworkActionPool close_network_pool_;
WriteActionPool write_pool_;

bool initiated_;
bool started_;
Expand Down
Loading
Loading