Skip to content

Command-line Interface

Introduction

The TC Terminal provides a large set of commands on the server console for administering TC fabric and TC terminal services.

  1. Process Management
  2. Owner Management
  3. Regions Management
  4. Token Management
  5. Device Management
  6. Router Management
  7. Inspection Commands
  8. PKI Management

Process Management

The following describes the commands for configuring, starting and stopping the basic TC process instances used in the TC fabric: ‘apis’, ‘nwks’, ‘appx’, ‘door’, ‘infos’, ‘joins’, ‘joinserver’, ‘muxs’, ‘dexs’.

Apis

The apis instances provide the Terminal REST interfaces. The swark.apis command allows to configure and start apis instances.

$ swark.apis --help
usage: swark.apis [-h] {list,add,remove,start} ...

Manage API server entries in system setup.
optional arguments:
  -h, --help            show this help message and exit

Subcommands:
  {list,add,remove,start}
    list                List API servers registered in the system configuration.
    add                 Add API server to system configuration.
    remove              Remove an API server from system configuration.
    start               Start a apis process.

List apis configurations.

$ swark.apis list --help
usage: swark.apis list [-h]

optional arguments:
  -h, --help  show this help message and exit

Example:
$ swark.apis list
apisid_________:_config_________________
::0             : {'uri': 'https://localhost:7006', 'keys': ['8b9a0592686c2fcfca6de0c04eb9bee4']}

Add apis configuration to system configuration.

$ swark.apis add --help
usage: swark.apis add [-h] [--id apisid] [--uri httpuri] [--extra file|json]

optional arguments:
  -h, --help         show this help message and exit
  --id apisid        Provide identity of the API server (apis). If absent find an unused identity.
  --uri httpuri      HTTP URI specifying host and port of the REST API server. Default: http://localhost:8081.
  --extra file|json  Provide a file with a yaml/json object or specify a yaml/json object literally. The fields of the object
                     are added to the data entry being created.

Example:
$ swark.apis add --id apis-::1 --uri https://localhost:8010

Remove apis configuration from system configuration.

$ swark.apis remove --help
usage: swark.apis remove [-h] apisid

positional arguments:
  apisid      Provide identity of the API server.

optional arguments:
  -h, --help  show this help message and exit

Example:
$ swark.apis remove apis-::0

Start configured apis instance.

$ swark.apis start --help
usage: swark.apis start [-h] [--pid file] apisid

positional arguments:
  apisid      Provide the identity of the apis.

optional arguments:
  -h, --help  show this help message and exit
  --pid file  The file or directory where to write the process pid. If the path ends with a slash then append a file name based on the id. Otherwise use the file as is. Default: /TCDIR/tc/temp.

Example:
$ swark.apis start apis-::0

Nwks/Appx

The nwks instances manage the devices and forward traffic received from routers and muxs to appx instances and backend applications. Downlink from backend applications and appx instances is forwarded to door instances before arriving at muxs instances. A nwks instance is always associated with an appx instance.

$ swark.nwks --help
usage: swark.nwks [-h] {list,info,add,remove,start} ...

Manage nwks entities.

optional arguments:
  -h, --help            show this help message and exit

Subcommands:
  {list,info,add,remove,start}
    list                List network servers registered in the system configuration.
    info                Show setup information for a network server.
    add                 Add network server to system configuration.
    remove              Removes a network server from the system configuration.
    start               Start a nwks process.

List nwks configurations.

$ swark.nwks list --help
usage: swark.nwks list [-h]

optional arguments:
  -h, --help  show this help message and exit

Example:
$ swark.nwks list
nwksid___________:_config_________________
::0              : {'uri': 'ws://localhost:7004'}
appxid___________:_config_________________
::0              : {'uri': 'ws://localhost:7002'}

Print nwks information and status.

$ swark.nwks info --help
usage: swark.nwks info [-h] nwksid [nwksid ...]

positional arguments:
  nwksid      Provide identity of the network server.

optional arguments:
  -h, --help  show this help message and exit

Example:
$ swark.nwks info nwks-::0
Config of network server: nwks-::0
dburi    : 'postgresql://localhost/tc'
dbup     : database accessible
dbtables : not all tables set up
nwkscfg  : {'uri': 'ws://localhost:7004'}
appxcfg  : {'uri': 'ws://localhost:7002'}
nwksuri  : 'ws://localhost:7004'
appxuri  : 'ws://localhost:7002'
nwksws   : server running
appxws   : server running

Add nwks and associated appx configuration to system configuration.

$ swark.nwks add --help
usage: swark.nwks add [-h] [--id nwksid] [--nwks wsuri] [--appx wsuri] [--db pguri] [--extra file|json]

optional arguments:
  -h, --help         show this help message and exit
  --id nwksid        Provide identity of the network server. If absent find an unused identity.
  --nwks wsuri       Host and port of the websocket for the network server. This is an internal websocket accepting mostly connections from MUXS servers. Default: ws://localhost:32032.
  --appx wsuri       Host and port of the websocket for the appx server. This is an external websocket accepting mostly connections from device owners. Default: ws://localhost:31031.
  --db pguri         The URI of the postgres database where the network server will hold its state. If absent use the 'lnsdb_<nwksid>' setting from $TRACKCENTRAL_DIR/setup.yaml. If this is absent too, then use the 'dburi' setting from the same file.
  --extra file|json  Provide a file with a yaml/json object or specify a yaml/json object literally. The fields of the object are added to the data entry being created.

Example:
$ swark.nwks add --id nwks-::1 --nwksuri ws://localhost:8011 --appx ws://localhost: 8012

Remove nwks/appx configuration from system configuration.

$ swark.nwks remove --help
usage: swark.nwks remove [-h] nwksid

positional arguments:
  nwksid      Provide identity of the network server.

optional arguments:
  -h, --help  show this help message and exit

Example:
$ swark.nwks remove nwks-::0

Start configured nwks instance.

$ swark.nwks start --help
usage: swark.nwks start [-h] [--pid file] nwksid

positional arguments:
  nwksid      Provide the identity of the nwks.

optional arguments:
  -h, --help  show this help message and exit
  --pid file  The file or directory where to write the process pid. If the path ends with a slash then append a file name based
              on the id. Otherwise use the file as is. Default: /TCDIR/tc/temp.

Example:
$ swark.nwks start nwks-::0

Start configured appx instance.

$ swark.appx start --help
usage: swark.appx start [-h] [--pid file] nwksid

positional arguments:
  nwksid      Provide the identity of the nwks.

optional arguments:
  -h, --help  show this help message and exit
  --pid file  The file or directory where to write the process pid. If the path ends with a slash then append a file name based
              on the id. Otherwise use the file as is. Default: /TCDIR/tc/temp.

Example:
$ swark.appx start appx-::0

List owners connected to appx.

$ swark.appx list-owners --help
usage: swark.appx list-owners [-h]

optional arguments:
  -h, --help  show this help message and exit

Example:
$ swark.appx list-owners
Per appx: # of links per owner:
appx-::0 (16 owners attached)
    0 | c::1a
    1 | 1::
    0 | c::3
    0 | c::4
    1 | c::1

Print appx connection info for owner.

$ swark.appx info-owner --help
usage: swark.appx info-owner [-h] ownerid

positional arguments:
  ownerid     Owner ID.

optional arguments:
  -h, --help  show this help message and exit

Example:
$ swark.appx info-owner  owner-c::1
appx-::0 (1 owners attached)
    owner    : c::1
    retention: 14d
    max links: 20
    links    : 1
     => priority      : 0
        exclusive     : []
        deveui ranges : []
        connect at    : 2017-11-17 10:51:52.816974
        last up action: 2017-11-17 10:51:52.816974
        in sync       : True

Door

The door instances manage the downlink traffic in the TC fabric and sit between nwks and muxs instances.

$ swark.door --help
usage: swark.door [-h] {list,add,remove,start} ...

Manage 'door' entries in system setup.

optional arguments:
  -h, --help            show this help message and exit

Subcommands:
  {list,add,remove,start}
    list                List 'door' entities registered in the system configuration.
    add                 Add 'door' entity to system configuration.
    remove              Remove 'door' entity from system configuration.
    start               Start a door process.

List door configurations.

$ swark.door list --help
usage: swark.door list [-h]

optional arguments:
  -h, --help  show this help message and exit

Example:
$ swark.door list
doorid_________:_config_________________
::0             : {'uri': 'ws://localhost:7003'}

Add door instance configuration to system configuration.

$ swark.door add --help
usage: swark.door add [-h] [--id doorid] [--uri wsuri] [--extra file|json]

optional arguments:
  -h, --help         show this help message and exit
  --id doorid        Provide identity of the 'door' entity. If absent find an unused identity.
  --uri wsuri        Websocket URI specifying host and port of the server. Door accepts connections from muxs and nwks at this
                     address. Default: ws://localhost:7003.
  --extra file|json  Provide a file with a yaml/json object or specify a yaml/json object literally. The fields of the object
                     are added to the data entry being created.

Example:
$ swark.door add --id door-::1 --uri ws://localhost:8013

Remove door configuration from system configuration.

$ swark.door remove --help
usage: swark.door remove [-h] doorid

positional arguments:
  doorid      Provide identity of the 'door' entity.

optional arguments:
  -h, --help  show this help message and exit

Example:
$ swark.door remove door-::0

Start configured door instance.

$ swark.door start --help
usage: swark.door start [-h] [--pid file] doorid

positional arguments:
  doorid      Provide the identity of the door.

optional arguments:
  -h, --help  show this help message and exit
  --pid file  The file or directory where to write the process pid. If the path ends with a slash then append a file name based
              on the id. Otherwise use the file as is. Default: /TCDIR/tc/temp.

Example:
$ swark.door start door-::0

Infos

The infos instance implements directory services for routers and owners to direct them to their web socket access point in the fabric (muxs or appx instance).

$ swark.infos --help
usage: swark.infos [-h] {list,add,remove,query,redirect-routers,start} ...

Manage infos entries in system setup.
optional arguments:
  -h, --help            show this help message and exit

Subcommands:
  {list,add,remove,query,redirect-routers,start}
    list                List infos registered in the system configuration.
        add                 Add infos to system configuration.
    remove              Remove infos from system configuration.
    query               Query remote infos and retrieve information.
    redirect-routers    Add/update/remove redirected information for routers. Existing URI entries are overwritten or deleted
                        if no routerids specified.
    start               Start a infos process.

List infos configurations.

$ swark.infos list --help
usage: swark.infos list [-h]

optional arguments:
  -h, --help  show this help message and exit

Example:
$ swark.infos list
infosid________:_config_________________
::0             : {'uri': 'ws://localhost:7000', 'influx': 'http://localhost:8086'}

Add infos instance configuration to system configuration.

$ swark.infos add --help
usage: swark.infos add [-h] [--id infosid] [--uri wsuri] [--influx httpuri] [--extra file|json]

optional arguments:
  -h, --help         show this help message and exit
  --id infosid       Provide identity of 'infos' service. If absent assume zero.
  --uri wsuri        Websocket URI specifying host and port of the server. Infos accepts connections from routers and owners at
                     this address. Default: ws://localhost:7000.
  --influx httpuri   Host and port of the influxdb server. Default: http://localhost:8086.
  --extra file|json  Provide a file with a yaml/json object or specify a yaml/json object literally. The fields of the object
                     are added to the data entry being created.

Example:
$ swark.infos add --id infos-::0 --uri ws://localhost:8014

Remove infos configuration from system configuration.

$ swark.infos remove --help
usage: swark.infos remove [-h] infosid

positional arguments:
  infosid     Provide identity of the infos.

optional arguments:
  -h, --help  show this help message and exit

Example:
$ swark.infos remove infos-::0

Start configured infos instance.

$ swark.infos start --help
usage: swark.infos start [-h] [--pid file] infosid

positional arguments:
  infosid     Provide the identity of the infos.

optional arguments:
  -h, --help  show this help message and exit
  --pid file  The file or directory where to write the process pid. If the path ends with a slash then append a file name based
              on the id. Otherwise use the file as is. Default: /TCDIR/tc/temp.

Example:
$ swark.infos start infos-::0

Query infos simulating router/owner client.

$ swark.infos query --help
usage: swark.infos query [-h] [--id id6] [--tls dir] uri entity

positional arguments:
  uri         URI of the infos service. URI must have scheme http/https or ws/wss.
  entity      The entity for which to retrieve info optional arguments:
  -h, --help  show this help message and exit
  --id id6    Use this identity when connecting to given URI. Default: infos-0
  --tls dir   Directory for TLS related files. Default: /TCDIR/tc/pki-stash

Example:
$ swark.infos query ws://localhost:7000 owner-c::1
{'appx_list': [{'appxid': 'appx-::0',
                'uri': 'ws://localhost:7002/owner-c::1',
                'version': 1}],
 'owner': 'owner-c::1',
 'release': 1,
 'version': 1}

Redirect incoming router queries to remote info server.

$ swark.infos redirect-routers --help
usage: swark.infos redirect-routers [-h] [--id infosid] infos_wsuri [routerid [routerid ...]]

positional arguments:
  infos_wsuri   Infos URI which is contacted to answer infos requests for the listed routers.
  routerid      List of routerids. Existing entry is replaced with the new list. If no routerids specified then the entry is
                deleted.

optional arguments:
  -h, --help    show this help message and exit
  --id infosid  Provide identity of 'infos' service. If absent assume zero.

Joins

The joins instances authenticate OTAA devices on join requests handled by muxs instances.

$ swark.joins --help
usage: swark.joins [-h] {list,add,remove,start} ...

Manage 'joins' entries in system setup.

optional arguments:
  -h, --help            show this help message and exit

Subcommands:
  {list,add,remove,start}
    list                List 'joins' entities registered in the system configuration.
    add                 Add 'joins' entity to system configuration.
    remove              Remove 'joins' entity from system configuration.
    start               Start a joins process.

List joins configurations.

$ swark.joins list --help
usage: swark.joins list [-h]

optional arguments:
  -h, --help  show this help message and exit

Example:
$ swark.joins list
joinsid_________:_config_________________
::0             : {'uri': 'ws://localhost:7005', 'netid': 0}

Add joins instance configuration to system configuration.

$ swark.joins add --help
usage: swark.joins add [-h] [--id joinsid] [--uri wsuri] [--netid num] [--extra file|json]

optional arguments:
  -h, --help         show this help message and exit
  --id joinsid       Provide identity of the 'joins' entity. If absent find an unused identity.
  --uri wsuri        Websocket URI specifying host and port of the server. Joins accepts connections from muxs at this address.
                     Default: ws://localhost:7005.
  --netid num        The network identifier used in join accept messages. Default: 0
  --extra file|json  Provide a file with a yaml/json object or specify a yaml/json object literally. The fields of the object
                     are added to the data entry being created.

Example:
$ swark.joins add --id joins-::0 --uri ws://localhost:8015 --netid 0

Remove joins configuration from system configuration.

$ swark.joins remove --help
usage: swark.joins remove [-h] joinsid

positional arguments:
  joinsid     Provide identity of the 'joins' entity.

optional arguments:
  -h, --help  show this help message and exit

Example:
$ swark.joins remove joins-::0

Start configured joins instance.

$ swark.joins start --help
usage: swark.joins start [-h] [--pid file] joinsid

positional arguments:
  joinsid     Provide the identity of the joins.

optional arguments:
  -h, --help  show this help message and exit
  --pid file  The file or directory where to write the process pid. If the path ends with a slash then append a file name based
              on the id. Otherwise use the file as is. Default: /TCDIR/tc/temp.

Example:
$ swark.joins start infos-::0

Joinserver

The ‘swark.joinserver’ command allows to add/remove Join EUIs handled by remote join servers.

$ swark.joinserver --help
usage: swark.joinserver [-h] {list,add,remove} ...

Manage join server entries in system setup.

optional arguments:
  -h, --help         show this help message and exit

Subcommands:
  {list,add,remove}
    list             List registered join servers in the system configuration.
    add              Add a join server to system configuration.
    remove           Remove a join server from system configuration.

List join server configurations.

$ swark.joinserver list --help
usage: swark.joinserver list [-h]

optional arguments:
  -h, --help  show this help message and exit

Example:
$ swark.joinserver list
joineui__________________:_config_________________
00-02-04-05-07-AA-BB-01 : {'uri': 'ws://localhost:9002', 'owner': 3377699720527873}

Register remote join server.

$ swark.joinserver add --help
usage: swark.joinserver add [-h] joineui wsuri owner

positional arguments:
  joineui     Provide the EUI of the join server.
  wsuri       Websocket URI specifying the server address.
  owner       The owner of the device authorized and enrolled through this join server.

optional arguments:
  -h, --help  show this help message and exit

Example:
$ swark.joinserver add 00-02-04-05-07-AA-BB-01 ws://localhost:9002 owner-c::1

Remove join server entry from system configuration.

$ swark.joinserver remove --help
usage: swark.joinserver remove [-h] joineui

positional arguments:
  joineui     Provide EUI of the join server.

optional arguments:
  -h, --help  show this help message and exit

Example:
$ swark.joinserver remove 00-02-04-05-07-AA-BB-01

Muxs

The muxs instances are the connection points for routers and forward traffic to responsible nwks instances.

$ swark.muxs --help
usage: swark.muxs [-h] {list,add,remove,drop,connections,start} ...

Manage muxs entries in system setup.

optional arguments:
  -h, --help            show this help message and exit

Subcommands:
  {list,add,remove,drop,connections,start}
    list                List muxs registered in the system configuration.
    add                 Add muxs to system configuration.
    remove              Remove muxs from system configuration.
    drop                Drop connections to routers and make them reconnect.
    connections         List router connections.
    start               Start a muxs process.

List muxs configurations.

$ swark.muxs list --help
usage: swark.muxs list [-h]

optional arguments:
  -h, --help  show this help message and exit

Example:
$ swark.muxs list
muxsid     | door       | joins      | pkfwd | uri             (-- etc. config)
-----------+------------+------------+-------+-------------------------------------
-
::0        | ::0        | ::0        |  1680 | ws://localhost:7001

Add muxs instance configuration to system configuration.

$ swark.muxs add --help
usage: swark.muxs add [-h] [--id muxsid] [--uri wsuri] [--door doorid] [--joins joinsid] [--pkfwd port] [--extra file|json]

optional arguments:
  -h, --help         show this help message and exit
  --id muxsid        Provide identity of the muxs. If absent find an unused identity.
  --uri wsuri        Websocket URI specifying host and port of the server. Muxs accepts connections from routers at this
                     address. Default: ws://localhost:33033.
  --door doorid      Identity of the door server that organizes down link traffic for this muxs and it's attached routers.
                     Default: 0
  --joins joinsid    Identity of the joins server that provides session state from join request messages. Default: 0
  --pkfwd port       Enable Semtech packet forwarder protocol on given UDP port. To disable Semtech packet forwarder specify
                     port 0. Default port is 1680
  --extra file|json  Provide a file with a yaml/json object or specify a yaml/json object literally. The fields of the object
                     are added to the data entry being created.

Example:
$ swark.muxs add --id muxs-::0 --uri ws://localhost:8015  --joins joins-::0 --door 
door-::0

Remove muxs configuration from system configuration.

$ swark.muxs remove --help
usage: swark.muxs remove [-h] muxsid

positional arguments:
  muxsid      Provide identity of the muxs.

optional arguments:
  -h, --help  show this help message and exit

Example:
$ swark.muxs remove muxs-::0

Start configured muxs instance.

$ swark.muxs start --help
usage: swark.muxs start [-h] [--pid file] muxsid

positional arguments:
  muxsid      Provide the identity of the muxs.

optional arguments:
  -h, --help  show this help message and exit
  --pid file  The file or directory where to write the process pid. If the path ends with a slash then append a file name based
              on the id. Otherwise use the file as is. Default: /TCDIR/tc/temp.

Example:
$ swark.muxs start muxs-::0

Query connection infos from muxs instances.

$ swark.muxs connections --help
usage: swark.muxs connections [-h]

optional arguments:
  -h, --help  show this help message and exit

Example:
$ swark.muxs connections
muxs-::0
+---------------------+--------------------------+----------------------------
| Router ID6          | Connected to             | Firmware
+---------------------+--------------------------+----------------------------
| 200:1c49:7bcd:4b8b  | ws://93.61.18.210:3711   | 1.15.13-odu 2017-11-08T15:35+01:00 EU868
| 201:1c49:7bcd:4b8b  | ws://93.61.18.210:3590   | 1.15.13-odu 2017-11-08T15:35+01:00 EU868
| 2:0:f:301           | ws://84.242.161.211:35434 | Simulation
| 1::                 | ws://84.242.161.211:35440 | Simulation
...

Drop muxs connections.

$ swark.muxs drop --help
usage: swark.muxs drop [-h] routerids [routerids ...]

positional arguments:
  routerids   Lists of router IDs. Ranges or individual IDs ({id6|id6..id6|id6#N},..)

optional arguments:
  -h, --help  show this help message and exit

DEXS

The dexs instances allow to bridge device traffic from owners to non-websocket communication protocols such as MQTT.

$ swark.dexs --help
usage: dexs [-h] {start,remove,info,add-mqtt,add-sqs,add-mhub} ...

Data exchange service.

optional arguments:
  -h, --help            show this help message and exit

Subcommands:
  {start,remove,info,add-mqtt,add-sqs,add-mhub}
    start               Start a dexs process.
    remove              Remove dexs from system configuration.
    info                Get dexs info from system configuration.
    add-mqtt            Add dexs to system configuration.
    add-sqs             Add sqs bridge to dexs configuration.
    add-mhub            Add mhub bridge to dexs configuration.

Print dexs and dexs bridges info.

$ swark.dexs info --help
usage: dexs info [-h] id

positional arguments:
  id          Dexs Id.

optional arguments:
  -h, --help  show this help message and exit

Example:
$ swark.dexs info dexs-::0
{   'bridgeid': 1,
    'clientid': 'clientid',
        'enabled': True,
    'host': 'localhost',
    'method': 'mqtt',
    'owner': 3377699720527873,
    'parser': None,
    'passwd': 'passwd',
    'port': 1883,
    'type': 'mqtt',
    'user': 'user',
    'variant': 'default'}

Remove dexs or dexs bridge.

$ swark.dexs remove --help
usage: dexs remove [-h] [--bridgeid BRIDGEID] id

positional arguments:
  id                   Dexs ID.

optional arguments:
  -h, --help           show this help message and exit
  --bridgeid BRIDGEID  Bridge ID.

Example:
$ swark.dexs remove --bridgeid 0 dexs-::0      # Remove bridge with ID 0
$ swark.dexs remove dexs-::0                   # Remove all bridges and dexs instance

Add or create MQTT bridge configuration for dexs configuration.

$ swark.dexs add-mqtt --help
usage: dexs add-mqtt [-h] [--id ID] [--user USER] [--passwd PASSWD] [--host HOST] [--port PORT] [--method METHOD]
                     [--clientid CLIENTID] [--variant VARIANT] [--parser PARSER]
                     owner

positional arguments:
  owner                Owner.

optional arguments:
  -h, --help           show this help message and exit
  --id ID              Dexs ID. Default: 0
  --user USER          MQTT username.
  --passwd PASSWD      MQTT password.
  --host HOST          MQTT password.
  --port PORT          MQTT port.
  --method METHOD      MQTT method.
  --clientid CLIENTID  MQTT clientid.
  --variant VARIANT    MQTT variant.
  --parser PARSER      Classname of PDU parser if required.

Example:
$ swark.dexs add-mqtt --user user --passwd passwd --clientid clientid owner-c::1

Add or create MessageHub bridge configuration for dexs configuration.

$ swark.dexs add-mhub --help
usage: dexs add-mhub [-h] [--id ID] [--uri URI] [--token TOKEN] [--topic TOPIC] [--parser PARSER] owner

positional arguments:
  owner            Owner.

optional arguments:
  -h, --help       show this help message and exit
  --id ID          Dexs ID. Default: 0
  --uri URI        Message hub uri.
  --token TOKEN    Message hub auth token.
  --topic TOPIC    Message hub topic.
  --parser PARSER  Classname of PDU parser if required.

Add or create SQS bridge configuration for dexs configuration.

$ swark.dexs add-sqs --help
usage: dexs add-sqs [-h] [--id ID] [--qname1 QNAME1] [--qname2 QNAME2] [--parser PARSER] [--owner OWNER]

optional arguments:
  -h, --help       show this help message and exit
  --id ID          Dexs ID. Default: 0
  --qname1 QNAME1  SQS queue name 1.
  --qname2 QNAME2  SQS queue name 2.
  --parser PARSER  Classname of PDU parser if required.
  --owner OWNER    Owner.

Start dexs instance.

$ swark.dexs start --help
usage: dexs start [-h] [--pid file] dexsid

positional arguments:
  dexsid      Provide the identity of the dexs.

optional arguments:
  -h, --help  show this help message and exit
  --pid file  The file or directory where to write the process pid. If the path end s with a slash then append a file name based
              on the id. Otherwise use the file as is. Default: /TCDIR/tc/temp.

Example:
$ swark.dexs start dexs-::0

Owner Management

List, add, configure or remove owners.

$ swark.owner --help
usage: swark.owner [-h] {list,add,remove,retention,rename} ...

Manage owner entries in system setup.

optional arguments:
  -h, --help            show this help message and exit

Subcommands:
  {list,add,remove,retention,rename}
    list                List owners registered in system configuration.
    add                 Add owner to system configuration.
    remove              Remove owner from system configuration.
    retention           View or change data retention of owners.
    rename              Rename user friendly name of an owner.

Add an owner.

$ swark.owner add --help
usage: swark.owner add [-h] [--id ownerid] [--name str] [--nwks nwksid,..] [--retain timespan] [--extra file|json]

optional arguments:
  -h, --help         show this help message and exit
  --id ownerid       Provide identity of the owner. If absent find an unused identity.
  --name str         User friendly name. If absent choose a default friendly name.
  --nwks nwksid,..   List of network server identities. The handling of devices from this owner will be spread out over these
                     servers. If absent use server 0 by default
  --retain timespan  Retain unclaimed up messages at most for this time span. Default: 14d
  --extra file|json  Provide a file with a yaml/json object or specify a yaml/json object literally. The fields of the object
                     are added to the data entry being created.

Example:
$ swark.owner add --name Name1 --id owner-c::1

Remove an owner.

$ swark.owner remove --help
usage: swark.owner remove [-h] ownerid

positional arguments:
  ownerid     Provide identity of the owner.

optional arguments:
  -h, --help  show this help message and exit

List owners.

$ swark.owner list --help
usage: swark.owner list [-h]

optional arguments:
  -h, --help  show this help message and exit

Example:
$ swark.owner list
ownerid      | retain |  nwks  | name
-------------+--------+--------+-----------------------------
1::          |    10m |      0 | owner-1::
c::1         |    20d |      0 | Name
c::2         |    14d |      0 | Name2
c::3         |    14d |      0 | Name3

Rename owner.

$ swark.owner rename --help
usage: swark.owner rename [-h] ownerid name

positional arguments:
  ownerid     Id of the owner
  name        New user friendly name

optional arguments:
  -h, --help  show this help message and exit

Example:
$ swark.owner rename owner-c::1 Name

List and modify retention timespan for owner.

$ swark.owner retention --help
usage: swark.owner retention [-h] [--span {NUM{d,h,m,s,ms}}..] [{id6|id6..id6|id6#N},.. [{id6|id6..id6|id6#N},.. ...]]
positional arguments:
  {id6|id6..id6|id6#N},..
                        List of individual owners or owner ranges. If absent assumeall currently enrolled owners.

optional arguments:
  -h, --help            show this help message and exit
  --span {NUM{d,h,m,s,ms}}..
                        Set retention period of all specified owners to this value.
 If absent just list the retention periods.

Example:
$ swark.owner retention
       10m |                 1:: | owner-1::
       20d |                c::1 | Name
       14d |                c::2 | Name2
       14d |                c::3 | Name3
$ swark.owner retention --span 20d owner-c::1
Appx processes will automatically pick up the new retention spans in about 1h
For an immediate change restart appx instances.

Regions Management

List, add, or remove regions.

$ swark.regions --help
usage: swark.regions [-h] {list,info,add,prune,defaults,sx1301,change} ...

Manage region specific channel plans.

optional arguments:
  -h, --help            show this help message and exit

Subcommands:
  {list,info,add,prune,defaults,sx1301,change}
    list                List all defined regions.
    info                Show detailed information for each specified region.
    add                 Add a new region setup.
    prune               Find regions not longer in use. Note: this operation is quite expensive since if scan the whole router
                        and device population.
    defaults            Setup default regions if not existing yet.
    sx1301              Map region to SX1301 hardware.
    change              Change a region's setup name and/or remark text.

Add a region.

$ swark.regions add --help
usage: swark.regions add [-h] [--remark text] region setup [spec [spec ...]]

positional arguments:
  region         The name of the region this setup is based on. Choose from the following list: AS923, AU915, CN470, CN779,
                 EU433, EU863, IN865, KR920, US902
  setup          Name of this specific region setup. This name must use only alphanumeric characters and underscore.
  spec           A list of setup specifications. Syntax depends on the region this is based on. Regions US902,AU915,CN470
                 require a list of channel numbers or channel ranges (e.g. 0-16 64 65). All other regions take a list of
                 frequencies with an optional datarate or datarate range. (e.g. 863.7MHz 863.9/7 863.9MHz/0-7 )

optional arguments:
  -h, --help     show this help message and exit
  --remark text  A short text describing this setup. Empty if absent.

Example:
$ swark.regions add EU863 tracknet 868.85/0-5 869.05/0-5 869.525/0-5

List regions:

$ swark.regions list --help
usage: swark.regions list [-h]

optional arguments:
  -h, --help  show this help message and exit

Example:
$ swark.regions list
___id_:_region_:_setup_________:_up_chnls_:_remark_________________
    1 : EU863  : default       :      3   :
    2 : US902  : default       :     72   :
    3 : EU433  : default       :      3   :
    4 : AU915  : default       :     72   :
    5 : CN470  : default       :     96   :
    6 : CN779  : default       :      3   :
    7 : AS923  : default       :      2   :
    8 : KR920  : default       :      3   :
    9 : IN865  : default       :      3   :
 1000 : EU863  : tracknet      :      6   :
 1001 : US902  : block0        :      9   :

Print regions info.

$ swark.regions info --help
usage: swark.regions info [-h] region [region ...]

positional arguments:
  region      Provide a regionid or the region name/setup (e.g. region-1, 1, EU863/default)

optional arguments:
  -h, --help  show this help message and exit

 Example:
$ swark.regions info EU863/tracknet
Region   : EU863/tracknet   region-1000
Remark   :
Spectrum : 863MHz - 870MHz
RX2      : 869.525MHz DR0

Datarates & mapping to DN datarates:
            RX1DRoff |   0  |   1  |   2  |   3  |   4  |   5  |
           effective |   0  |   1  |   2  |   3  |   4  |   5  |
DR0:SF12BW125        | DR0  | DR0  | DR0  | DR0  | DR0  | DR0  |
DR1:SF11BW125        | DR1  | DR0  | DR0  | DR0  | DR0  | DR0  |
DR2:SF10BW125        | DR2  | DR1  | DR0  | DR0  | DR0  | DR0  |
DR3:SF9BW125         | DR3  | DR2  | DR1  | DR0  | DR0  | DR0  |
DR4:SF8BW125         | DR4  | DR3  | DR2  | DR1  | DR0  | DR0  |
DR5:SF7BW125         | DR5  | DR4  | DR3  | DR2  | DR1  | DR0  |
DR6:SF7BW250         | DR6  | DR5  | DR4  | DR3  | DR2  | DR1  |
DR7:FSK              | DR7  | DR7  | DR5  | DR4  | DR3  | DR2  |
DR8:RFU              |
DR9:RFU              |
DR10:RFU             |
DR11:RFU             |
DR12:RFU             |
DR13:RFU             |
DR14:RFU             |
DR15:RFU             |

Channels 0-6:
0 : 868.1MHz   : DR0-DR5   |
1 : 868.3MHz   : DR0-DR5   |
2 : 868.5MHz   : DR0-DR5   |
3 : 868.85MHz  : DR0-DR5   |
4 : 869.05MHz  : DR0-DR5   |
5 : 869.525MHz : DR0-DR5   |

TXPower steps (Max EIRP - value):
Index |   0 |   1 |   2 |   3 |   4 |   5 |   6 |   7 |
Value |   0 |  -2 |  -4 |  -6 |  -8 | -10 | -12 | -14 |

Prune regions.

$ swark.regions prune --help
usage: swark.regions prune [-h] [--delete]

optional arguments:
  -h, --help  show this help message and exit
  --delete    Remove the obsolete entries. If absent just list them.

Setup default regions.

$ swark.regions defaults --help
usage: swark.regions defaults [-h]

optional arguments:
  -h, --help  show this help message and exit

Propose maping for SX1301.

$ swark.regions sx1301 --help
usage: swark.regions sx1301 [-h] [--json] [--text] region [nsx1301] [spec [spec ...]]

positional arguments:
  region      Provide a regionid or the region name/setup (e.g. region-1, 1, EU863/default)
  nsx1301     Number of available SX1301 units. If absent or 0 infer the number of SX1301 to serve this channel plan.
  spec        Tentative channel plan to be validated. If this is present argument `nsx1301` must be present too. Format of
              arguments as in `add` subcommand.

optional arguments:
  -h, --help  show this help message and exit
  --json      Print JSON configuration
  --text      Print human readable description

Change name/sescription of region.

$ swark.regions change --help
usage: swark.regions change [-h] [--setup text] [--remark text] region

positional arguments:
  region         Provide a regionid or the region name/setup. This specifier must identify a single region definition.

optional arguments:
  -h, --help     show this help message and exit
  --setup text   A new setup name. If absent do not change.
  --remark text  A new remark text accompaying the region. If absent do not change.

Token Management

Access tokens are associated with owners and capabilities and control the access by REST invcations. AES keys associated with a apis instances are used to create the random token strings.

$ swark.tocap --help
usage: swark.tocap [-h] {list-keys,add-key,remove-key,list,add,remove,show} ...

Manage tokens.

optional arguments:
  -h, --help            show this help message and exit

Subcommands:
  {list-keys,add-key,remove-key,list,add,remove,show}
    list-keys           List keys.
    add-key             Add key.
    remove-key          Remove key.
    list                List tocaps: <Id6> <Capabilities> <Token>
    add                 Add tocap.
    remove              Remove tocap.
    show                Show first token of specified owner.

List tokens.

$ swark.tocap list --help
usage: swark.tocap list [-h]

optional arguments:
  -h, --help  show this help message and exit

Example:
$ swark.tocap list
tocap-a283:c634:d5f6:dadc      None          Aa4wAFic3Xk6oZFOBoVKM08fP2Yq  DRTO
tocap-d550:ad7f:a399:3e49      owner-c::1    Aa4wAFiBsa/5WAL7UqQ5RsCRkskL  DR--
tocap-82f:77d0:e421:214f       owner-c::2    Aa4wAFiI1cn55Hajx5xf5HbSxwNV  DRT-
tocap-37ff:ef1:8c8e:c31a       owner-c::3    Aa4wAFhQ+oyITWFuRz0lspLddZAU  D---

Add a token.

$ swark.tocap add --help
usage: swark.tocap add [-h] [--apisid APISID] [--ownerid OWNERID] [--capabilities CAPABILITIES] [-r] [-d] [-o] [-t]

optional arguments:
  -h, --help            show this help message and exit
  --apisid APISID       API server id. Default: apis-::0.
  --ownerid OWNERID     Owner.
  --capabilities CAPABILITIES
                        Capabilities string, combination of 'D', 'R', 'O' and 'T'
  -r, --can-manage-router
                        If true, permits to manage routers. Default: True.
  -d, --can-manage-device
                        If true, permits to manage devices. Default: True.
  -o, --can-manage-owner
                        If true, permits to manage owner. Default: False.
  -t, --can-manage-token
                        If true, permits to manage tokens. Default: True.

Example:
$ swark.tocap add --ownerid c::2 --capabilities DRT

Remove a token.

$ swark.tocap remove --help
usage: swark.tocap remove [-h] tocap

positional arguments:
  tocap       Remove tocap, either specify tocap id or token.

optional arguments:
  -h, --help  show this help message and exit

Example:
$ swark.tocap remove tocap-309e:a9fd:cf87:5490

Show first token registered for owner.

$ swark.tocap show --help
usage: swark.tocap show [-h] [--ownerid OWNERID]

optional arguments:
  -h, --help         show this help message and exit
  --ownerid OWNERID  Owner.

Example:
$ swark.tocap show --ownerid c::2

List keys used for token generation.

$ swark.tocap list-keys --help
usage: swark.tocap list-keys [-h] [--apisid APISID]

optional arguments:
  -h, --help       show this help message and exit
  --apisid APISID  API server id. Default: apis-::0.

Example:
$ swark.tocap list-keys
apis-::0: 8b9a0592686c2fcfca6de0c04eb9bee4 (active)

Add a key for token generation.

$ swark.tocap add-key --help
usage: swark.tocap add-key [-h] [--apisid APISID] key

positional arguments:
  key              Key. 32 hex characters required.

optional arguments:
  -h, --help       show this help message and exit
  --apisid APISID  API server id. Default: apis-::0.

Example:
$ swark.tocap add-key 00.....FF

Remove a key.

$ swark.tocap remove-key --help
usage: swark.tocap remove-key [-h] [--apisid APISID] key

positional arguments:
  key              Key. 32 hex characters required.

optional arguments:
  -h, --help       show this help message and exit
  --apisid APISID  API server id. Default: apis-::0.

Example:
$ swark.tocap remove-key 00.....FF

Device Management

List, add, remove, configure devices.

$ swark.device --help
usage: swark.device [-h] {list,info,add,remove,adr,devaddr,upmsg} ...

Manage device entries in system setup.

optional arguments:
  -h, --help            show this help message and exit

Subcommands:
  {list,info,add,remove,adr,devaddr,upmsg}
    list                List enrolled devices and their owners.
    info                Print information about devices.
    add                 Add devices to system configuration.
    remove              Remove device from system configuration.
    adr                 Configure ADR for a set of devices.
    devaddr             List devices that might match a specific device short address.
    upmsg               List buffered up messages for the specified devices.

List devices.

$ swark.device list --help
usage: swark.device list [-h] [-l LIMIT] [-o OWNER] [-v] [deveui]

positional arguments:
  deveui                Continue listing after this device EUI.

optional arguments:
  -h, --help            show this help message and exit
  -l LIMIT, --limit LIMIT
                        Limit output to this number of lines. Default: 50
  -o OWNER, --owner OWNER
                        List devices for this owner only. If absent list all devices irrespective of ownership.
  -v, --verbose         List devices individually. If absent cluster blocks of devices with same owner.

Example:
$ swark.device list
-------------------------------+---------------------+----------------
Device EUI                     | Owner               | Remarks
-------------------------------+---------------------+----------------
00-01-00-00-00-00-00-00        |                 1:: | all live OTAA
00-02-0C-01-00-00-00-01..00-02 |                c::1 | all provisioned OTAA
00-02-0C-02-00-00-00-01..00-02 |                c::2 | all ABP
00-02-0C-03-00-00-00-01..00-02 |                c::3 | all provisioned OTAA
End of device list.

Print device info.

$ swark.device info --help
usage: swark.device info [-h] deveui [deveui ...]

positional arguments:
  deveui      Device EUIs or ranges of EUIs (eui..eui or eui#N).

optional arguments:
  -h, --help  show this help message and exit

 Example:
$ swark.device info 58-A0-CB-00-00-20-10-D9
58-A0-CB-00-00-20-10-D9 - OTAA provisioned and live
ownerid         : c::64
nwksid          : 0
provdb_pstate   : {'AppKey': 'F24714B86E30CB5E91DFD0943D51F186',
 'JoinEui': '00-00-00-00-00-00-00-00',
 'NwkKey': 'B42B9AAFE098F91AD4BA0AE55B71C81C',
 'OptNeg': 0,
 'dC': 0}
lns_sess_sstate : {'AFCntDown': 0,
 'AppSKey': 'C4685FDC46CA02629904D5C0AE2F4271',
 'DevAddr': 22623118,
 'FCntUp': 39,
 'NFCntDown': 1,
 'NextSessID': 4,
 'NwkSKeyDwn': 'B5A7ED37587E0B5E178D047FAEBACEFD',
 'NwkSKeyUp': '77DA91235CF9A477E6EDBF638540F196',
....

Add devices.

$ swark.device add --help
usage: swark.device add [-h] [--owner ownerid] [--lw10] [--devkey aeskey] [--nwkkey aeskey] [--appkey aeskey]
                        [--joineui joineui] [--devaddr num|0xHEX] [--nwkskeyup aeskey] [--nwkskeydn aeskey] [--nwkskey aeskey]
                        [--appskey aeskey] [--insecure-fcnt] [--extra file|json] [--derive-otaa secret] [--derive-abp secret]
                        [--region region] [--rxdelay 0-15] [--rx1droff off] [--rx2dr 0-15] [--rx2freq freq] [--classC]
                        {deveui|eui..eui|eui#N} .. [{deveui|eui..eui|eui#N} .. ...]

positional arguments:
  {deveui|eui..eui|eui#N} ..
                        Provide identity (EUI) of the device.
optional arguments:
  -h, --help            show this help message and exit
  --owner ownerid       Provide the identity of the owner. Default: 0.
  --lw10                Specify if device complies with LoraWan v1.0
  --devkey aeskey       Secret device key (OTAA, v1.0)
  --nwkkey aeskey       Network device key (OTAA, >v1.0)
  --appkey aeskey       Application device key (OTAA, >v1.0)
  --joineui joineui     Join EUI (OTAA). Default: 00-00-00-00-00-00-00-00.
  --devaddr num|0xHEX   Short address of device (ABP)
  --nwkskeyup aeskey    Network session key for up frame (ABP, > v1.0)
  --nwkskeydn aeskey    Network session key for down frames (ABP, > v1.0)
  --nwkskey aeskey      Network session key (ABP, v1.0)
  --appskey aeskey      Application session key (ABP)
  --insecure-fcnt       Enable insecure reset of frame counter.
  --extra file|json     Provide a file with a yaml/json object or specify a yaml/json object literally. The fields of the
                        object are added to the data entry being created.
  --derive-otaa secret  Cryptographically derive OTAA parameters from given secret string. The secret string should be ASCII
                        encodable.
  --derive-abp secret   Cryptographically derive ABP parameters from given secret string. The secret string should be ASCII
                        encodable.
  --region region       Provision a region. This is mandatory if one of the --rx* options is provided. If absent a region is
                        inferred from first uplink traffic.
  --rxdelay 0-15        Provision device with a specific RxDelay. If absent assume LaRa MAC default settings.
  --rx1droff off        Provision device with a specific RX1DRoff to counter up/down link budget asymmetry. If absent assume
                        LoRa MAC default settings.
  --rx2dr 0-15          Provision device with a specific RX2DR. If absent assume LoRa MAC default settings.
  --rx2freq freq        Provision device with a specific RX2Freq. If absent assume LoRa MAC default settings.
  --classC              Provision device with class C mode.

Example:
$ swark.device add --owner c::1 --derive-otaa abracadabra 00-02-0C-01-00-00-00-01#2
$ swark.device add --owner c::2 --derive-abp abracadabra 00-02-0C-02-00-00-00-01#2
$ swark.device add --owner c::3 --classC --derive-otaa abracadabra 00-02-0C-03-00-00-00-01#2

Remove devices.

$ swark.device remove --help
usage: swark.device remove [-h] {deveui|eui..eui|eui#N}.. [{deveui|eui..eui|eui#N}.. ...]

positional arguments:
  {deveui|eui..eui|eui#N}..
                        Provide single EUIs or EUI ranges.

optional arguments:
  -h, --help            show this help message and exit

Example:
$ swark.device remove 00-02-0C-01-00-00-00-01#2

Configure datarate for devices.

$ swark.device adr --help
usage: swark.device adr [-h] {dr=N deveui|eui..eui|eui#N ..}.. [{dr=N deveui|eui..eui|eui#N ..}.. ...]

positional arguments:
  {dr=N deveui|eui..eui|eui#N ..}..
                        Specify a datarate dr=N followed by a list of device EUIs. N is either a specific datarate number valid
                        for the device's region (0..14). Or it is one of the characters '-','x', or 'X' to denote that no
                        particular target datarate is set. In this case the default builtin ADR schema takes control. It is
                        possible to specify multiple datarate device EUI lists. A device EUIs may be specified individually or
                        as a range or as an EUI followed by '#' and the range length.

optional arguments:
  -h, --help            show this help message and exit

Router Management

List, add, remove, configure routers.

$ swark.router --help
usage: swark.router [-h] {info,list,add,update,remove} ...

Manage router entries in system setup.

optional arguments:
  -h, --help            show this help message and exit

Subcommands:
  {info,list,add,update,remove}
    info                List detailed info for a list of routers.
    list                List routers registered in the system configuration.
    add                 Add router to system configuration.
    update              Update a router's system configuration.
    remove              Remove router from system configuration.

List routers.

$ swark.router list --help
usage: swark.router list [-h] [-l LIMIT] [-o OWNER] [-v] [routerid]

positional arguments:
  routerid              Continue listing after this router id.

optional arguments:
  -h, --help            show this help message and exit
  -l LIMIT, --limit LIMIT
                        Limit output to this number of lines. Default: 50
  -o OWNER, --owner OWNER
                        List routers for this owner only. If absent list all routers irrespective of ownership.
  -v, --verbose         List all router configuration fields.

Example:
$ swark.router list
--------------------+---------------------+---------------------+----------------------+-------------------+---------------------------
Router ID6          | Owner               | Muxs                | GPS Location         | Region/Setup      |  Name
--------------------+---------------------+---------------------+----------------------+-------------------+---------------------------
b827:ebff:fefb:1761 | f::2                | ::0                 |  47.38758,   8.52750 | EU863/tracknet    | Limmatstr215
1::                 | 1::                 | ::0                 |   0.00000,   0.00000 | EU863/default     |
2:0:c:601           | c::6                | ::0                 |   0.00000,   0.00000 | EU863/default     | router-0C0601
...

Print router info.

$ swark.router info --help
usage: swark.router info [-h] routerid|mac [routerid|mac ...]

positional arguments:
  routerid|mac  Specify a routerid (ID6) or a MAC address (colon separated).

optional arguments:
  -h, --help    show this help message and exit

Example:
$ swark.router info b827:ebff:fefb:1761
--------------------------------------------------------------
Router ID6/MAC address : b827:ebff:fefb:1761 EB:FF:FE:FB:17:61
                 Owner : f::2
                  Muxs : ::0
               GPS loc : N47.387579,E8.527505
...

Add router.

$ swark.router add --help
usage: swark.router add [-h] [--id routerid] [--name label] [--muxs muxsid] [--region spec] [--gpsloc lat,lon]
                        [--owner ownerid] [--hw hwspec] [--count num] [--rxdelay num] [--rx1droff num] [--extra file|json]

optional arguments:
  -h, --help         show this help message and exit
  --id routerid      Provide identity of the router. If absent find an unused identity.
  --name label       Optional human readable name of the router. Empty string if absent.
  --muxs muxsid      Muxs instance to handle this router. Default: 0
  --region spec      Region setting. Default: EU863
  --gpsloc lat,lon   GPS location of router. If absent defaults to 0,0 which is an unlikly place for a router to be.
  --owner ownerid    This router is associated to a specific owner. If absent assume owner ::0.
  --hw hwspec        Hardware specifier. Choose from pkfwd,sx1301[/N],unknown. Assume unknown if absent.
  --count num        Create this number of routers with subsequent ids. All other parameters are the same for all created
                     routers.
  --rxdelay num      Indicate to the network server that down traffic via this router should prefer this RxDelay.
  --rx1droff num     Indicate to the network server that balancing up/down asymmetry would require this RX1DRoff.
  --extra file|json  Provide a file with a yaml/json object or specify a yaml/json object literally. The fields of the object
                     are added to the data entry being created.

Example:
$ swark.router add --id 58:A0:CB:01:02:8C --region US902/block0 --hw sx1301/1 --owner c::1

Update router.

$ swark.router update --help
usage: swark.router update [-h] --id routerid [--name label] [--muxs muxsid] [--region spec] [--gpsloc lat,lon]
                           [--owner ownerid] [--hw hwspec] [--count num] [--rxdelaynum] [--rx1droff num] [--extra file|json]

optional arguments:
  -h, --help         show this help message and exit
  --id routerid      Provide identity of the router which should be updated.
  --name label       Optional human readable name of the router. Empty string if absent.
  --muxs muxsid      Muxs instance to handle this router. Default: None
  --region spec      Region setting. Default: None
  --gpsloc lat,lon   GPS location of router. If absent defaults to None which is an unlikly place for a router to be.
  --owner ownerid    This router is associated to a specific owner. If absent assume owner ::0.
  --hw hwspec        Hardware specifier. Choose from pkfwd,sx1301[/N],unknown. Assume None if absent.
  --count num        Create this number of routers with subsequent ids. All other parameters are the same for all created
                     routers.
  --rxdelay num      Indicate to the network server that down traffic via this router should prefer this RxDelay.
  --rx1droff num     Indicate to the network server that balancing up/down asymmetry would require this RX1DRoff.
  --extra file|json  Provide a file with a yaml/json object or specify a yaml/json object literally. The fields of the object
                     are added to the data entry being created.

Export/Import State (Devices, Routers, Owners)

The swark.export command exports device/router/owner information into a folder which can then be imported on the same TC instance in a different owner account or imported on a separate TC installation (on the same owner account).

Export command.

$ swark.export --help
usage: swark.export [-h] {routers,routers-cont,devices,devices-cont,owners,owners-cont} ...

Export routers, devices, and owners together with associated data.
optional arguments:
  -h, --help            show this help message and exit

Subcommands:
  {routers,routers-cont,devices,devices-cont,owners,owners-cont}
    routers             Export routers from system.
    routers-cont        Continue exporting routers after an interruption.
    devices             Export devices from system.
    devices-cont        Continue exporting devices after an interruption.
    owners              Export owners from system.
    owners-cont         Continue exporting owners and associated routers/devices after an interruption.

Export devices.

$ swark.export devices --help
usage: swark.export devices [-h] [--dir DIR] [--remove] [--messages MESSAGES] devicespecs [devicespecs ...]

positional arguments:
  devicespecs          A list of device specifications. They are one of the followi

ng: owner, owner/euilist, euilist. Euilist
                       is a sequence of device EUIs or EUI ranges.
optional arguments:
  -h, --help           show this help message and exit
  --dir DIR            Export data into this directory. Default: exported_devices
  --remove             Remove devices after they have been exported
  --messages MESSAGES  If argument is "none" or 0 then do not export any messages. 
If argument is a time span (e.g. 3d, 1h
                       etc.) then export only the most recent messages. The default is to export all messages.

Example:
$ swark.export devices 00-02-0C-01-00-00-00-01#2

Continue last export of devices after an interruption.

$ swark.export devices-cont --help
usage: swark.export devices-cont [-h] [--dir DIR] [--retry | --skip] [-v]

optional arguments:
  -h, --help     show this help message and exit
  --dir DIR      Directory with data exported so far. Default: exported_devices
  --retry        Retry the failed removals
  --skip         Ignore the failures and move on
  -v, --verbose  Print detailed list of devices failed to remove.

Example:
$ swark.export devices-cont      # in directory of previous try

Export routers.

$ swark.export routers --help
usage: swark.export routers [-h] [--dir DIR] [--remove] routerspecs [routerspecs ...]

positional arguments:
  routerspecs  A list of router specifications. They are one of the following: owner, owner/routerlist, routerlist. Routerlist
               is a sequence of router ids or router ranges.

optional arguments:
  -h, --help   show this help message and exit
  --dir DIR    Export data into this directory. Default: exported_routers
  --remove     Remove routers after they have been exported

Example:
$ swark.export routers 2:0:c:601#2

Continue last export of routers after an interruption.

$ swark.export routers-cont --help
usage: swark.export routers-cont [-h] [--dir DIR] [--retry | --skip] [-v]

optional arguments:
  -h, --help     show this help message and exit
  --dir DIR      Directory with data exported so far. Default: exported_routers
  --retry        Retry the failed removals
  --skip         Ignore the failures and move on
  -v, --verbose  Print detailed list of routers failed to remove.

Example:
$ swark.export routers-cont      # in directory of previous try

Export owners.

$ swark.export owners --help
usage: swark.export owners [-h] [--dir DIR] [--remove] [--all-but] [--messages MESSAGES] [ownerspecs [ownerspecs ...]]

positional arguments:
  ownerspecs           A list of owner specifications. They are one of the following: owner, ownerlist. Ownerlist is a sequence
                       of owner ids or owner ranges. If omitted then export all owners present in the system if --all-but is
                       specified.

optional arguments:
  -h, --help           show this help message and exit
  --dir DIR            Export data into this directory. Default: exported_owners
  --remove             Remove owners and associated routers/devices after they have been exported
  --all-but            Export all owners present in the system but the ones listed.
  --messages MESSAGES  If argument is "none" or 0 then do not export any messages. 

If argument is a time span (e.g. 3d, 1h
                       etc.) then export only the most recent messages. The default is to export all messages.

Example:
$ swark.export owners c::1 c::2 c::3

Continue last export of owners after an interruption.

$ swark.export owners-cont --help
usage: swark.export owners-cont [-h] [--dir DIR] [--retry | --skip] [-v]

optional arguments:
  -h, --help     show this help message and exit
  --dir DIR      Directory with data exported so far. Default: exported_owners
  --retry        Retry the failed removals
  --skip         Ignore the failures and move on
  -v, --verbose  Print detailed list of the failure.

Example:
$ swark.export owners-cont      # in directory of previous try

Import command.

$ swark.import --help
usage: swark.import [-h] {routers,routers-cont,devices,devices-cont,owners,owners-cont} ...

Import routers, devices, and owners together with associated data.
optional arguments:
  -h, --help            show this help message and exit

Subcommands:
  {routers,routers-cont,devices,devices-cont,owners,owners-cont}
    routers             Import routers into system.
    routers-cont        Continue importing routers into system.
    devices             Import devices into system.
    devices-cont        Continue importing devices into system.
    owners              Import owners and associated routers/devices into this system.
    owners-cont         Continue importing owners into the system.

Import devices.

$ swark.import devices --help
usage: swark.import devices [-h] [-v] [--owner id6] [dir]

positional arguments:
  dir            Read export data from this directory. If absent assuming the defau
lt export directory: exported_devices

optional arguments:
  -h, --help     show this help message and exit
  -v, --verbose  Print more details on a failed import attempt
  --owner id6    Associate imported devices with this owner

Example:
$ swark.import devices 00-02-0C-01-00-00-00-01#2

Continue last import of devices after an interruption.

$ swark.import devices-cont --help
usage: swark.import devices-cont [-h] [-v] [--keep | --override] [dir]

positional arguments:
  dir            Read export data from this directory

optional arguments:
  -h, --help     show this help message and exit
  -v, --verbose  Print more details on a failed import attempt
  --keep         Keep the existing devices and discard conflicting import data.
  --override     Remove existing devices and replace with import data.

Example:
$ swark.import devices-cont      # in directory of previous try

Import routers.

$ swark.import routers --help
usage: swark.import routers [-h] [-v] [--owner id6] [--muxs {id6|id6..id6|id6#N},..] [--map-muxs name] [dir]

positional arguments:
  dir                   Read export data from this directory. If absent assuming the default export directory: exported_routers

optional arguments:
  -h, --help            show this help message and exit
  -v, --verbose         Print more details on a failed import attempt
  --owner id6           Associate imported routers with this owner
  --muxs {id6|id6..id6|id6#N},..
                        List of muxs ids to use during import procedure. An allocation scheme determines how imported routers
                        are mapped to this list. If absent use all currently provisioned muxs instances.
  --map-muxs name       Mapping scheme from old muxs to new muxs. Default: zero. Ch

oose one from: zero

Example:
$ swark.import routers 2:0:c:601#2

Continue last import of routers after an interruption.

$ swark.import routers-cont --help
usage: swark.import routers-cont [-h] [-v] [--keep | --override] [dir]

positional arguments:
  dir            Read export data from this directory

optional arguments:
  -h, --help     show this help message and exit
  -v, --verbose  Print more details on a failed import attempt
  --keep         Keep the existing routers and discard conflicting import data.
  --override     Remove existing routers and replace with import data.

Example:
$ swark.import routers-cont      # in directory of previous try

Import owners.

$ swark.import owners --help
usage: swark.import owners [-h] [-v] [--owner id6] [--as-owner id6] [--muxs {id6|id6..id6|id6#N},..] [--map-muxs name]
                           [--nwks {id6|id6..id6|id6#N},..] [--map-nwks name]
                           [dir]

positional arguments:
  dir                   Read export data from this directory. If absent assuming the default export directory: exported_owners

optional arguments:
  -h, --help            show this help message and exit
  -v, --verbose         Print more details on a failed import attempt
  --owner id6           Import only this owner out of all exported owners
  --as-owner id6        Rename owner during import to this id
  --muxs {id6|id6..id6|id6#N},..
                        List of muxs ids to use during import procedure. An allocation scheme determines how imported routers
                        are mapped to this list. If absent use all currently provisioned muxs instances.
  --map-muxs name       Mapping scheme from old muxs to new muxs. Default: zero. Choose one from: zero
  --nwks {id6|id6..id6|id6#N},..
                        List of nwks ids to use during import procedure. An allocation scheme determines how imported network
                        server references are mapped to this list. If absent use all currently provisioned nwks instances.
  --map-nwks name       Mapping scheme from old nwks to new nwks. Default: all. Choose one from: all

Example:
$ swark.import owners c::1 c::2 c::3

Continue last import of owners after an interruption.

$ swark.import owners-cont --help
usage: swark.import owners-cont [-h] [-v] [--keep | --override] [dir]

positional arguments:
  dir            Read export data from this directory

optional arguments:
  -h, --help     show this help message and exit
  -v, --verbose  Print more details on a failed import attempt
  --keep         Keep the existing items and discard conflicting import data.
  --override     Remove existing items and replace with import data.

Example:
$ swark.import owners-cont      # in directory of previous try

Inspection Commands

Event Log

Use ‘swark.evlog’ to filter and monitor events and messages between system process instances, routers and devices.

$ swark.evlog --help
usage: swark.evlog [-h] {list-filters,add-filter,remove-filters,sync-filters,add-watch,remove-watch,list-watch,show-events} ...

Manage event log entries in system setup and processes.

optional arguments:
  -h, --help            show this help message and exit

Subcommands:
  {list-filters,add-filter,remove-filters,sync-filters,add-watch,remove-watch,list-watch,show-events}
    list-filters        List all event log filter definitions.
    add-filter          Add filter condition for recording system events. Note, that events have a sense of direction. They
                        flow from LOCAL to PEER. If the event represents a message then LOCAL is the sender and PEER is the
                        receiving entity. If the event represents a process internal action then LOCAL is originating entity
                        and PEER describes what is acted upon.
    remove-filters      Remove specific event log filters.
    sync-filters        Sync filter settings in all process with database.
    add-watch           Add a filter watching for specific device EUIs or device short addresses.
    remove-watch        Remove specific device EUIs or device short addresses from watch filter.
    list-watch          List all device watches.
    show-events         List recorded events.

List all events filters.

$ swark.evlog list-filters --help
usage: swark.evlog list-filters [-h]

optional arguments:
  -h, --help  show this help message and exit

Example:
$ swark.evlog list-filters
Persisted filters from resdb:
filter id=muxs-router-connect-disconnect
  code: return evmsg.get("msgtype", "")=="connection"
  sink: resdb
  label   : muxs-router-connect-disconnect
  localcat: muxs

filter id=watch
  code: return evmsg.get('DevEui',None) in {'21-22-23-24-25-26-27-28', '36-35-36-30-79-36-5F-01'} or evmsg.get('DevAddr',None) in {538380295}
  sink: resdb
  label   : watch

Add event filter.

$ swark.evlog add-filter --help
usage: swark.evlog add-filter [-h] [--fid num] [--label str] [--code pycode|file|-|?|help] [--sink pguri] [--localcat cat,..]
                              [--localid id,..] [--peercat cat,..] [--peerid id,..]
optional arguments:
  -h, --help            show this help message and exit
  --fid num             Create or update the specified filter. If absent find a new empty filter id.
  --label str           User friendly label of the filter. Multiple filter definitions may carry the same label.
  --code pycode|file|-|?|help
                        Python code that checks if the filter applies. If absent assume "return True". Use '?' or 'help' to get
                        more info on function API.
  --sink pguri          A postgres URI where to sent the data to. If absent defaults to "resdb" which refers to the same
                        database that store res_config table.
  --localcat cat,..     A comma separated list of entity categories this filter applies to. Applies to any entity if absent.
  --localid id,..       A comma separated list of entity ids (Id6,EUI,integer) this filter applies to. Applies to any entity id
                        if absent.
  --peercat cat,..      A comma separated list of entity categories this filter applies to. Applies to any entity if absent.
  --peerid id,..        A comma separated list of entity ids (Id6,EUI,integer) this filter applies to. Applies to any entity id
                        if absent.

Example:
$ swark.evlog add-filter --fid 50000 --peerid router-b827:ebff:fefb:1761        # all events related to specified router

Remove event filter.

$ swark.evlog remove-filters --help
usage: swark.evlog remove-filters [-h] [--all] [--label str,..] [filterids [filterids ...]]

positional arguments:
  filterids       Provide a list of comma separated filter ids.

optional arguments:
  -h, --help      show this help message and exit
  --all           Remove all filters.
  --label str,..  Remove all filters carrying one of the labels. Can be specified multiple times.

Example:
$ swark.evlog remove-filters 50000

Synchronize event filters. Let all TC processes update their internal filters configuration with global system configuration.

$ swark.evlog sync-filters --help
usage: swark.evlog sync-filters [-h]

optional arguments:
  -h, --help  show this help message and exit

Add device watch, a set of filters for a particular device.

$ swark.evlog add-watch --help
usage: swark.evlog add-watch [-h] [--deveui {id6|eui|int},..] [--devaddr {0xHEX,int},..]

optional arguments:
  -h, --help            show this help message and exit
  --deveui {id6|eui|int},..
                        A comma separated list of device EUIs (as Id6, EUI, or integer value). This option may be used
                        repeatedly.
  --devaddr {0xHEX,int},..
                        A comma separated list of device EUIs (as Id6, EUI, or integer value). This option may be used
                        repeatedly.

Remove device watch and associated set of filters.

$ swark.evlog remove-watch --help
usage: swark.evlog remove-watch [-h] [--deveui {id6|eui|int},..] [--devaddr {0xHEX,int},..]

optional arguments:
  -h, --help            show this help message and exit
  --deveui {id6|eui|int},..
                        A comma separated list of device EUIs (as Id6, EUI, or integer value). This option may be used
                        repeatedly.
  --devaddr {0xHEX,int},..
                        A comma separated list of device EUIs (as Id6, EUI, or integer value). This option may be used
                        repeatedly.

List device watches.

$ swark.evlog remove-watch --help
usage: swark.evlog remove-watch [-h] [--deveui {id6|eui|int},..] [--devaddr {0xHEX, int},..]

optional arguments:
  -h, --help            show this help message and exit
  --deveui {id6|eui|int},..
                        A comma separated list of device EUIs (as Id6, EUI, or integer value). This option may be used
                        repeatedly.
  --devaddr {0xHEX,int},..
                        A comma separated list of device EUIs (as Id6, EUI, or integer value). This option may be used
                        repeatedly.

Example:
$ swark.evlog list-watch
Devices EUIs being watched:
    21-22-23-24-25-26-27-28  2122:2324:2526:2728  2387509390608836392
    36-35-36-30-79-36-5F-01  3635:3630:7936:5f01  3906087833633709825
Device short addresses being watched:
    538380295 (0x20170807)

Show events.

$ swark.evlog show-events --help
usage: swark.evlog show-events [-h] [-l num] [-b num|#evid|date|time] [-c pycode|file|-|?|help] [--matches n|n..|..m|n..m]

optional arguments:
  -h, --help            show this help message and exit
  -l num, --limit num   Limit the number of entries being printed. Default: 100
  -b num|#evid|date|time, --begin num|#evid|date|time
                        Start listing at this point. Date/time formats: Y-m-d, H:M:S, "Y-m-d H:M:S", Y-m-dTH:M:S.
  -c pycode|file|-|?|help, --code pycode|file|-|?|help
                        Specify some python code to select events. Use '?' or 'help' to get more info on function API.
  --matches n|n..|..m|n..m
                        Expected number of events. Exit with 2 if number of found events outside of range.

Example:
$ swark.evlog show-events
#31896     | muxs-::0 -->            | { 'DR': 5,
16:34:41   |            --> nwks-::0 |   'DevAddr': 366365,
           |                         |   'DevEui': '00-02-00-00-00-0F-03-01',
           |                         |   'FCntUp': 63070,
           |                         |   'FCtrl': 128,
           |                         |   'FOpts': '',
           |                         |   'FPort': 136,
           |                         |   'FRMPayload': 'F6C3FD59BEDB7E2E6BBBF3',
           |                         |   'Freq': 868300000,
           |                         |   'MHdr': 64,
           |                         |   'MIC': -1695147461,
           |                         |   'msgtype': 'updf',
           |                         |   'regionid': 1,
           |                         |   'upinfo': { 'ArrTime': 1510936481.7965991,
           |                         |               'RX1DRoff': 0,
           |                         |               'RxDelay': 0,
           |                         |               'doorid': 0,
           |                         |               'muxid': 0,
           |                         |               'regionid': 1,
           |                         |               'routerid': 562949954405121,
           |                         |               'rssi': -52,
           |                         |               'rxtime': 1510936481.7952192,
           |                         |               'snr': 2,
           |                         |               'xtime': 1208902820689}}

System Validation and Health Check

Use ‘swark.system’ for validation of the system configuration and health checks.

$ swark.system --help
usage: swark.system [-h] {validate,rebalance,health} ...

Run management/maintenance operations affecting the whole TrackCentral system.

optional arguments:
  -h, --help            show this help message and exit

Subcommands:
  {validate,rebalance,health}
    validate            Validate all database table if compliant with this code.
    rebalance           Rebalance devices or routers.
    health              Print health information for specified system components or the whole system.

Validate system configuration database.

$ swark.system validate --help
usage: swark.system validate [-h]

optional arguments:
  -h, --help  show this help message and exit

Perform healthcheck and print connections status.

$ swark.system health --help
usage: swark.system health [-h] [--raw] [catid [catid ...]]

positional arguments:
  catid       Provide a category or the identity of a system component.

optional arguments:
  -h, --help  show this help message and exit
  --raw       Display raw JSON and do not format data.

Example:
$ swark.system health
-----------------+------------------+-----+---------------------------------------------
door-::0         | muxs_pool        |   0 | max=100  muxs-::0         remote=['127.0.0.1', 47322]
                 | nwks_pool        |   0 | max=100  nwks-::0         remote=['127.0.0.1', 47388]
                 | special_devices  |   0 |
-----------------+------------------+-----+---------------------------------------------
joins-::0        | black_list       |   1 |
                 | replay_cache     |   1 |
                 | replica_queue    |   0 |
                 | forward_queue    |   0 |
                 | nwks_pool        |   0 | max=100  nwks-::0         remote=['127.0.0.1', 7004]
                 | muxs_pool        |   0 | max=100  muxs-::0         remote=['127.0.0.1', 35874]
-----------------+------------------+-----+---------------------------------------------
muxs-::0         | pkfwds           |   0 |
                 | router_pool      |   0 | max=100  router-1::       remote=['127.0.0.1', 48790]
                 | nwks_pool        |   0 | max=100  nwks-::0         remote=['127.0.0.1', 7004]
....

Device Traffic Inspection

The swark.appsink command connects to appx instances on behalf of owners to inspect device traffic.

$ swark.appsink --help
usage: swark.appsink [-h] [--interactive] [--back tspan] [--time tspec] [--upid num] [--prio num] [--excl {up,dn}]
                     [--devs {EUI|EUI#n|EUI..EUI},..] [--watch-joins]
                     ownerid [connect]

Pretend to be a specific owner and collect messages from all devices. This tool prints all messages using a logger named
'appsink'. Without any special option only messages that arrive after the process started are reported. Using --back or --from
reports older messages if still stored on the server. Note that requesting historical messages will certainly include the
requested timespan but might also include some even older messages.

positional arguments:
  ownerid               The id of the owner.
  connect               The URI of the network server info service negotiating access to appx instances. Default:
                        ws://localhost:7000

optional arguments:
  -h, --help            show this help message and exit
  --interactive, -i     Run an interactive command input loop.
  --back tspan          Start delivering messages from this timespan ago. Time span syntax is: {NUM{d,h,m,s,ms}}..
  --time tspec          Report messages from point in time on. Time spec syntax is: yyyy-mm-dd[{T }HH:MM:SS][Z]
  --upid num            Report messages from the specified upid. Zero means report all stored messages.
  --prio num            Priority attached to appx connection.
  --excl {up,dn}        If connection is exclusive for up (up) and/or down (dn) traffic.
  --devs {EUI|EUI#n|EUI..EUI},..
                        List of devices to interact with. Individual EUIs or range in the form EUI#N, EUI..partialEUI
  --watch-joins         Watch and report join messages only

Example:
$ swark.appsink owner-::2c9
2017-11-17 17:56:30.092510 appx-::0:
{'ArrTime': 1510937790.0764093,
 'DR': 5,
 'DevEui': '00-00-00-00-00-00-10-04',
 'FCntUp': 2,
 'FPort': 1,
 'FRMPayload': 'E4273E42178E08411E2D',
 'Freq': 868500000,
 'SessID': 1332026449508,
 'ciphered': False,
 'confirm': False,
 'msgtype': 'updf',
 'region': 'EU863',
 'regionid': 1,
 'upid': 27708990084339628}
 ...

Simulation

Use ‘swark.devsim’ to instantiate simulated device and routers and monitor the communication. The devices and routers must have been provisioned before.

$ swark.devsim --help
usage: swark.devsim [-h] [--region name] [--count num] [--interval span] [--msgspecmsg[,..]] [--owner ID] [--joineui EUI]
                    [--stats span] [--duration span] [--media-cnt num] [--traffic CUP[,DN[,CDN]]] [--grace num[%]]
                    [--conn-rate num] [--all-connected span] [--link-check init,dead,cont] [--target-dr num] [--infer-dr num]
                    [--no-adr] [--classC span] [--pid file]
                    deveui [routers] [connect]

Simulate a couple of devices sending user specified messages. Devices and routers must be appropriately provisioned before this command is being used.

positional arguments:
  deveui                The EUI of the device being simulated
  routers               A list of simulated routers to forward device messages to muxs instances. Note: These routers must be
                        provisioned explicitely. You can specify a range of router by using '..' and two ids or by adding #N to
                        an id where N is a decimal number. Default: 2::0,2::1
  connect               The websocket URI specifying host and port of the network server's info service negotiating access to
                        muxs instances. Default: ws://localhost:7000

optional arguments:
  -h, --help            show this help message and exit
  --region name         Region name of the device simulation. Default: EU863
  --count num           The number of simulated devices to create. It will use the next subsequent numbers to the specified

                        EUI. Default: 1.
  --interval span       Messages are send in regular intervals of this size. Default: 30s. Span has the form:
                        {NUM{d,h,m,s,ms}}..
  --msgspec msg[,..]    Message specification: [port:]HEX[,..] Cycle thru the specified messages when sending alive messages. A
                        message spec consists of an optional decimal port number followed by a hexadecimal payload. Port and
                        data are separated by a colon. An absent port uses the previously specified port. The initial default
                        port is 1. Multiple message specs can be listed separated by a comma. Default: "1:"

  --owner ID            Connect to network server and retrieve messages for the specified owner.
  --joineui EUI         OTAA devices use this EUI in join requests. Default: 0
  --stats span          Interval to print statistics.
  --duration span       Duration of the simulation run. Run forever if absent.
  --media-cnt num       Routers and devices will be each split up into evenly sized groups. Each group is assigned to one
                        medium. A message send by a device or a router will be received and process by all routers aka devices.
                        Increasing this number from the default (1) is meant to reduce system load and computational overhead.

  --traffic CUP[,DN[,CDN]]
                        Defines the traffic shape the devices run thru. Every CUP upstream message ask for confirmation. Every
                        DN upstream message respond with a downstream frame. Every CDN downstream message ask for confirmation.
  --grace num[%]        Allow test to pass even if numbers do not add up perfectly. A plain number sets a maximum difference. A
                        number followed by percent sign sets a maximum quotient. E.g. 1 would allow one expected event to be
                        missing and 1% would accept up to 0.1 of the expected events to be missing.
  --conn-rate num       Specify a connection rate (connections/sec). Once the simulation starts all routers will connect at
                        once. This parameter will slow down connection attempts to approximately this rate. If connect fails a
                        router will perform a back off. Default: 100
  --all-connected span  Wait this time for all routers to be connected before starting the devices. This allows for reliable
                        test results but might be unpractical on large router populations. A timespan of 0 means to start the
                        devices despite not all routers connected. Messages might be lost in this case. Default value: 0. The
                        time span has the form {NUM{d,h,m,s,ms}}..
  --link-check init,dead,cont
                        A sequence of 3 positive integer values. The define how devices check for live links. The values are
                        init,dead,cont. After "init" UP frames without a DN response from the network a device will ask for a
                        sign of live (ADRACKREQ). If no DN frame arrives after "dead" more UP frames the datarate is decreased.
                        After this the devices expects a DN frame within the next "cont" frames before decreasing the datarate
                        again. The last step is reapeated until the lowest datarate is reached. Any DN frame restarts the link
                        check with the "init" state. If absent use the builtin defaults of LMIC.

  --target-dr num       Target datarate for externally controlled ADR. All devices get told by the network to use this
                        datarate. Once all devices have adopted this datarate the test stops successfully.
  --infer-dr num        Setup media so that default ADR scheme of network converges on specified datarate. Once all devices
                        have adopted this datarate the test stops successfully.
  --no-adr              Devices run with ADR bit off. They are not ADR controlled by the network.
  --classC span         Interval sending DN message for class C devices.
  --pid file            The file or directory where to write the process pid. If the path ends with a slash then append a file
                        name based on the id. Otherwise use the file as is. Default: None.
Example:
$ swark.device add --owner c::1 --derive-otaa abracadabra 4096#4     # 4 devices starting 00-00-00-00-00-00-10-00
$ swark.device add --owner c::1 --derive-otaa abracadabra 4096#4     # 4 devices starting 00-00-00-00-00-00-10-00
$ swark.router add --owner c::1 --id 8192
$ swark.devsim --count 4 --traffic 0,0,0 4096 8192

PKI Management

TC fabric process instances and connected routers may be protected by TLS communication with client and server authentication. The necessary certificates are managed solely by the TC PKI infrastructure and are derived from a managed self-signed root certificate. Certificates enrollment, validation and extension are managed by the swark.pki command.

$ swark.pki --help
usage: swark.pki [-h] {export,enroll,list,root,wss,trust} ...

Manage pki infrastructure.

optional arguments:
  -h, --help            show this help message and exit

Subcommands:
  {export,enroll,list,root,wss,trust}
    export              Export TLS setup for specified entities.
    enroll              Enroll system entities into PKI infrastructure. Signal certain states via exit codes: (0) all fine, no
                        new certificate issued. (7) at least one new certificate was issued. (*) any other value is an error.
    list                List expiry information of currently issued certificates.
    root                Ensure root certificate meets certain validity requirements.
    wss                 Export TLS setup for a specific client/server and run some connection test using python websockets.
    trust               Export trusted set of certificates.

Enroll or renew system instance certificates.

$ swark.pki enroll --help
usage: swark.pki enroll [-h] [--renew] [--good-for span] [--req file] [--dns fqdn] 
[--on-renew ON_RENEW] [idspec [idspec ...]]

positional arguments:
  idspec               A list of individual or ranges of system identities. If absent all TLS enabled entities are checked.

optional arguments:
  -h, --help           show this help message and exit
  --renew              Enforce renewal of certificates irrespective of the remaining validity period.
  --good-for span      Renew certificates if validity is less than specified time span. Default: 30d
  --req file           If the specified entity is an "owner" then a certificate request maybe specified.
  --dns fqdn           If the certificate is issued for one of (infos,appx,muxs,cups,apis) then you can specify a FQDN or a DNS
                       name with a wildcard. If omitted it defaults to the hostname of the components configured URI. This
                       option is ignored for any other certificate categories.
  --on-renew ON_RENEW  Exit code if root certificate was renewed. Default 7

Example:
$ swark.pki enroll --req nofile muxs-0
$ swark.pki enroll --dns localhost  muxs-0 owner-0
$ swark.pki enroll router-1
$ swark.pki enroll --req xreq.pem owner-c::1

List expiry information.

$ swark.pki list --help
usage: swark.pki list [-h] [--days num[,num]]

optional arguments:
  -h, --help        show this help message and exit
  --days num[,num]  The number of days the certificates are still valid. Default: -10,10000

Export TLS setup for specified entity and remote deployment.

$ swark.pki export --help
usage: swark.pki export [-h] [--dir DIR] [--zip] [--tar] id [id ...]

positional arguments:
  id          Category and Id6 of system entities.

optional arguments:
  -h, --help  show this help message and exit
  --dir DIR   Store files in this directory. Default: /TCDIR/tc/pki-stash
  --zip       Instead of individual files create a ZIP archive
  --tar       Instead of individual files create a TAR archive

Example:
$ swark.pki export --zip apis-::0
$ unzip -l apis-::0.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
     3363  2017-11-17 18:14   apis-::0.crt
     3489  2017-11-17 18:14   trust.crt
     1679  2017-11-17 18:14   apis-::0.key
$ swark.pki export --zip owner-c::1

Renewal/validation of root certificate.

$ swark.pki root --help
usage: swark.pki root [-h] [--renew] [--good-for span] [--on-renew ON_RENEW]

optional arguments:
  -h, --help           show this help message and exit
  --renew              Enforce renewal of root certificate irrespective of the remaining validity period.
  --good-for span      Renew root certificate if validity is less than specified time span. Default: 90d
  --on-renew ON_RENEW  Exit code if root certificate was renewed. Default 7

Export trusted set of certificates.

$ swark.pki trust --help
usage: swark.pki trust [-h] file

positional arguments:
  file        Store certificates in this file (PEM format). Default: trust.crt

optional arguments:
  -h, --help  show this help message and exit