-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Adapt rpc_server to rpc_client interface - Add call to tm1637 from controller
- Loading branch information
Showing
22 changed files
with
549 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ on: | |
- main | ||
paths: | ||
- 'controller/**' | ||
- 'rpc_client/**' | ||
- 'scripts/**' | ||
- '.github/**' | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package config | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/torchiaf/Sensors/rpc_client/models" | ||
"github.com/torchiaf/Sensors/rpc_client/utils" | ||
) | ||
|
||
func isDevEnv() bool { | ||
env := os.Getenv("DEV_ENV") | ||
|
||
return len(env) > 0 | ||
} | ||
|
||
func initConfig() models.Config { | ||
|
||
modules := utils.ParseYamlFile[[]models.Module]("/sensors/modules.yaml") | ||
modulesMap := utils.Map(modules, func(m models.Module) string { return m.Name }) | ||
|
||
c := models.Config{ | ||
IsDev: isDevEnv(), | ||
RabbitMQ: models.RabbitMQ{ | ||
Host: os.Getenv("RABBITMQ_CLUSTER_SERVICE_HOST"), | ||
Port: os.Getenv("RABBITMQ_CLUSTER_SERVICE_PORT_AMQP"), | ||
Username: os.Getenv("RABBITMQ_USERNAME"), | ||
Password: os.Getenv("RABBITMQ_PASSWORD"), | ||
}, | ||
Modules: modulesMap, | ||
} | ||
|
||
return c | ||
} | ||
|
||
var Config = initConfig() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module github.com/torchiaf/Sensors/rpc_client | ||
|
||
go 1.23.1 | ||
|
||
require ( | ||
github.com/fatih/structs v1.1.0 | ||
github.com/itchyny/gojq v0.12.17 | ||
github.com/rabbitmq/amqp091-go v1.10.0 | ||
gopkg.in/yaml.v2 v2.4.0 | ||
) | ||
|
||
require github.com/itchyny/timefmt-go v0.1.6 // indirect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo= | ||
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= | ||
github.com/itchyny/gojq v0.12.17 h1:8av8eGduDb5+rvEdaOO+zQUjA04MS0m3Ps8HiD+fceg= | ||
github.com/itchyny/gojq v0.12.17/go.mod h1:WBrEMkgAfAGO1LUcGOckBl5O726KPp+OlkKug0I/FEY= | ||
github.com/itchyny/timefmt-go v0.1.6 h1:ia3s54iciXDdzWzwaVKXZPbiXzxxnv1SPGFfM/myJ5Q= | ||
github.com/itchyny/timefmt-go v0.1.6/go.mod h1:RRDZYC5s9ErkjQvTvvU7keJjxUYzIISJGxm9/mAERQg= | ||
github.com/rabbitmq/amqp091-go v1.10.0 h1:STpn5XsHlHGcecLmMFCtg7mqq0RnD+zFr4uzukfVhBw= | ||
github.com/rabbitmq/amqp091-go v1.10.0/go.mod h1:Hy4jKW5kQART1u+JkDTF9YYOQUHXqMuhrgxOEeS7G4o= | ||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= | ||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= | ||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package models | ||
|
||
type RabbitMQ struct { | ||
Host string | ||
Port string | ||
Username string | ||
Password string | ||
} | ||
|
||
type Config struct { | ||
IsDev bool | ||
RabbitMQ RabbitMQ | ||
Modules map[string]Module | ||
} | ||
|
||
type Module struct { | ||
Name string `yaml:"name"` | ||
NodeName string `yaml:"nodeName"` | ||
Type string `yaml:"type"` | ||
RoutingKey string `yaml:"routingKey"` | ||
Devices []Device | ||
} | ||
|
||
type Device struct { | ||
Name string `yaml:"name"` | ||
Type string `yaml:"type"` | ||
Config []DeviceConfig | ||
} | ||
|
||
type DeviceConfig struct { | ||
Name string `yaml:"name"` | ||
Value string `yaml:"value"` | ||
} | ||
|
||
type Message struct { | ||
Device string `json:"device"` | ||
Action string `json:"action"` | ||
Args []string `json:"args"` | ||
} |
Oops, something went wrong.