import { SimpleBLE } from "https://deno.land/x/simpleble@v1.1.0/ffi.ts";
An instance of a SimpleBLE interface.
Example
import { bindings } from "https://deno.land/x/webbluetooth@VERSION/mod.ts";
import { delay } from "https://deno.land/std@0.158.0/async/mod.ts";
const adaptersCount = bindings.simpleble_adapter_get_count();
if (adaptersCount === 0) {
console.error("No Bluetooth adapters found");
Deno.exit(1);
}
console.log(`Found ${adaptersCount} adapters`);
const adapter = bindings.simpleble_adapter_get_handle(0);
console.log(`Starting scan for 5 seconds`);
bindings.simpleble_adapter_scan_start(adapter);
await delay(5000);
bindings.simpleble_adapter_scan_stop(adapter);
console.log(`Finished scan`);
const count = bindings.simpleble_adapter_scan_get_results_count(adapter);
if (count === 0) {
console.error("No devices found");
Deno.exit(1);
}
console.log(`Found ${resultsCount} devices`);
Methods
Returns the number of paired devices.
Returns a handle to a paired device.
Begin scanning (with timeout).
NOTE: This function blocks until the timeout is reached.
Returns the number of devices found.
Returns a handle for a peripheral device.
Register a callback for when a peripheral is found.
Register a callback for when scanning begins.
Register a callback for when scanning stops.
Register a callback for when an adapter is updated.
Register a callback for peripheral indications.
Returns true if a peripheral can be connected to.
Returns true if a peripheral is currently connected.
Returns true if a peripheral is already paired.
Returns the size of the manufacturer data.
Returns the manufacturer data for device.
Register a callback for peripheral notifications.
Returns the RSSI (signal strength) of a peripheral.
Returns the number of services a peripheral has.
Returns a Service found on a peripheral.
Register a callback for when a peripheral is connected.
Register a callback for when a peripheral is disconnected.