Categorygithub.com/beeedge/device-plugin-framework
modulepackage
0.0.0-20221111085113-cccc83b8bf28
Repository: https://github.com/beeedge/device-plugin-framework.git
Documentation: pkg.go.dev

# README

device-plugin-framework

device-plugin-framework provides IoT device protocol parse framework for beethings.

Framework

device-plugin-framework bases on go-plugin and we only care about one interface with two methods as below:

// Converter is the interface that we're exposing as a plugin.
type Converter interface {
    // ConvertIssueMessage2Device converts issue request to protocol that device understands, which has four return parameters:
    // 1. inputMessages: device issue protocols for each of command input param.
    // 2. outputMessages: device data report protocols for each of command output param.
    // 3. issueTopic: device issue MQTT topic for input params.
    // 4. issueResponseTopic: device issue response MQ topic for output params.
    ConvertIssueMessage2Device(deviceId, modelId, featureId string, values map[string]string) ([]string, []string, string, string, error)
    // ConvertDeviceMessages2MQFormat receives device command issue responses and converts it to RabbitMQ normative format.
    ConvertDeviceMessages2MQFormat(messages []string) (string, []byte, error)
}

We can add on one device plugin by implementing above three methods in plugin/main.go.

Usage

# This builds the main CLI(main.go)
$ go build -o converter

# This builds the plugin written in Go(plugin/main.go)
$ go build -o converter-go-grpc

# This tells the Converter binary to use the "converter-go-grpc" binary
$ export DEVICE_PLUGIN="./converter-go-grpc"

# gRPC calls
$ ./converter
[Have a good try!!!]

Updating the Protocol

If you update the protocol buffers file, you can regenerate the file using the following command from this directory. You do not need to run this if you're just trying the example.

For Go:

$ protoc -I proto/ proto/converter.proto --go_out=plugins=grpc:proto --go-grpc_out=require_unimplemented_servers=false:proto

Refs

# Packages

No description provided by the author
No description provided by the author
Package shared contains shared data between the host and plugins.