Giter Club home page Giter Club logo

coap-cli's Introduction

CoAP-CLI

Tests npm version

CoAP-CLI is a command line interface for CoAP, built on node.js and node-coap.

What is CoAP?

Constrained Application Protocol (CoAP) is a software protocol intended to be used in very simple electronics devices that allows them to communicate interactively over the Internet. - Wikipedia

Install

Install node.js, and then from a terminal:

npm install coap-cli -g

Usage

  Usage: coap command [options] url


  Commands:

    get      performs a GET request
    put      performs a PUT request
    post     performs a POST request
    delete   performs a DELETE request

  Options:

    -h, --help                    output usage information
    -V, --version                 output the version number
    -o, --observe                 Observe the given resource
    -n, --no-new-line             No new line at the end of the stream
    -p, --payload <payload>       The payload for POST and PUT requests
    -b, --block2 <option>         set the block2 size option
    -q, --quiet                   Do not print status codes of received packets
    -c, --non-confirmable         non-confirmable
    -t, --timeout <seconds>       The maximum send time in seconds
    -T, --show-timing             Print request time, handy for simple performance tests
    -O, --coap-option <key,value> Add COAP-Option to the request (repeatable)

PUT and POST

PUT and POST requests body are sent from the standard input by default. E.g.

echo -n 'hello world' | coap post coap://localhost/message

If you want to type it you can end the standard input by pressing CTRL-D.

License

Copyright (c) 2013 Matteo Collina

node-coap is licensed under an MIT +no-false-attribs license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.

coap-cli's People

Contributors

av-nb avatar blueben82 avatar dependabot-preview[bot] avatar dependabot[bot] avatar gerdemann avatar github-actions[bot] avatar jcbernack avatar jelmert avatar jkrhb avatar mcollina avatar neophob avatar sillevl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

coap-cli's Issues

URI with encoded characters not supported

Hello. I know you are busy and not able to actively maintain coap-cli, but I'm reporting this in case someone else hits this bug or take the lead of the project.

When I enter a URI with an encoded character, e.g. coap://example.com:5683/ps/%2F/cached, coap-cli does not decode the character and sends %2F in the URI-Path. RFC 7252, Appendix B suggests that / (the decoded character) should be sent instead.

I'm using coap-cli 0.4.0.

Add CoAP Option in Request

What is the way to make request with coAp option? #17

Itried this way, but it didn't work:

1)"-O" option command:

Input;

coap get -O "test" + , + "test" coap://localhost:5684/basic

Output:

Error: Option 'test' is invalid.
Please provide options in this way:
-O [Key]" + coapOptionSeperator + "[Value]
OR --coap-option [Key],[Value]

2)"--coap-option" option command:

Input:

coap get --coap-option [test],[test] coap://localhost:5684/basic

Output:

Error: Option '[test],[test]' is invalid.
Please provide options in this way:
-O [Key]" + coapOptionSeperator + "[Value]
OR --coap-option [Key],[Value]

Could you provide some sample?

Echo adds newline to payload

Apparently using echo in bash adds a newline character to the end of the byte array.

If you don't know this, and your server rejects the request because it has a malformed payload, you might be looking for the cause for a while.

Might it be a good idea to update the Readme to use printf instead?

printf 'hello world' | coap post coap://localhost/message

Problems with sending coap ipv6 messages in version 0.6.0+

Description

problems with sending standard (not dtls) coap ipv6 messages to Contiki-NG node via coap-cli version 0.6.0 and upper

Steps to Reproduce

Expected behavior

Actual behavior

debian@beaglebone:~$ coap get coap://[fd00::212:4b00:1cbc:1d51]/node/dtls -p 11223344
events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: getaddrinfo ENOTFOUND [fd00::212:4b00:1cbc:1d51]
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:67:26)  

(with coap-cli version 0.5.1 all good - remote node successfully receive the message)

Affected Versions

0.6.0, 0.6.1, 0.7.0

CLI does not exit since 0.11.0

Since the update to version 0.11.0 the CLI application does not exit anymore. The request is handled as expected but the program does not exit afterwards until forced with ctrl-c. Until 0.10.1 the application is exiting normally after the request is handled.

I didn't have time to debug it yet, but I'm guessing it has to do with upstream changes from [email protected].

Observing more than one server

Hello, I would like to know if it's possible to observe more than one coap server simultaneously using coap-cli. If so, how?

Numeric options are not encoded correctly

Description

Trying to (manually) use the Accept option with coap-cli, I noticed that integer-based options are currently not encoded correctly. I suppose this is caused by not using the correct (network) byte order, causing the options to be corrupted.

Steps to Reproduce

Invoke coap get coap://coap.me/hello -O 17,50 from the command line. Observe the CoAP network traffic (for example, using Wireshark).

Expected behavior

An Accept option with value 50 (application/json) should be included in the request.

Actual behavior

An Accept option with value 13161 is included.

Affected Versions

This happens with the latest version 0.11.1.

How to realized request with uri_query?

I tried this, but didn't work.

coap get coap://127.0.0.1/.well-known/?rt=light-lux
I sniffed with wireshark and It doesnt' show filter query passed in URI.

How do I send a parameter value?

Hey - this is a great tool. I'm having a small issue - maybe you've an idea.

I'm trying to send a specific value to a node.

Here's the result of the GET command:

coap get coap://10.219.114.14:5683/15011/15012/
(2.05)  {"9023":"46.165.194.70","9024":"52.28.154.39","9025":"gateway","9026":"****","9032":"https://da2s1apgus9tm.cloudfront.net/gway/ota/version_info.json","9027":"YOUR_AP_SSID","9028":"****","9059":1462964924,"9060":"2016-05-11T11:08:44.051320Z","9055":100,"9062":0,"9061":0,"9029":"0.7.0032","9054":0}

But the 9032 node is a bit odd.

coap get coap://10.219.114.14:5683/15011/15012/9032
(4.04)  Not Found

Using the Copper Firefox tool, I send this.

{"9032":"my value"}

How might that translate to this tool? I tried a few things and couldn't get it to work. I tried:

echo "hello" | coap put coap://10.219.114.14:5683/15011/15012/9032

Thanks very much!

coaps (CoAP over DTLS) support as described in RFC 7252 section-9.1

Is your feature request related to a problem? Please describe.
coap post coaps://192.168.0.4/message

Describe the solution you'd like
Initiate a DTLS exchange and transport CoAP over that secure DTLS link

Describe alternatives you've considered
Tunnel CoAP over TCP-TLS link - may be intractable for mesh devices

Additional context
Add any other context or screenshots about the feature request here.
https://tools.ietf.org/html/rfc7252#section-9.1

Tokens with 8 bit length

Why does this and other coap modules. not accept 8 bit tokens? Its a valid token length according to the IETF spec.. This is a fine module, but not workable with 8 bit servers.
Always getting:

throw new RangeError('Trying to access beyond buffer length');

Remove CONTRIBUTORS.md and associated workflow?

Since the contributors are shown on the GitHub page and the workflow somehow does not work/keeps failing, I would consider removing both, since the additional markdown file does not have that much additional value for the project.

Would you be fine with this, @gerdemann and @Apollon77?

Support coap options as hex

Currently this library only supports coap options in string format, like -O 2048,HelloWorld.
But there is no way to send coap options in hex format, which would make sense to save some overhead. An option might be to prefix the value with 0x, e.g. -O 2048,0x61, which would result in a lowercase "a".

Not working anymore after breaking changes in `commander` dependency?

The current version of coap-cli here on GitHub currently seems to not be working anymore because of breaking API changes to the commander module it is built upon. I would try to submit a PR with fixes for this issue soon. It might require changes to the command line interface as well, though.

Support DTLS Setup

Not is possible include digital certified file to realizade DTLS connection in CoAP messages

To development DTLS setup logic in client-side and to create new parameter to identify the operation when digital certified file is used.

For instance, it's necessary to investigate change points your source-code .

No additional context

support param

coap get coap://xxxx:5683/test?a=123
no matches found: coap://xxxx:5683/test?a=123

coap-client can get result

Cannot set property 'method' of undefined

Description

When trying to get a resource, I get the error message:

/usr/lib/node_modules/coap-cli/index.js:63
url.method = method
           ^

TypeError: Cannot set property 'method' of undefined
    at Object.<anonymous> (/usr/lib/node_modules/coap-cli/index.js:63:12)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)

I guess the issue here is the IPv6 address. It's a valid address, but it seems like the code cannot handle it.

Steps to Reproduce

  1. Have a coap server with a IPv6 link-local address.
  2. Try to access this source like coap get coap://[fe80::fab6:41ff:fe43:b5ab%bt0]/echo

Expected behavior

Success

Actual behavior

Error message

Affected Versions

0.7.1

Recommend Projects

  • React photo React

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

  • Vue.js photo Vue.js

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

  • Typescript photo Typescript

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

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

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

  • web

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

  • server

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

  • Machine learning

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

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

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

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.