Skip to content

Commit 1c9f53d

Browse files
authored
NOISSUE - Add support for different architectures especially riscv (#16)
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
1 parent e0f7b32 commit 1c9f53d

File tree

2 files changed

+61
-16
lines changed

2 files changed

+61
-16
lines changed

Makefile

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,32 @@
11
# Copyright (c) Abstract Machines
22
# SPDX-License-Identifier: Apache-2.0
33

4-
INSTALL_DIR=/usr/local/bin
5-
BUILD_DIR=build
6-
BUILD_FLAGS=-ldflags "-s -w"
4+
INSTALL_DIR ?= /usr/local/bin
5+
BUILD_DIR ?= build
6+
BUILD_FLAGS ?= -ldflags "-s -w"
7+
GOOS ?= $(shell go env GOOS)
8+
GOARCH ?= $(shell go env GOARCH)
79

8-
.PHONY: all linux darwin windows install install-linux
10+
.PHONY: all linux darwin windows install
911

1012
all: linux darwin windows
1113

1214
linux:
13-
CGO_ENABLED=0 GOOS=linux go build $(BUILD_FLAGS) -o $(BUILD_DIR)/coap-cli-linux main.go
15+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build $(BUILD_FLAGS) -o $(BUILD_DIR)/coap-cli-linux-amd64 main.go
16+
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build $(BUILD_FLAGS) -o $(BUILD_DIR)/coap-cli-linux-arm64 main.go
17+
CGO_ENABLED=0 GOOS=linux GOARCH=riscv64 go build $(BUILD_FLAGS) -o $(BUILD_DIR)/coap-cli-linux-riscv64 main.go
1418

1519
darwin:
16-
CGO_ENABLED=0 GOOS=darwin go build $(BUILD_FLAGS) -o $(BUILD_DIR)/coap-cli-darwin main.go
20+
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build $(BUILD_FLAGS) -o $(BUILD_DIR)/coap-cli-darwin-amd64 main.go
21+
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build $(BUILD_FLAGS) -o $(BUILD_DIR)/coap-cli-darwin-arm64 main.go
1722

1823
windows:
19-
CGO_ENABLED=0 GOOS=windows go build $(BUILD_FLAGS) -o $(BUILD_DIR)/coap-cli-windows main.go
20-
21-
install: install-linux
24+
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build $(BUILD_FLAGS) -o $(BUILD_DIR)/coap-cli-windows-amd64 main.go
25+
CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build $(BUILD_FLAGS) -o $(BUILD_DIR)/coap-cli-windows-arm64 main.go
2226

23-
install-linux:
24-
@cp $(BUILD_DIR)/coap-cli-linux $(INSTALL_DIR)/coap-cli || { echo "Installation failed"; exit 1; }
27+
install:
28+
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build $(BUILD_FLAGS) -o $(BUILD_DIR)/coap-cli main.go
29+
cp $(BUILD_DIR)/coap-cli $(INSTALL_DIR)/coap-cli || { echo "Installation failed"; exit 1; }
2530

2631
clean:
2732
rm -rf $(BUILD_DIR)/*

README.md

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,52 @@
22

33
Simple CoAP cli client written in Go.
44

5+
## Installation
6+
7+
### Linux
8+
9+
```bash
10+
# x86_64
11+
curl -sL https://github.com/absmach/coap-cli/releases/download/v0.4.1/coap-cli-linux-amd64 -o coap-cli && chmod +x coap-cli
12+
# arm64
13+
curl -sL https://github.com/absmach/coap-cli/releases/download/v0.4.1/coap-cli-linux-arm64 -o coap-cli && chmod +x coap-cli
14+
# riscv64
15+
curl -sL https://github.com/absmach/coap-cli/releases/download/v0.4.1/coap-cli-linux-riscv64 -o coap-cli && chmod +x coap-cli
16+
```
17+
18+
### MacOS
19+
20+
```bash
21+
# x86_64
22+
curl -sL https://github.com/absmach/coap-cli/releases/download/v0.4.1/coap-cli-darwin-amd64 -o coap-cli && chmod +x coap-cli
23+
# arm64
24+
curl -sL https://github.com/absmach/coap-cli/releases/download/v0.4.1/coap-cli-darwin-arm64 -o coap-cli && chmod +x coap-cli
25+
```
26+
27+
### Windows
28+
29+
```bash
30+
# x86_64
31+
curl -sL https://github.com/absmach/coap-cli/releases/download/v0.4.1/coap-cli-windows-amd64 -o coap-cli.exe
32+
# arm64
33+
curl -sL https://github.com/absmach/coap-cli/releases/download/v0.4.1/coap-cli-windows-arm64 -o coap-cli.exe
34+
```
35+
36+
### Build from source
37+
38+
Make sure you have Go and Make installed.
39+
40+
```bash
41+
git clone https://github.com/absmach/coap-cli.git
42+
cd coap-cli
43+
make install # or INSTALL_DIR=~/go/bin make install
44+
```
45+
546
## Usage
647

748
```bash
49+
CLI for CoAP
50+
851
Usage:
952
coap-cli [command]
1053

@@ -26,13 +69,11 @@ Flags:
2669
-k, --keep-alive uint Send a ping after interval seconds of inactivity. If not specified (or 0), keep-alive is disabled (default).
2770
-K, --key-file string Client key file
2871
-m, --max-retries uint32 Max retries for keep alive (default 10)
29-
-O, --options num,text Add option num with contents of text to the request. If the text begins with 0x, then the hex text (two [0-9a-f] per byte) is converted to binary data.
72+
-O, --options stringArray Add option num with contents of text to the request. If the text begins with 0x, then the hex text (two [0-9a-f] per byte) is converted to binary data.
3073
-p, --port string Port (default "5683")
3174
-v, --verbose Verbose output
32-
-d, --data string Data(default "") - only available for put, post and delete commands
33-
-o, --observe bool Observe - only available for get command
3475

35-
Use "coap-cli [command] --help" for more information about a command
76+
Use "coap-cli [command] --help" for more information about a command.
3677
```
3778

3879
The options flag accepts a comma separated string comprising of the optionID defined by [RFC-7252](https://datatracker.ietf.org/doc/html/rfc7252) and a string or hex value. Hex values are used to set options that require numerical values e.g observe, maxAge
@@ -55,7 +96,6 @@ coap-cli get m/aa844fac-2f74-4ec3-8318-849b95d03bcc/c/0bb5ba61-a66e-4972-bab6-26
5596
coap-cli post m/aa844fac-2f74-4ec3-8318-849b95d03bcc/c/0bb5ba61-a66e-4972-bab6-26f19962678f/subtopic --auth 1e1017e6-dee7-45b4-8a13-00e6afeb66eb -d "hello world"
5697
```
5798

58-
5999
```bash
60100
coap-cli post m/aa844fac-2f74-4ec3-8318-849b95d03bcc/c/0bb5ba61-a66e-4972-bab6-26f19962678f/subtopic --auth 1e1017e6-dee7-45b4-8a13-00e6afeb66eb -d "hello world" -H 0.0.0.0 -p 1234
61101
```

0 commit comments

Comments
 (0)