All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.leshan.demo.bsserver.cli.LeshanBsServerDemoCLI Maven / Gradle / Ivy

The newest version!
/*******************************************************************************
 * Copyright (c) 2021 Sierra Wireless and others.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v2.0
 * and Eclipse Distribution License v1.0 which accompany this distribution.
 *
 * The Eclipse Public License is available at
 *    http://www.eclipse.org/legal/epl-v20.html
 * and the Eclipse Distribution License is available at
 *    http://www.eclipse.org/org/documents/edl-v10.html.
 *
 * Contributors:
 *     Sierra Wireless - initial API and implementation
 *******************************************************************************/
package org.eclipse.leshan.demo.bsserver.cli;

import org.eclipse.leshan.demo.bsserver.JSONFileBootstrapStore;
import org.eclipse.leshan.demo.cli.StandardHelpOptions;
import org.eclipse.leshan.demo.cli.VersionProvider;
import org.eclipse.leshan.demo.servers.cli.DtlsSection;
import org.eclipse.leshan.demo.servers.cli.GeneralSection;
import org.eclipse.leshan.demo.servers.cli.IdentitySection;

import picocli.CommandLine.ArgGroup;
import picocli.CommandLine.Command;
import picocli.CommandLine.Mixin;
import picocli.CommandLine.Model.CommandSpec;
import picocli.CommandLine.Option;
import picocli.CommandLine.Spec;

/**
 * This is the class defining the Command Line Interface of Leshan Server Demo.
 */
@Command(name = "leshan-demo-bsserver",
         sortOptions = false,
         description = "%n"//
                 + "@|italic " //
                 + "This is a LWM2M Bootstrap Server demo implemented with Leshan library.%n" //
                 + "You can launch it without any option.%n" //
                 + "%n" //
                 + "Californium is used as CoAP library and some CoAP parameters can be tweaked in 'Californium.properties' file." //
                 + "|@%n",
         versionProvider = VersionProvider.class)
public class LeshanBsServerDemoCLI implements Runnable {

    @Mixin
    public StandardHelpOptions helpsOptions;

    /* ********************************** General Section ******************************** */
    @ArgGroup(validate = false, heading = "%n")
    public BootstrapServerGeneralSection main = new BootstrapServerGeneralSection();

    public static class BootstrapServerGeneralSection extends GeneralSection {

        @Option(names = { "-cfg", "--config-file" },
                defaultValue = JSONFileBootstrapStore.DEFAULT_FILE,
                description = { //
                        "Set the filename for the configuration.", //
                        "Default: ${DEFAULT-VALUE}" })
        public String configFilename;

        @Option(names = { "-no", "--disable-oscore" },
                description = { //
                        "Disable experimental OSCORE feature." })
        public Boolean disableOscore = false;
    }

    /* ********************************** DTLS Section ******************************** */
    @ArgGroup(validate = false,
              heading = "%n@|bold,underline DTLS Options|@ %n%n"//
                      + "@|italic " //
                      + "Here some options aiming to configure the server behavior when it uses CoAP over DTLS." //
                      + "%n" //
                      + "Scandium is used as DTLS library and some DTLS parameters can be tweaked in 'Californium.properties' file." //
                      + "|@%n%n")
    public DtlsSection dtls = new DtlsSection();

    /* ********************************** Identity Section ******************************** */
    @ArgGroup(exclusive = true)
    public IdentitySection identity = new IdentitySection();

    @Spec
    CommandSpec spec;

    @Override
    public void run() {
        // Some post-validation which imply several options or input consolidation.
        identity.build(spec.commandLine());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy