Telephone
+1 (408) 475-8377
Social networks
Facebook LinkedIn
æather
Background

Java

1. Add the following code to your build file (build.gradle)

repositories {
    maven {
        url 'https://nexus.aethernet.io/repository/maven-releases/'
    }
}

dependencies {
    implementation 'io.aether:cloud-client:+'
}


2. Сreate two clients and wait for the registration to be completed

var aether1 = new AetherCloudClient().waitStart(10);
var aether2 = new AetherCloudClient().waitStart(10);


3. Configure receiving messages

var messageFuture = new ARFuture<String>();
aether1.onMessage((uid, msg) -> messageFuture.tryDone(new String(msg)));


4. Send a message to aether1

aether2.sendMessage(aether1.getUid(), "Hello World!".getBytes());


5. We are waiting for a message

if (messageFuture.waitDoneSeconds(10)) {
  System.out.println("receive the message: " + messageFuture.get());
} else {
  throw new IllegalStateException();
}


6. As a result, you should get this code in your file

import io.aether.cloud.client.AetherCloudClient;
import io.aether.utils.futures.ARFuture;

public class SomeJavaClass {
    public static void main(String[] args) {
       var aether1 = new AetherCloudClient().waitStart(10);
       var aether2 = new AetherCloudClient().waitStart(10);
		var messageFuture = new ARFuture<String>();
aether1.onMessage((uid, msg) -> messageFuture.tryDone(new String(msg)));
aether2.sendMessage(aether1.getUid(), "Hello World!".getBytes());

if (messageFuture.waitDoneSeconds(10)) {
  System.out.println("receive the message: " + messageFuture.get());
} else {
  throw new IllegalStateException();
}
    }
}

TypeScript

1. Open a Terminal in Your Project Folder bash

cd /path/to/your/project


2. Initialize the Project

npm init -y


3. Add dependency to aether

npm install https://nexus.aethernet.io/repository/npm-private/cloud-client/-/cloud-client-latest.tgz


4. Install TypeScript & Node.js Type Definitions (if needed)

npm install typescript @types/node --save-dev


5. Initialize TypeScript Configuration

npx tsc --init


6. Create Project Structure

mkdir src
touch src/index.ts


7. Add Scripts to package.json

{
  "scripts": {
    "build": "tsc",
    "start": "node dist/index.js",
    "dev": "tsc --watch & nodemon dist/index.js"
  }
}


8. Open the index.ts file

9. Сreate two clients and wait for the registration to be completed

 const aether1 = await new AetherCloudClient().waitStart(10);
 const aether2 = await new AetherCloudClient().waitStart(10);


10. Configure receiving messages

const messageFuture = new ARFuture<string>();
aether1.onMessage((uid: string, msg: Uint8Array) => {
    messageFuture.tryDone(Buffer.from(msg).toString());
});


11. Send a message to aether1

aether2.sendMessage(aether1.getUid(), "Hello World!".getBytes());


12. We are waiting for a message

try {
   const message = await messageFuture.waitDoneSeconds(10);
   console.log("receive the message:", message);
} catch (e) {
   throw new Error("Failed to receive message in time");
}


13. As a result, you should get this code in your file

import { AetherCloudClient } from 'io.aether.cloud.client';
import { ARFuture } from 'io.aether.utils.futures';

async function main() {
    const aether1 = await new AetherCloudClient().waitStart(10);
    const aether2 = await new AetherCloudClient().waitStart(10);

    const messageFuture = new ARFuture<string>();

    aether1.onMessage((uid: string, msg: Uint8Array) => {
        messageFuture.tryDone(Buffer.from(msg).toString());
    });

    await aether2.sendMessage(aether1.getUid(), Buffer.from("Hello World!"));

    try {
        const message = await messageFuture.waitDoneSeconds(10);
        console.log("receive the message:", message);
    } catch (e) {
        throw new Error("Failed to receive message in time");
    }
}

main().catch(console.error);

C++

To integrate your C++ code, choose the platform for the Æthernet client from the options below

Desktop

C++ Æthernet client library is provided as a GitHub repository which you are free to clone/submodule or copy near your project. We currently use CMake as a build system, more will be added in future

1. Add aether-cleint-cpp to your project as a submodule. Run in console:

git submodule add ‘https://github.com/aethernetio/aether-client-cpp.git’


2. Add aether library to your CMakeLists.txt and link it with your project

add_subdirectory(aether-client-cpp/aether aether)
target_link_libraries(<your_target_name> PRIVATE aether)


3. Then in your code (main.cpp for example). Include “ aether/all.h” and create an Æthernet application

auto aether_app = ae::AetherApp::Construct({});


4. Register two Æthernet clients. Registration is an asynchronous operation so you have to use special actions here, subscribe to its StatusEvent and wait until completed

constexpr auto parent_uid = ae::Uid::FromString(<YOUR APPLICATION UID>);
Сlient::ptr aether1;
Client::ptr aether2;
auto select_aether1 = aether_app->aether()->SelectClient(parent_uid, 0);
select_client_a->StatusEvent().Subscribe(ae::OnResult{[&](auto const& action) { aether1 = action.client(); }});
auto select_aether2 = aether_app->aether()->SelectClient(parent_uid, 1);
select_client_a->StatusEvent().Subscribe(ae::OnResult{[&](auto const& action) { aether2 = action.client(); }});
aether_app->WaitActions(select_aether1, select_aether2);


5. Make a data stream to receive messages. Streams are like data pipes from one client to another through the Æthernet servers

auto stream1 = ae::make_unique<ae::P2pStream>(*aether_app, aether1, aether2.uid());
stream1->out_data_event().Subscribe([&](std::vector<std::uint8_t> const& data){
  /* ... your code for message processing … */
  std::cout << “Received ” << std::string_view{data.data(), data.size()} << std::endl;
});


6. Make a data stream to send messages

auto stream2 = ae::make_unique<ae::P2pStream>(*aether_app, aether2, aether1.uid()))
auto message= std::string_view{"Hello"};
stream2->Write({std::begin(message), std::end(message)});


7. Lastly, you need to integrate aether_app into your current event loop or make a new loop

while(!aehter_app->IsExcited()){
  auto next_time = aether_app->Update(ae::Now());
  aether_app->WaitUntil(next_time);
}

For more examples check our GitHub repository


ESP IDF

C++ Æthernet client library is provided as a GitHub repository which you are free to clone/submodule or copy near your project

1. Add aether-cleint-cpp to your project as a submodule. Run in console:

git submodule add ‘https://github.com/aethernetio/aether-client-cpp.git’


2. Add an aether component to your ESP IDF project CMakeLists.txt and require it for your application component

list(APPEND EXTRA_COMPONENT_DIRS "aether-client-cpp/aether”)
idf_component_register(SRCS ${src_list}
      INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}
      PRIV_REQUIRES aether)


3. Then in your code (main.cpp for example). Include “aether/all.h” and create an Æthernet application

auto aether_app = ae::AetherApp::Construct({});


4. Register two Æthernet clients. Registration is an asynchronous operation so you have to use special actions here, subscribe to its StatusEvent and wait until completed

constexpr auto parent_uid = ae::Uid::FromString(<YOUR APPLICATION UID>);
Сlient::ptr aether1;
Client::ptr aether2;
auto select_aether1 = aether_app->aether()->SelectClient(parent_uid, 0);
select_client_a->StatusEvent().Subscribe(ae::OnResult{[&](auto const& action) { aether1 = action.client(); }});
auto select_aether2 = aether_app->aether()->SelectClient(parent_uid, 1);
select_client_a->StatusEvent().Subscribe(ae::OnResult{[&](auto const& action) { aether2 = action.client(); }});
aether_app->WaitActions(select_aether1, select_aether2);


5. Make a data stream to receive messages. Streams are like data pipes from one client to another through the Æthernet servers

auto stream1 = ae::make_unique<ae::P2pStream>(*aether_app, aether1, aether2.uid());
stream1->out_data_event().Subscribe([&](std::vector<std::uint8_t> const& data){
  /* ... your code for message processing … */
  std::cout << “Received ” << std::string_view{data.data(), data.size()} << std::endl;
});


6. Make a data stream to send messages

auto stream2 = ae::make_unique<ae::P2pStream>(*aether_app, aether2, aether1.uid()))
auto message= std::string_view{"Hello"};
stream2->Write({std::begin(message), std::end(message)});


7. Lastly, you need to integrate aether_app into your current event loop or make a new loop

while(!aehter_app->IsExcited()){
  auto next_time = aether_app->Update(ae::Now());
  aether_app->WaitUntil(next_time);
}

For more examples check our GitHub repository


Platformio

C++ Æthernet client library is provided as a GitHub repository which Platformio is able to fetch by itself

1. Add aether-cleint-cpp library dependency to your platfromio.ini

lib_deps = https://github.com/aethernetio/aether-client-cpp.git


2. Add an aether component to your Platformio project CMakeLists.txt and require it for your application component

list(APPEND EXTRA_COMPONENT_DIRS "${CMAKE_SOURCE_DIR}/.pio/libdeps/${configName}/Aether/aether")
idf_component_register(SRCS ${src_list}
      INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}
      PRIV_REQUIRES aether)


3. Then in your code (main.cpp for example). Include “aether/all.h” and create an Æthernet application

auto aether_app = ae::AetherApp::Construct({});


4. Register two Æthernet clients. Registration is an asynchronous operation so you have to use special actions here, subscribe to its StatusEvent and wait until completed

constexpr auto parent_uid = ae::Uid::FromString(<YOUR APPLICATION UID>);
Сlient::ptr aether1;
Client::ptr aether2;
auto select_aether1 = aether_app->aether()->SelectClient(parent_uid, 0);
select_client_a->StatusEvent().Subscribe(ae::OnResult{[&](auto const& action) { aether1 = action.client(); }});
auto select_aether2 = aether_app->aether()->SelectClient(parent_uid, 1);
select_client_a->StatusEvent().Subscribe(ae::OnResult{[&](auto const& action) { aether2 = action.client(); }});
aether_app->WaitActions(select_aether1, select_aether2);


5. Make a data stream to receive messages. Streams are like data pipes from one client to another through the Æthernet servers

auto stream1 = ae::make_unique<ae::P2pStream>(*aether_app, aether1, aether2.uid());
stream1->out_data_event().Subscribe([&](std::vector<std::uint8_t> const& data){
  /* ... your code for message processing … */
  std::cout << “Received ” << std::string_view{data.data(), data.size()} << std::endl;
});


6. Make a data stream to send messages

auto stream2 = ae::make_unique<ae::P2pStream>(*aether_app, aether2, aether1.uid()))
auto message= std::string_view{"Hello"};
stream2->Write({std::begin(message), std::end(message)});


7. Lastly, you need to integrate aether_app into your loop function

if(!aehter_app->IsExcited()){
  auto next_time = aether_app->Update(ae::Now());
  aether_app->WaitUntil(next_time);
}

For more examples check our GitHub repository

Arduino

Æthernet сlient for Arduino has an individual GitHub repository .Install it to your Arduino IDE library path

1. Download an Arduino repository as zip file from GitHub repository and install it to the Arduino IDE library path. In Arduino IDE select:

Sketch -> Include Library -> Add .ZIP Library…


2. Make aether build in distillation mode. Read about it in Documentation. Add to build_opt.h

"-D=AE_DISTILLATION=On"


3. Then in your sketch. Include “aether_lib.h” and create an Æthernet application

auto aether_app = ae::AetherApp::Construct({});


4. Register two Æthernet clients. Registration is an asynchronous operation so you have to use special actions here, subscribe to its StatusEvent and wait until completed

constexpr auto parent_uid = ae::Uid::FromString(<YOUR APPLICATION UID>);
Сlient::ptr aether1;
Client::ptr aether2;
auto select_aether1 = aether_app->aether()->SelectClient(parent_uid, 0);
select_client_a->StatusEvent().Subscribe(ae::OnResult{[&](auto const& action) { aether1 = action.client(); }});
auto select_aether2 = aether_app->aether()->SelectClient(parent_uid, 1);
select_client_a->StatusEvent().Subscribe(ae::OnResult{[&](auto const& action) { aether2 = action.client(); }});
aether_app->WaitActions(select_aether1, select_aether2);


5. Make a data stream to receive messages. Streams are like data pipes from one client to another through the Æthernet servers

auto stream1 = ae::make_unique<ae::P2pStream>(*aether_app, aether1, aether2.uid());
stream1->out_data_event().Subscribe([&](std::vector<std::uint8_t> const& data){
  /* ... your code for message processing … */
  std::cout << “Received ” << std::string_view{data.data(), data.size()} << std::endl;
});


6. Make a data stream to send messages

auto stream2 = ae::make_unique<ae::P2pStream>(*aether_app, aether2, aether1.uid()))
auto message= std::string_view{"Hello"};
stream2->Write({std::begin(message), std::end(message)});


7. Lastly, you need to integrate aether_app into your loop function

if(!aehter_app->IsExcited()){
  auto next_time = aether_app->Update(ae::Now());
  aether_app->WaitUntil(next_time);
}

For more examples check our GitHub repository