-
-
Notifications
You must be signed in to change notification settings - Fork 5
Download provisioning binaries from aws #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
f101f3c
Remove binaries from repo
polldo b29714c
Implement binary index
polldo 1ff2610
Use fwuploader verify function
polldo 6f8b0f2
Extract board in specific file
polldo fab51e5
Download provisioning binary
polldo 869367d
Validate fqbn during device create
polldo b5f8b18
Embed public key
polldo c62c409
Update go.mod
polldo 13933c8
Update readme
polldo a58df57
Add license to new files
polldo 5aef132
Change index download link to prod
polldo 78208bb
Download gz index and decompress it
polldo e930a52
Adapt to new index json structure
polldo 606c977
Improve board conversion
polldo 98c3301
Update command/device/createlora.go
9ad8345
Update command/device/create.go
fe7c592
Improve index URL const
polldo 180bc3e
Update internal/binary/index.go
1467fe2
Improve signature error
polldo 112ba05
Update internal/binary/download.go
98c2359
Fix update
polldo 3d52d25
Update command/device/provision.go
2748d52
improve errors
polldo 5a3458b
Improve checksum error
polldo 9762156
Fix typo
polldo da45e96
Remove leftover embed
polldo 988730e
Remove binaries from releases
polldo 7edd8d5
Remove index test
polldo 0e76121
Update go.sum
polldo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains hidden or 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,124 @@ | ||
// This file is part of arduino-cloud-cli. | ||
// | ||
// Copyright (C) 2021 ARDUINO SA (http://www.arduino.cc/) | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Affero General Public License as published | ||
// by the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
package device | ||
|
||
import ( | ||
"strings" | ||
|
||
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1" | ||
) | ||
|
||
var ( | ||
cryptoFQBN = []string{ | ||
"arduino:samd:nano_33_iot", | ||
"arduino:samd:mkrwifi1010", | ||
"arduino:mbed_nano:nanorp2040connect", | ||
"arduino:mbed_portenta:envie_m7", | ||
"arduino:samd:mkr1000", | ||
"arduino:samd:mkrgsm1400", | ||
"arduino:samd:mkrnb1500", | ||
} | ||
loraFQBN = []string{ | ||
"arduino:samd:mkrwan1310", | ||
"arduino:samd:mkrwan1300", | ||
} | ||
) | ||
|
||
// board contains details of a physical arduino board | ||
type board struct { | ||
fqbn string | ||
serial string | ||
dType string | ||
port string | ||
} | ||
|
||
// isCrypto checks if the board is a valid arduino board with a | ||
// supported crypto-chip | ||
func (b *board) isCrypto() bool { | ||
for _, f := range cryptoFQBN { | ||
if b.fqbn == f { | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
|
||
// isCrypto checks if the board is a valid LoRa arduino board | ||
func (b *board) isLora() bool { | ||
for _, f := range loraFQBN { | ||
if b.fqbn == f { | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
|
||
// boardFromPorts returns a board that matches all the criteria | ||
// passed in. If no criteria are passed, it returns the first board found. | ||
func boardFromPorts(ports []*rpc.DetectedPort, params *CreateParams) *board { | ||
for _, port := range ports { | ||
if portFilter(port, params) { | ||
continue | ||
} | ||
boardFound := boardFilter(port.Boards, params) | ||
if boardFound != nil { | ||
b := &board{ | ||
fqbn: boardFound.Fqbn, | ||
serial: port.SerialNumber, | ||
dType: strings.Split(boardFound.Fqbn, ":")[2], | ||
port: port.Address, | ||
} | ||
return b | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
// portFilter filters out the given port in the following cases: | ||
// - if the port parameter does not match the actual port address. | ||
// - if the the detected port does not contain any board. | ||
// It returns: | ||
// true -> to skip the port | ||
// false -> to keep the port | ||
func portFilter(port *rpc.DetectedPort, params *CreateParams) bool { | ||
if len(port.Boards) == 0 { | ||
return true | ||
} | ||
if params.Port != nil && *params.Port != port.Address { | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
// boardFilter looks for a board which has the same fqbn passed as parameter. | ||
// If fqbn parameter is nil, then the first board found is returned. | ||
// It returns: | ||
// - 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 { | ||
polldo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return boards[0] | ||
} | ||
for _, b := range boards { | ||
if b.Fqbn == *params.Fqbn { | ||
return b | ||
} | ||
} | ||
return | ||
} |
File renamed without changes.
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.