Coder Social home page Coder Social logo

Comments (3)

sbernard31 avatar sbernard31 commented on June 26, 2024

Iam not sure but maybeManualDataSender is what need ?

Do you test the it ? it is able to collect timestamped data then send all collected data ?

You can test its behavior with leshan-client-demo ? using this interactive command

help collect

Usage:  collect [<paths>...]
Collect data to send it later with 'send' command
      [<paths>...]   Paths of data to collect.

help send

Usage:  send [-c=<contentFormat>] (current-value | collected-value)
Send data to server
  -c, --content-format=<contentFormat>
         Name (e.g. SENML_JSON) or code (e.g. 110) of Content Format used to
           send data.
         Default : SENML_CBOR
Commands:
  current-value    Send current value
  collected-value  Send values collected with 'collect' command

You could have code example here :

/**
* A command to collect data.
*/
@Command(name = "collect",
description = "Collect data to send it later with 'send' command",
headerHeading = "%n",
footer = "")
static class CollectCommand implements Runnable {
@Parameters(description = "Paths of data to collect.", converter = LwM2mPathConverter.class)
private List<LwM2mPath> paths;
@ParentCommand
InteractiveCommands parent;
@Override
public void run() {
parent.client.getSendService().getDataSender(ManualDataSender.DEFAULT_NAME, ManualDataSender.class)
.collectData(paths);
}
}

and

@Command(name = "collected-value",
description = "Send values collected with 'collect' command",
headerHeading = "%n",
footer = "")
static class SendCollectedValue implements Runnable {
@ParentCommand
SendCommand sendCommand;
@Override
public void run() {
// get registered servers
Map<String, LwM2mServer> registeredServers = sendCommand.parent.client.getRegisteredServers();
if (registeredServers.isEmpty()) {
sendCommand.parent.printf("There is no registered server to send to.%n").flush();
}
// for each server send data
for (final LwM2mServer server : registeredServers.values()) {
LOG.info("Sending Collected data to {} using {}.", server, sendCommand.contentFormat);
// send collected data
SendService sendService = sendCommand.parent.client.getSendService();
try {
sendService.getDataSender(ManualDataSender.DEFAULT_NAME, ManualDataSender.class)
.sendCollectedData(server, sendCommand.contentFormat, sendCommand.timeout, false);
} catch (NoDataException e) {
sendCommand.parent.printf("No data collected, use `collect` command before.%n").flush();
}
}
}
}

If this doesn't match you need, could you try to explain why ? 🙏

from leshan.

sbernard31 avatar sbernard31 commented on June 26, 2024

Does that work for you ? should we close this issue ?

from leshan.

Ozame avatar Ozame commented on June 26, 2024

Yes, this actually looks to be exactly what we needed, thank you! I will close the issue.

from leshan.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.