Java
Install
We distribute the library as a single JAR file that contains:
-
Java 12 bytecode
-
Source code
-
JavaDoc
Download the library here:
https://github.com/aethernetio/aethernet-lib-java/releases
Or from the maven central repository
<dependency>
<groupId>io.aethernet</groupId>
<artifactId>aethernet</artifactId>
<version>1.3</version>
</dependency>
Include
Include the JAR file into your project. If you are using IDE then just add the library to the project structure / libraries. If you are using the command line compilation then use the -cp option.
Usage
In your java source file import the AetherClient class:
import io.aethernet.AetherClient;
Then create an instance of the client and use it:
AetherClient client = new AetherClient("path/to/the/state/file");
You can register a new client by self-provisioning procedure:
// Registers a new anonymous client (Aethernet / Anonymous)
client.register();
Or you can register a new client under your application server:
String parentUid = "0123456789abcdef0123456789abcdef";
client.register(parentUid);
Sending messages
String destinationUid = "0123456789abcdef0123456789abcdef";
String message = "Hello, World!";
client.send(destinationUid, message);
Receiving messages
client.onMessage((fromUid, message) -> {
System.out.println("Received message from " + fromUid + ": " + message);
});
TypeScript
Install
We distribute the library as an npm package.
Download the library here:
https://www.npmjs.com/package/aethernet
npm install aethernet
Include
Include the library into your project.
import { AetherClient } from 'aethernet';
Usage
Then create an instance of the client and use it:
const client = new AetherClient('path/to/the/state/file');
You can register a new client by self-provisioning procedure:
// Registers a new anonymous client (Aethernet / Anonymous)
await client.register();
Or you can register a new client under your application server:
const parentUid = '0123456789abcdef0123456789abcdef';
await client.register(parentUid);
Sending messages
const destinationUid = '0123456789abcdef0123456789abcdef';
const message = 'Hello, World!';
await client.send(destinationUid, message);
Receiving messages
client.onMessage((fromUid, message) => {
console.log(`Received message from ${fromUid}: ${message}`);
});
C++
Install
We distribute the library as a source code.
Download the library here:
https://github.com/aethernetio/aethernet-lib-cpp
Include
Include the library into your project.
#include "aether/aether.h"
Usage
Then create an instance of the client and use it:
AetherClient client("path/to/the/state/file");
You can register a new client by self-provisioning procedure:
// Registers a new anonymous client (Aethernet / Anonymous)
client.Register();
Or you can register a new client under your application server:
std::string parent_uid = "0123456789abcdef0123456789abcdef";
client.Register(parent_uid);
Sending messages
std::string destination_uid = "0123456789abcdef0123456789abcdef";
std::string message = "Hello, World!";
client.Send(destination_uid, message);
Receiving messages
client.OnMessage([](const std::string& from_uid, const std::string& message) {
std::cout << "Received message from " << from_uid << ": " << message << std::endl;
});
ESP32
You can run the C++ client on ESP32. We provide a PlatformIO project template for ESP32.
Download the template here:
https://github.com/aethernetio/aethernet-esp32-template
Or you can use the Arduino IDE library.
Download the library here:
https://github.com/aethernetio/aethernet-arduino
Or you can use the ESP-IDF component.
Download the component here:
https://github.com/aethernetio/aethernet-esp-idf
Wiring
Connect the ESP32 to the PC via USB. Connect the LED to the GPIO 2.