ardunno-cli
v0.1.10
Published
nice-grpc API for the Arduino CLI
Downloads
1,276
Maintainers
Readme
ardunno-cli
nice-grpc
API for the Arduino CLI.
The CLI API code in this repository is generated from the .proto
files of the Arduino CLI. The API is compatible with Arduino CLI v1.1.0
. This project uses ardunno-cli-gen
for the API generation.
Installing
npm i ardunno-cli --save
Usage
TypeScript:
import { createChannel, createClient } from 'nice-grpc';
import { ArduinoCoreServiceDefinition } from 'ardunno-cli';
JavaScript:
const { createChannel, createClient } = require('nice-grpc');
const { ArduinoCoreServiceDefinition } = require('ardunno-cli');
Create a gRPC client:
Requires a running Arduino CLI daemon to connect to.
% ./arduino-cli daemon --port 50051 --format json
{
"IP": "127.0.0.1",
"Port": "50051"
}
const channel = createChannel('localhost:50051');
const client = createClient(ArduinoCoreServiceDefinition, channel);
Create:
Creates a new Arduino Core instance.
const { instance } = await client.create({});
Initialize:
Initializes an existing Arduino Core instance by loading platforms and libraries.
for await (const { message } of client.init({ instance })) {
switch (message.$case) {
case 'error':
throw new Error(message.error);
}
}
Search platforms:
const { searchOutput } = await client.platformSearch({
instance,
searchArgs: 'SAMD',
});
searchOutput.forEach(({ id, latest }) => console.log(`${id}@${latest}`));
// arduino:[email protected]
// Arrow:[email protected]
// industruino:[email protected]
Configuration
The API contains typing and a JSON schema for the Arduino CLI configuration.
License
This project is licensed under the MIT License - see the LICENSE file for details.