Skip to content

Commit

Permalink
Providing a Common MQTT Mapper
Browse files Browse the repository at this point in the history
Signed-off-by: Prometheus-collab <[email protected]>
Signed-off-by: fuchendou <[email protected]>
  • Loading branch information
Prometheus-collab authored and fuchendou committed Oct 12, 2024
1 parent 6472750 commit 782b438
Show file tree
Hide file tree
Showing 31 changed files with 163 additions and 259 deletions.
78 changes: 0 additions & 78 deletions mappers/kubeedge-v1.17.0/mqtt-mapper/driver/devicetype.go

This file was deleted.

60 changes: 0 additions & 60 deletions mappers/kubeedge-v1.17.0/mqtt-mapper/driver/messagequeue.go

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
72 changes: 72 additions & 0 deletions mappers/mqtt-mapper/driver/devicetype.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package driver

import (
"sync"
"time"

"github.com/kubeedge/mapper-framework/pkg/common"
)

// CustomizedDev is the customized device configuration and client information.
type CustomizedDev struct {
CustomizedClient *CustomizedClient
Instance common.DeviceInstance
}

type CustomizedClient struct {
// TODO add some variables to help you better implement device drivers
deviceMutex sync.Mutex
ProtocolConfig
DeviceInfo string `json:"deviceInfo"`
ParsedDeviceInfo map[string]interface{} `json:"parsedDeviceInfo"`
}

type ProtocolConfig struct {
ProtocolName string `json:"protocolName"`
ConfigData `json:"configData"`
}

type ConfigData struct {
// MQTT protocol config data
ClientID string `json:"clientID"` // MQTT Client ID
BrokerURL string `json:"brokerURL"` // MQTT Broker URL
Topic string `json:"topic"` // Topic for publishing or subscribing
Message string `json:"message"` // Content of the message
Username string `json:"username"` // Username for MQTT broker authentication
Password string `json:"password"` // Password for MQTT broker authentication
ConnectionTTL time.Duration `json:"connectionTTL"` // Connection timeout duration
LastMessage time.Time `json:"lastMessage"` // Timestamp of the last received message
IsData bool `json:"isData"` // Indicates if there is valid data
}

type VisitorConfig struct {
ProtocolName string `json:"protocolName"`
VisitorConfigData `json:"configData"`
}

type VisitorConfigData struct {
DataType string `json:"dataType"`

ClientID string `json:"clientID"` // MQTT Client ID
DeviceInfo string `json:"deviceInfo"` // Device information, such as device identification or other important information.
OperationInfo OperationInfoType `json:"operationInfo"` // Operation information, such as adding, deleting, modifying and so on.
SerializedFormat SerializedFormatType `json:"fileType"` // Supported formats: json, xml and yaml.
ParsedMessage map[string]interface{} `json:"parsedMessage"` // The parsed message
}

// OperationInfoType defines the enumeration values for device operation.
type OperationInfoType uint

const (
UPDATE OperationInfoType = iota // revision
)

// SerializedFormatType defines the enumeration values for serialized types.
type SerializedFormatType uint

const (
JSON SerializedFormatType = iota // json
YAML // yaml
XML // xml
JSONPATH
)
Loading

0 comments on commit 782b438

Please sign in to comment.