{"id":26152235,"url":"https://github.com/lobaro/coap-go","last_synced_at":"2025-04-14T05:33:39.657Z","repository":{"id":118780551,"uuid":"72458898","full_name":"lobaro/coap-go","owner":"lobaro","description":"Lobaro CoAP for GoLang - server and client applications","archived":false,"fork":false,"pushed_at":"2021-10-18T12:58:03.000Z","size":812,"stargazers_count":20,"open_issues_count":1,"forks_count":1,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-27T19:21:34.011Z","etag":null,"topics":["cgo","coap","golang","stack","transport","uart"],"latest_commit_sha":null,"homepage":"http://www.lobaro.com/portfolio/lobaro-coap/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lobaro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-10-31T17:07:01.000Z","updated_at":"2024-12-26T23:57:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"4deaee5a-ccfc-4e10-b793-82ddc940d6ff","html_url":"https://github.com/lobaro/coap-go","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lobaro%2Fcoap-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lobaro%2Fcoap-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lobaro%2Fcoap-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lobaro%2Fcoap-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lobaro","download_url":"https://codeload.github.com/lobaro/coap-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248827613,"owners_count":21167909,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cgo","coap","golang","stack","transport","uart"],"created_at":"2025-03-11T06:59:30.768Z","updated_at":"2025-04-14T05:33:39.632Z","avatar_url":"https://github.com/lobaro.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lobaro CoAP for GoLang\n\nThis repository contains two parts: The **CoAP Client** and a **GoLang Server adapter**. The client focuses on RS232 connections where data is send via [Slip](https://tools.ietf.org/rfc/rfc1055.txt) and [SlipMUX](https://tools.ietf.org/html/draft-bormann-t2trg-slipmux-01)\n\n## Currently not Maintained\n\nSince we moved to existing more major CoAP implementations, this repo will stay unmaintained.\n\nWe recommend:\n\n* https://github.com/plgd-dev/go-coap\n* Plus DTLS: https://github.com/pion/dtls\n\n# GoLang CoAP RS232 Client \nCurrently only RS232 is supported. Transports for other Protocols like TCP/IP and UDP are planned.\n\n**Install:**\n```\ngo get -u github.com/lobaro/coap-go/coap\n```\n\nThe package is strctured similiar to the http package and tries to follow go idematic coding styles.\n\n# GoLang Server adapter for lobaro-coap\n\n**A word of warning:** While the C code works fine and is already used in several projects, the Go wrapper is still under construction. We might even considder to reimplement the server in Go rather than wrapping the C code.\n\n[Lobaro CoAP](https://github.com/lobaro/lobaro-coap) provides a highly portable CoAP stack for Client and Server running on almost any hardware.\n\nThe **GoLang adapter** uses cgo to provide a CoAP stack based on the code of Lobaro CoAP. It can be used for **testing the stack on a PC** and to **write server applications in go** that can handle CoAP connections.\n\n## Getting Started\n\nThe project consists of multiple submodules:\n\n* **coap** - A pure Go client library with an API similar to Go's http package. Supports multiple Transports (e.g. RS232).\n* **liblobarocoap** - A CGO wrapper around [Lobaro CoAP](https://github.com/lobaro/lobaro-coap) C Implementation.\n* **coapmsg** The underlying CoAP message structure used by other packages. Based on [dustin/go-coap](https://github.com/dustin/go-coap).\n\nIt is planned to extend the `coap` package to support more transports like UDP, TCP in future. The package will also get some code to setup CoAP servers. First based on `liblobarocoap` and later also in native Go.\n\nContributions are welcome!\n\n### Prerequisite \nTo build the project you need a C compiler and the matching [Go](https://golang.org/dl/) toolkit installed. \n\nFor Windows you can use [MinGW](http://www.mingw.org/) to install the gcc. \n\nWhen you have a 32 bit C compiler make sure you also use 32 bit Go. Else cgo will not be able to compile the C code.\n\n### Install the code\n\n```\ngo get -u github.com/lobaro/coap-go\n```\n\nExecute tests\n```\ngo test github.com/lobaro/coap-go\n```\n\nTo use the library in your project, just import\n```\nimport \"github.com/lobaro/coap-go\"\n```\n\n# Usage\n\n## Observe\n\n```\n// Start observing, res is the result of a GET request\nres, err := coap.Observe(url)\nif err != nil {\n\tpanic(err)\n}\n// Gracefully cancel the observe at the end of this function\ndefer coap.CancelObserve(res)\nvar timeoutCh time.After(60 * time.Second)\n\nfor {\n\tselect {\n\t// res.Next returns a response with a new Next channel\n\t// as soon as the client receives a notification from the server\n\tcase nextRes, ok := \u003c-res.Next:\n\t\tif !ok {\n\t\t\treturn\n\t\t}\n\t\tres = nextRes // update res for next interation\n\t\t// Handle the Notification (res)\n\tcase \u003c-time.After(20 * time.Second):\n\t\treturn // Cancel observe after 20 seconds of silence\n\tcase \u003c-timeoutCh:\n\t\treturn // Cancel observe after 60 seconds\n\t}\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flobaro%2Fcoap-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flobaro%2Fcoap-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flobaro%2Fcoap-go/lists"}