Skip to content
forked from bulyshko/coiot

CoIoT (based on CoAP) implementation for Shelly device in Go

License

Notifications You must be signed in to change notification settings

shelly-tools/coiot

 
 

Repository files navigation

CoIoT Library written in Golang

Package shelly-tools/coiot provides CoIoT (CoAP) communication with the popular Shelly IoT-Devices from Allterco Robotics. The CoIoT protocol is yet another protocol for IoT communication and integration. CoIoT is based on CoAP with some additions as new request code 0.30 for status publishing. All payloads are JSON encoded.

Installation

Install via $ go get github.com/shelly-tools/coiot.

Please add -u flag to update in the future.

Examples

A basic client example to query /cit/d path from the Shelly:

package main

import (
	"log"
	"os"

	"github.com/shelly-tools/coiot"
)

func main() {
	req := coiot.Message{
		Type:      coiot.Confirmable,
		Code:      coiot.GET,
		MessageID: 12,
		Payload:   []byte("Hello Shelly"),
	}
	req.SetPathString("/cit/d")
	c, err := coiot.Dial("udp", "192.168.178.212:5683")
	if err != nil {
		log.Fatalf("Error dialing: %v", err)
	}
	rv, err := c.Send(req)
	if err != nil {
		log.Fatalf("Error sending request: %v", err)
	}

	if rv != nil {
		log.Printf("Response payload: %s", rv.Payload)
	}
}

please check the example directory for more..

Credits

This library is based on the following packages:

Special "Thanks" to Dustin Sallings & Romuald Bulyshko who did most of the work.

About

CoIoT (based on CoAP) implementation for Shelly device in Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%