device-sdk-go

module
v4.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 10, 2025 License: MIT

README

MODE Device SDK for Go (version 4)

GoDoc

This SDK is for anyone implementing MODE device drivers in the Go language. It is being released as a public Go module that provides a Go API for devices to interact with the MODE cloud.

Installation

Our recommendation is to use the package as a module. In module mode, Go will automatically download the module when it sees an import statement referencing this repository. If it is not already, your workspace should be a Go module which will be able to consume this one:

go mod init <your module path>

This will allow go you to download and install the module at build or run time.

If you are not yet using Go modules and are still in GOPATH mode, you may use go get to fetch the SDK:

go get github.com/moderepo/device-sdk-go/v4

Using the SDK

You will be using the mode package. For example:

package main

import (
    "fmt"
    "github.com/moderepo/device-sdk-go/v4/mode"
)

func main() {
    dc := &mode.DeviceContext{
        DeviceID:  __DEVICE_ID__,
        AuthToken: "__DEVICE_TOKEN__",
    }

    if d, err := dc.GetInfo(); err == nil {
        fmt.Printf("I am %v\n", d)
    }
}

See more examples here.

Documentation

See the full API documentation here.

Code and documentation copyright 2024 Mode, Inc. Released under the MIT license.

Directories

Path Synopsis
Package dummymqttd can be used to simulate MODE's MQTT server for testing.
Package dummymqttd can be used to simulate MODE's MQTT server for testing.
examples
echo command
In this example, the device sends an "echo" event whenever it receives a "doEcho" command.
In this example, the device sends an "echo" event whenever it receives a "doEcho" command.
websocket_echo command
In this example, the device connects to the MQTT server via WebSocket.
In this example, the device connects to the MQTT server via WebSocket.
internal
packet
Package packet implements functionality for encoding and decoding MQTT 3.1.1 (http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/) packets.
Package packet implements functionality for encoding and decoding MQTT 3.1.1 (http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/) packets.
Package mode is the Go API for devices to interact with the MODE cloud.
Package mode is the Go API for devices to interact with the MODE cloud.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL