SebyOne Srl – Solo Logo Centrale

Below are the basic methods for configuring and using the node.

Initial Node Setup #

#include <iostream>
#include <string>
#include "daas.h"

using namespace std;

const char *_ssid = "SSID";
const char *_password = "password";
din_t localDin;
din_t localSid;

din_t remoteDin;
link_t linkDriver;

using namespace daas::api;
DaasAPI node("desktop");

void setup()
{
  Serial.begin(115200);
  delay(100);
  WiFi.mode(WIFI_STA);
  WiFi.begin(_ssid, _password);

  while (WiFi.status() != WL_CONNECTED)
  {
    Serial.print(".");
    delay(200);
  }
  Serial.print("Local IP: ");
  Serial.println(WiFi.localIP());

  remoteDin = 101;
}

bool initCore(int sid, int din)
{
  localSid = sid;
  localDin = din;

  int initCoreRes = node.doInit(sid, din);

  if (initCoreRes == ERROR_NONE)
  {
    Serial.print("[SID] ");
    Serial.println(sid);
    Serial.print("[DIN] ");
    Serial.println(din);
    return true;
  }

  Serial.print("Core not initialized! Error code: ");
  Serial.println(initCoreRes);
  return false;
}

Description: #

The initCore function initialises the core using a network identifier (sid) and node identifier (din).

Parameters: #

  • sid: Network identifier.
  • din: Node identifier in the network.

Return values: #

  • true if the core initialisation was successful.
  • false if an error occurred during initialisation.

Note: #

If the operation fails, an error message accompanied by the relevant error code is printed on the serial channel.

bool enableDriver(const char* uri)
{
  int enableDriverRes = node.enableDriver(_LINK_INET4, uri);
 
  if (enableDriverRes != ERROR_NONE)
  {
    Serial.print("Driver not enabled! Error code: ");
    Serial.println(enableDriverRes);
    return false;
  }

  return true;
}

Description: #

The enableDriver function enables a driver for a node by a URI

Parameters: #

  • uri: URI associated with the driver we want to enable

Return value: #

The function returns:

  • true if the driver has been successfully enabled
  • false if an error has occurred

Note: #

If the operation return false, an error message, followed by the corresponding error code, is printed on the serial channel

bool mapNode(din_t din, link_t link, const char* uri){
  int mapNodeRes = node.map(din, link, uri);
  if (mapNodeRes != ERROR_NONE)
  {
    Serial.print("Node not mapped! Error code: ");
    Serial.println(mapNodeRes);
    return false;
  }
  return true;
}

Description: #

The mapNode function maps a node (din), specifying the connection (link) and a URI (uri).

Parameters: #

  • din: remote node mapped.
  • link: connection link.
  • uri: URI associated with a node.

Return value: #

The function returns a boolean value:

  • true if the node mapping has been successfully completed
  • false if an error has occurred.

Note: #

If the operation return false, an error message, followed by the corresponding error code, is printed on the serial channel

void loop()
{
  if (!initCore(100, 110) ||
      !enableDriver(String(WiFi.localIP().toString() + ":2020").c_str()) ||
      !mapNode(remoteDin, _LINK_INET4, "127.0.0.1:2024")) {
    return;
  }

  while(node.doPerform(PERFORM_CORE_NO_THREAD) == ERROR_NONE){
    // Code for the node
  }  
}

Data transmission

Reception #

DDO *inboundData;
unsigned char buffer[1024] = {0};

node.locate(remoteDin);
if (node.pull(remoteDin, &inboundData) == ERROR_NONE) {
  if (inboundData != nullptr){
    Serial.println("DDO: ");
    inboundData->getPayloadAsBinary(buffer, 0, inboundData->getPayloadSize());
    Serial.println((char*)buffer);
  }
}

Transmission #

const char* msg = "Hello World\0";
DDO out = DDO(12);
out.setPayload(msg, strlen(msg));
out.setTimestamp(0); //Insert a valid timestamp
node.push(remoteDin, out);

Last updated: Ottobre 21, 2025 at 5:00 PM

SebyOne Srl – Ultra Compact Footer