Skip to content

tofupilot/matlab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TofuPilot MATLAB Client

MATLAB client for the TofuPilot REST API. Struct-based, with retries and request lifecycle hooks.

Installation

Option 1: Add-On Explorer (recommended)

Search for TofuPilot in the MATLAB Add-On Explorer and click Install.

Option 2: GitHub

git clone https://github.com/tofupilot/matlab.git

Then add to your MATLAB path:

addpath('/path/to/matlab');
savepath;  % persist across sessions

Quick Start

sdk = tofupilot.TofuPilot('your-api-key');

% Create a test run
req.procedure_id = '550e8400-e29b-41d4-a716-446655440000';
req.serial_number = 'SN-001234';
req.part_number = 'PCB-V1.2';
req.outcome = 'PASS';
req.started_at = '2026-04-07T10:00:00Z';
req.ended_at = '2026-04-07T10:05:00Z';

run = sdk.Runs.create(req);
fprintf('Created run: %s\n', run.id);

Available Resources

Resource Methods Docs
Procedures list, create, get, delete, update docs/sdks/procedures
Runs list, create, delete, get, update docs/sdks/runs
Attachments initialize, delete, finalize docs/sdks/attachments
Units list, create, delete, get, update, addChild, removeChild docs/sdks/units
Parts list, create, get, delete, update docs/sdks/parts
Batches get, delete, update, list, create docs/sdks/batches
Stations list, create, getCurrent, get, remove, update docs/sdks/stations
User list docs/sdks/user
Versions get, delete, create docs/sdks/versions
Revisions get, delete, update, create docs/sdks/revisions
AttachmentHelpers upload, download docs/sdks/attachments

File Upload

The SDK provides helpers that handle the three-step upload flow (initialize → PUT → finalize) in a single call:

% Upload from disk
attachId = tofupilot.AttachmentHelpers.upload(sdk.Attachments, 'report.pdf');

% Link to a run
sdk.Runs.update(run.id, struct('attachments', {{attachId}}));

% Download a file
tofupilot.AttachmentHelpers.download(downloadUrl, 'local-report.pdf');

Phases & Measurements

now = char(datetime('now', 'TimeZone', 'UTC', 'Format', 'yyyy-MM-dd''T''HH:mm:ss''Z'''));

measurement = struct( ...
    'name', 'output_voltage', ...
    'outcome', 'PASS', ...
    'measured_value', 3.3, ...
    'unit', 'V');

phase = struct( ...
    'name', 'voltage_check', ...
    'outcome', 'PASS', ...
    'started_at', now, ...
    'ended_at', now, ...
    'measurements', {{measurement}});

req.procedure_id = 'your-procedure-id';
req.serial_number = 'SN-001';
req.part_number = 'PCB-V1';
req.outcome = 'PASS';
req.started_at = now;
req.ended_at = now;
req.phases = {{phase}};

run = sdk.Runs.create(req);

Retries

The client automatically retries on 429 (rate limit) and 5xx errors with exponential backoff (1s, 2s, 4s, ...). Default: 3 retries.

% Custom retry count
sdk = tofupilot.TofuPilot('your-api-key', 'MaxRetries', 5);

% Disable retries
sdk = tofupilot.TofuPilot('your-api-key', 'MaxRetries', 0);

Hooks

Inspect requests and responses with lifecycle hooks:

sdk = tofupilot.TofuPilot('your-api-key', ...
    'BeforeRequest', {@(ctx) fprintf('-> %s %s\n', ctx.method, ctx.path)}, ...
    'AfterSuccess', {@(ctx, resp) fprintf('OK\n')}, ...
    'AfterError', {@(ctx, err) fprintf('Error: %s\n', err.message)});

Self-Hosted

Point the client at your own TofuPilot instance:

sdk = tofupilot.TofuPilot('your-api-key', 'BaseUrl', 'https://your-instance.example.com/api');

Configuration

sdk = tofupilot.TofuPilot('your-api-key', ...
    'BaseUrl', 'https://your-server.com/api', ...
    'Timeout', 60, ...
    'MaxRetries', 5);

Requirements

  • MATLAB R2019b or later
  • No additional toolboxes required

License

This SDK is distributed under the MIT License. See LICENSE for details.

About

Upload hardware test data to TofuPilot from MATLAB.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages