Skip to content

Commit 99f8235

Browse files
committed
docs: add comments to clarify functions and handlers in config, hub, serial, and update files
1 parent 640e644 commit 99f8235

File tree

6 files changed

+14
-4
lines changed

6 files changed

+14
-4
lines changed

config/config.go

+5
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ func SetInstallCertsIni(filename string, value string) error {
143143
return nil
144144
}
145145

146+
// GetConfigPath returns the full path to the Arduino Create Agent configuration file.
147+
// It will check if the config file exists in the default location
148+
// and if not, it will generate a new one.
149+
// It will also check if the ARDUINO_CREATE_AGENT_CONFIG environment variable is set,
150+
// and if so, it will use that path instead of the default one.
146151
func GetConfigPath() *paths.Path {
147152
// Let's handle the config
148153
configDir := GetDefaultConfigDir()

hub.go

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ type hub struct {
5252
serialPortList *SerialPortList
5353
}
5454

55+
// NewHub creates a hub that acts as a central hub for handling
56+
// WebSocket connections, broadcasting messages, and processing commands.
5557
func NewHub(serialhub *serialhub, serialList *SerialPortList) *hub {
5658
hub := &hub{
5759
broadcast: make(chan []byte, 1000),

info.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func infoHandler(c *gin.Context) {
4141
})
4242
}
4343

44-
func PauseHandler(h *hub, s *systray.Systray) func(c *gin.Context) {
44+
func pauseHandler(h *hub, s *systray.Systray) func(c *gin.Context) {
4545
return func(c *gin.Context) {
4646
go func() {
4747
ports, _ := serial.GetPortsList()

main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,8 @@ func loop(stray *systray.Systray, configPath *paths.Path) {
450450
r.Handle("WS", "/socket.io/", socketHandler)
451451
r.Handle("WSS", "/socket.io/", socketHandler)
452452
r.GET("/info", infoHandler)
453-
r.POST("/pause", PauseHandler(hub, stray))
454-
r.POST("/update", UpdateHandler(stray))
453+
r.POST("/pause", pauseHandler(hub, stray))
454+
r.POST("/update", updateHandler(stray))
455455

456456
// Mount goa handlers
457457
goa := v2.Server(config.GetDataDir().String(), Index, signaturePubKey)

serial.go

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ type serialhub struct {
3838
OnUnregister func(port *serport)
3939
}
4040

41+
// NewSerialHub creates a new serial hub
42+
// It is used to manage serial ports and their connections.
4143
func NewSerialHub() *serialhub {
4244
return &serialhub{
4345
ports: make(map[*serport]bool),
@@ -53,6 +55,7 @@ type SerialPortList struct {
5355
OnErr func(string) `json:"-"`
5456
}
5557

58+
// NewSerialPortList creates a new serial port list
5659
func NewSerialPortList() *SerialPortList {
5760
return &SerialPortList{}
5861
}

update.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import (
3535
"github.com/gin-gonic/gin"
3636
)
3737

38-
func UpdateHandler(s *systray.Systray) func(c *gin.Context) {
38+
func updateHandler(s *systray.Systray) func(c *gin.Context) {
3939
return func(c *gin.Context) {
4040
restartPath, err := updater.CheckForUpdates(version, *updateURL, *appName)
4141
if err != nil {

0 commit comments

Comments
 (0)