Skip to content
Open
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
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ option(AE_FILTRATION "Build aether in filtration mode" Off)
option(AE_INSTALL "Install aether" ${AE_ROOT_PORJECT})
option(AE_BUILD_TOOLS "Build tools" ${AE_ROOT_PORJECT})
option(AE_BUILD_EXAMPLES "Build examples" ${AE_ROOT_PORJECT})
option(AE_BUILD_PREPARED_TEST_IOT "Build Windows prepared LTE IoT example" OFF)
option(AE_BUILD_TESTS "Build tests" ${AE_ROOT_PORJECT})
option(AE_BUILD_ANDROID_SMOKE "Build Android NDK smoke shared library and runner" Off)
option(AE_ADDRESS_SANITIZE "Enable address sanitizer" Off)
Expand Down Expand Up @@ -177,6 +178,10 @@ CPMAddPackage(
EXCLUDE_FROM_ALL FALSE
)

if(MSVC)
target_compile_options(aether-objects PRIVATE /Zc:preprocessor)
endif()

add_library(${TARGET_NAME} STATIC )
# collect sources
add_subdirectory(aether)
Expand Down Expand Up @@ -225,7 +230,8 @@ if(ESP_PLATFORM)
idf::esp_netif
idf::nvs_flash
idf::spiffs
idf::esp_driver_uart)
idf::esp_driver_uart
idf::esp_driver_gpio)

# test if they exists
foreach(c ${idf_components})
Expand Down Expand Up @@ -358,6 +364,10 @@ if(AE_BUILD_TESTS)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/tests ${CMAKE_BINARY_DIR}/tests)
endif()

if(AE_BUILD_PREPARED_TEST_IOT)
add_subdirectory(examples/prepared_test_iot)
endif()

if(ANDROID AND AE_BUILD_ANDROID_SMOKE)
message(STATUS "Aether builds Android NDK smoke targets!")
# Shared-library consumers require PIC for aether and static dependencies.
Expand Down
151 changes: 151 additions & 0 deletions CMakeSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
{
"configurations": [
{
"name": "x64-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [
"msvc_x64_x64"
],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-j 4",
"ctestCommandArgs": ""
},
{
"name": "x64-Release",
"generator": "Ninja",
"configurationType": "RelWithDebInfo",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-j 4",
"ctestCommandArgs": "",
"inheritEnvironments": [
"msvc_x64_x64"
],
"variables": []
},
{
"name": "prepared-iot-sim7070",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [
"msvc_x64_x64"
],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-j 4",
"ctestCommandArgs": "-R \"prepared|serial-port|modem-shutdown\" --output-on-failure",
"variables": [
{
"name": "AE_BUILD_PREPARED_TEST_IOT",
"value": "ON",
"type": "BOOL"
},
{
"name": "AE_BUILD_EXAMPLES",
"value": "OFF",
"type": "BOOL"
},
{
"name": "AE_BUILD_TOOLS",
"value": "OFF",
"type": "BOOL"
},
{
"name": "AE_INSTALL",
"value": "OFF",
"type": "BOOL"
},
{
"name": "AE_BUILD_TESTS",
"value": "ON",
"type": "BOOL"
},
{
"name": "AE_DISTILLATION",
"value": "ON",
"type": "BOOL"
},
{
"name": "AE_FILTRATION",
"value": "OFF",
"type": "BOOL"
},
{
"name": "CMAKE_EXPORT_COMPILE_COMMANDS",
"value": "ON",
"type": "BOOL"
},
{
"name": "USER_CONFIG",
"value": "${projectDir}/examples/prepared_test_iot/user_config_sim7070g.h",
"type": "PATH"
}
]
},
{
"name": "prepared-iot-thingy91x",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [
"msvc_x64_x64"
],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-j 4",
"ctestCommandArgs": "-R \"prepared|serial-port|modem-shutdown\" --output-on-failure",
"variables": [
{
"name": "AE_BUILD_PREPARED_TEST_IOT",
"value": "ON",
"type": "BOOL"
},
{
"name": "AE_BUILD_EXAMPLES",
"value": "OFF",
"type": "BOOL"
},
{
"name": "AE_BUILD_TOOLS",
"value": "OFF",
"type": "BOOL"
},
{
"name": "AE_INSTALL",
"value": "OFF",
"type": "BOOL"
},
{
"name": "AE_BUILD_TESTS",
"value": "ON",
"type": "BOOL"
},
{
"name": "AE_DISTILLATION",
"value": "ON",
"type": "BOOL"
},
{
"name": "AE_FILTRATION",
"value": "OFF",
"type": "BOOL"
},
{
"name": "CMAKE_EXPORT_COMPILE_COMMANDS",
"value": "ON",
"type": "BOOL"
},
{
"name": "USER_CONFIG",
"value": "${projectDir}/examples/prepared_test_iot/user_config_thingy91x.h",
"type": "PATH"
}
]
}
]
}
21 changes: 21 additions & 0 deletions CppProperties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"configurations": [
{
"inheritEnvironments": [
"msvc_x64"
],
"name": "x64-Debug",
"includePath": [
"${env.INCLUDE}",
"${workspaceRoot}\\**"
],
"defines": [
"WIN32",
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"intelliSenseMode": "windows-msvc-x64"
}
]
}
1 change: 1 addition & 0 deletions aether/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ cmake_minimum_required(VERSION 3.16.0)
list(APPEND aether_srcs
"aether_app.cpp"
"aether.cpp"
"escaped_io_stream_trap.cpp"
"adapter_registry.cpp"
"client_connectivity_policy.cpp"
"client.cpp"
Expand Down
27 changes: 27 additions & 0 deletions aether/adapters/adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,34 @@
#include <vector>

#include "aether-objects/obj/obj.h"
#include "aether/actions/action.h"
#include "aether/events/event_subscription.h"
#include "aether/events/events.h"

#include "aether/access_points/access_point.h"

namespace ae {
/// Runtime shutdown operation owned by an adapter, never serialized.
class IAdapterStop : public Action {};

/// Completes immediately or follows a driver-owned shutdown action.
class AdapterStop final : public IAdapterStop {
public:
AdapterStop() { Finish(); }
explicit AdapterStop(Action& action) {
if (action.is_finished()) {
Finish();
return;
}
finished_sub_ = action.finished_event().Subscribe([this]() {
finished_sub_.Reset();
Finish();
});
}

private:
Subscription finished_sub_;
};
/**
* \brief The interface to control network adapter.
* It must configure interface and provide list of access points.
Expand All @@ -46,6 +69,10 @@ class Adapter : public Obj {

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

// Stop runtime network resources. The adapter owns the returned action and
// keeps it alive until destruction, including after completion.
virtual IAdapterStop& Stop() = 0;

virtual NewAccessPoint::Subscriber new_access_point();

protected:
Expand Down
3 changes: 3 additions & 0 deletions aether/adapters/ethernet.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ class EthernetAdapter final : public Adapter {
AE_OBJECT_REFLECT(AE_MMBRS(ethernet_access_point_))

std::vector<AccessPoint::ptr> access_points() override;
// This adapter currently has no asynchronous shutdown sequence.
IAdapterStop& Stop() override { return stop_operation_; }

private:
AdapterStop stop_operation_;
EthernetAccessPoint::ptr ethernet_access_point_;
};
} // namespace ae
Expand Down
7 changes: 5 additions & 2 deletions aether/adapters/lora_module_adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

# include "aether/events/events.h"

# include "aether/lora_modules/ilora_module_driver.h"
# include "aether/adapters/parent_lora_module.h"
# include "aether/access_points/access_point.h"
# include "aether/adapters/parent_lora_module.h"
# include "aether/lora_modules/ilora_module_driver.h"

# define LORA_MODULE_TCP_TRANSPORT_ENABLED 1

Expand All @@ -47,10 +47,13 @@ class LoraModuleAdapter : public ParentLoraModuleAdapter {
AE_OBJECT_REFLECT(AE_MMBRS(access_point_))

std::vector<AccessPoint::ptr> access_points() override;
// This adapter currently has no asynchronous shutdown sequence.
IAdapterStop& Stop() override { return stop_operation_; }

ILoraModuleDriver& lora_module_driver();

private:
AdapterStop stop_operation_;
bool connected_{false};

std::unique_ptr<ILoraModuleDriver> lora_module_driver_;
Expand Down
12 changes: 12 additions & 0 deletions aether/adapters/modem_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,17 @@ IModemDriver& ModemAdapter::modem_driver() {
return *modem_driver_;
}

IAdapterStop& ModemAdapter::Stop() {
if (!stop_operation_) {
auto* operation = modem_driver_ ? modem_driver_->Stop() : nullptr;
if (operation != nullptr) {
stop_operation_.emplace(*operation);
} else {
stop_operation_.emplace();
}
}
return *stop_operation_;
}

} // namespace ae
#endif
5 changes: 4 additions & 1 deletion aether/adapters/modem_adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
#include "aether/config.h"

#if AE_SUPPORT_MODEMS
# include "aether/adapters/parent_modem.h"
# include <optional>
# include "aether/access_points/access_point.h"
# include "aether/adapters/parent_modem.h"

namespace ae {
class IModemDriver;
Expand All @@ -42,6 +43,7 @@ class ModemAdapter final : public ParentModemAdapter {
AE_OBJECT_REFLECT(AE_MMBRS(access_point_))

std::vector<AccessPoint::ptr> access_points() override;
IAdapterStop& Stop() override;

IModemDriver& modem_driver();

Expand All @@ -50,6 +52,7 @@ class ModemAdapter final : public ParentModemAdapter {

std::unique_ptr<IModemDriver> modem_driver_;
AccessPoint::ptr access_point_;
std::optional<AdapterStop> stop_operation_;
};

} // namespace ae
Expand Down
7 changes: 5 additions & 2 deletions aether/adapters/wifi_adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@

#if AE_SUPPORT_WIFIS

# include "aether/wifi/wifi_driver.h"
# include "aether/adapters/parent_wifi.h"
# include "aether/access_points/wifi_access_point.h"
# include "aether/adapters/parent_wifi.h"
# include "aether/wifi/wifi_driver.h"

namespace ae {

Expand All @@ -42,10 +42,13 @@ class WifiAdapter final : public ParentWifiAdapter {
AE_OBJECT_REFLECT(AE_MMBRS(access_points_))

std::vector<AccessPoint::ptr> access_points() override;
// This adapter currently has no asynchronous shutdown sequence.
IAdapterStop& Stop() override { return stop_operation_; }

WifiDriver& driver();

private:
AdapterStop stop_operation_;
std::unique_ptr<WifiDriver> wifi_driver_;
std::vector<AccessPoint::ptr> access_points_;
};
Expand Down
9 changes: 9 additions & 0 deletions aether/aether.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ Aether::Aether(ObjProp prop)

Aether::~Aether() { AE_TELE_DEBUG(AetherDestroyed); }

void Aether::StopNetworking() {
for (auto& [id, client] : clients_) {
if (client.is_loaded()) {
Ptr<Client> loaded = client.Load();
loaded->StopNetworking();
}
}
}

AeCtx Aether::ToAeContext() const {
static constexpr AeCtxTable ae_table{
[](void* obj) -> Aether& { return *static_cast<Aether*>(obj); },
Expand Down
Loading