Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,24 @@
],
"configurations": [
{
"name": "Launch Notecard CLI",
"name": "Launch Notecard CLI (empty)",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/notecard",
"env": {
"BLUES": ""
}
},
{
"name": "Launch Notecard CLI (with request)",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/notecard",
"args": ["-req", "${input:requestJson}"],
"env": {
"BLUES": "abucknall@blues.com"
"BLUES": ""
}
},
{
Expand All @@ -29,7 +39,10 @@
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/notehub",
"args": ["-req", "${input:requestJson}"]
"args": ["-req", "${input:requestJson}"],
"env": {
"BLUES": ""
}
}
]
}
12 changes: 11 additions & 1 deletion lib/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"time"

"github.com/blues/note-go/note"
"github.com/blues/note-go/notecard"
"github.com/blues/note-go/notehub"
)

Expand Down Expand Up @@ -56,7 +57,16 @@ func ConfigRead() error {
// Read the config file
contents, err := os.ReadFile(configSettingsPath())
if os.IsNotExist(err) {
ConfigReset()
// If no interface has been provided and no saved config, set defaults
if Config.Interface == "" {
ConfigReset()
newConfigPort := Config.IPort[Config.Interface]
Config.Interface, newConfigPort.Port, newConfigPort.PortConfig = notecard.Defaults()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notehub is an equal consumer of lib.

It does not seem right from a layering perspective that you are referencing notecard and setting defaults in here. It may be fine but it does not seem right in the spirit of a shared library. That is why I had suggested doing it in notecard main.go

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. I discovered this area, because it was responsible for blowing away the changes as you originally suggested them.

This section of code only runs on the first launch after a new installation (or removal of the configuration data).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am yielding and you should do what you think is best. However, make sure that you test and thoroughly understand

  • blow away, then use the notehub utility, then use the notecard utility, all with no interface specified.
  • Blow away, then use the notecard utility then use the notehub utility, all with no interface specified
  • Blow away, then use the notehub utility with "-interface lease", then use the notecard utility with no interface
  • Blow away, then use the notecard utility with "-interface serial", then use the notehub utility with no interface

Copy link
Copy Markdown
Contributor Author

@zfields zfields May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I doing something wrong, or did you have something else in mind?

Notehub CLI

$ notehub -interface lease
flag provided but not defined: -interface
notehub - Command line tool for interacting with notehub
USAGE: notehub [options]

Notecard CLI

$ notecard -interface lease -req '{"req":"card.version"}'
{"body":{"built":"Dec 22 2023 14:43:52","org":"Blues Wireless","product":"Notecard","target":"r5","ver_build":16332,"ver_major":6,"ver_minor":1,"ver_patch":1,"version":"notecard-6.1.1"},"version":"notecard-6.1.1.16332","name":"Blues Wireless Notecard","device":"dev:868050040018596","sku":"NOTE-WBNA-500","board":"1.11","cell":true,"gps":true,"api":6}

Config.IPort[Config.Interface] = newConfigPort
ConfigWrite()
} else {
ConfigReset()
}
err = nil
} else if err == nil {
err = note.JSONUnmarshal(contents, &Config)
Expand Down
9 changes: 7 additions & 2 deletions notecard/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,12 @@ func main() {
fmt.Printf("Ports on '%s':\n", nInterface)
for _, port := range ports {
if port == nPort {
fmt.Printf(" %s ***\n", port)
nPortConfig := lib.Config.IPort[lib.Config.Interface].PortConfig
if nPortConfig == 0 {
fmt.Printf(" %s ***\n", port)
} else {
fmt.Printf(" %s (%d) ***\n", port, nPortConfig)
}
} else {
fmt.Printf(" %s\n", port)
}
Expand Down Expand Up @@ -298,7 +303,7 @@ func main() {
// Process non-config commands
var rsp notecard.Request

// The timouts in the note-go library are set under the assumption that
// The timeouts in the note-go library are set under the assumption that
// the device is connected with long header wires that have significant
// capacitance and resistance, and where there may be arbitrary activity
// on the Notecard. This switch uses a larger buffer and shorter inter-segment
Expand Down