Skip to content

Commit 8a61f4f

Browse files
Paolo Calaopolldo
Paolo Calao
authored andcommitted
Fix fqbn case (#81)
1 parent 18e465c commit 8a61f4f

File tree

7 files changed

+16
-16
lines changed

7 files changed

+16
-16
lines changed

Diff for: cli/device/create.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func runCreateCommand(cmd *cobra.Command, args []string) {
5858
params.Port = &createFlags.port
5959
}
6060
if createFlags.fqbn != "" {
61-
params.Fqbn = &createFlags.fqbn
61+
params.FQBN = &createFlags.fqbn
6262
}
6363

6464
dev, err := device.Create(params)

Diff for: cli/device/createlora.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func runCreateLoraCommand(cmd *cobra.Command, args []string) {
6565
params.Port = &createLoraFlags.port
6666
}
6767
if createLoraFlags.fqbn != "" {
68-
params.Fqbn = &createLoraFlags.fqbn
68+
params.FQBN = &createLoraFlags.fqbn
6969
}
7070

7171
dev, err := device.CreateLora(params)

Diff for: command/device/board.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ func portFilter(port *rpc.DetectedPort, params *CreateParams) bool {
112112
// - a board if it is found.
113113
// - nil if no board matching the fqbn parameter is found.
114114
func boardFilter(boards []*rpc.BoardListItem, params *CreateParams) (board *rpc.BoardListItem) {
115-
if params.Fqbn == nil {
115+
if params.FQBN == nil {
116116
return boards[0]
117117
}
118118
for _, b := range boards {
119-
if b.Fqbn == *params.Fqbn {
119+
if b.Fqbn == *params.FQBN {
120120
return b
121121
}
122122
}

Diff for: command/device/board_test.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -66,50 +66,50 @@ func TestBoardFromPorts(t *testing.T) {
6666

6767
{
6868
name: "port-filter",
69-
filter: &CreateParams{Fqbn: nil, Port: stringPointer("ACM1")},
69+
filter: &CreateParams{FQBN: nil, Port: stringPointer("ACM1")},
7070
ports: portsTwoBoards,
7171
want: &board{fqbn: "arduino:avr:uno", port: "ACM1"},
7272
},
7373

7474
{
7575
name: "fqbn-filter",
76-
filter: &CreateParams{Fqbn: stringPointer("arduino:avr:uno"), Port: nil},
76+
filter: &CreateParams{FQBN: stringPointer("arduino:avr:uno"), Port: nil},
7777
ports: portsTwoBoards,
7878
want: &board{fqbn: "arduino:avr:uno", port: "ACM1"},
7979
},
8080

8181
{
8282
name: "no-filter-noboards",
83-
filter: &CreateParams{Fqbn: nil, Port: nil},
83+
filter: &CreateParams{FQBN: nil, Port: nil},
8484
ports: portsNoBoards,
8585
want: nil,
8686
},
8787

8888
{
8989
name: "no-filter",
90-
filter: &CreateParams{Fqbn: nil, Port: nil},
90+
filter: &CreateParams{FQBN: nil, Port: nil},
9191
ports: portsTwoBoards,
9292
// first board found is selected
9393
want: &board{fqbn: "arduino:samd:nano_33_iot", port: "ACM0"},
9494
},
9595

9696
{
9797
name: "both-filter-noboards",
98-
filter: &CreateParams{Fqbn: stringPointer("arduino:avr:uno"), Port: stringPointer("ACM1")},
98+
filter: &CreateParams{FQBN: stringPointer("arduino:avr:uno"), Port: stringPointer("ACM1")},
9999
ports: portsNoBoards,
100100
want: nil,
101101
},
102102

103103
{
104104
name: "both-filter-found",
105-
filter: &CreateParams{Fqbn: stringPointer("arduino:avr:uno"), Port: stringPointer("ACM1")},
105+
filter: &CreateParams{FQBN: stringPointer("arduino:avr:uno"), Port: stringPointer("ACM1")},
106106
ports: portsTwoBoards,
107107
want: &board{fqbn: "arduino:avr:uno", port: "ACM1"},
108108
},
109109

110110
{
111111
name: "both-filter-notfound",
112-
filter: &CreateParams{Fqbn: stringPointer("arduino:avr:uno"), Port: stringPointer("ACM0")},
112+
filter: &CreateParams{FQBN: stringPointer("arduino:avr:uno"), Port: stringPointer("ACM0")},
113113
ports: portsTwoBoards,
114114
want: nil,
115115
},

Diff for: command/device/create.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import (
3232
type CreateParams struct {
3333
Name string // Device name
3434
Port *string // Serial port - Optional - If omitted then each serial port is analyzed
35-
Fqbn *string // Board FQBN - Optional - If omitted then the first device found gets selected
35+
FQBN *string // Board FQBN - Optional - If omitted then the first device found gets selected
3636
}
3737

3838
// Create command is used to provision a new arduino device

Diff for: internal/binary/index.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ type Index struct {
4343

4444
// IndexBoard describes all the binaries available for a specific board
4545
type IndexBoard struct {
46-
Fqbn string `json:"fqbn"`
46+
FQBN string `json:"fqbn"`
4747
Provision *IndexBin `json:"provision"`
4848
}
4949

@@ -98,7 +98,7 @@ func LoadIndex() (*Index, error) {
9898
// Returns nil if the binary is not found
9999
func (i *Index) FindProvisionBin(fqbn string) *IndexBin {
100100
for _, b := range i.Boards {
101-
if b.Fqbn == fqbn {
101+
if b.FQBN == fqbn {
102102
return b.Provision
103103
}
104104
}

Diff for: internal/binary/index_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ func TestFindProvisionBin(t *testing.T) {
2929
)
3030
index := &Index{
3131
Boards: []IndexBoard{
32-
{Fqbn: fqbnOK1, Provision: &IndexBin{URL: "mkr"}},
33-
{Fqbn: fqbnOK2, Provision: &IndexBin{URL: "nano"}},
32+
{FQBN: fqbnOK1, Provision: &IndexBin{URL: "mkr"}},
33+
{FQBN: fqbnOK2, Provision: &IndexBin{URL: "nano"}},
3434
},
3535
}
3636

0 commit comments

Comments
 (0)