Skip to content

matlab/matlab-agentic-toolkit / skills-catalog/test-and-measurement/matlab-connect-bluetooth-low-energy-device

matlab-connect-bluetooth-low-energy-device

Verified

Discover and connect to Bluetooth Low Energy (BLE) peripheral devices from MATLAB. Use this skill when the user wants to scan for BLE devices, connect to a BLE peripheral, read or write BLE characteristics, subscribe to notifications, or any task that requires a BLE connection as a prerequisite (e.g., read sensor data over BLE, monitor heart rate, log accelerometer, stream data from wearable, IoT device communication). Triggers on: BLE, Bluetooth Low Energy, blelist, ble device, BLE characteristic, GATT, service UUID, scan for devices, BLE sensor, subscribe notify, BLE read, BLE write, peripheral device, BLE connect, wireless sensor.

FileKindSize
SKILL.mdskill md12.9 KB
manifest.yamlconfig410 B
scripts/bleDataCollector.mother1.8 KB

scripts/bleDataCollector.m

View on GitHub
function bleDataCollector(bleObj, serviceID, characteristicID, duration, filename)
%bleDataCollector Log BLE characteristic notification data to a text file.
%   bleDataCollector(bleObj, serviceID, characteristicID, duration, filename)
%   subscribes to notifications on the specified characteristic, logs each
%   notification's timestamp and raw byte values to a tab-separated text
%   file for the given duration, then unsubscribes and closes the file.
%
%   The output file has one row per notification:
%       timestamp<TAB>byte1 byte2 byte3 ...
%
%   Example:
%       b = ble("HeartSensor");
%       bleDataCollector(b, "180D", "2A37", 10, "heartRateLog.txt")
%
%   See also ble, characteristic, subscribe, unsubscribe

    arguments
        bleObj (1,1)
        serviceID (1,1) string
        characteristicID (1,1) string
        duration (1,1) double {mustBePositive} = 10
        filename (1,1) string = "bleLog.txt"
    end

    charObj = characteristic(bleObj, serviceID, characteristicID);
    fileID = fopen(filename, "w+");
    if fileID == -1
        error("bleDataCollector:fileOpen", "Cannot open file: %s", filename);
    end

    charObj.DataAvailableFcn = @(src, ~) logNotification(src, fileID);
    subscribe(charObj);
    fprintf("Logging BLE data to %s for %d seconds...\n", filename, duration);
    pause(duration);
    unsubscribe(charObj);
    charObj.DataAvailableFcn = [];
    fclose(fileID);
    fprintf("Done. File saved: %s\n", filename);
end

function logNotification(src, fileID)
%logNotification Callback that reads buffered notification and writes to file.
    [data, timestamp] = read(src, "oldest");
    timestamp.Format = "yyyy-MM-dd HH:mm:ss.SSSS";
    fprintf(fileID, "%s\t", timestamp);
    fprintf(fileID, repmat('%d ', 1, length(data)), data);
    fprintf(fileID, "\n");
end
% Copyright 2026 The MathWorks, Inc.
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall