diff --git a/README.md b/README.md index 92aeb0b3f..849de638a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ +[![License: GPL v2](https://img.shields.io/badge/License-GPL%20v2-blue.svg)](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html) arduino-create-agent ==================== + ## GOA 2 refactoring The agent is currently transitioning to the v2 of the GOA framework for API management, please refer to the following [documentation](https://github.com/goadesign/goa/tree/v2) in order to install tools and libraries @@ -16,18 +18,18 @@ goa gen github.com/arduino/arduino-create-agent/design Get the latest version of the Agent for all supported platforms: ### Windows -* [Windows with Edge](http://downloads.arduino.cc/CreateBridgeStable/ArduinoCreateAgent-1.1-windows-installer-edge.exe) -* [Windows with Chrome](http://downloads.arduino.cc/CreateBridgeStable/ArduinoCreateAgent-1.1-windows-installer-chrome.exe) -* [Windows with Firefox](http://downloads.arduino.cc/CreateBridgeStable/ArduinoCreateAgent-1.1-windows-installer-firefox.exe) +* [Windows with Edge](https://downloads.arduino.cc/CreateBridgeStable/ArduinoCreateAgent-1.1-windows-installer-edge.exe) +* [Windows with Chrome](https://downloads.arduino.cc/CreateBridgeStable/ArduinoCreateAgent-1.1-windows-installer-chrome.exe) +* [Windows with Firefox](https://downloads.arduino.cc/CreateBridgeStable/ArduinoCreateAgent-1.1-windows-installer-firefox.exe) ### MacOSX -* [MacOSX with Safari](http://downloads.arduino.cc/CreateBridgeStable/ArduinoCreateAgent-1.1-osx-installer-safari.dmg) -* [MacOSX with Chrome](http://downloads.arduino.cc/CreateBridgeStable/ArduinoCreateAgent-1.1-osx-installer-chrome.dmg) -* [MacOSX with Firefox](http://downloads.arduino.cc/CreateBridgeStable/ArduinoCreateAgent-1.1-osx-installer-firefox.dmg) +* [MacOSX with Safari](https://downloads.arduino.cc/CreateBridgeStable/ArduinoCreateAgent-1.1-osx-installer-safari.dmg) +* [MacOSX with Chrome](https://downloads.arduino.cc/CreateBridgeStable/ArduinoCreateAgent-1.1-osx-installer-chrome.dmg) +* [MacOSX with Firefox](https://downloads.arduino.cc/CreateBridgeStable/ArduinoCreateAgent-1.1-osx-installer-firefox.dmg) ### Linux -* [Linux x64 with Chrome](http://downloads.arduino.cc/CreateBridgeStable/ArduinoCreateAgent-1.1-linux-x64-installer-chrome.tar.gz) -* [Linux x64 with Firefox](http://downloads.arduino.cc/CreateBridgeStable/ArduinoCreateAgent-1.1-linux-x64-installer-firefox.tar.gz) +* [Linux x64 with Chrome](https://downloads.arduino.cc/CreateBridgeStable/ArduinoCreateAgent-1.1-linux-x64-installer-chrome.tar.gz) +* [Linux x64 with Firefox](https://downloads.arduino.cc/CreateBridgeStable/ArduinoCreateAgent-1.1-linux-x64-installer-firefox.tar.gz) arduino-create-agent is a fork of @[johnlauer](https://github.com/johnlauer)'s [serial-port-json-server](https://github.com/johnlauer/serial-port-json-server) (which we really want to thank for his kindness and great work) @@ -146,18 +148,18 @@ or in the location selected during the installation Please use the current latest version: ### Windows -* [Windows with Edge dev](http://downloads.arduino.cc/CreateBridge/staging/ArduinoCreateAgent-1.0-windows-installer-edge.exe) -* [Windows with Chrome dev](http://downloads.arduino.cc/CreateBridge/staging/ArduinoCreateAgent-1.0-windows-installer.exe) -* [Windows with Firefox dev](http://downloads.arduino.cc/CreateBridge/staging/ArduinoCreateAgent-1.0-windows-installer-firefox.exe) +* [Windows with Edge dev](https://downloads.arduino.cc/CreateBridge/staging/ArduinoCreateAgent-1.0-windows-installer-edge.exe) +* [Windows with Chrome dev](https://downloads.arduino.cc/CreateBridge/staging/ArduinoCreateAgent-1.0-windows-installer.exe) +* [Windows with Firefox dev](https://downloads.arduino.cc/CreateBridge/staging/ArduinoCreateAgent-1.0-windows-installer-firefox.exe) ### MacOSX -* [MacOSX with Safari dev](http://downloads.arduino.cc/CreateBridge/staging/ArduinoCreateAgent-1.0-osx-installer-safari.dmg) -* [MacOSX with Chrome dev](http://downloads.arduino.cc/CreateBridge/staging/ArduinoCreateAgent-1.0-osx-installer-chrome.dmg) -* [MacOSX with Firefox dev](http://downloads.arduino.cc/CreateBridge/staging/ArduinoCreateAgent-1.0-osx-installer-firefox.dmg) +* [MacOSX with Safari dev](https://downloads.arduino.cc/CreateBridge/staging/ArduinoCreateAgent-1.0-osx-installer-safari.dmg) +* [MacOSX with Chrome dev](https://downloads.arduino.cc/CreateBridge/staging/ArduinoCreateAgent-1.0-osx-installer-chrome.dmg) +* [MacOSX with Firefox dev](https://downloads.arduino.cc/CreateBridge/staging/ArduinoCreateAgent-1.0-osx-installer-firefox.dmg) ### Linux -* [Linux x64 with Chrome dev](http://downloads.arduino.cc/CreateBridge/staging/ArduinoCreateAgent-1.0-linux-x64-installer-chrome.run) -* [Linux x64 with Firefox dev](http://downloads.arduino.cc/CreateBridge/staging/ArduinoCreateAgent-1.0-linux-x64-installer-firefox.run) +* [Linux x64 with Chrome dev](https://downloads.arduino.cc/CreateBridge/staging/ArduinoCreateAgent-1.0-linux-x64-installer-chrome.run) +* [Linux x64 with Firefox dev](https://downloads.arduino.cc/CreateBridge/staging/ArduinoCreateAgent-1.0-linux-x64-installer-firefox.run) ## How to use it @@ -242,7 +244,7 @@ You will receive an object of all the boards connected with USB or over the netw } ``` -## Open/Close ports +### Open/Close ports To read input from a board connected to USB you must first open the port with the command @@ -350,7 +352,7 @@ The payload is a json object that looks like this: { "board":"arduino:avr:leonardo", "port":"/dev/ttyACM1", - "commandline":"\"{runtime.tools.avrdude.path}/bin/avrdude\" \"-C{runtime.tools.avrdude.path}/etc/avrdude.conf\" {upload.verbose} -patmega32u4 -cavr109 -P{serial.port} -b57600 -D \"-Uflash:w:{build.path}/{build.project_name}.hex:i\"", + "commandline":"\"{runtime.tools.avrdude.path}/bin/avrdude\" \"-C{runtime.tools.avrdude.path}/etc/avrdude.conf\" -v -patmega32u4 -cavr109 -P{serial.port} -b57600 -D \"-Uflash:w:{build.path}/{build.project_name}.hex:i\"", "signature":"97db97ced2c", "hex":"OjEwMDAwMDAwMEM5NEU1MDAwQzk0MEQwMTBDOTQwRDAxMEM5NDBEMDE2MQ0KOjEwMDAxMDAwMEM5NDBEMDEwQzk0M", "filename":"Blink.ino.hex", @@ -365,16 +367,13 @@ The payload is a json object that looks like this: "wait_for_upload_port":true, "use_1200bps_touch":true, "network":false, - "params_verbose":"-v", - "params_quiet":"-q -q", - "verbose":true } } ``` - commandline is the command to execute to perform the upload. This is, for example, avrdude on a Leonardo. -- hex contains the sketch hex encoded in base64 +- hex contains the sketch binary encoded in base64 (could decode in Intel hex or raw binary) - signature is the signature of the commandline signed with the private key that matches the public key contained in the config.ini of the arduino-create-agent @@ -386,6 +385,10 @@ The results of the upload will be delivered via websocket with messages that loo {"Flash":"Ok","ProgrammerStatus":"Done"} ``` +### Javacript client library + +You can install the [arduino-create-agent-js-client](https://github.com/arduino/arduino-create-agent-js-client) in your client application + --- ## Development @@ -469,4 +472,4 @@ By making a contribution to this project, I certify that: ## Creating a release Just create a new release on GitHub, and our drone server will build and upload -the compiled binaries for every architecture in a zip file in the release itself. \ No newline at end of file +the compiled binaries for every architecture in a zip file in the release itself. diff --git a/config.ini b/config.ini index 17f1312db..80678555b 100644 --- a/config.ini +++ b/config.ini @@ -3,6 +3,6 @@ hostname = unknown-hostname # Override the hostname we get from the OS regex = usb|acm|com # Regular expression to filter serial port list v = true # show debug logging appName = CreateBridge -updateUrl = http://downloads.arduino.cc/ +updateUrl = https://downloads.arduino.cc/ origins = http://local.arduino.cc:8000 #httpProxy = http://your.proxy:port # Proxy server for HTTP requests diff --git a/conn.go b/conn.go index 29367b0f1..87d11e841 100644 --- a/conn.go +++ b/conn.go @@ -70,7 +70,7 @@ type Upload struct { ExtraFiles []AdditionalFile `json:"extrafiles"` } -var uploadStatusStr string = "ProgrammerStatus" +var uploadStatusStr = "ProgrammerStatus" func uploadHandler(c *gin.Context) { @@ -156,7 +156,7 @@ func uploadHandler(c *gin.Context) { return } - l := PLogger{Verbose: data.Extra.Verbose} + l := PLogger{Verbose: true} // Upload if data.Extra.Network { @@ -183,7 +183,7 @@ type PLogger struct { Verbose bool } -// Debug only sends messages if verbose is true +// Debug only sends messages if verbose is true (always true for now) func (l PLogger) Debug(args ...interface{}) { if l.Verbose { l.Info(args...) diff --git a/design/pkgs.go b/design/pkgs.go index f99adb91e..2e566fdbe 100644 --- a/design/pkgs.go +++ b/design/pkgs.go @@ -84,7 +84,7 @@ var IndexPayload = Type("arduino.index", func() { TypeName("IndexPayload") Attribute("url", String, "The url of the index file", func() { - Example("http://downloads.arduino.cc/packages/package_index.json") + Example("https://downloads.arduino.cc/packages/package_index.json") }) Required("url") }) diff --git a/docs/tools.md b/docs/tools.md index f6ffd2a09..35be570c9 100644 --- a/docs/tools.md +++ b/docs/tools.md @@ -27,7 +27,7 @@ Usage: You have to instantiate the struct by passing it the required parameters: _tools := tools.Tools{ Directory: "/home/user/.arduino-create", - IndexURL: "http://downloads.arduino.cc/packages/package_index.json" + IndexURL: "https://downloads.arduino.cc/packages/package_index.json" Logger: log.Logger } diff --git a/main.go b/main.go index d25604795..133eabc77 100755 --- a/main.go +++ b/main.go @@ -253,7 +253,7 @@ func loop() { extraOrigins := []string{ "https://create.arduino.cc", - "http://create.arduino.cc", "https://create-dev.arduino.cc", "http://create-dev.arduino.cc", "https://create-intel.arduino.cc", "http://create-intel.arduino.cc", + "https://create-dev.arduino.cc", "https://create-intel.arduino.cc", } for i := 8990; i < 9001; i++ { @@ -357,9 +357,8 @@ const homeTemplateHtml = ` if (messages.length > 2000) { messages.shift(); } - var doScroll = log.scrollTop == log.scrollHeight - log.clientHeight; log.innerHTML = messages.join('
'); - if (autoscroll.checked && doScroll) { + if (autoscroll.checked) { log.scrollTop = log.scrollHeight - log.clientHeight; } } @@ -429,6 +428,7 @@ body { } .buttons { + align-items: center; display: flex; padding: 0 .5em; margin: 0; diff --git a/tools/download_test.go b/tools/download_test.go index 4798ed854..fcd22fd31 100644 --- a/tools/download_test.go +++ b/tools/download_test.go @@ -40,12 +40,12 @@ func Test_findBaseDir(t *testing.T) { func TestTools_DownloadAndUnpackBehaviour(t *testing.T) { urls := []string{ - "http://downloads.arduino.cc/tools/avrdude-6.3.0-arduino14-armhf-pc-linux-gnu.tar.bz2", - "http://downloads.arduino.cc/tools/avrdude-6.3.0-arduino14-aarch64-pc-linux-gnu.tar.bz2", - "http://downloads.arduino.cc/tools/avrdude-6.3.0-arduino14-i386-apple-darwin11.tar.bz2", - "http://downloads.arduino.cc/tools/avrdude-6.3.0-arduino14-x86_64-pc-linux-gnu.tar.bz2", - "http://downloads.arduino.cc/tools/avrdude-6.3.0-arduino14-i686-pc-linux-gnu.tar.bz2", - "http://downloads.arduino.cc/tools/avrdude-6.3.0-arduino14-i686-w64-mingw32.zip", + "https://downloads.arduino.cc/tools/avrdude-6.3.0-arduino14-armhf-pc-linux-gnu.tar.bz2", + "https://downloads.arduino.cc/tools/avrdude-6.3.0-arduino14-aarch64-pc-linux-gnu.tar.bz2", + "https://downloads.arduino.cc/tools/avrdude-6.3.0-arduino14-i386-apple-darwin11.tar.bz2", + "https://downloads.arduino.cc/tools/avrdude-6.3.0-arduino14-x86_64-pc-linux-gnu.tar.bz2", + "https://downloads.arduino.cc/tools/avrdude-6.3.0-arduino14-i686-pc-linux-gnu.tar.bz2", + "https://downloads.arduino.cc/tools/avrdude-6.3.0-arduino14-i686-w64-mingw32.zip", } expectedDirList := []string{"bin", "etc"} diff --git a/tools/tools.go b/tools/tools.go index 615cabf8e..2884325da 100644 --- a/tools/tools.go +++ b/tools/tools.go @@ -26,7 +26,7 @@ import ( // You have to instantiate the struct by passing it the required parameters: // _tools := tools.Tools{ // Directory: "/home/user/.arduino-create", -// IndexURL: "http://downloads.arduino.cc/packages/package_index.json" +// IndexURL: "https://downloads.arduino.cc/packages/package_index.json" // Logger: log.Logger // } type Tools struct { diff --git a/trayicon.go b/trayicon.go index c7b1d671d..b8ef0ed6a 100644 --- a/trayicon.go +++ b/trayicon.go @@ -166,7 +166,7 @@ func setupSysTrayReal() { go func() { for { <-mUrl.ClickedCh - open.Start("http://create.arduino.cc") + open.Start("https://create.arduino.cc") } }() } diff --git a/upload/README.md b/upload/README.md index f34a001a0..a958e9352 100644 --- a/upload/README.md +++ b/upload/README.md @@ -113,9 +113,6 @@ type Extra struct { WaitForUploadPort bool `json:"wait_for_upload_port"` Network bool `json:"network"` Auth Auth `json:"auth"` - Verbose bool `json:"verbose"` - ParamsVerbose string `json:"params_verbose"` - ParamsQuiet string `json:"params_quiet"` } ``` Extra contains some options used during the upload diff --git a/upload/doc.go b/upload/doc.go index c460d61b8..db6963d28 100644 --- a/upload/doc.go +++ b/upload/doc.go @@ -31,7 +31,7 @@ // commandline = upload.Resolve("/dev/ttyACM0", "arduino:avr:leonardo", "./sketch.hex", commandline, upload.Extra{}, t) // ``` // -// t must implement the locater interface (the Tools package does!) +// 't' must implement the locater interface (the Tools package does!) // // **Logging** // If you're interested in the output of the commands, you can implement the logger interface. Here's an example: diff --git a/upload/upload.go b/upload/upload.go index b25e7703c..99e561048 100644 --- a/upload/upload.go +++ b/upload/upload.go @@ -39,14 +39,11 @@ type Auth struct { // Extra contains some options used during the upload type Extra struct { - Use1200bpsTouch bool `json:"use_1200bps_touch"` - WaitForUploadPort bool `json:"wait_for_upload_port"` - Network bool `json:"network"` - Auth Auth `json:"auth"` - Verbose bool `json:"verbose"` - ParamsVerbose string `json:"params_verbose"` - ParamsQuiet string `json:"params_quiet"` - SSH bool `json:"ssh,omitempty"` + Use1200bpsTouch bool `json:"use_1200bps_touch"` + WaitForUploadPort bool `json:"wait_for_upload_port"` + Network bool `json:"network"` + Auth Auth `json:"auth"` + SSH bool `json:"ssh,omitempty"` } // PartiallyResolve replaces some symbols in the commandline with the appropriate values @@ -57,12 +54,6 @@ func PartiallyResolve(board, file, platformPath, commandline string, extra Extra commandline = strings.Replace(commandline, "{network.password}", extra.Auth.Password, -1) commandline = strings.Replace(commandline, "{runtime.platform.path}", filepath.ToSlash(platformPath), -1) - if extra.Verbose == true { - commandline = strings.Replace(commandline, "{upload.verbose}", extra.ParamsVerbose, -1) - } else { - commandline = strings.Replace(commandline, "{upload.verbose}", extra.ParamsQuiet, -1) - } - // search for runtime variables and replace with values from Locater var runtimeRe = regexp.MustCompile("\\{(.*?)\\}") runtimeVars := runtimeRe.FindAllString(commandline, -1) diff --git a/upload/upload_test.go b/upload/upload_test.go index adf495917..3289e2ca4 100644 --- a/upload/upload_test.go +++ b/upload/upload_test.go @@ -45,13 +45,23 @@ var TestNetworkData = []struct { Name string Port string Board string - File string + Files []string Commandline string - Auth upload.Auth + Extra upload.Extra }{ { - "yun", "", "", "", - ``, upload.Auth{}}, + "yun", + "", + "", + []string{"filename"}, + "", + upload.Extra{ + Use1200bpsTouch: true, + WaitForUploadPort: true, + Network: true, + Auth: upload.Auth{}, + }, + }, } func TestNetwork(t *testing.T) { @@ -62,27 +72,27 @@ func TestNetwork(t *testing.T) { for _, test := range TestNetworkData { commandline := strings.Replace(test.Commandline, "$HOME", home, -1) - err := upload.Network(test.Port, test.Board, test.File, commandline, test.Auth, logger) + err := upload.Network(test.Port, test.Board, test.Files, commandline, test.Extra.Auth, logger, test.Extra.SSH) log.Println(err) } } var TestResolveData = []struct { - Port string - Board string - File string - Commandline string - Extra upload.Extra - Result string + Board string + File string + PlatformPath string + Commandline string + Extra upload.Extra + Result string }{ - {"/dev/ttyACM0", "arduino:avr:leonardo", "./upload_test.hex", - `"{runtime.tools.avrdude.path}/bin/avrdude" "-C{runtime.tools.avrdude.path}/etc/avrdude.conf" {upload.verbose} {upload.verify} -patmega32u4 -cavr109 -P{serial.port} -b57600 -D "-Uflash:w:{build.path}/{build.project_name}.hex:i"`, upload.Extra{Use1200bpsTouch: true, WaitForUploadPort: true}, - `"$loc$loc{runtime.tools.avrdude.path}/bin/avrdude" "-C{runtime.tools.avrdude.path}/etc/avrdude.conf" $loc{upload.verify} -patmega32u4 -cavr109 -P/dev/ttyACM0 -b57600 -D "-Uflash:w:./upload_test.hex:i"`}, + {"arduino:avr:leonardo", "./upload_test.hex", "", + `"{runtime.tools.avrdude.path}/bin/avrdude" "-C{runtime.tools.avrdude.path}/etc/avrdude.conf" -v {upload.verify} -patmega32u4 -cavr109 -P/dev/ttyACM0 -b57600 -D "-Uflash:w:{build.path}/{build.project_name}.hex:i"`, upload.Extra{Use1200bpsTouch: true, WaitForUploadPort: true}, + `"$loc$loc{runtime.tools.avrdude.path}/bin/avrdude" "-C{runtime.tools.avrdude.path}/etc/avrdude.conf" -v $loc{upload.verify} -patmega32u4 -cavr109 -P/dev/ttyACM0 -b57600 -D "-Uflash:w:./upload_test.hex:i"`}, } func TestResolve(t *testing.T) { for _, test := range TestResolveData { - result, _ := upload.Resolve(test.Port, test.Board, test.File, test.Commandline, test.Extra, mockTools{}) + result, _ := upload.PartiallyResolve(test.Board, test.File, test.PlatformPath, test.Commandline, test.Extra, mockTools{}) if result != test.Result { t.Error("expected " + test.Result + ", got " + result) continue diff --git a/v2/pkgs/tools_test.go b/v2/pkgs/tools_test.go index 30fdb8cd0..0355d0508 100644 --- a/v2/pkgs/tools_test.go +++ b/v2/pkgs/tools_test.go @@ -144,10 +144,10 @@ func strpoint(s string) *string { func url() string { urls := map[string]string{ - "linuxamd64": "http://downloads.arduino.cc/tools/avrdude-6.0.1-arduino2-x86_64-pc-linux-gnu.tar.bz2", - "linux386": "http://downloads.arduino.cc/tools/avrdude-6.0.1-arduino2-i686-pc-linux-gnu.tar.bz2", - "darwinamd64": "http://downloads.arduino.cc/tools/avrdude-6.0.1-arduino2-i386-apple-darwin11.tar.bz2", - "windows386": "http://downloads.arduino.cc/tools/avrdude-6.0.1-arduino2-i686-mingw32.zip", + "linuxamd64": "https://downloads.arduino.cc/tools/avrdude-6.0.1-arduino2-x86_64-pc-linux-gnu.tar.bz2", + "linux386": "https://downloads.arduino.cc/tools/avrdude-6.0.1-arduino2-i686-pc-linux-gnu.tar.bz2", + "darwinamd64": "https://downloads.arduino.cc/tools/avrdude-6.0.1-arduino2-i386-apple-darwin11.tar.bz2", + "windows386": "https://downloads.arduino.cc/tools/avrdude-6.0.1-arduino2-i686-mingw32.zip", } return urls[runtime.GOOS+runtime.GOARCH]