Skip to content
Draft
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
3 changes: 0 additions & 3 deletions .github/workflows/ci-cd-multi-platforms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ jobs:
- {
name: "Optimized",
user_config: "./config/user_config_optimized.h",
fs_init: "./config/file_system_init.h",
}

steps:
Expand All @@ -167,8 +166,6 @@ jobs:
command: idf.py build
-DCOMPILE_EXAMPLE=${{ matrix.compile_example }}
-DUSER_CONFIG=../../../../../${{ matrix.platforms.user_config }}
-DFS_INIT="../../../../../${{ matrix.platforms.fs_init }}"
-DAE_DISTILLATION=Off

- name: Rename artifact
run: |
Expand Down
3 changes: 0 additions & 3 deletions aether/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ list(APPEND dns_srcs
list(APPEND obj_srcs
"obj/obj.cpp"
"obj/domain.cpp"
"obj/obj_id.cpp"
"obj/registry.cpp"
"obj/obj_ptr.cpp"
)

list(APPEND ptr_srcs
Expand Down
8 changes: 2 additions & 6 deletions aether/access_points/access_point.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
#include <vector>

#include "aether/obj/obj.h"
#include "aether/obj/obj_ptr.h"

namespace ae {
class Channel;
class Server;
Expand All @@ -41,10 +39,8 @@ class AccessPoint : public Obj {

explicit AccessPoint(Domain* domain);

AE_OBJECT_REFLECT()

virtual std::vector<ObjPtr<Channel>> GenerateChannels(
ObjPtr<Server> const& server) = 0;
virtual std::vector<std::unique_ptr<Channel>> GenerateChannels(
Server& server) = 0;
};
} // namespace ae

Expand Down
34 changes: 13 additions & 21 deletions aether/access_points/ethernet_access_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,43 +17,35 @@

#include "aether/access_points/ethernet_access_point.h"

#include <utility>

#include "aether/aether.h"
#include "aether/server.h"
#include "aether/poller/poller.h"
#include "aether/dns/dns_resolve.h"
#include "aether/channels/ethernet_channel.h"
#include "aether/access_points/filter_endpoints.h"

namespace ae {
EthernetAccessPoint::EthernetAccessPoint(ObjPtr<Aether> aether,
ObjPtr<IPoller> poller,
ObjPtr<DnsResolver> dns_resolver,
EthernetAccessPoint::EthernetAccessPoint(Aether& aether, IPoller& poller,
DnsResolver& dns_resolver,
Domain* domain)
: AccessPoint{domain},
aether_{std::move(aether)},
poller_{std::move(poller)},
dns_resolver_{std::move(dns_resolver)} {}

std::vector<ObjPtr<Channel>> EthernetAccessPoint::GenerateChannels(
ObjPtr<Server> const& server) {
Aether::ptr aether = aether_;
DnsResolver::ptr resolver = dns_resolver_;
IPoller::ptr poller = poller_;

std::vector<ObjPtr<Channel>> channels;
channels.reserve(server->endpoints.size());
for (auto const& endpoint : server->endpoints) {
aether_{&aether},
poller_{&poller},
dns_resolver_{&dns_resolver} {}

std::vector<std::unique_ptr<Channel>> EthernetAccessPoint::GenerateChannels(
Server& server) {
std::vector<std::unique_ptr<Channel>> channels;
channels.reserve(server.endpoints.size());
for (auto const& endpoint : server.endpoints) {
if (!FilterAddresses<AddrVersion::kIpV4, AddrVersion::kIpV6,
AddrVersion::kNamed>(endpoint)) {
continue;
}
if (!FilterProtocol<Protocol::kTcp, Protocol::kUdp>(endpoint)) {
continue;
}
channels.emplace_back(domain_->CreateObj<EthernetChannel>(
aether, resolver, poller, endpoint));
channels.emplace_back(std::make_unique<EthernetChannel>(
*aether_, *dns_resolver_, *poller_, endpoint, domain_));
}
return channels;
}
Expand Down
17 changes: 7 additions & 10 deletions aether/access_points/ethernet_access_point.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include "aether/access_points/access_point.h"

#include "aether/obj/obj.h"
#include "aether/obj/obj_ptr.h"

namespace ae {
class Aether;
Expand All @@ -33,18 +32,16 @@ class EthernetAccessPoint : public AccessPoint {
public:
EthernetAccessPoint() = default;

EthernetAccessPoint(ObjPtr<Aether> aether, ObjPtr<IPoller> poller,
ObjPtr<DnsResolver> dns_resolver, Domain* domain);
EthernetAccessPoint(Aether& aether, IPoller& poller,
DnsResolver& dns_resolver, Domain* domain);

AE_OBJECT_REFLECT(AE_MMBRS(aether_, poller_, dns_resolver_))

std::vector<ObjPtr<Channel>> GenerateChannels(
ObjPtr<Server> const& server) override;
std::vector<std::unique_ptr<Channel>> GenerateChannels(
Server& server) override;

private:
Obj::ptr aether_;
Obj::ptr poller_;
Obj::ptr dns_resolver_;
Aether* aether_;
IPoller* poller_;
DnsResolver* dns_resolver_;
};
} // namespace ae

Expand Down
42 changes: 18 additions & 24 deletions aether/access_points/wifi_access_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,57 +65,51 @@ UpdateStatus WifiConnectAction::Update() {

WifiConnectAction::State WifiConnectAction::state() const { return state_; }

WifiAccessPoint::WifiAccessPoint(ObjPtr<Aether> aether,
ObjPtr<WifiAdapter> adapter,
ObjPtr<IPoller> poller,
ObjPtr<DnsResolver> resolver,
WifiAccessPoint::WifiAccessPoint(Aether& aether, WifiAdapter& adapter,
IPoller& poller, DnsResolver& resolver,
WifiCreds wifi_creds, Domain* domain)
: AccessPoint{domain},
aether_{std::move(aether)},
adapter_{std::move(adapter)},
poller_{std::move(poller)},
resolver_{std::move(resolver)},
aether_{&aether},
adapter_{&adapter},
poller_{&poller},
resolver_{&resolver},
wifi_creds_{std::move(wifi_creds)} {}

std::vector<ObjPtr<Channel>> WifiAccessPoint::GenerateChannels(
ObjPtr<Server> const& server) {
Aether::ptr aether = aether_;
IPoller::ptr poller = poller_;
DnsResolver::ptr resolver = resolver_;
WifiAccessPoint::ptr wifi_access_point = MakePtrFromThis(this);

std::vector<ObjPtr<Channel>> channels;
channels.reserve(server->endpoints.size());
for (auto const& endpoint : server->endpoints) {
std::vector<std::unique_ptr<Channel>> WifiAccessPoint::GenerateChannels(
Server& server) {
std::vector<std::unique_ptr<Channel>> channels;
channels.reserve(server.endpoints.size());
for (auto const& endpoint : server.endpoints) {
if (!FilterAddresses<AddrVersion::kIpV4, AddrVersion::kIpV6,
AddrVersion::kNamed>(endpoint)) {
continue;
}
if (!FilterProtocol<Protocol::kTcp, Protocol::kUdp>(endpoint)) {
continue;
}
channels.emplace_back(domain_->CreateObj<WifiChannel>(
aether, poller, resolver, wifi_access_point, endpoint));
channels.emplace_back(std::make_unique<WifiChannel>(
*aether_, *poller_, *resolver_, *this, endpoint, domain_));
}
return channels;
}

ActionPtr<WifiConnectAction> WifiAccessPoint::Connect() {
// reuse connect action if it's in progress
if (!connect_action_) {
connect_action_ = ActionPtr<WifiConnectAction>{
*aether_.as<Aether>(), adapter_.as<WifiAdapter>()->driver(),
wifi_creds_};
connect_action_ =
ActionPtr<WifiConnectAction>{*aether_, adapter_->driver(), wifi_creds_};
connect_sub_ = connect_action_->FinishedEvent().Subscribe(
[this]() { connect_action_.reset(); });
}
return connect_action_;
}

bool WifiAccessPoint::IsConnected() {
auto& driver = adapter_.as<WifiAdapter>()->driver();
auto& driver = adapter_->driver();
auto connected_to = driver.connected_to();
return connected_to.ssid == wifi_creds_.ssid;
}

WifiCreds const& WifiAccessPoint::creds() const { return wifi_creds_; }

} // namespace ae
23 changes: 10 additions & 13 deletions aether/access_points/wifi_access_point.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#include <cstdint>

#include "aether/obj/obj_ptr.h"
#include "aether/actions/action.h"
#include "aether/actions/action_ptr.h"
#include "aether/types/state_machine.h"
Expand Down Expand Up @@ -61,15 +60,11 @@ class WifiAccessPoint final : public AccessPoint {
WifiAccessPoint() = default;

public:
WifiAccessPoint(ObjPtr<Aether> aether, ObjPtr<WifiAdapter> adapter,
ObjPtr<IPoller> poller, ObjPtr<DnsResolver> resolver,
WifiCreds wifi_creds, Domain* domain);
WifiAccessPoint(Aether& aether, WifiAdapter& adapter, IPoller& poller,
DnsResolver& resolver, WifiCreds wifi_creds, Domain* domain);

AE_OBJECT_REFLECT(AE_MMBRS(aether_, adapter_, poller_, resolver_,
wifi_creds_))

std::vector<ObjPtr<Channel>> GenerateChannels(
ObjPtr<Server> const& server) override;
std::vector<std::unique_ptr<Channel>> GenerateChannels(
Server& server) override;

/**
* \brief Connect or ensure it's connected to current access point.
Expand All @@ -78,11 +73,13 @@ class WifiAccessPoint final : public AccessPoint {

bool IsConnected();

WifiCreds const& creds() const;

private:
Obj::ptr aether_;
Obj::ptr adapter_;
Obj::ptr poller_;
Obj::ptr resolver_;
Aether* aether_;
WifiAdapter* adapter_;
IPoller* poller_;
DnsResolver* resolver_;
WifiCreds wifi_creds_;
ActionPtr<WifiConnectAction> connect_action_;
Subscription connect_sub_;
Expand Down
2 changes: 1 addition & 1 deletion aether/actions/action_trigger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ bool ActionTrigger::WaitUntil(TimePoint timeout) {
}

void ActionTrigger::Trigger() {
std::lock_guard lock(sync_object_->mutex);
std::scoped_lock lock(sync_object_->mutex);
sync_object_->triggered = true;
sync_object_->condition.notify_all();
}
Expand Down
6 changes: 2 additions & 4 deletions aether/adapter_registry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@
#include "aether/adapter_registry.h"

namespace ae {
#if AE_DISTILLATION
AdapterRegistry::AdapterRegistry(Domain* domain) : Obj{domain} {}
#endif

void AdapterRegistry::Add(Adapter::ptr adapter) {
void AdapterRegistry::Add(std::shared_ptr<Adapter> adapter) {
adapters_.emplace_back(std::move(adapter));
}

std::vector<Adapter::ptr> const& AdapterRegistry::adapters() const {
std::vector<std::shared_ptr<Adapter>> const& AdapterRegistry::adapters() const {
return adapters_;
}
} // namespace ae
12 changes: 3 additions & 9 deletions aether/adapter_registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,18 @@ namespace ae {
class AdapterRegistry final : public Obj {
AE_OBJECT(AdapterRegistry, Obj, 0)

AdapterRegistry() = default;

public:
#if AE_DISTILLATION
explicit AdapterRegistry(Domain* domain);
#endif

AE_OBJECT_REFLECT(AE_MMBRS(adapters_))

/**
* \brief Add adapter to the registry
*/
void Add(Adapter::ptr adapter);
void Add(std::shared_ptr<Adapter> adapter);

std::vector<Adapter::ptr> const& adapters() const;
std::vector<std::shared_ptr<Adapter>> const& adapters() const;

private:
std::vector<Adapter::ptr> adapters_;
std::vector<std::shared_ptr<Adapter>> adapters_;
};
} // namespace ae

Expand Down
2 changes: 0 additions & 2 deletions aether/adapters/adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
#include "aether/adapters/adapter.h"

namespace ae {
#ifdef AE_DISTILLATION
Adapter::Adapter(Domain* domain) : Obj{domain} {}
#endif // AE_DISTILLATION

Adapter::NewAccessPoint::Subscriber Adapter::new_access_point() {
return EventSubscriber{new_access_point_event_};
Expand Down
11 changes: 2 additions & 9 deletions aether/adapters/adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,12 @@ namespace ae {
class Adapter : public Obj {
AE_OBJECT(Adapter, Obj, 0)

protected:
Adapter() = default;

public:
using NewAccessPoint = Event<void(AccessPoint::ptr const&)>;
using NewAccessPoint = Event<void(AccessPoint&)>;

#ifdef AE_DISTILLATION
explicit Adapter(Domain* domain);
#endif // AE_DISTILLATION

AE_OBJECT_REFLECT()

virtual std::vector<AccessPoint::ptr> access_points() = 0;
virtual std::vector<AccessPoint*> access_points() = 0;

virtual NewAccessPoint::Subscriber new_access_point();

Expand Down
11 changes: 5 additions & 6 deletions aether/adapters/ethernet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,16 @@
namespace ae {

#ifdef AE_DISTILLATION
EthernetAdapter::EthernetAdapter(ObjPtr<Aether> aether, IPoller::ptr poller,
DnsResolver::ptr dns_resolver, Domain* domain)
EthernetAdapter::EthernetAdapter(Aether& aether, IPoller& poller,
DnsResolver& dns_resolver, Domain* domain)
: Adapter{domain},
ethernet_access_point_{domain->CreateObj<EthernetAccessPoint>(
std::move(aether), std::move(poller), std::move(dns_resolver))} {
ethernet_access_point_{aether, poller, dns_resolver, domain_} {
AE_TELED_INFO("EthernetAdapter created");
}
#endif // AE_DISTILLATION

std::vector<AccessPoint::ptr> EthernetAdapter::access_points() {
return {ethernet_access_point_};
std::vector<AccessPoint*> EthernetAdapter::access_points() {
return {&ethernet_access_point_};
}

} // namespace ae
14 changes: 4 additions & 10 deletions aether/adapters/ethernet.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,14 @@ class Aether;
class EthernetAdapter final : public Adapter {
AE_OBJECT(EthernetAdapter, Adapter, 0)

EthernetAdapter() = default;

public:
#ifdef AE_DISTILLATION
EthernetAdapter(ObjPtr<Aether> aether, IPoller::ptr poller,
DnsResolver::ptr dns_resolver, Domain* domain);
#endif // AE_DISTILLATION

AE_OBJECT_REFLECT(AE_MMBRS(ethernet_access_point_))
EthernetAdapter(Aether& aether, IPoller& poller, DnsResolver& dns_resolver,
Domain* domain);

std::vector<AccessPoint::ptr> access_points() override;
std::vector<AccessPoint*> access_points() override;

private:
EthernetAccessPoint::ptr ethernet_access_point_;
EthernetAccessPoint ethernet_access_point_;
};
} // namespace ae

Expand Down
Loading