### Example Platform Installation Directories (Manual) Source: https://github.com/arduino/arduino-cli/blob/master/docs/platform-specification.md Shows the directory structure for platforms manually installed by users in the sketchbook's user directory, omitting the version. ```shell {directories.user}/hardware/arduino/avr/... {directories.user}/hardware/arduino/esp32/... {directories.user}/hardware/arduino/nrf52/... {directories.user}/hardware/adafruit/nrf52/... {directories.user}/hardware/esp32/esp32/... ``` -------------------------------- ### Example Platform Installation Directories (Board Manager) Source: https://github.com/arduino/arduino-cli/blob/master/docs/platform-specification.md Illustrates the directory structure for platforms installed via the Arduino Board Manager, showing vendor, architecture, and version. ```shell {directories.data}/packages/arduino/hardware/avr/1.8.6/... {directories.data}/packages/arduino/hardware/esp32/2.0.18-arduino.5/... {directories.data}/packages/arduino/hardware/nrf52/1.4.5/... {directories.data}/packages/adafruit/hardware/nrf52/1.6.1/... {directories.data}/packages/esp32/hardware/esp32/3.0.7/... ``` -------------------------------- ### Example Sketch with Manager Links Source: https://github.com/arduino/arduino-cli/blob/master/docs/sketch-specification.md This C++ example demonstrates how to include a library and uses comments with URIs to link to the Arduino IDE's Boards Manager and Library Manager for dependency installation. ```c++ // install the Arduino SAMD Boards platform to add support for your MKR WiFi 1010 board // if using the Arduino IDE, click here: http://boardsmanager/Arduino#SAMD // install the WiFiNINA library via Library Manager // if using the Arduino IDE, click here: http://librarymanager/Arduino/Communication#WiFiNINA #include ``` -------------------------------- ### Run Client Example Source: https://github.com/arduino/arduino-cli/blob/master/rpc/internal/client_example/README.md Execute the client example after the Arduino CLI daemon is running. This simulates a gRPC consumer. ```bash client_example ``` -------------------------------- ### Arduino Setup and Loop Functions Source: https://github.com/arduino/arduino-cli/blob/master/internal/integrationtest/compile_4/testdata/SketchWithFakeFunctionPointer/SketchWithFakeFunctionPointer.preprocessed.txt Standard Arduino 'setup' and 'loop' functions. The 'setup' function demonstrates the usage of the overloaded '+=' operator on the 'Foo' class instances. The 'loop' function is empty as per typical Arduino sketch structure for simple examples. ```cpp void setup(){ a += b; } void loop(){} ``` -------------------------------- ### Basic Arduino Sketch Structure Source: https://github.com/arduino/arduino-cli/blob/master/internal/arduino/builder/testdata/TestMergeSketchSources.txt A standard Arduino sketch includes setup() and loop() functions. This example shows the minimal structure. ```arduino #include #line 1 "%s/testdata/TestLoadSketchFolder/TestLoadSketchFolder.ino" void setup() { } void loop() { } ``` -------------------------------- ### Serve Documentation Locally Source: https://github.com/arduino/arduino-cli/blob/master/docs/CONTRIBUTING.md Run a local server to preview documentation changes. Ensure you have Go, Taskfile, and Python installed, and have run 'poetry install'. ```shell task website:serve ``` -------------------------------- ### Arduino Setup and Loop Functions Source: https://github.com/arduino/arduino-cli/blob/master/internal/integrationtest/compile_4/testdata/SketchWithConst/SketchWithConst.preprocessed.txt Standard Arduino setup and loop functions. The setup function runs once, and the loop function runs repeatedly. ```c++ #include void setup() {} void loop() {} ``` -------------------------------- ### Basic Arduino Setup and Loop Source: https://github.com/arduino/arduino-cli/blob/master/internal/integrationtest/compile_4/testdata/SketchWithIfDef/SketchWithIfDef.preprocessed.txt Standard Arduino sketch structure with setup() for initialization and loop() for repeated execution. These functions are always compiled. ```cpp void setup() { // put your setup code here, to run once: } ``` ```cpp void loop() { // put your main code here, to run repeatedly: } ``` -------------------------------- ### Library Examples Folder Structure Source: https://github.com/arduino/arduino-cli/blob/master/docs/library-specification.md Library examples must be placed in the 'examples' folder. Sketches within this folder will appear in the Arduino IDE's Examples menu. ```text Servo/examples/... ``` -------------------------------- ### START command success response Source: https://github.com/arduino/arduino-cli/blob/master/docs/pluggable-discovery-specification.md The START command initializes discovery subroutines. A successful response indicates that the discovery process has started. ```json { "eventType": "start", "message": "OK" } ``` -------------------------------- ### Arduino Sketch Setup and Function Calls Source: https://github.com/arduino/arduino-cli/blob/master/internal/integrationtest/compile_4/testdata/SketchWithMultilinePrototypes/SketchWithMultilinePrototypes.preprocessed.txt The setup function in an Arduino sketch, demonstrating calls to various other functions with different parameter counts. This serves as the entry point for sketch execution. ```cpp #include void setup() { myctagstestfunc(1,2,3,4); test(); test3(); test5(1,2,3); test7(); test8(); test9(42, 42); test10(0,0,0); } ``` -------------------------------- ### Install Arduino CLI to a custom directory Source: https://github.com/arduino/arduino-cli/blob/master/docs/installation.md Use the BINDIR environment variable with the install script to specify a custom installation directory. ```bash curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=~/local/bin sh ``` -------------------------------- ### Install Arduino CLI using the install script Source: https://github.com/arduino/arduino-cli/blob/master/docs/installation.md Execute this script to install the latest Arduino CLI version to the current directory. Ensure 'sh' is available. ```bash curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh ``` -------------------------------- ### Enable unsafe library installation Source: https://github.com/arduino/arduino-cli/blob/master/docs/UPGRADING.md To enable installation from Git URLs or zip files, you must explicitly set the `library.enable_unsafe_install` configuration key. ```properties library.enable_unsafe_install=true ``` -------------------------------- ### START command error response Source: https://github.com/arduino/arduino-cli/blob/master/docs/pluggable-discovery-specification.md If the discovery tool fails to start for any reason, it should report an error with a descriptive message. ```json { "eventType": "start", "error": true, "message": "Permission error" } ``` -------------------------------- ### Install Fish Completion File Source: https://github.com/arduino/arduino-cli/blob/master/docs/command-line-completion.md Create the fish completions directory if it doesn't exist and then move the generated completion file into it. ```fish mkdir -p ~/.config/fish/completions/ ``` ```fish mv arduino-cli.fish ~/.config/fish/completions/ ``` -------------------------------- ### Arduino Sketch Setup and Loop Source: https://github.com/arduino/arduino-cli/blob/master/internal/integrationtest/compile_4/testdata/SketchWithExternCMultiline/SketchWithExternCMultiline.preprocessed.txt Standard Arduino setup and loop functions. The loop calls various external C functions. ```cpp #include void setup(); void loop(); extern "C" void test2(); extern "C" void test4(); extern "C" void test6(); void test7(); extern "C" void test10(); void setup() { // put your setup code here, to run once: } void loop() { // put your main code here, to run repeatedly: test2(); test4(); test6(); test7(); test10(); } ``` -------------------------------- ### Complete Arduino Library Example Structure Source: https://github.com/arduino/arduino-cli/blob/master/docs/library-specification.md Illustrates a typical directory structure for a hypothetical 'Servo' Arduino library, including properties, keywords, source files, examples, and extra documentation. ```text Servo/ Servo/library.properties Servo/keywords.txt Servo/src/ Servo/src/Servo.h Servo/src/Servo.cpp Servo/src/ServoTimers.h Servo/examples/ Servo/examples/Sweep/Sweep.ino Servo/examples/Pot/Pot.ino Servo/extras/ Servo/extras/Servo_Connectors.pdf ``` -------------------------------- ### Arduino Setup and Loop Functions Source: https://github.com/arduino/arduino-cli/blob/master/internal/integrationtest/compile_4/testdata/SketchWithClass/SketchWithClass.preprocessed.txt Standard Arduino sketch functions for initialization and main execution loop. The setup function runs once, and the loop function runs repeatedly. ```cpp void setup() { } void loop() { } ``` -------------------------------- ### List Installed Arduino Cores Source: https://github.com/arduino/arduino-cli/blob/master/docs/getting-started.md Verifies the proper installation of a core by listing all installed cores and their versions. ```sh $ arduino-cli core list ``` -------------------------------- ### Dependency Version Constraint Examples Source: https://github.com/arduino/arduino-cli/blob/master/docs/library-specification.md Illustrates various version constraint operators for library dependencies. These examples show how to specify exact versions, ranges, and combinations using AND/OR logic. ```text ArduinoHttpClient ArduinoHttpClient (=1.0.0) ArduinoHttpClient (>1.0.0) ArduinoHttpClient (>=1.0.0) ArduinoHttpClient (<2.0.0) ArduinoHttpClient (<=2.0.0) ArduinoHttpClient (!=1.0.0) ArduinoHttpClient (>1.0.0 && <2.1.0) ArduinoHttpClient (<1.0.0 || >2.0.0) ArduinoHttpClient ((>0.1.0 && <2.0.0) || >2.1.0) ``` -------------------------------- ### Complete Example of User Provided Fields in Upload Recipe Source: https://github.com/arduino/arduino-cli/blob/master/docs/platform-specification.md A full example demonstrating the declaration of username and password fields, including a secret password, and their integration into the upload pattern. ```text tools.arduino_ota.upload.field.username=Username tools.arduino_ota.upload.field.password=Password tools.arduino_ota.upload.field.password.secret=true tools.arduino_ota.upload.pattern="{runtime.tools.arduinoOTA.path}/bin/arduinoOTA" -address {upload.port.address} -port 65280 -username "{upload.field.username} -password "{upload.field.password}" -sketch "{build.path}/{build.project_name}.bin" ``` -------------------------------- ### Preprocessor Recipe Example Source: https://github.com/arduino/arduino-cli/blob/master/docs/platform-specification.md Defines the flags and command pattern for running the preprocessor. This recipe is used for detecting libraries and generating function prototypes. ```text preproc.macros.flags=-w -x c++ -E -CC recipe.preproc.macros="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} {preproc.macros.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{preprocessed_file_path}" ``` -------------------------------- ### Install an Arduino Library Source: https://github.com/arduino/arduino-cli/blob/master/docs/getting-started.md Install a specific library, like FTDebouncer, to add its functionalities to your sketches. The CLI will handle dependencies. ```sh $ arduino-cli lib install FTDebouncer ``` -------------------------------- ### Example Custom BLE Monitor Pattern Source: https://github.com/arduino/arduino-cli/blob/master/docs/platform-specification.md An example of a custom BLE monitor pattern, launching a specific tool with parameters. For development purposes. ```properties pluggable_monitor.pattern.custom-ble="{runtime.tools.my-ble-monitor.path}/my-ble-monitor" -H ``` -------------------------------- ### Arduino Sketch Setup and Loop Source: https://github.com/arduino/arduino-cli/blob/master/internal/integrationtest/compile_4/testdata/SketchWithFunctionSignatureInsideIfdef/SketchWithFunctionSignatureInsideIfdef.preprocessed.txt Standard Arduino setup and loop functions. The loop function calls the adalight function to visualize LEDs. ```cpp #include void setup(); void loop(); int8_t adalight(); void setup() {} void loop() { // Visualize leds via Adalight int8_t newData = adalight(); } ``` -------------------------------- ### Arduino Setup and Loop with Class Method Call Source: https://github.com/arduino/arduino-cli/blob/master/internal/integrationtest/compile_4/testdata/SketchWithClassAndMethodSubstring/SketchWithClassAndMethodSubstring.preprocessed.txt The Arduino 'setup' function calls the 'blooper' method with input 1, and the 'loop' function calls it with input 2. Ensure the class and its instance are defined before these functions. ```cpp void setup() { foo.blooper(1); } void loop() { foo.blooper(2); } ``` -------------------------------- ### Example Serial Port Discovery Response Source: https://github.com/arduino/arduino-cli/blob/master/docs/pluggable-discovery-specification.md An example of a successful LIST command response from the serial-discovery plugin, showing a detected USB serial port. ```json { "eventType": "list", "ports": [ { "address": "/dev/ttyACM0", "label": "ttyACM0", "protocol": "serial", "protocolLabel": "Serial Port (USB)", "hardwareId": "EBEABFD6514D32364E202020FF10181E", "properties": { "pid": "0x804e", "vid": "0x2341", "serialNumber": "EBEABFD6514D32364E202020FF10181E", "name": "ttyACM0" } } ] } ``` -------------------------------- ### Sketch File Structure Example Source: https://github.com/arduino/arduino-cli/blob/master/docs/sketch-specification.md Illustrates the typical directory and file layout for an Arduino sketch, including source files, libraries, data, and configuration. ```text Foo |_ arduino_secrets.h |_ Abc.ino |_ Def.cpp |_ Def.h |_ Foo.ino |_ Ghi.c |_ Ghi.h |_ Jkl.h |_ Jkl.S |_ sketch.yaml |_ data | |_ Schematic.pdf |_ src |_ SomeLib |_ library.properties |_ src |_ SomeLib.h |_ SomeLib.cpp ``` -------------------------------- ### Protobuf: Example DownloadProgress sequences Source: https://github.com/arduino/arduino-cli/blob/master/docs/UPGRADING.md Illustrates the sequence of `DownloadProgress` messages for successful downloads, errors, and cached files using the new protobuf structure. ```protobuf DownloadProgressStart{url="https://...", label="Downloading package index..." DownloadProgressUpdate{downloaded=0, total_size=103928} DownloadProgressUpdate{downloaded=29380, total_size=103928} DownloadProgressUpdate{downloaded=69540, total_size=103928} DownloadProgressEnd{success=true, message=""} ``` ```protobuf DownloadProgressStart{url="https://...", label="Downloading package index..." DownloadProgressUpdate{downloaded=0, total_size=103928} DownloadProgressEnd{success=false, message="Server closed connection"} ``` ```protobuf DownloadProgressStart{url="https://...", label="Downloading package index..." DownloadProgressEnd{success=true, message="Index already downloaded"} ``` -------------------------------- ### Example Baudrate Configuration Source: https://github.com/arduino/arduino-cli/blob/master/docs/platform-specification.md Sets the baudrate for the serial port of a specific board to 9600. ```properties myboard.monitor_port.serial.baudrate=9600 ``` -------------------------------- ### Install Bash Completion File Source: https://github.com/arduino/arduino-cli/blob/master/docs/command-line-completion.md After generating the bash completion script, move it to the /etc/bash_completion.d/ directory using sudo to enable system-wide completion. ```bash sudo mv arduino-cli.sh /etc/bash_completion.d/ ``` -------------------------------- ### Describe Monitor Configuration Parameters Source: https://github.com/arduino/arduino-cli/blob/master/docs/FAQ.md Use this command to get a description of the available configuration parameters for the serial monitor. ```bash $ arduino-cli monitor -p --describe ``` -------------------------------- ### Start Sync Command Success Response Source: https://github.com/arduino/arduino-cli/blob/master/docs/pluggable-discovery-specification.md This JSON is returned when the START_SYNC command is successfully processed, indicating the discovery tool has entered 'events' mode. ```json { "eventType": "start_sync", "message": "OK" } ``` -------------------------------- ### HELLO Command Example Source: https://github.com/arduino/arduino-cli/blob/master/docs/pluggable-monitor-specification.md The HELLO command must be the first command sent to the monitor tool. It identifies the client/IDE and the supported protocol version. The monitor responds with its supported protocol version and an OK message. ```text HELLO 1 "Arduino IDE 1.8.13" ``` ```text HELLO 1 "arduino-cli 1.2.3" ``` -------------------------------- ### Pre and Post Build Hooks Example Source: https://github.com/arduino/arduino-cli/blob/master/docs/platform-specification.md Demonstrates how to define custom commands to be executed before sketch compilation and after linking. Hooks are specified using numbered patterns. ```text recipe.hooks.sketch.prebuild.1.pattern=echo sketch compilation started at recipe.hooks.sketch.prebuild.2.pattern=date recipe.hooks.linking.postlink.1.pattern=echo linking is complete ``` -------------------------------- ### Empty Arduino Loop Function Source: https://github.com/arduino/arduino-cli/blob/master/internal/integrationtest/compile_4/testdata/SketchWithMultilinePrototypes/SketchWithMultilinePrototypes.preprocessed.txt The standard loop function in an Arduino sketch, which runs repeatedly after setup. This example shows an empty implementation. ```cpp void loop() {} ``` -------------------------------- ### Complete Sketch Project File Example Source: https://github.com/arduino/arduino-cli/blob/master/docs/sketch-project-file.md Defines multiple profiles with specific FQBNs, platforms, and libraries. Use this to manage different build configurations for your sketches. ```yaml profiles: nanorp: fqbn: arduino:mbed_nano:nanorp2040connect platforms: - platform: arduino:mbed_nano (2.1.0) libraries: - ArduinoIoTCloud (1.0.2) - Arduino_ConnectionHandler (0.6.4) - TinyDHT sensor library (1.1.0) another_profile_name: notes: testing the limit of the AVR platform, may be unstable fqbn: arduino:avr:uno platforms: - platform: arduino:avr (1.8.4) libraries: - VitconMQTT (1.0.1) - Arduino_ConnectionHandler (0.6.4) - TinyDHT sensor library (1.1.0) port: /dev/ttyACM0 port_config: baudrate: 115200 tiny: notes: testing the very limit of the AVR platform, it will be very unstable fqbn: attiny:avr:ATtinyX5:cpu=attiny85,clock=internal16 platforms: - platform: attiny:avr (1.0.2) platform_index_url: https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json - platform: arduino:avr (1.8.3) libraries: - ArduinoIoTCloud (1.0.2) - Arduino_ConnectionHandler (0.6.4) - TinyDHT sensor library (1.1.0) feather: fqbn: adafruit:samd:adafruit_feather_m0 platforms: - platform: adafruit:samd (1.6.0) platform_index_url: https://adafruit.github.io/arduino-board-index/package_adafruit_index.json libraries: - ArduinoIoTCloud (1.0.2) - Arduino_ConnectionHandler (0.6.4) - TinyDHT sensor library (1.1.0) default_profile: nanorp ``` -------------------------------- ### Run Arduino CLI Daemon Source: https://github.com/arduino/arduino-cli/blob/master/rpc/internal/client_example/README.md Start the Arduino CLI daemon to enable gRPC communication. This command must be run before executing the client example. ```bash arduino-cli daemon ``` -------------------------------- ### Arduino Sketch with Custom Function Source: https://github.com/arduino/arduino-cli/blob/master/internal/arduino/builder/testdata/TestMergeSketchSources.txt An Arduino sketch can contain custom functions beyond setup() and loop(). This example defines a simple string-returning function. ```arduino #line 1 "%s/testdata/TestLoadSketchFolder/other.ino" String hello() { return "world"; } ``` -------------------------------- ### HELLO command example Source: https://github.com/arduino/arduino-cli/blob/master/docs/pluggable-discovery-specification.md The HELLO command is the first command sent to the discovery tool to identify the client/IDE and its supported protocol version. The response indicates the protocol version that will be used for communication. ```text HELLO 1 "Arduino IDE 1.8.13" ``` ```text HELLO 1 "arduino-cli 1.2.3" ``` ```json { "eventType": "hello", "protocolVersion": 1, "message": "OK" } ``` -------------------------------- ### Old PackageManager Initialization in Go Source: https://github.com/arduino/arduino-cli/blob/master/docs/UPGRADING.md Shows the previous approach to initializing and loading hardware and tools using the monolithic PackageManager. ```go pm := packagemanager.NewPackageManager(...) err = pm.LoadHardware() err = pm.LoadHardwareFromDirectories(...) err = pm.LoadHardwareFromDirectory(...) err = pm.LoadToolsFromPackageDir(...) err = pm.LoadToolsFromBundleDirectories(...) err = pm.LoadToolsFromBundleDirectory(...) pack = pm.GetOrCreatePackage("packagername") // ...use `pack` to tweak or load more hardware... err = pm.LoadPackageIndex(...) err = pm.LoadPackageIndexFromFile(...) err = pm.LoadHardwareForProfile(...) // ...use `pm` to implement business logic... ``` -------------------------------- ### Initialize Configuration File with Additional Boards Manager URL Source: https://github.com/arduino/arduino-cli/blob/master/docs/configuration.md Create a new configuration file and set an additional Boards Manager URL using the `config init` command. ```shell arduino-cli config init --additional-urls https://downloads.arduino.cc/packages/package_staging_index.json ``` -------------------------------- ### Install Arduino Core Source: https://github.com/arduino/arduino-cli/blob/master/docs/getting-started.md Installs the specified platform core for your Arduino board. This command downloads and installs necessary tools and core files. ```sh $ arduino-cli core install arduino:samd ``` -------------------------------- ### Install a specific Arduino CLI version Source: https://github.com/arduino/arduino-cli/blob/master/docs/installation.md Pass the desired version number as an argument to the install script to download and install a specific release. ```bash curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh -s 0.9.0 ``` -------------------------------- ### Go: Initialize and use Arduino CLI as a gRPC service Source: https://github.com/arduino/arduino-cli/blob/master/docs/UPGRADING.md Demonstrates how to create a daemon-less Arduino CLI gRPC server and use its methods for core operations like creating, initializing, and destroying instances, as well as searching for platforms. Requires importing `github.com/arduino/arduino-cli`. ```go package main import ( "context" "fmt" "io" "log" "github.com/arduino/arduino-cli/commands" rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1" "github.com/sirupsen/logrus" ) func main() { // Create a new ArduinoCoreServer srv := commands.NewArduinoCoreServer() // Disable logging logrus.SetOutput(io.Discard) // Create a new instance in the server ctx := context.Background() resp, err := srv.Create(ctx, &rpc.CreateRequest{}) if err != nil { log.Fatal("Error creating instance:", err) } instance := resp.GetInstance() // Defer the destruction of the instance defer func() { if _, err := srv.Destroy(ctx, &rpc.DestroyRequest{Instance: instance}); err != nil { log.Fatal("Error destroying instance:", err) } fmt.Println("Instance successfully destroyed") }() // Initialize the instance initStream := commands.InitStreamResponseToCallbackFunction(ctx, func(r *rpc.InitResponse) error { fmt.Println("INIT> ", r) return nil }) if err := srv.Init(&rpc.InitRequest{Instance: instance}, initStream); err != nil { log.Fatal("Error during initialization:", err) } // Search for platforms and output the result searchResp, err := srv.PlatformSearch(ctx, &rpc.PlatformSearchRequest{Instance: instance}) if err != nil { log.Fatal("Error searching for platforms:", err) } for _, platformSummary := range searchResp.GetSearchOutput() { installed := platformSummary.GetInstalledRelease() meta := platformSummary.GetMetadata() fmt.Printf("%30s %8s %s\n", meta.GetId(), installed.GetVersion(), installed.GetName()) } } ``` -------------------------------- ### Squid Proxy Access Log Example Source: https://github.com/arduino/arduino-cli/blob/master/rpc/internal/client_example/README.md Example log entries showing successful requests passing through the Squid proxy. ```log 1612176447.893 400234 172.17.0.1 TCP_TUNNEL/200 116430 CONNECT downloads.arduino.cc:443 - HIER_DIRECT/104.18.28.45 - 1612176448.197 400245 172.17.0.1 TCP_TUNNEL/200 1621708 CONNECT downloads.arduino.cc:443 - HIER_DIRECT/104.18.28.45 - 1612176448.946 400256 172.17.0.1 TCP_TUNNEL/200 354882 CONNECT downloads.arduino.cc:443 - HIER_DIRECT/104.18.28.45 - ``` -------------------------------- ### Removed parameter `installLocation` from `LibrariesManager.Install` Source: https://github.com/arduino/arduino-cli/blob/master/docs/UPGRADING.md The `installLocation` parameter has been removed from the `Install` method of `github.com/arduino/arduino-cli/arduino/libraries/librariesmanager.LibrariesManager`. The install location is now determined from `libPath`. ```APIDOC ## Method Signature Change: `LibrariesManager.Install` ### Description The `Install` method in `github.com/arduino/arduino-cli/arduino/libraries/librariesmanager.LibrariesManager` no longer accepts the `installLocation` parameter. ### Old Signature ```go func (lm *LibrariesManager) Install(indexLibrary *librariesindex.Release, libPath *paths.Path, installLocation libraries.LibraryLocation) error ``` ### New Signature ```go func (lm *LibrariesManager) Install(indexLibrary *librariesindex.Release, libPath *paths.Path) error ``` ### Reason The install location is now automatically determined from the `libPath` parameter. ``` -------------------------------- ### Example keywords.txt for Arduino Library Source: https://github.com/arduino/arduino-cli/blob/master/docs/library-specification.md This file defines keywords for syntax highlighting in the Arduino IDE. It maps specific terms to different token types like datatypes and functions. ```text Servo/keywords.txt ``` ```text # Syntax Coloring Map For ExampleLibrary # Datatypes (KEYWORD1) Test KEYWORD1 # Methods and Functions (KEYWORD2) doSomething KEYWORD2 # Instances (KEYWORD2) # Constants (LITERAL1) ``` -------------------------------- ### Arduino Yún Bridge Setup Source: https://github.com/arduino/arduino-cli/blob/master/internal/integrationtest/compile_4/testdata/BridgeExample/BridgeExample.preprocessed.txt Initializes the Bridge library and sets up the web server to listen for incoming connections on localhost. Configures pin 13 for output. ```cpp #include #include #include #include // Listen to the default port 5555, the Yún webserver // will forward there all the HTTP requests you send BridgeServer server; void setup() { // Bridge startup pinMode(13, OUTPUT); digitalWrite(13, LOW); Bridge.begin(); digitalWrite(13, HIGH); // Listen for incoming connection only from localhost // (no one from the external network could connect) server.listenOnLocalhost(); server.begin(); } ``` -------------------------------- ### Go: Remove installLocation parameter from LibrariesManager.Install Source: https://github.com/arduino/arduino-cli/blob/master/docs/UPGRADING.md The `installLocation` parameter is no longer required for the `Install` method in `LibrariesManager`. The install location is now determined by `libPath`. ```go func (lm *LibrariesManager) Install(indexLibrary *librariesindex.Release, libPath *paths.Path, installLocation libraries.LibraryLocation) error { ... } ``` ```go func (lm *LibrariesManager) Install(indexLibrary *librariesindex.Release, libPath *paths.Path) error { ... } ``` -------------------------------- ### Install Arduino CLI via Homebrew Source: https://github.com/arduino/arduino-cli/blob/master/docs/installation.md Use this command to install the Arduino CLI using the Homebrew package manager on macOS and Linux. ```bash brew update brew install arduino-cli ``` -------------------------------- ### Port Properties Example Source: https://github.com/arduino/arduino-cli/blob/master/docs/pluggable-discovery-specification.md Example of 'properties' field within a port object, used for board identification. This includes VID, PID, and serial number. ```json "port": { "address": "/dev/ttyACM0", "properties": { "pid": "0x804e", "vid": "0x2341", "serialNumber": "EBEABFD6514D32364E202020FF10181E", "name": "ttyACM0" }, ... } ``` -------------------------------- ### Add TaskProgressCB to UninstallPlatform, InstallTool, UninstallTool Source: https://github.com/arduino/arduino-cli/blob/master/docs/UPGRADING.md The `UninstallPlatform`, `InstallTool`, and `UninstallTool` methods now require a `TaskProgressCB` callback. Pass an empty callback if task events are not needed. ```go func (pm *PackageManager) UninstallPlatform(platformRelease *cores.PlatformRelease, taskCB rpc.TaskProgressCB) error { func (pm *PackageManager) InstallTool(toolRelease *cores.ToolRelease, taskCB rpc.TaskProgressCB) error { func (pm *PackageManager) UninstallTool(toolRelease *cores.ToolRelease, taskCB rpc.TaskProgressCB) error { ``` -------------------------------- ### Arduino Sketch Code Example Source: https://github.com/arduino/arduino-cli/blob/master/docs/getting-started.md Modify the sketch code to include basic functionality like blinking the built-in LED. This example demonstrates `pinMode`, `digitalWrite`, and `delay`. ```c void setup() { pinMode(LED_BUILTIN, OUTPUT); } void loop() { digitalWrite(LED_BUILTIN, HIGH); delay(1000); digitalWrite(LED_BUILTIN, LOW); delay(1000); } ``` -------------------------------- ### Compile Sketch with Multiple Board Options Source: https://github.com/arduino/arduino-cli/blob/master/docs/FAQ.md Demonstrates how to set multiple board options for compilation using the FQBN string. Options are separated by commas. ```bash $ arduino-cli compile --fqbn "esp8266:esp8266:generic:xtal=160,baud=57600" TestSketch ``` -------------------------------- ### Configure Post-Build Hook for Image Tool Source: https://github.com/arduino/arduino-cli/blob/master/docs/guides/secure-boot.md Define the post-build command pattern to use `imgtool` for signing and encrypting the binary. This configuration is typically placed in `platform.txt`. ```properties recipe.hooks.objcopy.postobjcopy.1.pattern={build.postbuild.cmd} # # IMGTOOL # tools.imgtool.cmd=imgtool tools.imgtool.flags=sign --key "{build.keys.keychain}/{build.keys.sign_key}" --encrypt "{build.keys.keychain}/{build.keys.encrypt_key}" "{build.path}/{build.project_name}.bin" "{build.path}/{build.project_name}.bin" --align {build.alignment} --max-align {build.alignment} --version {build.version} --header-size {build.header_size} --pad-header --slot-size {build.slot_size} ``` -------------------------------- ### boards.txt Example for Arduino Zero Source: https://github.com/arduino/arduino-cli/blob/master/docs/pluggable-discovery-specification.md Illustrative snippet from a boards.txt file, showing how upload port properties (VID and PID) are defined for different Arduino Zero models. ```text # Arduino Zero (Programming Port) # --------------------------------------- arduino_zero_edbg.name=Arduino Zero (Programming Port) arduino_zero_edbg.upload_port.vid=0x03eb arduino_zero_edbg.upload_port.pid=0x2157 [...CUT...] # Arduino Zero (Native USB Port) # -------------------------------------- arduino_zero_native.name=Arduino Zero (Native USB Port) arduino_zero_native.upload_port.0.vid=0x2341 arduino_zero_native.upload_port.0.pid=0x804d arduino_zero_native.upload_port.1.vid=0x2341 arduino_zero_native.upload_port.1.pid=0x004d arduino_zero_native.upload_port.2.vid=0x2341 arduino_zero_native.upload_port.2.pid=0x824d arduino_zero_native.upload_port.3.vid=0x2341 arduino_zero_native.upload_port.3.pid=0x024d [...CUT...] # Arduino MKR1000 ```