All Projects → plgd-dev → Go Coap

plgd-dev / Go Coap

Licence: apache-2.0
Implementation of CoAP Server & Client in Go

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Go Coap

Jetlinks
JetLinks Core
Stars: ✭ 380 (+68.14%)
Mutual labels:  coap, iot, udp
Californium
CoAP/DTLS Java Implementation
Stars: ✭ 521 (+130.53%)
Mutual labels:  coap, iot
Leshan
Eclipse Leshan is an OMA Lightweight M2M (LWM2M) implementation in Java.
Stars: ✭ 483 (+113.72%)
Mutual labels:  coap, iot
Emqx
An Open-Source, Cloud-Native, Distributed MQTT Message Broker for IoT.
Stars: ✭ 8,951 (+3860.62%)
Mutual labels:  coap, iot
Wakaama
Eclipse Wakaama is a C implementation of the Open Mobile Alliance's LightWeight M2M protocol (LWM2M).
Stars: ✭ 358 (+58.41%)
Mutual labels:  coap, iot
Groza
开源物联网平台 - 物联网解决方案的设备管理,数据收集,处理
Stars: ✭ 364 (+61.06%)
Mutual labels:  coap, iot
Rtos Wot
Open source FreeRTOS SDK for ESP8266 WiFi Module
Stars: ✭ 29 (-87.17%)
Mutual labels:  coap, iot
Iot Technical Guide
🐝 IoT Technical Guide --- 从零搭建高性能物联网平台及物联网解决方案和Thingsboard源码分析 ✨ ✨ ✨ (IoT Platform, SaaS, MQTT, CoAP, HTTP, Modbus, OPC, WebSocket, 物模型,Protobuf, PostgreSQL, MongoDB, Spring Security, OAuth2, RuleEngine, Kafka, Docker)
Stars: ✭ 2,334 (+932.74%)
Mutual labels:  coap, iot
Mainflux
Industrial IoT Messaging and Device Management Platform
Stars: ✭ 1,341 (+493.36%)
Mutual labels:  coap, iot
Awalwm2m
Awa LWM2M is an implementation of the OMA Lightweight M2M protocol in C.
Stars: ✭ 93 (-58.85%)
Mutual labels:  coap, iot
Pjon
PJON (Padded Jittering Operative Network) is an experimental, arduino-compatible, multi-master, multi-media network protocol.
Stars: ✭ 2,615 (+1057.08%)
Mutual labels:  iot, udp
Designiot
教你设计物联网系统。构建自己的Internet of Things 。
Stars: ✭ 1,983 (+777.43%)
Mutual labels:  coap, iot
Coapnet
CoAPnet is a high performance .NET library for CoAP based communication. It provides a CoAP client and a CoAP server. It also has DTLS support out of the box.
Stars: ✭ 23 (-89.82%)
Mutual labels:  coap, iot
Thingsboard
Open-source IoT Platform - Device management, data collection, processing and visualization.
Stars: ✭ 10,526 (+4557.52%)
Mutual labels:  coap, iot
Anjay
C implementation of the client-side OMA LwM2M protocol
Stars: ✭ 115 (-49.12%)
Mutual labels:  coap, iot
Ohsce
PHP HI-REL SOCKET TCP/UDP/ICMP/Serial .高可靠性PHP通信&控制框架SOCKET-TCP/UDP/ICMP/硬件Serial-RS232/RS422/RS485 AND MORE!
Stars: ✭ 206 (-8.85%)
Mutual labels:  iot, udp
Incubator Streampipes
Apache StreamPipes - A self-service (Industrial) IoT toolbox to enable non-technical users to connect, analyze and explore IoT data streams.
Stars: ✭ 209 (-7.52%)
Mutual labels:  iot
Vernemq
A distributed MQTT message broker based on Erlang/OTP. Built for high quality & Industrial use cases.
Stars: ✭ 2,628 (+1062.83%)
Mutual labels:  iot
Homeassistant Config
Stars: ✭ 211 (-6.64%)
Mutual labels:  iot
Aleph
Asynchronous communication for Clojure
Stars: ✭ 2,389 (+957.08%)
Mutual labels:  udp

Build Status codecov Go Report FOSSA Status backer sponsors contributors GitHub stars GitHub license GoDoc Sourcegraph

Go-CoAP

The Constrained Application Protocol (CoAP) is a specialized web transfer protocol for use with constrained nodes and constrained networks in the Internet of Things. The protocol is designed for machine-to-machine (M2M) applications such as smart energy and building automation.

The go-coap provides servers and clients for DTLS, TCP-TLS, UDP, TCP in golang language.

Features

Samples

Simple

Server UDP/TCP

	// Server
	
	// Middleware function, which will be called for each request.
	func loggingMiddleware(next mux.Handler) mux.Handler {
		return mux.HandlerFunc(func(w mux.ResponseWriter, r *mux.Message) {
			log.Printf("ClientAddress %v, %v\n", w.Client().RemoteAddr(), r.String())
			next.ServeCOAP(w, r)
		})
	}
	
	// See /examples/simple/server/main.go
	func handleA(w mux.ResponseWriter, req *message.Message) {
		err := w.SetResponse(codes.GET, message.TextPlain, bytes.NewReader([]byte("hello world")))
		if err != nil {
			log.Printf("cannot set response: %v", err)
		}
	}

	func main() {
		r := mux.NewRouter()
		r.Use(loggingMiddleware)
		r.Handle("/a", mux.HandlerFunc(handleA))
		r.Handle("/b", mux.HandlerFunc(handleB))

		log.Fatal(coap.ListenAndServe("udp", ":5688", r))

		
		// for tcp
		// log.Fatal(coap.ListenAndServe("tcp", ":5688",  r))

		// for tcp-tls
		// log.Fatal(coap.ListenAndServeTLS("tcp", ":5688", &tls.Config{...}, r))

		// for udp-dtls
		// log.Fatal(coap.ListenAndServeDTLS("udp", ":5688", &dtls.Config{...}, r))
	}

Client

	// Client
	// See /examples/simpler/client/main.go
	func main() {
		co, err := udp.Dial("localhost:5688")
		
		// for tcp
		// co, err := tcp.Dial("localhost:5688")
		
		// for tcp-tls
		// co, err := tcp.Dial("localhost:5688", tcp.WithTLS(&tls.Config{...}))

		// for dtls
		// co, err := dtls.Dial("localhost:5688", &dtls.Config{...}))

		if err != nil {
			log.Fatalf("Error dialing: %v", err)
		}
		ctx, cancel := context.WithTimeout(context.Background(), time.Second)
		defer cancel()
		resp, err := co.Get(ctx, "/a")
		if err != nil {
			log.Fatalf("Cannot get response: %v", err)
			return
		}
		log.Printf("Response: %+v", resp)
	}

Observe / Notify

Server example.

Client example.

Multicast

Server example.

Client example.

Contributing

In order to run the tests that the CI will run locally, the following two commands can be used to build the Docker image and run the tests. When making changes, these are the tests that the CI will run, so please make sure that the tests work locally before committing.

$ docker build . --network=host -t go-coap:build --target build
$ docker run --mount type=bind,source="$(pwd)",target=/shared,readonly --network=host go-coap:build go test './...'

License

Apache 2.0

FOSSA Status

Sponsors

Become a sponsor and get your logo on our README on Github with a link to your site.

Backers

Become a backer and get your image on our README on Github with a link to your site.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].