-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Migrate gocoap from v2 to v3.3
Signed-off-by: 1998-felix <[email protected]>
- Loading branch information
1 parent
cf8155f
commit bb2d8c1
Showing
763 changed files
with
292 additions
and
211,161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
COAP_CLI_HOST=localhost | ||
COAP_CLI_PORT=5683 | ||
COAP_CLI_CONTENT_FORMAT=50 | ||
COAP_CLI_AUTH= | ||
COAP_CLI_OBSERVE= | ||
COAP_CLI_CERT_FILE= | ||
COAP_CLI_KEY_FILE= | ||
COAP_CLI_SERVER_CA_FILE= | ||
COAP_CLI_CLIENT_CA_FILE= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,5 @@ | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
# Copyright (c) Abstract Machines | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# Test binary, build with `go test -c` | ||
*.test | ||
build/* | ||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
# build dirs | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
# Copyright (c) Abstract Machines | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
all: | ||
CGO_ENABLED=0 GOOS=linux go build -mod=vendor -ldflags "-s -w" -o build/coap-cli-linux cmd/main.go | ||
CGO_ENABLED=0 GOOS=darwin go build -mod=vendor -ldflags "-s -w" -o build/coap-cli-darwin cmd/main.go | ||
CGO_ENABLED=0 GOOS=windows go build -mod=vendor -ldflags "-s -w" -o build/coap-cli-windows cmd/main.go | ||
CGO_ENABLED=0 GOOS=linux go build -ldflags "-s -w" -o build/coap-cli-linux cmd/main.go | ||
CGO_ENABLED=0 GOOS=darwin go build -ldflags "-s -w" -o build/coap-cli-darwin cmd/main.go | ||
CGO_ENABLED=0 GOOS=windows go build -ldflags "-s -w" -o build/coap-cli-windows cmd/main.go | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,34 @@ | ||
# CoAP CLI | ||
Simple CoAP cli client written in Go. | ||
|
||
Simple CoAP cli client written in Go. | ||
|
||
## Usage | ||
|
||
Pre-built binary can be found here: https://github.com/mainflux/coap-cli/releases/tag/v0.3.3. | ||
When running, please provide following format: | ||
`coap-cli` followed by method code (`get`, `put`, `post`, `delete`) and CoAP URL. After that, you can pass following flags: | ||
|
||
| Flag | Description | Default value | | ||
| ---- | ---------------------------------------------- | ---------------- | | ||
| o | observe option - only valid with GET request | false | | ||
| auth | auth option sent as URI Query | "" | | ||
| h | host | "localhost" | | ||
| p | port | "5683" | | ||
| d | data to be sent in POST or PUT | "" | | ||
| cf | content format | 50 (JSON format) | | ||
| Flag | Description | Default value | | ||
| ---- | -------------------------------------------- | ---------------- | | ||
| o | observe option - only valid with GET request | false | | ||
| a | auth option sent as URI Query | "" | | ||
| H | host | "localhost" | | ||
| p | port | "5683" | | ||
| d | data to be sent in POST or PUT | "" | | ||
| cf | content format | 50 (JSON format) | | ||
|
||
The default values are as set in the [.env](.env) file. Modify them as required. | ||
|
||
## Examples: | ||
|
||
```bash | ||
coap-cli get channels/0bb5ba61-a66e-4972-bab6-26f19962678f/messages/subtopic -auth 1e1017e6-dee7-45b4-8a13-00e6afeb66eb -o | ||
coap-cli get channels/0bb5ba61-a66e-4972-bab6-26f19962678f/messages/subtopic --auth 1e1017e6-dee7-45b4-8a13-00e6afeb66eb -o | ||
``` | ||
|
||
```bash | ||
coap-cli post channels/0bb5ba61-a66e-4972-bab6-26f19962678f/messages/subtopic -auth 1e1017e6-dee7-45b4-8a13-00e6afeb66eb -d "hello world" | ||
coap-cli post channels/0bb5ba61-a66e-4972-bab6-26f19962678f/messages/subtopic -a 1e1017e6-dee7-45b4-8a13-00e6afeb66eb -d "hello world" | ||
``` | ||
|
||
```bash | ||
coap-cli post channels/0bb5ba61-a66e-4972-bab6-26f19962678f/messages/subtopic -auth 1e1017e6-dee7-45b4-8a13-00e6afeb66eb -d "hello world" -h 0.0.0.0 -p 1234 | ||
coap-cli post channels/0bb5ba61-a66e-4972-bab6-26f19962678f/messages/subtopic --auth 1e1017e6-dee7-45b4-8a13-00e6afeb66eb -d "hello world" -H 0.0.0.0 -p 1234 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package coapcli | ||
|
||
import ( | ||
"github.com/caarlos0/env/v10" | ||
"github.com/joho/godotenv" | ||
) | ||
|
||
type Config struct { | ||
Host string `env:"COAP_CLI_HOST"` | ||
Port string `env:"COAP_CLI_PORT"` | ||
ContentFormat int `env:"COAP_CLI_CONTENT_FORMAT"` | ||
Auth string `env:"COAP_CLI_AUTH"` | ||
Observe bool `env:"COAP_CLI_OBSERVE"` | ||
} | ||
|
||
func LoadConfig() (Config, error) { | ||
c := Config{} | ||
err := godotenv.Load() | ||
if err != nil { | ||
panic(err) | ||
} | ||
if err := env.Parse(&c); err != nil { | ||
return Config{}, err | ||
} | ||
return c, nil | ||
} |
Oops, something went wrong.