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 v0.35.0-rc.2
. This project uses ardunno-cli-gen
for the API generation.
npm i ardunno-cli --save
import { createChannel, createClient } from 'nice-grpc';
import { ArduinoCoreServiceDefinition } from 'ardunno-cli';
const { createChannel, createClient } = require('nice-grpc');
const { ArduinoCoreServiceDefinition } = require('ardunno-cli');
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);
Creates a new Arduino Core instance.
const { instance } = await client.create({});
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);
}
}
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]
The API contains typing and a JSON schema for the Arduino CLI configuration.
This project is licensed under the MIT License - see the LICENSE file for details.