From 07696a075c934680afc3aeb0eb19be86405af71f Mon Sep 17 00:00:00 2001 From: Paolo Calao Date: Mon, 13 Dec 2021 11:28:43 +0100 Subject: [PATCH] Fix fqbn case --- cli/device/create.go | 2 +- cli/device/createlora.go | 2 +- command/device/board.go | 4 ++-- command/device/board_test.go | 14 +++++++------- command/device/create.go | 2 +- internal/binary/index.go | 4 ++-- internal/binary/index_test.go | 4 ++-- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/cli/device/create.go b/cli/device/create.go index ceee0887..d9869134 100644 --- a/cli/device/create.go +++ b/cli/device/create.go @@ -58,7 +58,7 @@ func runCreateCommand(cmd *cobra.Command, args []string) { params.Port = &createFlags.port } if createFlags.fqbn != "" { - params.Fqbn = &createFlags.fqbn + params.FQBN = &createFlags.fqbn } dev, err := device.Create(params) diff --git a/cli/device/createlora.go b/cli/device/createlora.go index f9c8227e..b9f2a697 100644 --- a/cli/device/createlora.go +++ b/cli/device/createlora.go @@ -65,7 +65,7 @@ func runCreateLoraCommand(cmd *cobra.Command, args []string) { params.Port = &createLoraFlags.port } if createLoraFlags.fqbn != "" { - params.Fqbn = &createLoraFlags.fqbn + params.FQBN = &createLoraFlags.fqbn } dev, err := device.CreateLora(params) diff --git a/command/device/board.go b/command/device/board.go index f0eaf527..9edae355 100644 --- a/command/device/board.go +++ b/command/device/board.go @@ -112,11 +112,11 @@ func portFilter(port *rpc.DetectedPort, params *CreateParams) bool { // - a board if it is found. // - nil if no board matching the fqbn parameter is found. func boardFilter(boards []*rpc.BoardListItem, params *CreateParams) (board *rpc.BoardListItem) { - if params.Fqbn == nil { + if params.FQBN == nil { return boards[0] } for _, b := range boards { - if b.Fqbn == *params.Fqbn { + if b.Fqbn == *params.FQBN { return b } } diff --git a/command/device/board_test.go b/command/device/board_test.go index 4df55091..8874ada7 100644 --- a/command/device/board_test.go +++ b/command/device/board_test.go @@ -66,28 +66,28 @@ func TestBoardFromPorts(t *testing.T) { { name: "port-filter", - filter: &CreateParams{Fqbn: nil, Port: stringPointer("ACM1")}, + filter: &CreateParams{FQBN: nil, Port: stringPointer("ACM1")}, ports: portsTwoBoards, want: &board{fqbn: "arduino:avr:uno", port: "ACM1"}, }, { name: "fqbn-filter", - filter: &CreateParams{Fqbn: stringPointer("arduino:avr:uno"), Port: nil}, + filter: &CreateParams{FQBN: stringPointer("arduino:avr:uno"), Port: nil}, ports: portsTwoBoards, want: &board{fqbn: "arduino:avr:uno", port: "ACM1"}, }, { name: "no-filter-noboards", - filter: &CreateParams{Fqbn: nil, Port: nil}, + filter: &CreateParams{FQBN: nil, Port: nil}, ports: portsNoBoards, want: nil, }, { name: "no-filter", - filter: &CreateParams{Fqbn: nil, Port: nil}, + filter: &CreateParams{FQBN: nil, Port: nil}, ports: portsTwoBoards, // first board found is selected want: &board{fqbn: "arduino:samd:nano_33_iot", port: "ACM0"}, @@ -95,21 +95,21 @@ func TestBoardFromPorts(t *testing.T) { { name: "both-filter-noboards", - filter: &CreateParams{Fqbn: stringPointer("arduino:avr:uno"), Port: stringPointer("ACM1")}, + filter: &CreateParams{FQBN: stringPointer("arduino:avr:uno"), Port: stringPointer("ACM1")}, ports: portsNoBoards, want: nil, }, { name: "both-filter-found", - filter: &CreateParams{Fqbn: stringPointer("arduino:avr:uno"), Port: stringPointer("ACM1")}, + filter: &CreateParams{FQBN: stringPointer("arduino:avr:uno"), Port: stringPointer("ACM1")}, ports: portsTwoBoards, want: &board{fqbn: "arduino:avr:uno", port: "ACM1"}, }, { name: "both-filter-notfound", - filter: &CreateParams{Fqbn: stringPointer("arduino:avr:uno"), Port: stringPointer("ACM0")}, + filter: &CreateParams{FQBN: stringPointer("arduino:avr:uno"), Port: stringPointer("ACM0")}, ports: portsTwoBoards, want: nil, }, diff --git a/command/device/create.go b/command/device/create.go index 6042d93b..7962da6a 100644 --- a/command/device/create.go +++ b/command/device/create.go @@ -32,7 +32,7 @@ import ( type CreateParams struct { Name string // Device name Port *string // Serial port - Optional - If omitted then each serial port is analyzed - Fqbn *string // Board FQBN - Optional - If omitted then the first device found gets selected + FQBN *string // Board FQBN - Optional - If omitted then the first device found gets selected } // Create command is used to provision a new arduino device diff --git a/internal/binary/index.go b/internal/binary/index.go index ef67b795..b7d0dfd4 100644 --- a/internal/binary/index.go +++ b/internal/binary/index.go @@ -43,7 +43,7 @@ type Index struct { // IndexBoard describes all the binaries available for a specific board type IndexBoard struct { - Fqbn string `json:"fqbn"` + FQBN string `json:"fqbn"` Provision *IndexBin `json:"provision"` } @@ -98,7 +98,7 @@ func LoadIndex() (*Index, error) { // Returns nil if the binary is not found func (i *Index) FindProvisionBin(fqbn string) *IndexBin { for _, b := range i.Boards { - if b.Fqbn == fqbn { + if b.FQBN == fqbn { return b.Provision } } diff --git a/internal/binary/index_test.go b/internal/binary/index_test.go index b657263b..fd78470e 100644 --- a/internal/binary/index_test.go +++ b/internal/binary/index_test.go @@ -29,8 +29,8 @@ func TestFindProvisionBin(t *testing.T) { ) index := &Index{ Boards: []IndexBoard{ - {Fqbn: fqbnOK1, Provision: &IndexBin{URL: "mkr"}}, - {Fqbn: fqbnOK2, Provision: &IndexBin{URL: "nano"}}, + {FQBN: fqbnOK1, Provision: &IndexBin{URL: "mkr"}}, + {FQBN: fqbnOK2, Provision: &IndexBin{URL: "nano"}}, }, }